From 7da8db8544fbb59c91dacb807fe5a7494471181a Mon Sep 17 00:00:00 2001 From: Adam Leventhal Date: Mon, 24 Apr 2023 19:03:33 -0700 Subject: [PATCH] generate `httpmock`-based testing code (#437) --- CHANGELOG.adoc | 2 + progenitor-impl/Cargo.toml | 1 + progenitor-impl/src/cli.rs | 1 + progenitor-impl/src/httpmock.rs | 344 + progenitor-impl/src/lib.rs | 4 +- progenitor-impl/src/method.rs | 12 +- progenitor-impl/src/template.rs | 25 + .../tests/output/buildomat-httpmock.out | 976 + .../tests/output/keeper-httpmock.out | 349 + .../tests/output/nexus-httpmock.out | 16471 ++++++++++++++++ .../tests/output/param-overrides-httpmock.out | 67 + .../tests/output/propolis-server-httpmock.out | 518 + progenitor-impl/tests/test_output.rs | 19 + 13 files changed, 18782 insertions(+), 7 deletions(-) create mode 100644 progenitor-impl/src/httpmock.rs create mode 100644 progenitor-impl/tests/output/buildomat-httpmock.out create mode 100644 progenitor-impl/tests/output/keeper-httpmock.out create mode 100644 progenitor-impl/tests/output/nexus-httpmock.out create mode 100644 progenitor-impl/tests/output/param-overrides-httpmock.out create mode 100644 progenitor-impl/tests/output/propolis-server-httpmock.out diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 9ea7a3e0..51393ead 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -17,6 +17,8 @@ https://github.com/oxidecomputer/progenitor/compare/v0.2.0\...HEAD[Full list of * Add support for header parameters (#210) * Add support for YAML input (#227) +* Add generation for `clap`-based CLIs +* Add generation for strongly-typed mocks with `httpmock` == 0.2.0 (released 2022-09-11) diff --git a/progenitor-impl/Cargo.toml b/progenitor-impl/Cargo.toml index 97fe118b..65afa010 100644 --- a/progenitor-impl/Cargo.toml +++ b/progenitor-impl/Cargo.toml @@ -9,6 +9,7 @@ readme = "../README.md" [dependencies] heck = "0.4.1" +http = "0.2.9" getopts = "0.2" indexmap = "1.9" openapiv3 = "1.0.0" diff --git a/progenitor-impl/src/cli.rs b/progenitor-impl/src/cli.rs index f7d265d4..505a2cb8 100644 --- a/progenitor-impl/src/cli.rs +++ b/progenitor-impl/src/cli.rs @@ -42,6 +42,7 @@ impl Generator { space_out_items(content) } + /// Generate a `clap`-based CLI. pub fn cli( &mut self, spec: &OpenAPI, diff --git a/progenitor-impl/src/httpmock.rs b/progenitor-impl/src/httpmock.rs new file mode 100644 index 00000000..5c8bd1bc --- /dev/null +++ b/progenitor-impl/src/httpmock.rs @@ -0,0 +1,344 @@ +// Copyright 2023 Oxide Computer Company + +//! Generation of mocking extensions for `httpmock` + +use openapiv3::OpenAPI; +use proc_macro2::TokenStream; +use quote::{format_ident, quote, ToTokens}; + +use crate::{ + method::{ + HttpMethod, OperationParameter, OperationParameterKind, + OperationParameterType, OperationResponse, OperationResponseStatus, + }, + to_schema::ToSchema, + util::{sanitize, Case}, + validate_openapi, Generator, Result, +}; + +struct MockOp { + when: TokenStream, + when_impl: TokenStream, + then: TokenStream, + then_impl: TokenStream, +} + +impl Generator { + /// Generate a strongly-typed mocking extension to the `httpmock` crate. + pub fn httpmock( + &mut self, + spec: &OpenAPI, + crate_name: &str, + ) -> Result { + validate_openapi(spec)?; + + // Convert our components dictionary to schemars + let schemas = spec.components.iter().flat_map(|components| { + components.schemas.iter().map(|(name, ref_or_schema)| { + (name.clone(), ref_or_schema.to_schema()) + }) + }); + + self.type_space.add_ref_types(schemas)?; + + let raw_methods = spec + .paths + .iter() + .flat_map(|(path, ref_or_item)| { + // Exclude externally defined path items. + let item = ref_or_item.as_item().unwrap(); + item.iter().map(move |(method, operation)| { + (path.as_str(), method, operation, &item.parameters) + }) + }) + .map(|(path, method, operation, path_parameters)| { + self.process_operation( + operation, + &spec.components, + path, + method, + path_parameters, + ) + }) + .collect::>>()?; + + let methods = raw_methods + .iter() + .map(|method| self.httpmock_method(method)) + .collect::>(); + + let op = raw_methods + .iter() + .map(|method| format_ident!("{}", &method.operation_id)) + .collect::>(); + let when = methods.iter().map(|op| &op.when).collect::>(); + let when_impl = + methods.iter().map(|op| &op.when_impl).collect::>(); + let then = methods.iter().map(|op| &op.then).collect::>(); + let then_impl = + methods.iter().map(|op| &op.then_impl).collect::>(); + + let crate_ident = format_ident!("{}", crate_name); + + let code = quote! { + pub mod operations { + + //! [`When`](httpmock::When) and [`Then`](httpmock::Then) + //! wrappers for each operation. Each can be converted to + //! its inner type with a call to `into_inner()`. This can + //! be used to explicitly deviate from permitted values. + + use #crate_ident::*; + + #( + pub struct #when(httpmock::When); + #when_impl + + pub struct #then(httpmock::Then); + #then_impl + )* + } + + /// An extension trait for [`MockServer`](httpmock::MockServer) that + /// adds a method for each operation. These are the equivalent of + /// type-checked [`mock()`](httpmock::MockServer::mock) calls. + pub trait MockServerExt { + #( + fn #op(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::#when, operations::#then); + )* + } + + impl MockServerExt for httpmock::MockServer { + #( + fn #op(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::#when, operations::#then) + { + self.mock(|when, then| { + config_fn( + operations::#when::new(when), + operations::#then::new(then), + ) + }) + } + )* + } + }; + Ok(code) + } + + fn httpmock_method( + &mut self, + method: &crate::method::OperationMethod, + ) -> MockOp { + let when_name = + sanitize(&format!("{}-when", method.operation_id), Case::Pascal); + let when = format_ident!("{}", when_name).to_token_stream(); + let then_name = + sanitize(&format!("{}-then", method.operation_id), Case::Pascal); + let then = format_ident!("{}", then_name).to_token_stream(); + + let http_method = match &method.method { + HttpMethod::Get => quote! { httpmock::Method::GET }, + HttpMethod::Put => quote! { httpmock::Method::PUT }, + HttpMethod::Post => quote! { httpmock::Method::POST }, + HttpMethod::Delete => quote! { httpmock::Method::DELETE }, + HttpMethod::Options => quote! { httpmock::Method::OPTIONS }, + HttpMethod::Head => quote! { httpmock::Method::HEAD }, + HttpMethod::Patch => quote! { httpmock::Method::PATCH }, + HttpMethod::Trace => quote! { httpmock::Method::TRACE }, + }; + + let path_re = method.path.as_wildcard(); + + // Generate methods corresponding to each parameter so that callers + // can specify a prescribed value for that parameter. + let when_methods = method.params.iter().map( + |OperationParameter { + name, typ, kind, .. + }| { + let arg_type_name = match typ { + OperationParameterType::Type(arg_type_id) => { + let arg_type = + self.type_space.get_type(arg_type_id).unwrap(); + let arg_details = arg_type.details(); + let arg_type_name = match &arg_details { + typify::TypeDetails::Option(opt_id) => { + let inner_type = + self.type_space.get_type(opt_id).unwrap(); + inner_type.parameter_ident() + } + _ => arg_type.parameter_ident(), + }; + arg_type_name + } + OperationParameterType::RawBody => quote! { + serde_json::Value + }, + }; + + let name_ident = format_ident!("{}", name); + let handler = match kind { + OperationParameterKind::Path => { + let re_fmt = method.path.as_wildcard_param(name); + quote! { + let re = regex::Regex::new( + &format!(#re_fmt, value.to_string()) + ).unwrap(); + Self(self.0.path_matches(re)) + } + } + OperationParameterKind::Query(_) => quote! { + Self(self.0.query_param(#name, value.to_string())) + }, + OperationParameterKind::Header(_) => quote! { todo!() }, + OperationParameterKind::Body(_) => match typ { + OperationParameterType::Type(_) => quote! { + Self(self.0.json_body_obj(value)) + + }, + OperationParameterType::RawBody => quote! { + Self(self.0.json_body(value)) + }, + }, + }; + quote! { + pub fn #name_ident(self, value: #arg_type_name) -> Self { + #handler + } + } + }, + ); + + let when_impl = quote! { + impl #when { + pub fn new(inner: httpmock::When) -> Self { + Self(inner + .method(#http_method) + .path_matches(regex::Regex::new(#path_re).unwrap())) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + #(#when_methods)* + } + }; + + // Methods for each discrete response. For specific status codes we use + // the name of that code; for classes of codes we use the class name + // and require a status code that must be within the prescribed range. + let then_methods = method.responses.iter().map( + |OperationResponse { + status_code, typ, .. + }| { + let (value_param, value_use) = match typ { + crate::method::OperationResponseType::Type(arg_type_id) => { + let arg_type = + self.type_space.get_type(arg_type_id).unwrap(); + let arg_type_ident = arg_type.parameter_ident(); + ( + quote! { + value: #arg_type_ident, + }, + quote! { + .header("content-type", "application/json") + .json_body_obj(value) + }, + ) + } + crate::method::OperationResponseType::None => { + Default::default() + } + crate::method::OperationResponseType::Raw => ( + quote! { + value: serde_json::Value, + }, + quote! { + .header("content-type", "application/json") + .json_body(value) + }, + ), + crate::method::OperationResponseType::Upgrade => { + Default::default() + } + }; + + match status_code { + OperationResponseStatus::Code(status_code) => { + let canonical_reason = + http::StatusCode::from_u16(*status_code) + .unwrap() + .canonical_reason() + .unwrap(); + let fn_name = format_ident!( + "{}", + &sanitize(canonical_reason, Case::Snake) + ); + + quote! { + pub fn #fn_name(self, #value_param) -> Self { + Self(self.0 + .status(#status_code) + #value_use + ) + } + } + } + OperationResponseStatus::Range(status_type) => { + let status_string = match status_type { + 1 => "informational", + 2 => "success", + 3 => "redirect", + 4 => "client_error", + 5 => "server_error", + _ => unreachable!(), + }; + let fn_name = format_ident!("{}", status_string); + quote! { + pub fn #fn_name(self, status: u16, #value_param) -> Self { + assert_eq!(status / 100u16, #status_type); + Self(self.0 + .status(status) + #value_use + ) + } + } + } + OperationResponseStatus::Default => quote! { + pub fn default_response(self, status: u16, #value_param) -> Self { + Self(self.0 + .status(status) + #value_use + ) + } + }, + } + }, + ); + + let then_impl = quote! { + impl #then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + #(#then_methods)* + } + }; + + MockOp { + when, + when_impl, + then, + then_impl, + } + } +} diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index 331c3b1a..4a1bed7c 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -15,6 +15,7 @@ pub use typify::TypeSpaceImpl as TypeImpl; pub use typify::TypeSpacePatch as TypePatch; mod cli; +mod httpmock; mod method; mod template; mod to_schema; @@ -556,7 +557,7 @@ impl Generator { } } -pub(crate) fn space_out_items(content: String) -> Result { +pub fn space_out_items(content: String) -> Result { // Add newlines after end-braces at <= two levels of indentation. Ok(if cfg!(not(windows)) { let regex = regex::Regex::new(r#"(})(\n\s{0,8}[^} ])"#).unwrap(); @@ -567,6 +568,7 @@ pub(crate) fn space_out_items(content: String) -> Result { }) } +/// Do some very basic checks of the OpenAPI documents. pub fn validate_openapi(spec: &OpenAPI) -> Result<()> { match spec.openapi.as_str() { "3.0.0" | "3.0.1" | "3.0.2" | "3.0.3" => (), diff --git a/progenitor-impl/src/method.rs b/progenitor-impl/src/method.rs index 7de965de..f2942d40 100644 --- a/progenitor-impl/src/method.rs +++ b/progenitor-impl/src/method.rs @@ -22,17 +22,17 @@ use crate::{to_schema::ToSchema, util::ReferenceOrExt}; pub(crate) struct OperationMethod { pub operation_id: String, pub tags: Vec, - method: HttpMethod, - path: PathTemplate, + pub method: HttpMethod, + pub path: PathTemplate, pub summary: Option, pub description: Option, pub params: Vec, - responses: Vec, + pub responses: Vec, pub dropshot_paginated: Option, dropshot_websocket: bool, } -enum HttpMethod { +pub enum HttpMethod { Get, Put, Post, @@ -140,8 +140,8 @@ impl FromStr for BodyContentType { #[derive(Debug)] pub(crate) struct OperationResponse { - status_code: OperationResponseStatus, - typ: OperationResponseType, + pub status_code: OperationResponseStatus, + pub typ: OperationResponseType, // TODO this isn't currently used because dropshot doesn't give us a // particularly useful message here. #[allow(dead_code)] diff --git a/progenitor-impl/src/template.rs b/progenitor-impl/src/template.rs index 98db6085..aa377bf2 100644 --- a/progenitor-impl/src/template.rs +++ b/progenitor-impl/src/template.rs @@ -63,6 +63,31 @@ impl PathTemplate { }) .collect() } + + pub fn as_wildcard(&self) -> String { + let inner = self + .components + .iter() + .map(|c| match c { + Component::Constant(name) => name.clone(), + Component::Parameter(_) => ".*".to_string(), + }) + .collect::(); + format!("^{}$", inner) + } + + pub fn as_wildcard_param(&self, param: &str) -> String { + let inner = self + .components + .iter() + .map(|c| match c { + Component::Constant(name) => name.clone(), + Component::Parameter(p) if p == param => "{}".to_string(), + Component::Parameter(_) => ".*".to_string(), + }) + .collect::(); + format!("^{}$", inner) + } } pub fn parse(t: &str) -> Result { diff --git a/progenitor-impl/tests/output/buildomat-httpmock.out b/progenitor-impl/tests/output/buildomat-httpmock.out new file mode 100644 index 00000000..57099ca9 --- /dev/null +++ b/progenitor-impl/tests/output/buildomat-httpmock.out @@ -0,0 +1,976 @@ +pub mod operations { + #![doc = r" [`When`](httpmock::When) and [`Then`](httpmock::Then)"] + #![doc = r" wrappers for each operation. Each can be converted to"] + #![doc = r" its inner type with a call to `into_inner()`. This can"] + #![doc = r" be used to explicitly deviate from permitted values."] + use sdk::*; + pub struct ControlHoldWhen(httpmock::When); + impl ControlHoldWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/control/hold$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct ControlHoldThen(httpmock::Then); + impl ControlHoldThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: ()) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ControlResumeWhen(httpmock::When); + impl ControlResumeWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/control/resume$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct ControlResumeThen(httpmock::Then); + impl ControlResumeThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self) -> Self { + Self(self.0.status(200u16)) + } + } + + pub struct TaskGetWhen(httpmock::When); + impl TaskGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/task/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn task(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/v1/task/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct TaskGetThen(httpmock::Then); + impl TaskGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Task) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct TasksGetWhen(httpmock::When); + impl TasksGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/tasks$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct TasksGetThen(httpmock::Then); + impl TasksGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &Vec) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct TaskSubmitWhen(httpmock::When); + impl TaskSubmitWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/tasks$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::TaskSubmit) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct TaskSubmitThen(httpmock::Then); + impl TaskSubmitThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::TaskSubmitResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct TaskEventsGetWhen(httpmock::When); + impl TaskEventsGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/tasks/.*/events$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn task(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/v1/tasks/{}/events$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn minseq(self, value: u32) -> Self { + Self(self.0.query_param("minseq", value.to_string())) + } + } + + pub struct TaskEventsGetThen(httpmock::Then); + impl TaskEventsGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &Vec) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct TaskOutputsGetWhen(httpmock::When); + impl TaskOutputsGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/tasks/.*/outputs$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn task(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/v1/tasks/{}/outputs$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct TaskOutputsGetThen(httpmock::Then); + impl TaskOutputsGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &Vec) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct TaskOutputDownloadWhen(httpmock::When); + impl TaskOutputDownloadWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/tasks/.*/outputs/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn task(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/v1/tasks/{}/outputs/.*$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn output(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/v1/tasks/.*/outputs/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct TaskOutputDownloadThen(httpmock::Then); + impl TaskOutputDownloadThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn success(self, status: u16, value: serde_json::Value) -> Self { + assert_eq!(status / 100u16, 2u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct UserCreateWhen(httpmock::When); + impl UserCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/users$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::UserCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct UserCreateThen(httpmock::Then); + impl UserCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::UserCreateResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WhoamiWhen(httpmock::When); + impl WhoamiWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/whoami$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct WhoamiThen(httpmock::Then); + impl WhoamiThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::WhoamiResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerBootstrapWhen(httpmock::When); + impl WorkerBootstrapWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/worker/bootstrap$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::WorkerBootstrap) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerBootstrapThen(httpmock::Then); + impl WorkerBootstrapThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::WorkerBootstrapResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerPingWhen(httpmock::When); + impl WorkerPingWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/worker/ping$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct WorkerPingThen(httpmock::Then); + impl WorkerPingThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::WorkerPingResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerTaskAppendWhen(httpmock::When); + impl WorkerTaskAppendWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/worker/task/.*/append$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn task(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/v1/worker/task/{}/append$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::WorkerAppendTask) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerTaskAppendThen(httpmock::Then); + impl WorkerTaskAppendThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self) -> Self { + Self(self.0.status(201u16)) + } + } + + pub struct WorkerTaskUploadChunkWhen(httpmock::When); + impl WorkerTaskUploadChunkWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/worker/task/.*/chunk$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn task(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/v1/worker/task/{}/chunk$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: serde_json::Value) -> Self { + Self(self.0.json_body(value)) + } + } + + pub struct WorkerTaskUploadChunkThen(httpmock::Then); + impl WorkerTaskUploadChunkThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::UploadedChunk) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkerTaskCompleteWhen(httpmock::When); + impl WorkerTaskCompleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/worker/task/.*/complete$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn task(self, value: &str) -> Self { + let re = + regex::Regex::new(&format!("^/v1/worker/task/{}/complete$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::WorkerCompleteTask) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerTaskCompleteThen(httpmock::Then); + impl WorkerTaskCompleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self) -> Self { + Self(self.0.status(200u16)) + } + } + + pub struct WorkerTaskAddOutputWhen(httpmock::When); + impl WorkerTaskAddOutputWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/worker/task/.*/output$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn task(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/v1/worker/task/{}/output$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::WorkerAddOutput) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct WorkerTaskAddOutputThen(httpmock::Then); + impl WorkerTaskAddOutputThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self) -> Self { + Self(self.0.status(201u16)) + } + } + + pub struct WorkersListWhen(httpmock::When); + impl WorkersListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/workers$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct WorkersListThen(httpmock::Then); + impl WorkersListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::WorkersResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct WorkersRecycleWhen(httpmock::When); + impl WorkersRecycleWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/workers/recycle$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct WorkersRecycleThen(httpmock::Then); + impl WorkersRecycleThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self) -> Self { + Self(self.0.status(200u16)) + } + } +} + +#[doc = r" An extension trait for [`MockServer`](httpmock::MockServer) that"] +#[doc = r" adds a method for each operation. These are the equivalent of"] +#[doc = r" type-checked [`mock()`](httpmock::MockServer::mock) calls."] +pub trait MockServerExt { + fn control_hold(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ControlHoldWhen, operations::ControlHoldThen); + fn control_resume(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ControlResumeWhen, operations::ControlResumeThen); + fn task_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TaskGetWhen, operations::TaskGetThen); + fn tasks_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TasksGetWhen, operations::TasksGetThen); + fn task_submit(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TaskSubmitWhen, operations::TaskSubmitThen); + fn task_events_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TaskEventsGetWhen, operations::TaskEventsGetThen); + fn task_outputs_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TaskOutputsGetWhen, operations::TaskOutputsGetThen); + fn task_output_download(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TaskOutputDownloadWhen, operations::TaskOutputDownloadThen); + fn user_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UserCreateWhen, operations::UserCreateThen); + fn whoami(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WhoamiWhen, operations::WhoamiThen); + fn worker_bootstrap(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerBootstrapWhen, operations::WorkerBootstrapThen); + fn worker_ping(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerPingWhen, operations::WorkerPingThen); + fn worker_task_append(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskAppendWhen, operations::WorkerTaskAppendThen); + fn worker_task_upload_chunk(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskUploadChunkWhen, operations::WorkerTaskUploadChunkThen); + fn worker_task_complete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskCompleteWhen, operations::WorkerTaskCompleteThen); + fn worker_task_add_output(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskAddOutputWhen, operations::WorkerTaskAddOutputThen); + fn workers_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkersListWhen, operations::WorkersListThen); + fn workers_recycle(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkersRecycleWhen, operations::WorkersRecycleThen); +} + +impl MockServerExt for httpmock::MockServer { + fn control_hold(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ControlHoldWhen, operations::ControlHoldThen), + { + self.mock(|when, then| { + config_fn( + operations::ControlHoldWhen::new(when), + operations::ControlHoldThen::new(then), + ) + }) + } + + fn control_resume(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ControlResumeWhen, operations::ControlResumeThen), + { + self.mock(|when, then| { + config_fn( + operations::ControlResumeWhen::new(when), + operations::ControlResumeThen::new(then), + ) + }) + } + + fn task_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TaskGetWhen, operations::TaskGetThen), + { + self.mock(|when, then| { + config_fn( + operations::TaskGetWhen::new(when), + operations::TaskGetThen::new(then), + ) + }) + } + + fn tasks_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TasksGetWhen, operations::TasksGetThen), + { + self.mock(|when, then| { + config_fn( + operations::TasksGetWhen::new(when), + operations::TasksGetThen::new(then), + ) + }) + } + + fn task_submit(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TaskSubmitWhen, operations::TaskSubmitThen), + { + self.mock(|when, then| { + config_fn( + operations::TaskSubmitWhen::new(when), + operations::TaskSubmitThen::new(then), + ) + }) + } + + fn task_events_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TaskEventsGetWhen, operations::TaskEventsGetThen), + { + self.mock(|when, then| { + config_fn( + operations::TaskEventsGetWhen::new(when), + operations::TaskEventsGetThen::new(then), + ) + }) + } + + fn task_outputs_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TaskOutputsGetWhen, operations::TaskOutputsGetThen), + { + self.mock(|when, then| { + config_fn( + operations::TaskOutputsGetWhen::new(when), + operations::TaskOutputsGetThen::new(then), + ) + }) + } + + fn task_output_download(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TaskOutputDownloadWhen, operations::TaskOutputDownloadThen), + { + self.mock(|when, then| { + config_fn( + operations::TaskOutputDownloadWhen::new(when), + operations::TaskOutputDownloadThen::new(then), + ) + }) + } + + fn user_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UserCreateWhen, operations::UserCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::UserCreateWhen::new(when), + operations::UserCreateThen::new(then), + ) + }) + } + + fn whoami(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WhoamiWhen, operations::WhoamiThen), + { + self.mock(|when, then| { + config_fn( + operations::WhoamiWhen::new(when), + operations::WhoamiThen::new(then), + ) + }) + } + + fn worker_bootstrap(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerBootstrapWhen, operations::WorkerBootstrapThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerBootstrapWhen::new(when), + operations::WorkerBootstrapThen::new(then), + ) + }) + } + + fn worker_ping(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerPingWhen, operations::WorkerPingThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerPingWhen::new(when), + operations::WorkerPingThen::new(then), + ) + }) + } + + fn worker_task_append(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskAppendWhen, operations::WorkerTaskAppendThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerTaskAppendWhen::new(when), + operations::WorkerTaskAppendThen::new(then), + ) + }) + } + + fn worker_task_upload_chunk(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskUploadChunkWhen, operations::WorkerTaskUploadChunkThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerTaskUploadChunkWhen::new(when), + operations::WorkerTaskUploadChunkThen::new(then), + ) + }) + } + + fn worker_task_complete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskCompleteWhen, operations::WorkerTaskCompleteThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerTaskCompleteWhen::new(when), + operations::WorkerTaskCompleteThen::new(then), + ) + }) + } + + fn worker_task_add_output(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkerTaskAddOutputWhen, operations::WorkerTaskAddOutputThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkerTaskAddOutputWhen::new(when), + operations::WorkerTaskAddOutputThen::new(then), + ) + }) + } + + fn workers_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkersListWhen, operations::WorkersListThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkersListWhen::new(when), + operations::WorkersListThen::new(then), + ) + }) + } + + fn workers_recycle(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::WorkersRecycleWhen, operations::WorkersRecycleThen), + { + self.mock(|when, then| { + config_fn( + operations::WorkersRecycleWhen::new(when), + operations::WorkersRecycleThen::new(then), + ) + }) + } +} diff --git a/progenitor-impl/tests/output/keeper-httpmock.out b/progenitor-impl/tests/output/keeper-httpmock.out new file mode 100644 index 00000000..0175d8f4 --- /dev/null +++ b/progenitor-impl/tests/output/keeper-httpmock.out @@ -0,0 +1,349 @@ +pub mod operations { + #![doc = r" [`When`](httpmock::When) and [`Then`](httpmock::Then)"] + #![doc = r" wrappers for each operation. Each can be converted to"] + #![doc = r" its inner type with a call to `into_inner()`. This can"] + #![doc = r" be used to explicitly deviate from permitted values."] + use sdk::*; + pub struct EnrolWhen(httpmock::When); + impl EnrolWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/enrol$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn authorization(self, value: &str) -> Self { + todo!() + } + + pub fn body(self, value: &types::EnrolBody) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct EnrolThen(httpmock::Then); + impl EnrolThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self) -> Self { + Self(self.0.status(201u16)) + } + } + + pub struct GlobalJobsWhen(httpmock::When); + impl GlobalJobsWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/global/jobs$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn authorization(self, value: &str) -> Self { + todo!() + } + } + + pub struct GlobalJobsThen(httpmock::Then); + impl GlobalJobsThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::GlobalJobsResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct PingWhen(httpmock::When); + impl PingWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/ping$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn authorization(self, value: &str) -> Self { + todo!() + } + } + + pub struct PingThen(httpmock::Then); + impl PingThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::PingResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ReportFinishWhen(httpmock::When); + impl ReportFinishWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/report/finish$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn authorization(self, value: &str) -> Self { + todo!() + } + + pub fn body(self, value: &types::ReportFinishBody) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct ReportFinishThen(httpmock::Then); + impl ReportFinishThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::ReportResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ReportOutputWhen(httpmock::When); + impl ReportOutputWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/report/output$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn authorization(self, value: &str) -> Self { + todo!() + } + + pub fn body(self, value: &types::ReportOutputBody) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct ReportOutputThen(httpmock::Then); + impl ReportOutputThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::ReportResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ReportStartWhen(httpmock::When); + impl ReportStartWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/report/start$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn authorization(self, value: &str) -> Self { + todo!() + } + + pub fn body(self, value: &types::ReportStartBody) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct ReportStartThen(httpmock::Then); + impl ReportStartThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::ReportResult) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } +} + +#[doc = r" An extension trait for [`MockServer`](httpmock::MockServer) that"] +#[doc = r" adds a method for each operation. These are the equivalent of"] +#[doc = r" type-checked [`mock()`](httpmock::MockServer::mock) calls."] +pub trait MockServerExt { + fn enrol(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::EnrolWhen, operations::EnrolThen); + fn global_jobs(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::GlobalJobsWhen, operations::GlobalJobsThen); + fn ping(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::PingWhen, operations::PingThen); + fn report_finish(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ReportFinishWhen, operations::ReportFinishThen); + fn report_output(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ReportOutputWhen, operations::ReportOutputThen); + fn report_start(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ReportStartWhen, operations::ReportStartThen); +} + +impl MockServerExt for httpmock::MockServer { + fn enrol(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::EnrolWhen, operations::EnrolThen), + { + self.mock(|when, then| { + config_fn( + operations::EnrolWhen::new(when), + operations::EnrolThen::new(then), + ) + }) + } + + fn global_jobs(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::GlobalJobsWhen, operations::GlobalJobsThen), + { + self.mock(|when, then| { + config_fn( + operations::GlobalJobsWhen::new(when), + operations::GlobalJobsThen::new(then), + ) + }) + } + + fn ping(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::PingWhen, operations::PingThen), + { + self.mock(|when, then| { + config_fn( + operations::PingWhen::new(when), + operations::PingThen::new(then), + ) + }) + } + + fn report_finish(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ReportFinishWhen, operations::ReportFinishThen), + { + self.mock(|when, then| { + config_fn( + operations::ReportFinishWhen::new(when), + operations::ReportFinishThen::new(then), + ) + }) + } + + fn report_output(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ReportOutputWhen, operations::ReportOutputThen), + { + self.mock(|when, then| { + config_fn( + operations::ReportOutputWhen::new(when), + operations::ReportOutputThen::new(then), + ) + }) + } + + fn report_start(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ReportStartWhen, operations::ReportStartThen), + { + self.mock(|when, then| { + config_fn( + operations::ReportStartWhen::new(when), + operations::ReportStartThen::new(then), + ) + }) + } +} diff --git a/progenitor-impl/tests/output/nexus-httpmock.out b/progenitor-impl/tests/output/nexus-httpmock.out new file mode 100644 index 00000000..1f1d45f1 --- /dev/null +++ b/progenitor-impl/tests/output/nexus-httpmock.out @@ -0,0 +1,16471 @@ +pub mod operations { + #![doc = r" [`When`](httpmock::When) and [`Then`](httpmock::Then)"] + #![doc = r" wrappers for each operation. Each can be converted to"] + #![doc = r" its inner type with a call to `into_inner()`. This can"] + #![doc = r" be used to explicitly deviate from permitted values."] + use sdk::*; + pub struct DiskViewByIdWhen(httpmock::When); + impl DiskViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/disks/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!("^/by-id/disks/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct DiskViewByIdThen(httpmock::Then); + impl DiskViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Disk) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ImageViewByIdWhen(httpmock::When); + impl ImageViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/images/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!("^/by-id/images/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct ImageViewByIdThen(httpmock::Then); + impl ImageViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Image) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceViewByIdWhen(httpmock::When); + impl InstanceViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/instances/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = + regex::Regex::new(&format!("^/by-id/instances/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceViewByIdThen(httpmock::Then); + impl InstanceViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceNetworkInterfaceViewByIdWhen(httpmock::When); + impl InstanceNetworkInterfaceViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/network-interfaces/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/by-id/network-interfaces/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceNetworkInterfaceViewByIdThen(httpmock::Then); + impl InstanceNetworkInterfaceViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::NetworkInterface) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationViewByIdWhen(httpmock::When); + impl OrganizationViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/organizations/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!("^/by-id/organizations/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct OrganizationViewByIdThen(httpmock::Then); + impl OrganizationViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Organization) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectViewByIdWhen(httpmock::When); + impl ProjectViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/projects/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = + regex::Regex::new(&format!("^/by-id/projects/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct ProjectViewByIdThen(httpmock::Then); + impl ProjectViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Project) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SnapshotViewByIdWhen(httpmock::When); + impl SnapshotViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/snapshots/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = + regex::Regex::new(&format!("^/by-id/snapshots/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SnapshotViewByIdThen(httpmock::Then); + impl SnapshotViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Snapshot) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterRouteViewByIdWhen(httpmock::When); + impl VpcRouterRouteViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/vpc-router-routes/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = + regex::Regex::new(&format!("^/by-id/vpc-router-routes/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcRouterRouteViewByIdThen(httpmock::Then); + impl VpcRouterRouteViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::RouterRoute) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterViewByIdWhen(httpmock::When); + impl VpcRouterViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/vpc-routers/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = + regex::Regex::new(&format!("^/by-id/vpc-routers/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcRouterViewByIdThen(httpmock::Then); + impl VpcRouterViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcRouter) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcSubnetViewByIdWhen(httpmock::When); + impl VpcSubnetViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/vpc-subnets/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = + regex::Regex::new(&format!("^/by-id/vpc-subnets/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcSubnetViewByIdThen(httpmock::Then); + impl VpcSubnetViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcSubnet) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcViewByIdWhen(httpmock::When); + impl VpcViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/by-id/vpcs/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!("^/by-id/vpcs/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcViewByIdThen(httpmock::Then); + impl VpcViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Vpc) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DeviceAuthRequestWhen(httpmock::When); + impl DeviceAuthRequestWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/device/auth$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::DeviceAuthRequest) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct DeviceAuthRequestThen(httpmock::Then); + impl DeviceAuthRequestThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16, value: serde_json::Value) -> Self { + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct DeviceAuthConfirmWhen(httpmock::When); + impl DeviceAuthConfirmWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/device/confirm$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::DeviceAuthVerify) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct DeviceAuthConfirmThen(httpmock::Then); + impl DeviceAuthConfirmThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DeviceAccessTokenWhen(httpmock::When); + impl DeviceAccessTokenWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/device/token$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::DeviceAccessTokenRequest) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct DeviceAccessTokenThen(httpmock::Then); + impl DeviceAccessTokenThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16, value: serde_json::Value) -> Self { + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct GroupListWhen(httpmock::When); + impl GroupListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/groups$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct GroupListThen(httpmock::Then); + impl GroupListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::GroupResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct LoginSpoofWhen(httpmock::When); + impl LoginSpoofWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/login$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::SpoofLoginBody) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct LoginSpoofThen(httpmock::Then); + impl LoginSpoofThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct LoginLocalWhen(httpmock::When); + impl LoginLocalWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/login/.*/local$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/login/{}/local$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::UsernamePasswordCredentials) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct LoginLocalThen(httpmock::Then); + impl LoginLocalThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn see_other(self) -> Self { + Self(self.0.status(303u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn success(self, status: u16, value: serde_json::Value) -> Self { + assert_eq!(status / 100u16, 2u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct LoginSamlBeginWhen(httpmock::When); + impl LoginSamlBeginWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/login/.*/saml/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/login/{}/saml/.*$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn provider_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/login/.*/saml/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct LoginSamlBeginThen(httpmock::Then); + impl LoginSamlBeginThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn found(self) -> Self { + Self(self.0.status(302u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn success(self, status: u16, value: serde_json::Value) -> Self { + assert_eq!(status / 100u16, 2u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct LoginSamlWhen(httpmock::When); + impl LoginSamlWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/login/.*/saml/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/login/{}/saml/.*$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn provider_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/login/.*/saml/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: serde_json::Value) -> Self { + Self(self.0.json_body(value)) + } + } + + pub struct LoginSamlThen(httpmock::Then); + impl LoginSamlThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn see_other(self) -> Self { + Self(self.0.status(303u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn success(self, status: u16, value: serde_json::Value) -> Self { + assert_eq!(status / 100u16, 2u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct LogoutWhen(httpmock::When); + impl LogoutWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/logout$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct LogoutThen(httpmock::Then); + impl LogoutThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationListWhen(httpmock::When); + impl OrganizationListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/organizations$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameOrIdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct OrganizationListThen(httpmock::Then); + impl OrganizationListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::OrganizationResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationCreateWhen(httpmock::When); + impl OrganizationCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/organizations$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::OrganizationCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct OrganizationCreateThen(httpmock::Then); + impl OrganizationCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Organization) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationViewWhen(httpmock::When); + impl OrganizationViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/organizations/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/organizations/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct OrganizationViewThen(httpmock::Then); + impl OrganizationViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Organization) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationUpdateWhen(httpmock::When); + impl OrganizationUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/organizations/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/organizations/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::OrganizationUpdate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct OrganizationUpdateThen(httpmock::Then); + impl OrganizationUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Organization) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationDeleteWhen(httpmock::When); + impl OrganizationDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/organizations/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/organizations/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct OrganizationDeleteThen(httpmock::Then); + impl OrganizationDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationPolicyViewWhen(httpmock::When); + impl OrganizationPolicyViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/organizations/.*/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/organizations/{}/policy$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct OrganizationPolicyViewThen(httpmock::Then); + impl OrganizationPolicyViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::OrganizationRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationPolicyUpdateWhen(httpmock::When); + impl OrganizationPolicyUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/organizations/.*/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/organizations/{}/policy$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::OrganizationRolePolicy) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct OrganizationPolicyUpdateThen(httpmock::Then); + impl OrganizationPolicyUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::OrganizationRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectListWhen(httpmock::When); + impl ProjectListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/organizations/.*/projects$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/organizations/{}/projects$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameOrIdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct ProjectListThen(httpmock::Then); + impl ProjectListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::ProjectResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectCreateWhen(httpmock::When); + impl ProjectCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/organizations/.*/projects$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/organizations/{}/projects$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::ProjectCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct ProjectCreateThen(httpmock::Then); + impl ProjectCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Project) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectViewWhen(httpmock::When); + impl ProjectViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/organizations/.*/projects/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct ProjectViewThen(httpmock::Then); + impl ProjectViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Project) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectUpdateWhen(httpmock::When); + impl ProjectUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/organizations/.*/projects/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::ProjectUpdate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct ProjectUpdateThen(httpmock::Then); + impl ProjectUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Project) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectDeleteWhen(httpmock::When); + impl ProjectDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/organizations/.*/projects/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct ProjectDeleteThen(httpmock::Then); + impl ProjectDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DiskListWhen(httpmock::When); + impl DiskListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/disks$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/disks$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/disks$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct DiskListThen(httpmock::Then); + impl DiskListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::DiskResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DiskCreateWhen(httpmock::When); + impl DiskCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/disks$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/disks$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/disks$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::DiskCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct DiskCreateThen(httpmock::Then); + impl DiskCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Disk) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DiskViewWhen(httpmock::When); + impl DiskViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/disks/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/disks/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/disks/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn disk_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/disks/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct DiskViewThen(httpmock::Then); + impl DiskViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Disk) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DiskDeleteWhen(httpmock::When); + impl DiskDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::DELETE).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/disks/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/disks/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/disks/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn disk_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/disks/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct DiskDeleteThen(httpmock::Then); + impl DiskDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DiskMetricsListWhen(httpmock::When); + impl DiskMetricsListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/disks/.*/metrics/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/disks/.*/metrics/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/disks/.*/metrics/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn disk_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/disks/{}/metrics/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn metric_name(self, value: types::DiskMetricName) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/disks/.*/metrics/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn end_time(self, value: &chrono::DateTime) -> Self { + Self(self.0.query_param("end_time", value.to_string())) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn start_time(self, value: &chrono::DateTime) -> Self { + Self(self.0.query_param("start_time", value.to_string())) + } + } + + pub struct DiskMetricsListThen(httpmock::Then); + impl DiskMetricsListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::MeasurementResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ImageListWhen(httpmock::When); + impl ImageListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/images$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/images$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/images$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct ImageListThen(httpmock::Then); + impl ImageListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::ImageResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ImageCreateWhen(httpmock::When); + impl ImageCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/images$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/images$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/images$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::ImageCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct ImageCreateThen(httpmock::Then); + impl ImageCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Image) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ImageViewWhen(httpmock::When); + impl ImageViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/images/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/images/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/images/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn image_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/images/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct ImageViewThen(httpmock::Then); + impl ImageViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Image) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ImageDeleteWhen(httpmock::When); + impl ImageDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::DELETE).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/images/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/images/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/images/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn image_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/images/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct ImageDeleteThen(httpmock::Then); + impl ImageDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceListWhen(httpmock::When); + impl InstanceListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct InstanceListThen(httpmock::Then); + impl InstanceListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::InstanceResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceCreateWhen(httpmock::When); + impl InstanceCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::InstanceCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceCreateThen(httpmock::Then); + impl InstanceCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceViewWhen(httpmock::When); + impl InstanceViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceViewThen(httpmock::Then); + impl InstanceViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceDeleteWhen(httpmock::When); + impl InstanceDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::DELETE).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceDeleteThen(httpmock::Then); + impl InstanceDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceDiskListWhen(httpmock::When); + impl InstanceDiskListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances/.*/disks$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/disks$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/disks$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/disks$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct InstanceDiskListThen(httpmock::Then); + impl InstanceDiskListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::DiskResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceDiskAttachWhen(httpmock::When); + impl InstanceDiskAttachWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances/.*/disks/attach$") + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/disks/attach$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/disks/attach$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/disks/attach$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::DiskIdentifier) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceDiskAttachThen(httpmock::Then); + impl InstanceDiskAttachThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::Disk) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceDiskDetachWhen(httpmock::When); + impl InstanceDiskDetachWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances/.*/disks/detach$") + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/disks/detach$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/disks/detach$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/disks/detach$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::DiskIdentifier) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceDiskDetachThen(httpmock::Then); + impl InstanceDiskDetachThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::Disk) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceExternalIpListWhen(httpmock::When); + impl InstanceExternalIpListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances/.*/external-ips$") + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/external-ips$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/external-ips$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/external-ips$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceExternalIpListThen(httpmock::Then); + impl InstanceExternalIpListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::ExternalIpResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceMigrateWhen(httpmock::When); + impl InstanceMigrateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances/.*/migrate$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/migrate$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/migrate$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/migrate$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::InstanceMigrate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceMigrateThen(httpmock::Then); + impl InstanceMigrateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceNetworkInterfaceListWhen(httpmock::When); + impl InstanceNetworkInterfaceListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/instances/.*/network-interfaces$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/network-interfaces$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/network-interfaces$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/network-interfaces$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct InstanceNetworkInterfaceListThen(httpmock::Then); + impl InstanceNetworkInterfaceListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::NetworkInterfaceResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceNetworkInterfaceCreateWhen(httpmock::When); + impl InstanceNetworkInterfaceCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/instances/.*/network-interfaces$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/network-interfaces$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/network-interfaces$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/network-interfaces$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::NetworkInterfaceCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceNetworkInterfaceCreateThen(httpmock::Then); + impl InstanceNetworkInterfaceCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::NetworkInterface) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceNetworkInterfaceViewWhen(httpmock::When); + impl InstanceNetworkInterfaceViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/instances/.*/network-interfaces/.*$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/network-interfaces/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/network-interfaces/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/network-interfaces/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn interface_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/.*/network-interfaces/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceNetworkInterfaceViewThen(httpmock::Then); + impl InstanceNetworkInterfaceViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::NetworkInterface) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceNetworkInterfaceUpdateWhen(httpmock::When); + impl InstanceNetworkInterfaceUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::PUT).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/instances/.*/network-interfaces/.*$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/network-interfaces/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/network-interfaces/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/network-interfaces/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn interface_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/.*/network-interfaces/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::NetworkInterfaceUpdate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceNetworkInterfaceUpdateThen(httpmock::Then); + impl InstanceNetworkInterfaceUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::NetworkInterface) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceNetworkInterfaceDeleteWhen(httpmock::When); + impl InstanceNetworkInterfaceDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::DELETE).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/instances/.*/network-interfaces/.*$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/network-interfaces/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/network-interfaces/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/network-interfaces/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn interface_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/.*/network-interfaces/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceNetworkInterfaceDeleteThen(httpmock::Then); + impl InstanceNetworkInterfaceDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceRebootWhen(httpmock::When); + impl InstanceRebootWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances/.*/reboot$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/reboot$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/reboot$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/reboot$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceRebootThen(httpmock::Then); + impl InstanceRebootThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceSerialConsoleWhen(httpmock::When); + impl InstanceSerialConsoleWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/instances/.*/serial-console$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/serial-console$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/serial-console$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/serial-console$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn from_start(self, value: u64) -> Self { + Self(self.0.query_param("from_start", value.to_string())) + } + + pub fn max_bytes(self, value: u64) -> Self { + Self(self.0.query_param("max_bytes", value.to_string())) + } + + pub fn most_recent(self, value: u64) -> Self { + Self(self.0.query_param("most_recent", value.to_string())) + } + } + + pub struct InstanceSerialConsoleThen(httpmock::Then); + impl InstanceSerialConsoleThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::InstanceSerialConsoleData) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceSerialConsoleStreamWhen(httpmock::When); + impl InstanceSerialConsoleStreamWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/instances/.*/serial-console/stream$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/serial-console/stream$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/serial-console/stream$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/serial-console/stream$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceSerialConsoleStreamThen(httpmock::Then); + impl InstanceSerialConsoleStreamThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16) -> Self { + Self(self.0.status(status)) + } + + pub fn switching_protocols(self) -> Self { + Self(self.0.status(101u16)) + } + } + + pub struct InstanceStartWhen(httpmock::When); + impl InstanceStartWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances/.*/start$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/start$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/start$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/start$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceStartThen(httpmock::Then); + impl InstanceStartThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceStopWhen(httpmock::When); + impl InstanceStopWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/instances/.*/stop$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/instances/.*/stop$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/instances/.*/stop$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn instance_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/instances/{}/stop$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceStopThen(httpmock::Then); + impl InstanceStopThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectPolicyViewWhen(httpmock::When); + impl ProjectPolicyViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/policy$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/policy$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/policy$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct ProjectPolicyViewThen(httpmock::Then); + impl ProjectPolicyViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::ProjectRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectPolicyUpdateWhen(httpmock::When); + impl ProjectPolicyUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::PUT).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/policy$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/policy$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/policy$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::ProjectRolePolicy) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct ProjectPolicyUpdateThen(httpmock::Then); + impl ProjectPolicyUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::ProjectRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SnapshotListWhen(httpmock::When); + impl SnapshotListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/snapshots$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/snapshots$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/snapshots$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SnapshotListThen(httpmock::Then); + impl SnapshotListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SnapshotResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SnapshotCreateWhen(httpmock::When); + impl SnapshotCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/snapshots$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/snapshots$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/snapshots$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::SnapshotCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct SnapshotCreateThen(httpmock::Then); + impl SnapshotCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Snapshot) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SnapshotViewWhen(httpmock::When); + impl SnapshotViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/snapshots/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/snapshots/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/snapshots/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn snapshot_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/snapshots/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SnapshotViewThen(httpmock::Then); + impl SnapshotViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Snapshot) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SnapshotDeleteWhen(httpmock::When); + impl SnapshotDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::DELETE).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/snapshots/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/snapshots/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/snapshots/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn snapshot_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/snapshots/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SnapshotDeleteThen(httpmock::Then); + impl SnapshotDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcListWhen(httpmock::When); + impl VpcListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct VpcListThen(httpmock::Then); + impl VpcListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcCreateWhen(httpmock::When); + impl VpcCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::VpcCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct VpcCreateThen(httpmock::Then); + impl VpcCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Vpc) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcViewWhen(httpmock::When); + impl VpcViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcViewThen(httpmock::Then); + impl VpcViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Vpc) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcUpdateWhen(httpmock::When); + impl VpcUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::PUT).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::VpcUpdate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct VpcUpdateThen(httpmock::Then); + impl VpcUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Vpc) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcDeleteWhen(httpmock::When); + impl VpcDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::DELETE).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcDeleteThen(httpmock::Then); + impl VpcDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcFirewallRulesViewWhen(httpmock::When); + impl VpcFirewallRulesViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/firewall/rules$") + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/firewall/rules$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/firewall/rules$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/firewall/rules$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcFirewallRulesViewThen(httpmock::Then); + impl VpcFirewallRulesViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcFirewallRules) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcFirewallRulesUpdateWhen(httpmock::When); + impl VpcFirewallRulesUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::PUT).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/firewall/rules$") + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/firewall/rules$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/firewall/rules$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/firewall/rules$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::VpcFirewallRuleUpdateParams) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct VpcFirewallRulesUpdateThen(httpmock::Then); + impl VpcFirewallRulesUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcFirewallRules) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterListWhen(httpmock::When); + impl VpcRouterListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/routers$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/routers$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/routers$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/routers$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct VpcRouterListThen(httpmock::Then); + impl VpcRouterListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcRouterResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterCreateWhen(httpmock::When); + impl VpcRouterCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/routers$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/routers$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/routers$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/routers$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::VpcRouterCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct VpcRouterCreateThen(httpmock::Then); + impl VpcRouterCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::VpcRouter) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterViewWhen(httpmock::When); + impl VpcRouterViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/routers/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/routers/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/routers/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/routers/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn router_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcRouterViewThen(httpmock::Then); + impl VpcRouterViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcRouter) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterUpdateWhen(httpmock::When); + impl VpcRouterUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::PUT).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/routers/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/routers/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/routers/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/routers/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn router_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::VpcRouterUpdate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct VpcRouterUpdateThen(httpmock::Then); + impl VpcRouterUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcRouter) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterDeleteWhen(httpmock::When); + impl VpcRouterDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::DELETE).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/routers/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/routers/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/routers/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/routers/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn router_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcRouterDeleteThen(httpmock::Then); + impl VpcRouterDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterRouteListWhen(httpmock::When); + impl VpcRouterRouteListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/routers/.*/routes$") + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/routers/.*/routes$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/routers/.*/routes$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/routers/.*/routes$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn router_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/{}/routes$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct VpcRouterRouteListThen(httpmock::Then); + impl VpcRouterRouteListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::RouterRouteResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterRouteCreateWhen(httpmock::When); + impl VpcRouterRouteCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/routers/.*/routes$") + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/routers/.*/routes$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/routers/.*/routes$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/routers/.*/routes$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn router_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/{}/routes$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::RouterRouteCreateParams) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct VpcRouterRouteCreateThen(httpmock::Then); + impl VpcRouterRouteCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::RouterRoute) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterRouteViewWhen(httpmock::When); + impl VpcRouterRouteViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/vpcs/.*/routers/.*/routes/.*$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/routers/.*/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/routers/.*/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/routers/.*/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn router_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/{}/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn route_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/.*/routes/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcRouterRouteViewThen(httpmock::Then); + impl VpcRouterRouteViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::RouterRoute) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterRouteUpdateWhen(httpmock::When); + impl VpcRouterRouteUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::PUT).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/vpcs/.*/routers/.*/routes/.*$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/routers/.*/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/routers/.*/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/routers/.*/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn router_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/{}/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn route_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/.*/routes/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::RouterRouteUpdateParams) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct VpcRouterRouteUpdateThen(httpmock::Then); + impl VpcRouterRouteUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::RouterRoute) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcRouterRouteDeleteWhen(httpmock::When); + impl VpcRouterRouteDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::DELETE).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/vpcs/.*/routers/.*/routes/.*$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/routers/.*/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/routers/.*/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/routers/.*/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn router_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/{}/routes/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn route_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/routers/.*/routes/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcRouterRouteDeleteThen(httpmock::Then); + impl VpcRouterRouteDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcSubnetListWhen(httpmock::When); + impl VpcSubnetListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/subnets$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/subnets$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/subnets$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/subnets$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct VpcSubnetListThen(httpmock::Then); + impl VpcSubnetListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcSubnetResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcSubnetCreateWhen(httpmock::When); + impl VpcSubnetCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/subnets$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/subnets$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/subnets$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/subnets$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::VpcSubnetCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct VpcSubnetCreateThen(httpmock::Then); + impl VpcSubnetCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::VpcSubnet) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcSubnetViewWhen(httpmock::When); + impl VpcSubnetViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/subnets/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/subnets/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/subnets/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/subnets/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn subnet_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/subnets/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcSubnetViewThen(httpmock::Then); + impl VpcSubnetViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcSubnet) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcSubnetUpdateWhen(httpmock::When); + impl VpcSubnetUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::PUT).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/subnets/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/subnets/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/subnets/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/subnets/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn subnet_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/subnets/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::VpcSubnetUpdate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct VpcSubnetUpdateThen(httpmock::Then); + impl VpcSubnetUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::VpcSubnet) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcSubnetDeleteWhen(httpmock::When); + impl VpcSubnetDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::DELETE).path_matches( + regex::Regex::new("^/organizations/.*/projects/.*/vpcs/.*/subnets/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/subnets/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/subnets/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/subnets/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn subnet_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/subnets/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct VpcSubnetDeleteThen(httpmock::Then); + impl VpcSubnetDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct VpcSubnetListNetworkInterfacesWhen(httpmock::When); + impl VpcSubnetListNetworkInterfacesWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new( + "^/organizations/.*/projects/.*/vpcs/.*/subnets/.*/network-interfaces$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/{}/projects/.*/vpcs/.*/subnets/.*/network-interfaces$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn project_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/{}/vpcs/.*/subnets/.*/network-interfaces$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn vpc_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/{}/subnets/.*/network-interfaces$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn subnet_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/organizations/.*/projects/.*/vpcs/.*/subnets/{}/network-interfaces$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct VpcSubnetListNetworkInterfacesThen(httpmock::Then); + impl VpcSubnetListNetworkInterfacesThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::NetworkInterfaceResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct PolicyViewWhen(httpmock::When); + impl PolicyViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct PolicyViewThen(httpmock::Then); + impl PolicyViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SiloRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct PolicyUpdateWhen(httpmock::When); + impl PolicyUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::SiloRolePolicy) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct PolicyUpdateThen(httpmock::Then); + impl PolicyUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SiloRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct RoleListWhen(httpmock::When); + impl RoleListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/roles$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + } + + pub struct RoleListThen(httpmock::Then); + impl RoleListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::RoleResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct RoleViewWhen(httpmock::When); + impl RoleViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/roles/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn role_name(self, value: &str) -> Self { + let re = regex::Regex::new(&format!("^/roles/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct RoleViewThen(httpmock::Then); + impl RoleViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Role) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SessionMeWhen(httpmock::When); + impl SessionMeWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/session/me$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct SessionMeThen(httpmock::Then); + impl SessionMeThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::User) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SessionMeGroupsWhen(httpmock::When); + impl SessionMeGroupsWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/session/me/groups$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SessionMeGroupsThen(httpmock::Then); + impl SessionMeGroupsThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::GroupResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SessionSshkeyListWhen(httpmock::When); + impl SessionSshkeyListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/session/me/sshkeys$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SessionSshkeyListThen(httpmock::Then); + impl SessionSshkeyListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SshKeyResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SessionSshkeyCreateWhen(httpmock::When); + impl SessionSshkeyCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/session/me/sshkeys$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::SshKeyCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct SessionSshkeyCreateThen(httpmock::Then); + impl SessionSshkeyCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::SshKey) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SessionSshkeyViewWhen(httpmock::When); + impl SessionSshkeyViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/session/me/sshkeys/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn ssh_key_name(self, value: &types::Name) -> Self { + let re = + regex::Regex::new(&format!("^/session/me/sshkeys/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SessionSshkeyViewThen(httpmock::Then); + impl SessionSshkeyViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SshKey) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SessionSshkeyDeleteWhen(httpmock::When); + impl SessionSshkeyDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/session/me/sshkeys/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn ssh_key_name(self, value: &types::Name) -> Self { + let re = + regex::Regex::new(&format!("^/session/me/sshkeys/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SessionSshkeyDeleteThen(httpmock::Then); + impl SessionSshkeyDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemImageViewByIdWhen(httpmock::When); + impl SystemImageViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/by-id/images/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!("^/system/by-id/images/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SystemImageViewByIdThen(httpmock::Then); + impl SystemImageViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::GlobalImage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolViewByIdWhen(httpmock::When); + impl IpPoolViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/by-id/ip-pools/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!("^/system/by-id/ip-pools/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct IpPoolViewByIdThen(httpmock::Then); + impl IpPoolViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::IpPool) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SiloViewByIdWhen(httpmock::When); + impl SiloViewByIdWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/by-id/silos/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = + regex::Regex::new(&format!("^/system/by-id/silos/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SiloViewByIdThen(httpmock::Then); + impl SiloViewByIdThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Silo) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct CertificateListWhen(httpmock::When); + impl CertificateListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/certificates$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct CertificateListThen(httpmock::Then); + impl CertificateListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::CertificateResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct CertificateCreateWhen(httpmock::When); + impl CertificateCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/system/certificates$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::CertificateCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct CertificateCreateThen(httpmock::Then); + impl CertificateCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Certificate) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct CertificateViewWhen(httpmock::When); + impl CertificateViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/certificates/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn certificate(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/system/certificates/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct CertificateViewThen(httpmock::Then); + impl CertificateViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Certificate) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct CertificateDeleteWhen(httpmock::When); + impl CertificateDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/system/certificates/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn certificate(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/system/certificates/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct CertificateDeleteThen(httpmock::Then); + impl CertificateDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct PhysicalDiskListWhen(httpmock::When); + impl PhysicalDiskListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/hardware/disks$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct PhysicalDiskListThen(httpmock::Then); + impl PhysicalDiskListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::PhysicalDiskResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct RackListWhen(httpmock::When); + impl RackListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/hardware/racks$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct RackListThen(httpmock::Then); + impl RackListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::RackResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct RackViewWhen(httpmock::When); + impl RackViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/hardware/racks/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn rack_id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!("^/system/hardware/racks/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct RackViewThen(httpmock::Then); + impl RackViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Rack) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SledListWhen(httpmock::When); + impl SledListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/hardware/sleds$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SledListThen(httpmock::Then); + impl SledListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SledResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SledViewWhen(httpmock::When); + impl SledViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/hardware/sleds/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn sled_id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!("^/system/hardware/sleds/{}$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SledViewThen(httpmock::Then); + impl SledViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Sled) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SledPhysicalDiskListWhen(httpmock::When); + impl SledPhysicalDiskListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/hardware/sleds/.*/disks$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn sled_id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/system/hardware/sleds/{}/disks$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SledPhysicalDiskListThen(httpmock::Then); + impl SledPhysicalDiskListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::PhysicalDiskResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemImageListWhen(httpmock::When); + impl SystemImageListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/images$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SystemImageListThen(httpmock::Then); + impl SystemImageListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::GlobalImageResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemImageCreateWhen(httpmock::When); + impl SystemImageCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/system/images$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::GlobalImageCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct SystemImageCreateThen(httpmock::Then); + impl SystemImageCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::GlobalImage) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemImageViewWhen(httpmock::When); + impl SystemImageViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/images/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn image_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/system/images/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SystemImageViewThen(httpmock::Then); + impl SystemImageViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::GlobalImage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemImageDeleteWhen(httpmock::When); + impl SystemImageDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/system/images/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn image_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/system/images/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SystemImageDeleteThen(httpmock::Then); + impl SystemImageDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolListWhen(httpmock::When); + impl IpPoolListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/ip-pools$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameOrIdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct IpPoolListThen(httpmock::Then); + impl IpPoolListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::IpPoolResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolCreateWhen(httpmock::When); + impl IpPoolCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/system/ip-pools$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::IpPoolCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct IpPoolCreateThen(httpmock::Then); + impl IpPoolCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::IpPool) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolViewWhen(httpmock::When); + impl IpPoolViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/ip-pools/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn pool_name(self, value: &types::Name) -> Self { + let re = + regex::Regex::new(&format!("^/system/ip-pools/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct IpPoolViewThen(httpmock::Then); + impl IpPoolViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::IpPool) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolUpdateWhen(httpmock::When); + impl IpPoolUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/system/ip-pools/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn pool_name(self, value: &types::Name) -> Self { + let re = + regex::Regex::new(&format!("^/system/ip-pools/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::IpPoolUpdate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct IpPoolUpdateThen(httpmock::Then); + impl IpPoolUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::IpPool) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolDeleteWhen(httpmock::When); + impl IpPoolDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/system/ip-pools/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn pool_name(self, value: &types::Name) -> Self { + let re = + regex::Regex::new(&format!("^/system/ip-pools/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct IpPoolDeleteThen(httpmock::Then); + impl IpPoolDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolRangeListWhen(httpmock::When); + impl IpPoolRangeListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/ip-pools/.*/ranges$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn pool_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/system/ip-pools/{}/ranges$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + } + + pub struct IpPoolRangeListThen(httpmock::Then); + impl IpPoolRangeListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::IpPoolRangeResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolRangeAddWhen(httpmock::When); + impl IpPoolRangeAddWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/system/ip-pools/.*/ranges/add$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn pool_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/system/ip-pools/{}/ranges/add$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::IpRange) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct IpPoolRangeAddThen(httpmock::Then); + impl IpPoolRangeAddThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::IpPoolRange) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolRangeRemoveWhen(httpmock::When); + impl IpPoolRangeRemoveWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/system/ip-pools/.*/ranges/remove$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn pool_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/system/ip-pools/{}/ranges/remove$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::IpRange) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct IpPoolRangeRemoveThen(httpmock::Then); + impl IpPoolRangeRemoveThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolServiceViewWhen(httpmock::When); + impl IpPoolServiceViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/ip-pools-service$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct IpPoolServiceViewThen(httpmock::Then); + impl IpPoolServiceViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::IpPool) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolServiceRangeListWhen(httpmock::When); + impl IpPoolServiceRangeListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/ip-pools-service/ranges$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + } + + pub struct IpPoolServiceRangeListThen(httpmock::Then); + impl IpPoolServiceRangeListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::IpPoolRangeResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolServiceRangeAddWhen(httpmock::When); + impl IpPoolServiceRangeAddWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/system/ip-pools-service/ranges/add$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::IpRange) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct IpPoolServiceRangeAddThen(httpmock::Then); + impl IpPoolServiceRangeAddThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::IpPoolRange) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct IpPoolServiceRangeRemoveWhen(httpmock::When); + impl IpPoolServiceRangeRemoveWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/system/ip-pools-service/ranges/remove$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::IpRange) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct IpPoolServiceRangeRemoveThen(httpmock::Then); + impl IpPoolServiceRangeRemoveThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemMetricWhen(httpmock::When); + impl SystemMetricWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/metrics/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn metric_name(self, value: types::SystemMetricName) -> Self { + let re = + regex::Regex::new(&format!("^/system/metrics/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn end_time(self, value: &chrono::DateTime) -> Self { + Self(self.0.query_param("end_time", value.to_string())) + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + Self(self.0.query_param("id", value.to_string())) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn start_time(self, value: &chrono::DateTime) -> Self { + Self(self.0.query_param("start_time", value.to_string())) + } + } + + pub struct SystemMetricThen(httpmock::Then); + impl SystemMetricThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::MeasurementResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemPolicyViewWhen(httpmock::When); + impl SystemPolicyViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct SystemPolicyViewThen(httpmock::Then); + impl SystemPolicyViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::FleetRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemPolicyUpdateWhen(httpmock::When); + impl SystemPolicyUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/system/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::FleetRolePolicy) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct SystemPolicyUpdateThen(httpmock::Then); + impl SystemPolicyUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::FleetRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SagaListWhen(httpmock::When); + impl SagaListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/sagas$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SagaListThen(httpmock::Then); + impl SagaListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SagaResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SagaViewWhen(httpmock::When); + impl SagaViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/sagas/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn saga_id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!("^/system/sagas/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SagaViewThen(httpmock::Then); + impl SagaViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Saga) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SiloListWhen(httpmock::When); + impl SiloListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/silos$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameOrIdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SiloListThen(httpmock::Then); + impl SiloListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SiloResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SiloCreateWhen(httpmock::When); + impl SiloCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/system/silos$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::SiloCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct SiloCreateThen(httpmock::Then); + impl SiloCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Silo) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SiloViewWhen(httpmock::When); + impl SiloViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/silos/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/system/silos/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SiloViewThen(httpmock::Then); + impl SiloViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Silo) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SiloDeleteWhen(httpmock::When); + impl SiloDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/system/silos/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/system/silos/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SiloDeleteThen(httpmock::Then); + impl SiloDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SiloIdentityProviderListWhen(httpmock::When); + impl SiloIdentityProviderListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/system/silos/.*/identity-providers$").unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/{}/identity-providers$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SiloIdentityProviderListThen(httpmock::Then); + impl SiloIdentityProviderListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::IdentityProviderResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct LocalIdpUserCreateWhen(httpmock::When); + impl LocalIdpUserCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/system/silos/.*/identity-providers/local/users$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/{}/identity-providers/local/users$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::UserCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct LocalIdpUserCreateThen(httpmock::Then); + impl LocalIdpUserCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::User) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct LocalIdpUserDeleteWhen(httpmock::When); + impl LocalIdpUserDeleteWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::DELETE).path_matches( + regex::Regex::new("^/system/silos/.*/identity-providers/local/users/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/{}/identity-providers/local/users/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn user_id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/.*/identity-providers/local/users/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct LocalIdpUserDeleteThen(httpmock::Then); + impl LocalIdpUserDeleteThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct LocalIdpUserSetPasswordWhen(httpmock::When); + impl LocalIdpUserSetPasswordWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new( + "^/system/silos/.*/identity-providers/local/users/.*/set-password$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/{}/identity-providers/local/users/.*/set-password$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn user_id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/.*/identity-providers/local/users/{}/set-password$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::UserPassword) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct LocalIdpUserSetPasswordThen(httpmock::Then); + impl LocalIdpUserSetPasswordThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SamlIdentityProviderCreateWhen(httpmock::When); + impl SamlIdentityProviderCreateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::POST).path_matches( + regex::Regex::new("^/system/silos/.*/identity-providers/saml$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/{}/identity-providers/saml$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::SamlIdentityProviderCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct SamlIdentityProviderCreateThen(httpmock::Then); + impl SamlIdentityProviderCreateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::SamlIdentityProvider) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SamlIdentityProviderViewWhen(httpmock::When); + impl SamlIdentityProviderViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/system/silos/.*/identity-providers/saml/.*$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/{}/identity-providers/saml/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn provider_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/.*/identity-providers/saml/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SamlIdentityProviderViewThen(httpmock::Then); + impl SamlIdentityProviderViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SamlIdentityProvider) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SiloPolicyViewWhen(httpmock::When); + impl SiloPolicyViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/silos/.*/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/system/silos/{}/policy$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SiloPolicyViewThen(httpmock::Then); + impl SiloPolicyViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SiloRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SiloPolicyUpdateWhen(httpmock::When); + impl SiloPolicyUpdateWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/system/silos/.*/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/system/silos/{}/policy$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::SiloRolePolicy) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct SiloPolicyUpdateThen(httpmock::Then); + impl SiloPolicyUpdateThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SiloRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SiloUsersListWhen(httpmock::When); + impl SiloUsersListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/silos/.*/users/all$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/system/silos/{}/users/all$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SiloUsersListThen(httpmock::Then); + impl SiloUsersListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::UserResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SiloUserViewWhen(httpmock::When); + impl SiloUserViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/silos/.*/users/id/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn silo_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/{}/users/id/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn user_id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/system/silos/.*/users/id/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SiloUserViewThen(httpmock::Then); + impl SiloUserViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::User) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemUserListWhen(httpmock::When); + impl SystemUserListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/user$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SystemUserListThen(httpmock::Then); + impl SystemUserListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::UserBuiltinResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemUserViewWhen(httpmock::When); + impl SystemUserViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/system/user/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn user_name(self, value: &types::Name) -> Self { + let re = regex::Regex::new(&format!("^/system/user/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SystemUserViewThen(httpmock::Then); + impl SystemUserViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::UserBuiltin) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct TimeseriesSchemaGetWhen(httpmock::When); + impl TimeseriesSchemaGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/timeseries/schema$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + } + + pub struct TimeseriesSchemaGetThen(httpmock::Then); + impl TimeseriesSchemaGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::TimeseriesSchemaResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct UserListWhen(httpmock::When); + impl UserListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/users$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct UserListThen(httpmock::Then); + impl UserListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::UserResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DiskListV1When(httpmock::When); + impl DiskListV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/disks$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + + pub fn sort_by(self, value: types::NameOrIdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct DiskListV1Then(httpmock::Then); + impl DiskListV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::DiskResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DiskCreateV1When(httpmock::When); + impl DiskCreateV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/disks$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + + pub fn body(self, value: &types::DiskCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct DiskCreateV1Then(httpmock::Then); + impl DiskCreateV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Disk) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DiskViewV1When(httpmock::When); + impl DiskViewV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/disks/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn disk(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/v1/disks/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + } + + pub struct DiskViewV1Then(httpmock::Then); + impl DiskViewV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Disk) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct DiskDeleteV1When(httpmock::When); + impl DiskDeleteV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/v1/disks/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn disk(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/v1/disks/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + } + + pub struct DiskDeleteV1Then(httpmock::Then); + impl DiskDeleteV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceListV1When(httpmock::When); + impl InstanceListV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/instances$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + + pub fn sort_by(self, value: types::NameOrIdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct InstanceListV1Then(httpmock::Then); + impl InstanceListV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::InstanceResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceCreateV1When(httpmock::When); + impl InstanceCreateV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/instances$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + + pub fn body(self, value: &types::InstanceCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceCreateV1Then(httpmock::Then); + impl InstanceCreateV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceViewV1When(httpmock::When); + impl InstanceViewV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/instances/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/v1/instances/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + } + + pub struct InstanceViewV1Then(httpmock::Then); + impl InstanceViewV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceDeleteV1When(httpmock::When); + impl InstanceDeleteV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/v1/instances/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/v1/instances/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + } + + pub struct InstanceDeleteV1Then(httpmock::Then); + impl InstanceDeleteV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceDiskListV1When(httpmock::When); + impl InstanceDiskListV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/instances/.*/disks$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = + regex::Regex::new(&format!("^/v1/instances/{}/disks$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + + pub fn sort_by(self, value: types::NameOrIdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct InstanceDiskListV1Then(httpmock::Then); + impl InstanceDiskListV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::DiskResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceDiskAttachV1When(httpmock::When); + impl InstanceDiskAttachV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/instances/.*/disks/attach$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!( + "^/v1/instances/{}/disks/attach$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + + pub fn body(self, value: &types::DiskPath) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceDiskAttachV1Then(httpmock::Then); + impl InstanceDiskAttachV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::Disk) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceDiskDetachV1When(httpmock::When); + impl InstanceDiskDetachV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/instances/.*/disks/detach$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!( + "^/v1/instances/{}/disks/detach$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + + pub fn body(self, value: &types::DiskPath) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceDiskDetachV1Then(httpmock::Then); + impl InstanceDiskDetachV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::Disk) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceMigrateV1When(httpmock::When); + impl InstanceMigrateV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/instances/.*/migrate$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/v1/instances/{}/migrate$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + + pub fn body(self, value: &types::InstanceMigrate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceMigrateV1Then(httpmock::Then); + impl InstanceMigrateV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceRebootV1When(httpmock::When); + impl InstanceRebootV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/instances/.*/reboot$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/v1/instances/{}/reboot$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + } + + pub struct InstanceRebootV1Then(httpmock::Then); + impl InstanceRebootV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceSerialConsoleV1When(httpmock::When); + impl InstanceSerialConsoleV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/instances/.*/serial-console$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!( + "^/v1/instances/{}/serial-console$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn from_start(self, value: u64) -> Self { + Self(self.0.query_param("from_start", value.to_string())) + } + + pub fn max_bytes(self, value: u64) -> Self { + Self(self.0.query_param("max_bytes", value.to_string())) + } + + pub fn most_recent(self, value: u64) -> Self { + Self(self.0.query_param("most_recent", value.to_string())) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + } + + pub struct InstanceSerialConsoleV1Then(httpmock::Then); + impl InstanceSerialConsoleV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::InstanceSerialConsoleData) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceSerialConsoleStreamV1When(httpmock::When); + impl InstanceSerialConsoleStreamV1When { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/v1/instances/.*/serial-console/stream$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!( + "^/v1/instances/{}/serial-console/stream$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + } + + pub struct InstanceSerialConsoleStreamV1Then(httpmock::Then); + impl InstanceSerialConsoleStreamV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16) -> Self { + Self(self.0.status(status)) + } + + pub fn switching_protocols(self) -> Self { + Self(self.0.status(101u16)) + } + } + + pub struct InstanceStartV1When(httpmock::When); + impl InstanceStartV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/instances/.*/start$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = + regex::Regex::new(&format!("^/v1/instances/{}/start$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + } + + pub struct InstanceStartV1Then(httpmock::Then); + impl InstanceStartV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceStopV1When(httpmock::When); + impl InstanceStopV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/instances/.*/stop$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn instance(self, value: &types::NameOrId) -> Self { + let re = + regex::Regex::new(&format!("^/v1/instances/{}/stop$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn project(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("project", value.to_string())) + } + } + + pub struct InstanceStopV1Then(httpmock::Then); + impl InstanceStopV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::Instance) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationListV1When(httpmock::When); + impl OrganizationListV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/organizations$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameOrIdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct OrganizationListV1Then(httpmock::Then); + impl OrganizationListV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::OrganizationResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationCreateV1When(httpmock::When); + impl OrganizationCreateV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/organizations$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::OrganizationCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct OrganizationCreateV1Then(httpmock::Then); + impl OrganizationCreateV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Organization) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationViewV1When(httpmock::When); + impl OrganizationViewV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/organizations/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + let re = + regex::Regex::new(&format!("^/v1/organizations/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct OrganizationViewV1Then(httpmock::Then); + impl OrganizationViewV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Organization) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationUpdateV1When(httpmock::When); + impl OrganizationUpdateV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/v1/organizations/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + let re = + regex::Regex::new(&format!("^/v1/organizations/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::OrganizationUpdate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct OrganizationUpdateV1Then(httpmock::Then); + impl OrganizationUpdateV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Organization) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationDeleteV1When(httpmock::When); + impl OrganizationDeleteV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/v1/organizations/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + let re = + regex::Regex::new(&format!("^/v1/organizations/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct OrganizationDeleteV1Then(httpmock::Then); + impl OrganizationDeleteV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationPolicyViewV1When(httpmock::When); + impl OrganizationPolicyViewV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/organizations/.*/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + let re = + regex::Regex::new(&format!("^/v1/organizations/{}/policy$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct OrganizationPolicyViewV1Then(httpmock::Then); + impl OrganizationPolicyViewV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::OrganizationRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct OrganizationPolicyUpdateV1When(httpmock::When); + impl OrganizationPolicyUpdateV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/v1/organizations/.*/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + let re = + regex::Regex::new(&format!("^/v1/organizations/{}/policy$", value.to_string())) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn body(self, value: &types::OrganizationRolePolicy) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct OrganizationPolicyUpdateV1Then(httpmock::Then); + impl OrganizationPolicyUpdateV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::OrganizationRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectListV1When(httpmock::When); + impl ProjectListV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/projects$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::NameOrIdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct ProjectListV1Then(httpmock::Then); + impl ProjectListV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::ProjectResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectCreateV1When(httpmock::When); + impl ProjectCreateV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/projects$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn body(self, value: &types::ProjectCreate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct ProjectCreateV1Then(httpmock::Then); + impl ProjectCreateV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::Project) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectViewV1When(httpmock::When); + impl ProjectViewV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/projects/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn project(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/v1/projects/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + } + + pub struct ProjectViewV1Then(httpmock::Then); + impl ProjectViewV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Project) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectUpdateV1When(httpmock::When); + impl ProjectUpdateV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/v1/projects/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn project(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/v1/projects/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn body(self, value: &types::ProjectUpdate) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct ProjectUpdateV1Then(httpmock::Then); + impl ProjectUpdateV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::Project) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectDeleteV1When(httpmock::When); + impl ProjectDeleteV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::DELETE) + .path_matches(regex::Regex::new("^/v1/projects/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn project(self, value: &types::NameOrId) -> Self { + let re = regex::Regex::new(&format!("^/v1/projects/{}$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + } + + pub struct ProjectDeleteV1Then(httpmock::Then); + impl ProjectDeleteV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectPolicyViewV1When(httpmock::When); + impl ProjectPolicyViewV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/projects/.*/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn project(self, value: &types::NameOrId) -> Self { + let re = + regex::Regex::new(&format!("^/v1/projects/{}/policy$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + } + + pub struct ProjectPolicyViewV1Then(httpmock::Then); + impl ProjectPolicyViewV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::ProjectRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct ProjectPolicyUpdateV1When(httpmock::When); + impl ProjectPolicyUpdateV1When { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/v1/projects/.*/policy$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn project(self, value: &types::NameOrId) -> Self { + let re = + regex::Regex::new(&format!("^/v1/projects/{}/policy$", value.to_string())).unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn organization(self, value: &types::NameOrId) -> Self { + Self(self.0.query_param("organization", value.to_string())) + } + + pub fn body(self, value: &types::ProjectRolePolicy) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct ProjectPolicyUpdateV1Then(httpmock::Then); + impl ProjectPolicyUpdateV1Then { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::ProjectRolePolicy) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemComponentVersionListWhen(httpmock::When); + impl SystemComponentVersionListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/system/update/components$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SystemComponentVersionListThen(httpmock::Then); + impl SystemComponentVersionListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::UpdateableComponentResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct UpdateDeploymentsListWhen(httpmock::When); + impl UpdateDeploymentsListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/system/update/deployments$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct UpdateDeploymentsListThen(httpmock::Then); + impl UpdateDeploymentsListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::UpdateDeploymentResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct UpdateDeploymentViewWhen(httpmock::When); + impl UpdateDeploymentViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/system/update/deployments/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/v1/system/update/deployments/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct UpdateDeploymentViewThen(httpmock::Then); + impl UpdateDeploymentViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::UpdateDeployment) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemUpdateRefreshWhen(httpmock::When); + impl SystemUpdateRefreshWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/system/update/refresh$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct SystemUpdateRefreshThen(httpmock::Then); + impl SystemUpdateRefreshThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemUpdateStartWhen(httpmock::When); + impl SystemUpdateStartWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/system/update/start$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::SystemUpdateStart) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct SystemUpdateStartThen(httpmock::Then); + impl SystemUpdateStartThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn accepted(self, value: &types::UpdateDeployment) -> Self { + Self( + self.0 + .status(202u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemUpdateStopWhen(httpmock::When); + impl SystemUpdateStopWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/system/update/stop$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct SystemUpdateStopThen(httpmock::Then); + impl SystemUpdateStopThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemUpdateListWhen(httpmock::When); + impl SystemUpdateListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/system/update/updates$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: std::num::NonZeroU32) -> Self { + Self(self.0.query_param("limit", value.to_string())) + } + + pub fn page_token(self, value: &str) -> Self { + Self(self.0.query_param("page_token", value.to_string())) + } + + pub fn sort_by(self, value: types::IdSortMode) -> Self { + Self(self.0.query_param("sort_by", value.to_string())) + } + } + + pub struct SystemUpdateListThen(httpmock::Then); + impl SystemUpdateListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SystemUpdateResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemUpdateViewWhen(httpmock::When); + impl SystemUpdateViewWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/system/update/updates/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn version(self, value: &types::SemverVersion) -> Self { + let re = regex::Regex::new(&format!( + "^/v1/system/update/updates/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SystemUpdateViewThen(httpmock::Then); + impl SystemUpdateViewThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SystemUpdate) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemUpdateComponentsListWhen(httpmock::When); + impl SystemUpdateComponentsListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self(inner.method(httpmock::Method::GET).path_matches( + regex::Regex::new("^/v1/system/update/updates/.*/components$").unwrap(), + )) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn version(self, value: &types::SemverVersion) -> Self { + let re = regex::Regex::new(&format!( + "^/v1/system/update/updates/{}/components$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SystemUpdateComponentsListThen(httpmock::Then); + impl SystemUpdateComponentsListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::ComponentUpdateResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemVersionWhen(httpmock::When); + impl SystemVersionWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/system/update/version$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct SystemVersionThen(httpmock::Then); + impl SystemVersionThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SystemVersion) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } +} + +#[doc = r" An extension trait for [`MockServer`](httpmock::MockServer) that"] +#[doc = r" adds a method for each operation. These are the equivalent of"] +#[doc = r" type-checked [`mock()`](httpmock::MockServer::mock) calls."] +pub trait MockServerExt { + fn disk_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskViewByIdWhen, operations::DiskViewByIdThen); + fn image_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ImageViewByIdWhen, operations::ImageViewByIdThen); + fn instance_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceViewByIdWhen, operations::InstanceViewByIdThen); + fn instance_network_interface_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceViewByIdWhen, + operations::InstanceNetworkInterfaceViewByIdThen, + ); + fn organization_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationViewByIdWhen, operations::OrganizationViewByIdThen); + fn project_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectViewByIdWhen, operations::ProjectViewByIdThen); + fn snapshot_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SnapshotViewByIdWhen, operations::SnapshotViewByIdThen); + fn vpc_router_route_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteViewByIdWhen, operations::VpcRouterRouteViewByIdThen); + fn vpc_router_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterViewByIdWhen, operations::VpcRouterViewByIdThen); + fn vpc_subnet_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetViewByIdWhen, operations::VpcSubnetViewByIdThen); + fn vpc_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcViewByIdWhen, operations::VpcViewByIdThen); + fn device_auth_request(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DeviceAuthRequestWhen, operations::DeviceAuthRequestThen); + fn device_auth_confirm(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DeviceAuthConfirmWhen, operations::DeviceAuthConfirmThen); + fn device_access_token(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DeviceAccessTokenWhen, operations::DeviceAccessTokenThen); + fn group_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::GroupListWhen, operations::GroupListThen); + fn login_spoof(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LoginSpoofWhen, operations::LoginSpoofThen); + fn login_local(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LoginLocalWhen, operations::LoginLocalThen); + fn login_saml_begin(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LoginSamlBeginWhen, operations::LoginSamlBeginThen); + fn login_saml(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LoginSamlWhen, operations::LoginSamlThen); + fn logout(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LogoutWhen, operations::LogoutThen); + fn organization_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationListWhen, operations::OrganizationListThen); + fn organization_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationCreateWhen, operations::OrganizationCreateThen); + fn organization_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationViewWhen, operations::OrganizationViewThen); + fn organization_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationUpdateWhen, operations::OrganizationUpdateThen); + fn organization_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationDeleteWhen, operations::OrganizationDeleteThen); + fn organization_policy_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationPolicyViewWhen, operations::OrganizationPolicyViewThen); + fn organization_policy_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::OrganizationPolicyUpdateWhen, + operations::OrganizationPolicyUpdateThen, + ); + fn project_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectListWhen, operations::ProjectListThen); + fn project_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectCreateWhen, operations::ProjectCreateThen); + fn project_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectViewWhen, operations::ProjectViewThen); + fn project_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectUpdateWhen, operations::ProjectUpdateThen); + fn project_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectDeleteWhen, operations::ProjectDeleteThen); + fn disk_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskListWhen, operations::DiskListThen); + fn disk_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskCreateWhen, operations::DiskCreateThen); + fn disk_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskViewWhen, operations::DiskViewThen); + fn disk_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskDeleteWhen, operations::DiskDeleteThen); + fn disk_metrics_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskMetricsListWhen, operations::DiskMetricsListThen); + fn image_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ImageListWhen, operations::ImageListThen); + fn image_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ImageCreateWhen, operations::ImageCreateThen); + fn image_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ImageViewWhen, operations::ImageViewThen); + fn image_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ImageDeleteWhen, operations::ImageDeleteThen); + fn instance_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceListWhen, operations::InstanceListThen); + fn instance_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceCreateWhen, operations::InstanceCreateThen); + fn instance_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceViewWhen, operations::InstanceViewThen); + fn instance_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDeleteWhen, operations::InstanceDeleteThen); + fn instance_disk_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskListWhen, operations::InstanceDiskListThen); + fn instance_disk_attach(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskAttachWhen, operations::InstanceDiskAttachThen); + fn instance_disk_detach(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskDetachWhen, operations::InstanceDiskDetachThen); + fn instance_external_ip_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceExternalIpListWhen, operations::InstanceExternalIpListThen); + fn instance_migrate(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceMigrateWhen, operations::InstanceMigrateThen); + fn instance_network_interface_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceListWhen, + operations::InstanceNetworkInterfaceListThen, + ); + fn instance_network_interface_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceCreateWhen, + operations::InstanceNetworkInterfaceCreateThen, + ); + fn instance_network_interface_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceViewWhen, + operations::InstanceNetworkInterfaceViewThen, + ); + fn instance_network_interface_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceUpdateWhen, + operations::InstanceNetworkInterfaceUpdateThen, + ); + fn instance_network_interface_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceDeleteWhen, + operations::InstanceNetworkInterfaceDeleteThen, + ); + fn instance_reboot(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceRebootWhen, operations::InstanceRebootThen); + fn instance_serial_console(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceSerialConsoleWhen, operations::InstanceSerialConsoleThen); + fn instance_serial_console_stream(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceSerialConsoleStreamWhen, + operations::InstanceSerialConsoleStreamThen, + ); + fn instance_start(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStartWhen, operations::InstanceStartThen); + fn instance_stop(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStopWhen, operations::InstanceStopThen); + fn project_policy_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectPolicyViewWhen, operations::ProjectPolicyViewThen); + fn project_policy_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectPolicyUpdateWhen, operations::ProjectPolicyUpdateThen); + fn snapshot_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SnapshotListWhen, operations::SnapshotListThen); + fn snapshot_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SnapshotCreateWhen, operations::SnapshotCreateThen); + fn snapshot_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SnapshotViewWhen, operations::SnapshotViewThen); + fn snapshot_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SnapshotDeleteWhen, operations::SnapshotDeleteThen); + fn vpc_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcListWhen, operations::VpcListThen); + fn vpc_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcCreateWhen, operations::VpcCreateThen); + fn vpc_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcViewWhen, operations::VpcViewThen); + fn vpc_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcUpdateWhen, operations::VpcUpdateThen); + fn vpc_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcDeleteWhen, operations::VpcDeleteThen); + fn vpc_firewall_rules_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcFirewallRulesViewWhen, operations::VpcFirewallRulesViewThen); + fn vpc_firewall_rules_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcFirewallRulesUpdateWhen, operations::VpcFirewallRulesUpdateThen); + fn vpc_router_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterListWhen, operations::VpcRouterListThen); + fn vpc_router_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterCreateWhen, operations::VpcRouterCreateThen); + fn vpc_router_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterViewWhen, operations::VpcRouterViewThen); + fn vpc_router_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterUpdateWhen, operations::VpcRouterUpdateThen); + fn vpc_router_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterDeleteWhen, operations::VpcRouterDeleteThen); + fn vpc_router_route_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteListWhen, operations::VpcRouterRouteListThen); + fn vpc_router_route_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteCreateWhen, operations::VpcRouterRouteCreateThen); + fn vpc_router_route_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteViewWhen, operations::VpcRouterRouteViewThen); + fn vpc_router_route_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteUpdateWhen, operations::VpcRouterRouteUpdateThen); + fn vpc_router_route_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteDeleteWhen, operations::VpcRouterRouteDeleteThen); + fn vpc_subnet_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetListWhen, operations::VpcSubnetListThen); + fn vpc_subnet_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetCreateWhen, operations::VpcSubnetCreateThen); + fn vpc_subnet_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetViewWhen, operations::VpcSubnetViewThen); + fn vpc_subnet_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetUpdateWhen, operations::VpcSubnetUpdateThen); + fn vpc_subnet_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetDeleteWhen, operations::VpcSubnetDeleteThen); + fn vpc_subnet_list_network_interfaces(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::VpcSubnetListNetworkInterfacesWhen, + operations::VpcSubnetListNetworkInterfacesThen, + ); + fn policy_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::PolicyViewWhen, operations::PolicyViewThen); + fn policy_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::PolicyUpdateWhen, operations::PolicyUpdateThen); + fn role_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::RoleListWhen, operations::RoleListThen); + fn role_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::RoleViewWhen, operations::RoleViewThen); + fn session_me(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionMeWhen, operations::SessionMeThen); + fn session_me_groups(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionMeGroupsWhen, operations::SessionMeGroupsThen); + fn session_sshkey_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionSshkeyListWhen, operations::SessionSshkeyListThen); + fn session_sshkey_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionSshkeyCreateWhen, operations::SessionSshkeyCreateThen); + fn session_sshkey_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionSshkeyViewWhen, operations::SessionSshkeyViewThen); + fn session_sshkey_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionSshkeyDeleteWhen, operations::SessionSshkeyDeleteThen); + fn system_image_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemImageViewByIdWhen, operations::SystemImageViewByIdThen); + fn ip_pool_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolViewByIdWhen, operations::IpPoolViewByIdThen); + fn silo_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloViewByIdWhen, operations::SiloViewByIdThen); + fn certificate_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::CertificateListWhen, operations::CertificateListThen); + fn certificate_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::CertificateCreateWhen, operations::CertificateCreateThen); + fn certificate_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::CertificateViewWhen, operations::CertificateViewThen); + fn certificate_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::CertificateDeleteWhen, operations::CertificateDeleteThen); + fn physical_disk_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::PhysicalDiskListWhen, operations::PhysicalDiskListThen); + fn rack_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::RackListWhen, operations::RackListThen); + fn rack_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::RackViewWhen, operations::RackViewThen); + fn sled_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SledListWhen, operations::SledListThen); + fn sled_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SledViewWhen, operations::SledViewThen); + fn sled_physical_disk_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SledPhysicalDiskListWhen, operations::SledPhysicalDiskListThen); + fn system_image_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemImageListWhen, operations::SystemImageListThen); + fn system_image_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemImageCreateWhen, operations::SystemImageCreateThen); + fn system_image_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemImageViewWhen, operations::SystemImageViewThen); + fn system_image_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemImageDeleteWhen, operations::SystemImageDeleteThen); + fn ip_pool_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolListWhen, operations::IpPoolListThen); + fn ip_pool_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolCreateWhen, operations::IpPoolCreateThen); + fn ip_pool_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolViewWhen, operations::IpPoolViewThen); + fn ip_pool_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolUpdateWhen, operations::IpPoolUpdateThen); + fn ip_pool_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolDeleteWhen, operations::IpPoolDeleteThen); + fn ip_pool_range_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolRangeListWhen, operations::IpPoolRangeListThen); + fn ip_pool_range_add(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolRangeAddWhen, operations::IpPoolRangeAddThen); + fn ip_pool_range_remove(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolRangeRemoveWhen, operations::IpPoolRangeRemoveThen); + fn ip_pool_service_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolServiceViewWhen, operations::IpPoolServiceViewThen); + fn ip_pool_service_range_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolServiceRangeListWhen, operations::IpPoolServiceRangeListThen); + fn ip_pool_service_range_add(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolServiceRangeAddWhen, operations::IpPoolServiceRangeAddThen); + fn ip_pool_service_range_remove(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::IpPoolServiceRangeRemoveWhen, + operations::IpPoolServiceRangeRemoveThen, + ); + fn system_metric(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemMetricWhen, operations::SystemMetricThen); + fn system_policy_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemPolicyViewWhen, operations::SystemPolicyViewThen); + fn system_policy_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemPolicyUpdateWhen, operations::SystemPolicyUpdateThen); + fn saga_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SagaListWhen, operations::SagaListThen); + fn saga_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SagaViewWhen, operations::SagaViewThen); + fn silo_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloListWhen, operations::SiloListThen); + fn silo_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloCreateWhen, operations::SiloCreateThen); + fn silo_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloViewWhen, operations::SiloViewThen); + fn silo_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloDeleteWhen, operations::SiloDeleteThen); + fn silo_identity_provider_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SiloIdentityProviderListWhen, + operations::SiloIdentityProviderListThen, + ); + fn local_idp_user_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LocalIdpUserCreateWhen, operations::LocalIdpUserCreateThen); + fn local_idp_user_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LocalIdpUserDeleteWhen, operations::LocalIdpUserDeleteThen); + fn local_idp_user_set_password(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LocalIdpUserSetPasswordWhen, operations::LocalIdpUserSetPasswordThen); + fn saml_identity_provider_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SamlIdentityProviderCreateWhen, + operations::SamlIdentityProviderCreateThen, + ); + fn saml_identity_provider_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SamlIdentityProviderViewWhen, + operations::SamlIdentityProviderViewThen, + ); + fn silo_policy_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloPolicyViewWhen, operations::SiloPolicyViewThen); + fn silo_policy_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloPolicyUpdateWhen, operations::SiloPolicyUpdateThen); + fn silo_users_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloUsersListWhen, operations::SiloUsersListThen); + fn silo_user_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloUserViewWhen, operations::SiloUserViewThen); + fn system_user_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUserListWhen, operations::SystemUserListThen); + fn system_user_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUserViewWhen, operations::SystemUserViewThen); + fn timeseries_schema_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TimeseriesSchemaGetWhen, operations::TimeseriesSchemaGetThen); + fn user_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UserListWhen, operations::UserListThen); + fn disk_list_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskListV1When, operations::DiskListV1Then); + fn disk_create_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskCreateV1When, operations::DiskCreateV1Then); + fn disk_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskViewV1When, operations::DiskViewV1Then); + fn disk_delete_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskDeleteV1When, operations::DiskDeleteV1Then); + fn instance_list_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceListV1When, operations::InstanceListV1Then); + fn instance_create_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceCreateV1When, operations::InstanceCreateV1Then); + fn instance_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceViewV1When, operations::InstanceViewV1Then); + fn instance_delete_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDeleteV1When, operations::InstanceDeleteV1Then); + fn instance_disk_list_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskListV1When, operations::InstanceDiskListV1Then); + fn instance_disk_attach_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskAttachV1When, operations::InstanceDiskAttachV1Then); + fn instance_disk_detach_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskDetachV1When, operations::InstanceDiskDetachV1Then); + fn instance_migrate_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceMigrateV1When, operations::InstanceMigrateV1Then); + fn instance_reboot_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceRebootV1When, operations::InstanceRebootV1Then); + fn instance_serial_console_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceSerialConsoleV1When, operations::InstanceSerialConsoleV1Then); + fn instance_serial_console_stream_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceSerialConsoleStreamV1When, + operations::InstanceSerialConsoleStreamV1Then, + ); + fn instance_start_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStartV1When, operations::InstanceStartV1Then); + fn instance_stop_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStopV1When, operations::InstanceStopV1Then); + fn organization_list_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationListV1When, operations::OrganizationListV1Then); + fn organization_create_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationCreateV1When, operations::OrganizationCreateV1Then); + fn organization_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationViewV1When, operations::OrganizationViewV1Then); + fn organization_update_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationUpdateV1When, operations::OrganizationUpdateV1Then); + fn organization_delete_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationDeleteV1When, operations::OrganizationDeleteV1Then); + fn organization_policy_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::OrganizationPolicyViewV1When, + operations::OrganizationPolicyViewV1Then, + ); + fn organization_policy_update_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::OrganizationPolicyUpdateV1When, + operations::OrganizationPolicyUpdateV1Then, + ); + fn project_list_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectListV1When, operations::ProjectListV1Then); + fn project_create_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectCreateV1When, operations::ProjectCreateV1Then); + fn project_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectViewV1When, operations::ProjectViewV1Then); + fn project_update_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectUpdateV1When, operations::ProjectUpdateV1Then); + fn project_delete_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectDeleteV1When, operations::ProjectDeleteV1Then); + fn project_policy_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectPolicyViewV1When, operations::ProjectPolicyViewV1Then); + fn project_policy_update_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectPolicyUpdateV1When, operations::ProjectPolicyUpdateV1Then); + fn system_component_version_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SystemComponentVersionListWhen, + operations::SystemComponentVersionListThen, + ); + fn update_deployments_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UpdateDeploymentsListWhen, operations::UpdateDeploymentsListThen); + fn update_deployment_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UpdateDeploymentViewWhen, operations::UpdateDeploymentViewThen); + fn system_update_refresh(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUpdateRefreshWhen, operations::SystemUpdateRefreshThen); + fn system_update_start(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUpdateStartWhen, operations::SystemUpdateStartThen); + fn system_update_stop(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUpdateStopWhen, operations::SystemUpdateStopThen); + fn system_update_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUpdateListWhen, operations::SystemUpdateListThen); + fn system_update_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUpdateViewWhen, operations::SystemUpdateViewThen); + fn system_update_components_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SystemUpdateComponentsListWhen, + operations::SystemUpdateComponentsListThen, + ); + fn system_version(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemVersionWhen, operations::SystemVersionThen); +} + +impl MockServerExt for httpmock::MockServer { + fn disk_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskViewByIdWhen, operations::DiskViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::DiskViewByIdWhen::new(when), + operations::DiskViewByIdThen::new(then), + ) + }) + } + + fn image_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ImageViewByIdWhen, operations::ImageViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::ImageViewByIdWhen::new(when), + operations::ImageViewByIdThen::new(then), + ) + }) + } + + fn instance_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceViewByIdWhen, operations::InstanceViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceViewByIdWhen::new(when), + operations::InstanceViewByIdThen::new(then), + ) + }) + } + + fn instance_network_interface_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceViewByIdWhen, + operations::InstanceNetworkInterfaceViewByIdThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::InstanceNetworkInterfaceViewByIdWhen::new(when), + operations::InstanceNetworkInterfaceViewByIdThen::new(then), + ) + }) + } + + fn organization_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationViewByIdWhen, operations::OrganizationViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationViewByIdWhen::new(when), + operations::OrganizationViewByIdThen::new(then), + ) + }) + } + + fn project_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectViewByIdWhen, operations::ProjectViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::ProjectViewByIdWhen::new(when), + operations::ProjectViewByIdThen::new(then), + ) + }) + } + + fn snapshot_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SnapshotViewByIdWhen, operations::SnapshotViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::SnapshotViewByIdWhen::new(when), + operations::SnapshotViewByIdThen::new(then), + ) + }) + } + + fn vpc_router_route_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteViewByIdWhen, operations::VpcRouterRouteViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterRouteViewByIdWhen::new(when), + operations::VpcRouterRouteViewByIdThen::new(then), + ) + }) + } + + fn vpc_router_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterViewByIdWhen, operations::VpcRouterViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterViewByIdWhen::new(when), + operations::VpcRouterViewByIdThen::new(then), + ) + }) + } + + fn vpc_subnet_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetViewByIdWhen, operations::VpcSubnetViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcSubnetViewByIdWhen::new(when), + operations::VpcSubnetViewByIdThen::new(then), + ) + }) + } + + fn vpc_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcViewByIdWhen, operations::VpcViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcViewByIdWhen::new(when), + operations::VpcViewByIdThen::new(then), + ) + }) + } + + fn device_auth_request(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DeviceAuthRequestWhen, operations::DeviceAuthRequestThen), + { + self.mock(|when, then| { + config_fn( + operations::DeviceAuthRequestWhen::new(when), + operations::DeviceAuthRequestThen::new(then), + ) + }) + } + + fn device_auth_confirm(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DeviceAuthConfirmWhen, operations::DeviceAuthConfirmThen), + { + self.mock(|when, then| { + config_fn( + operations::DeviceAuthConfirmWhen::new(when), + operations::DeviceAuthConfirmThen::new(then), + ) + }) + } + + fn device_access_token(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DeviceAccessTokenWhen, operations::DeviceAccessTokenThen), + { + self.mock(|when, then| { + config_fn( + operations::DeviceAccessTokenWhen::new(when), + operations::DeviceAccessTokenThen::new(then), + ) + }) + } + + fn group_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::GroupListWhen, operations::GroupListThen), + { + self.mock(|when, then| { + config_fn( + operations::GroupListWhen::new(when), + operations::GroupListThen::new(then), + ) + }) + } + + fn login_spoof(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LoginSpoofWhen, operations::LoginSpoofThen), + { + self.mock(|when, then| { + config_fn( + operations::LoginSpoofWhen::new(when), + operations::LoginSpoofThen::new(then), + ) + }) + } + + fn login_local(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LoginLocalWhen, operations::LoginLocalThen), + { + self.mock(|when, then| { + config_fn( + operations::LoginLocalWhen::new(when), + operations::LoginLocalThen::new(then), + ) + }) + } + + fn login_saml_begin(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LoginSamlBeginWhen, operations::LoginSamlBeginThen), + { + self.mock(|when, then| { + config_fn( + operations::LoginSamlBeginWhen::new(when), + operations::LoginSamlBeginThen::new(then), + ) + }) + } + + fn login_saml(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LoginSamlWhen, operations::LoginSamlThen), + { + self.mock(|when, then| { + config_fn( + operations::LoginSamlWhen::new(when), + operations::LoginSamlThen::new(then), + ) + }) + } + + fn logout(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LogoutWhen, operations::LogoutThen), + { + self.mock(|when, then| { + config_fn( + operations::LogoutWhen::new(when), + operations::LogoutThen::new(then), + ) + }) + } + + fn organization_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationListWhen, operations::OrganizationListThen), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationListWhen::new(when), + operations::OrganizationListThen::new(then), + ) + }) + } + + fn organization_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationCreateWhen, operations::OrganizationCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationCreateWhen::new(when), + operations::OrganizationCreateThen::new(then), + ) + }) + } + + fn organization_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationViewWhen, operations::OrganizationViewThen), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationViewWhen::new(when), + operations::OrganizationViewThen::new(then), + ) + }) + } + + fn organization_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationUpdateWhen, operations::OrganizationUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationUpdateWhen::new(when), + operations::OrganizationUpdateThen::new(then), + ) + }) + } + + fn organization_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationDeleteWhen, operations::OrganizationDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationDeleteWhen::new(when), + operations::OrganizationDeleteThen::new(then), + ) + }) + } + + fn organization_policy_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationPolicyViewWhen, operations::OrganizationPolicyViewThen), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationPolicyViewWhen::new(when), + operations::OrganizationPolicyViewThen::new(then), + ) + }) + } + + fn organization_policy_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::OrganizationPolicyUpdateWhen, + operations::OrganizationPolicyUpdateThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationPolicyUpdateWhen::new(when), + operations::OrganizationPolicyUpdateThen::new(then), + ) + }) + } + + fn project_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectListWhen, operations::ProjectListThen), + { + self.mock(|when, then| { + config_fn( + operations::ProjectListWhen::new(when), + operations::ProjectListThen::new(then), + ) + }) + } + + fn project_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectCreateWhen, operations::ProjectCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::ProjectCreateWhen::new(when), + operations::ProjectCreateThen::new(then), + ) + }) + } + + fn project_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectViewWhen, operations::ProjectViewThen), + { + self.mock(|when, then| { + config_fn( + operations::ProjectViewWhen::new(when), + operations::ProjectViewThen::new(then), + ) + }) + } + + fn project_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectUpdateWhen, operations::ProjectUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::ProjectUpdateWhen::new(when), + operations::ProjectUpdateThen::new(then), + ) + }) + } + + fn project_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectDeleteWhen, operations::ProjectDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::ProjectDeleteWhen::new(when), + operations::ProjectDeleteThen::new(then), + ) + }) + } + + fn disk_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskListWhen, operations::DiskListThen), + { + self.mock(|when, then| { + config_fn( + operations::DiskListWhen::new(when), + operations::DiskListThen::new(then), + ) + }) + } + + fn disk_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskCreateWhen, operations::DiskCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::DiskCreateWhen::new(when), + operations::DiskCreateThen::new(then), + ) + }) + } + + fn disk_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskViewWhen, operations::DiskViewThen), + { + self.mock(|when, then| { + config_fn( + operations::DiskViewWhen::new(when), + operations::DiskViewThen::new(then), + ) + }) + } + + fn disk_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskDeleteWhen, operations::DiskDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::DiskDeleteWhen::new(when), + operations::DiskDeleteThen::new(then), + ) + }) + } + + fn disk_metrics_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskMetricsListWhen, operations::DiskMetricsListThen), + { + self.mock(|when, then| { + config_fn( + operations::DiskMetricsListWhen::new(when), + operations::DiskMetricsListThen::new(then), + ) + }) + } + + fn image_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ImageListWhen, operations::ImageListThen), + { + self.mock(|when, then| { + config_fn( + operations::ImageListWhen::new(when), + operations::ImageListThen::new(then), + ) + }) + } + + fn image_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ImageCreateWhen, operations::ImageCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::ImageCreateWhen::new(when), + operations::ImageCreateThen::new(then), + ) + }) + } + + fn image_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ImageViewWhen, operations::ImageViewThen), + { + self.mock(|when, then| { + config_fn( + operations::ImageViewWhen::new(when), + operations::ImageViewThen::new(then), + ) + }) + } + + fn image_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ImageDeleteWhen, operations::ImageDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::ImageDeleteWhen::new(when), + operations::ImageDeleteThen::new(then), + ) + }) + } + + fn instance_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceListWhen, operations::InstanceListThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceListWhen::new(when), + operations::InstanceListThen::new(then), + ) + }) + } + + fn instance_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceCreateWhen, operations::InstanceCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceCreateWhen::new(when), + operations::InstanceCreateThen::new(then), + ) + }) + } + + fn instance_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceViewWhen, operations::InstanceViewThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceViewWhen::new(when), + operations::InstanceViewThen::new(then), + ) + }) + } + + fn instance_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDeleteWhen, operations::InstanceDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceDeleteWhen::new(when), + operations::InstanceDeleteThen::new(then), + ) + }) + } + + fn instance_disk_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskListWhen, operations::InstanceDiskListThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceDiskListWhen::new(when), + operations::InstanceDiskListThen::new(then), + ) + }) + } + + fn instance_disk_attach(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskAttachWhen, operations::InstanceDiskAttachThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceDiskAttachWhen::new(when), + operations::InstanceDiskAttachThen::new(then), + ) + }) + } + + fn instance_disk_detach(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskDetachWhen, operations::InstanceDiskDetachThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceDiskDetachWhen::new(when), + operations::InstanceDiskDetachThen::new(then), + ) + }) + } + + fn instance_external_ip_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceExternalIpListWhen, operations::InstanceExternalIpListThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceExternalIpListWhen::new(when), + operations::InstanceExternalIpListThen::new(then), + ) + }) + } + + fn instance_migrate(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceMigrateWhen, operations::InstanceMigrateThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceMigrateWhen::new(when), + operations::InstanceMigrateThen::new(then), + ) + }) + } + + fn instance_network_interface_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceListWhen, + operations::InstanceNetworkInterfaceListThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::InstanceNetworkInterfaceListWhen::new(when), + operations::InstanceNetworkInterfaceListThen::new(then), + ) + }) + } + + fn instance_network_interface_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceCreateWhen, + operations::InstanceNetworkInterfaceCreateThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::InstanceNetworkInterfaceCreateWhen::new(when), + operations::InstanceNetworkInterfaceCreateThen::new(then), + ) + }) + } + + fn instance_network_interface_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceViewWhen, + operations::InstanceNetworkInterfaceViewThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::InstanceNetworkInterfaceViewWhen::new(when), + operations::InstanceNetworkInterfaceViewThen::new(then), + ) + }) + } + + fn instance_network_interface_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceUpdateWhen, + operations::InstanceNetworkInterfaceUpdateThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::InstanceNetworkInterfaceUpdateWhen::new(when), + operations::InstanceNetworkInterfaceUpdateThen::new(then), + ) + }) + } + + fn instance_network_interface_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceNetworkInterfaceDeleteWhen, + operations::InstanceNetworkInterfaceDeleteThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::InstanceNetworkInterfaceDeleteWhen::new(when), + operations::InstanceNetworkInterfaceDeleteThen::new(then), + ) + }) + } + + fn instance_reboot(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceRebootWhen, operations::InstanceRebootThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceRebootWhen::new(when), + operations::InstanceRebootThen::new(then), + ) + }) + } + + fn instance_serial_console(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceSerialConsoleWhen, operations::InstanceSerialConsoleThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceSerialConsoleWhen::new(when), + operations::InstanceSerialConsoleThen::new(then), + ) + }) + } + + fn instance_serial_console_stream(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceSerialConsoleStreamWhen, + operations::InstanceSerialConsoleStreamThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::InstanceSerialConsoleStreamWhen::new(when), + operations::InstanceSerialConsoleStreamThen::new(then), + ) + }) + } + + fn instance_start(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStartWhen, operations::InstanceStartThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceStartWhen::new(when), + operations::InstanceStartThen::new(then), + ) + }) + } + + fn instance_stop(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStopWhen, operations::InstanceStopThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceStopWhen::new(when), + operations::InstanceStopThen::new(then), + ) + }) + } + + fn project_policy_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectPolicyViewWhen, operations::ProjectPolicyViewThen), + { + self.mock(|when, then| { + config_fn( + operations::ProjectPolicyViewWhen::new(when), + operations::ProjectPolicyViewThen::new(then), + ) + }) + } + + fn project_policy_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectPolicyUpdateWhen, operations::ProjectPolicyUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::ProjectPolicyUpdateWhen::new(when), + operations::ProjectPolicyUpdateThen::new(then), + ) + }) + } + + fn snapshot_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SnapshotListWhen, operations::SnapshotListThen), + { + self.mock(|when, then| { + config_fn( + operations::SnapshotListWhen::new(when), + operations::SnapshotListThen::new(then), + ) + }) + } + + fn snapshot_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SnapshotCreateWhen, operations::SnapshotCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::SnapshotCreateWhen::new(when), + operations::SnapshotCreateThen::new(then), + ) + }) + } + + fn snapshot_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SnapshotViewWhen, operations::SnapshotViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SnapshotViewWhen::new(when), + operations::SnapshotViewThen::new(then), + ) + }) + } + + fn snapshot_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SnapshotDeleteWhen, operations::SnapshotDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::SnapshotDeleteWhen::new(when), + operations::SnapshotDeleteThen::new(then), + ) + }) + } + + fn vpc_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcListWhen, operations::VpcListThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcListWhen::new(when), + operations::VpcListThen::new(then), + ) + }) + } + + fn vpc_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcCreateWhen, operations::VpcCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcCreateWhen::new(when), + operations::VpcCreateThen::new(then), + ) + }) + } + + fn vpc_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcViewWhen, operations::VpcViewThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcViewWhen::new(when), + operations::VpcViewThen::new(then), + ) + }) + } + + fn vpc_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcUpdateWhen, operations::VpcUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcUpdateWhen::new(when), + operations::VpcUpdateThen::new(then), + ) + }) + } + + fn vpc_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcDeleteWhen, operations::VpcDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcDeleteWhen::new(when), + operations::VpcDeleteThen::new(then), + ) + }) + } + + fn vpc_firewall_rules_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcFirewallRulesViewWhen, operations::VpcFirewallRulesViewThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcFirewallRulesViewWhen::new(when), + operations::VpcFirewallRulesViewThen::new(then), + ) + }) + } + + fn vpc_firewall_rules_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcFirewallRulesUpdateWhen, operations::VpcFirewallRulesUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcFirewallRulesUpdateWhen::new(when), + operations::VpcFirewallRulesUpdateThen::new(then), + ) + }) + } + + fn vpc_router_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterListWhen, operations::VpcRouterListThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterListWhen::new(when), + operations::VpcRouterListThen::new(then), + ) + }) + } + + fn vpc_router_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterCreateWhen, operations::VpcRouterCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterCreateWhen::new(when), + operations::VpcRouterCreateThen::new(then), + ) + }) + } + + fn vpc_router_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterViewWhen, operations::VpcRouterViewThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterViewWhen::new(when), + operations::VpcRouterViewThen::new(then), + ) + }) + } + + fn vpc_router_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterUpdateWhen, operations::VpcRouterUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterUpdateWhen::new(when), + operations::VpcRouterUpdateThen::new(then), + ) + }) + } + + fn vpc_router_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterDeleteWhen, operations::VpcRouterDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterDeleteWhen::new(when), + operations::VpcRouterDeleteThen::new(then), + ) + }) + } + + fn vpc_router_route_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteListWhen, operations::VpcRouterRouteListThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterRouteListWhen::new(when), + operations::VpcRouterRouteListThen::new(then), + ) + }) + } + + fn vpc_router_route_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteCreateWhen, operations::VpcRouterRouteCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterRouteCreateWhen::new(when), + operations::VpcRouterRouteCreateThen::new(then), + ) + }) + } + + fn vpc_router_route_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteViewWhen, operations::VpcRouterRouteViewThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterRouteViewWhen::new(when), + operations::VpcRouterRouteViewThen::new(then), + ) + }) + } + + fn vpc_router_route_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteUpdateWhen, operations::VpcRouterRouteUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterRouteUpdateWhen::new(when), + operations::VpcRouterRouteUpdateThen::new(then), + ) + }) + } + + fn vpc_router_route_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcRouterRouteDeleteWhen, operations::VpcRouterRouteDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcRouterRouteDeleteWhen::new(when), + operations::VpcRouterRouteDeleteThen::new(then), + ) + }) + } + + fn vpc_subnet_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetListWhen, operations::VpcSubnetListThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcSubnetListWhen::new(when), + operations::VpcSubnetListThen::new(then), + ) + }) + } + + fn vpc_subnet_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetCreateWhen, operations::VpcSubnetCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcSubnetCreateWhen::new(when), + operations::VpcSubnetCreateThen::new(then), + ) + }) + } + + fn vpc_subnet_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetViewWhen, operations::VpcSubnetViewThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcSubnetViewWhen::new(when), + operations::VpcSubnetViewThen::new(then), + ) + }) + } + + fn vpc_subnet_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetUpdateWhen, operations::VpcSubnetUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcSubnetUpdateWhen::new(when), + operations::VpcSubnetUpdateThen::new(then), + ) + }) + } + + fn vpc_subnet_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::VpcSubnetDeleteWhen, operations::VpcSubnetDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::VpcSubnetDeleteWhen::new(when), + operations::VpcSubnetDeleteThen::new(then), + ) + }) + } + + fn vpc_subnet_list_network_interfaces(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::VpcSubnetListNetworkInterfacesWhen, + operations::VpcSubnetListNetworkInterfacesThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::VpcSubnetListNetworkInterfacesWhen::new(when), + operations::VpcSubnetListNetworkInterfacesThen::new(then), + ) + }) + } + + fn policy_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::PolicyViewWhen, operations::PolicyViewThen), + { + self.mock(|when, then| { + config_fn( + operations::PolicyViewWhen::new(when), + operations::PolicyViewThen::new(then), + ) + }) + } + + fn policy_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::PolicyUpdateWhen, operations::PolicyUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::PolicyUpdateWhen::new(when), + operations::PolicyUpdateThen::new(then), + ) + }) + } + + fn role_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::RoleListWhen, operations::RoleListThen), + { + self.mock(|when, then| { + config_fn( + operations::RoleListWhen::new(when), + operations::RoleListThen::new(then), + ) + }) + } + + fn role_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::RoleViewWhen, operations::RoleViewThen), + { + self.mock(|when, then| { + config_fn( + operations::RoleViewWhen::new(when), + operations::RoleViewThen::new(then), + ) + }) + } + + fn session_me(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionMeWhen, operations::SessionMeThen), + { + self.mock(|when, then| { + config_fn( + operations::SessionMeWhen::new(when), + operations::SessionMeThen::new(then), + ) + }) + } + + fn session_me_groups(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionMeGroupsWhen, operations::SessionMeGroupsThen), + { + self.mock(|when, then| { + config_fn( + operations::SessionMeGroupsWhen::new(when), + operations::SessionMeGroupsThen::new(then), + ) + }) + } + + fn session_sshkey_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionSshkeyListWhen, operations::SessionSshkeyListThen), + { + self.mock(|when, then| { + config_fn( + operations::SessionSshkeyListWhen::new(when), + operations::SessionSshkeyListThen::new(then), + ) + }) + } + + fn session_sshkey_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionSshkeyCreateWhen, operations::SessionSshkeyCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::SessionSshkeyCreateWhen::new(when), + operations::SessionSshkeyCreateThen::new(then), + ) + }) + } + + fn session_sshkey_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionSshkeyViewWhen, operations::SessionSshkeyViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SessionSshkeyViewWhen::new(when), + operations::SessionSshkeyViewThen::new(then), + ) + }) + } + + fn session_sshkey_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SessionSshkeyDeleteWhen, operations::SessionSshkeyDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::SessionSshkeyDeleteWhen::new(when), + operations::SessionSshkeyDeleteThen::new(then), + ) + }) + } + + fn system_image_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemImageViewByIdWhen, operations::SystemImageViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemImageViewByIdWhen::new(when), + operations::SystemImageViewByIdThen::new(then), + ) + }) + } + + fn ip_pool_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolViewByIdWhen, operations::IpPoolViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolViewByIdWhen::new(when), + operations::IpPoolViewByIdThen::new(then), + ) + }) + } + + fn silo_view_by_id(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloViewByIdWhen, operations::SiloViewByIdThen), + { + self.mock(|when, then| { + config_fn( + operations::SiloViewByIdWhen::new(when), + operations::SiloViewByIdThen::new(then), + ) + }) + } + + fn certificate_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::CertificateListWhen, operations::CertificateListThen), + { + self.mock(|when, then| { + config_fn( + operations::CertificateListWhen::new(when), + operations::CertificateListThen::new(then), + ) + }) + } + + fn certificate_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::CertificateCreateWhen, operations::CertificateCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::CertificateCreateWhen::new(when), + operations::CertificateCreateThen::new(then), + ) + }) + } + + fn certificate_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::CertificateViewWhen, operations::CertificateViewThen), + { + self.mock(|when, then| { + config_fn( + operations::CertificateViewWhen::new(when), + operations::CertificateViewThen::new(then), + ) + }) + } + + fn certificate_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::CertificateDeleteWhen, operations::CertificateDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::CertificateDeleteWhen::new(when), + operations::CertificateDeleteThen::new(then), + ) + }) + } + + fn physical_disk_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::PhysicalDiskListWhen, operations::PhysicalDiskListThen), + { + self.mock(|when, then| { + config_fn( + operations::PhysicalDiskListWhen::new(when), + operations::PhysicalDiskListThen::new(then), + ) + }) + } + + fn rack_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::RackListWhen, operations::RackListThen), + { + self.mock(|when, then| { + config_fn( + operations::RackListWhen::new(when), + operations::RackListThen::new(then), + ) + }) + } + + fn rack_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::RackViewWhen, operations::RackViewThen), + { + self.mock(|when, then| { + config_fn( + operations::RackViewWhen::new(when), + operations::RackViewThen::new(then), + ) + }) + } + + fn sled_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SledListWhen, operations::SledListThen), + { + self.mock(|when, then| { + config_fn( + operations::SledListWhen::new(when), + operations::SledListThen::new(then), + ) + }) + } + + fn sled_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SledViewWhen, operations::SledViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SledViewWhen::new(when), + operations::SledViewThen::new(then), + ) + }) + } + + fn sled_physical_disk_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SledPhysicalDiskListWhen, operations::SledPhysicalDiskListThen), + { + self.mock(|when, then| { + config_fn( + operations::SledPhysicalDiskListWhen::new(when), + operations::SledPhysicalDiskListThen::new(then), + ) + }) + } + + fn system_image_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemImageListWhen, operations::SystemImageListThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemImageListWhen::new(when), + operations::SystemImageListThen::new(then), + ) + }) + } + + fn system_image_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemImageCreateWhen, operations::SystemImageCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemImageCreateWhen::new(when), + operations::SystemImageCreateThen::new(then), + ) + }) + } + + fn system_image_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemImageViewWhen, operations::SystemImageViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemImageViewWhen::new(when), + operations::SystemImageViewThen::new(then), + ) + }) + } + + fn system_image_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemImageDeleteWhen, operations::SystemImageDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemImageDeleteWhen::new(when), + operations::SystemImageDeleteThen::new(then), + ) + }) + } + + fn ip_pool_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolListWhen, operations::IpPoolListThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolListWhen::new(when), + operations::IpPoolListThen::new(then), + ) + }) + } + + fn ip_pool_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolCreateWhen, operations::IpPoolCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolCreateWhen::new(when), + operations::IpPoolCreateThen::new(then), + ) + }) + } + + fn ip_pool_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolViewWhen, operations::IpPoolViewThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolViewWhen::new(when), + operations::IpPoolViewThen::new(then), + ) + }) + } + + fn ip_pool_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolUpdateWhen, operations::IpPoolUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolUpdateWhen::new(when), + operations::IpPoolUpdateThen::new(then), + ) + }) + } + + fn ip_pool_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolDeleteWhen, operations::IpPoolDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolDeleteWhen::new(when), + operations::IpPoolDeleteThen::new(then), + ) + }) + } + + fn ip_pool_range_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolRangeListWhen, operations::IpPoolRangeListThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolRangeListWhen::new(when), + operations::IpPoolRangeListThen::new(then), + ) + }) + } + + fn ip_pool_range_add(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolRangeAddWhen, operations::IpPoolRangeAddThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolRangeAddWhen::new(when), + operations::IpPoolRangeAddThen::new(then), + ) + }) + } + + fn ip_pool_range_remove(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolRangeRemoveWhen, operations::IpPoolRangeRemoveThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolRangeRemoveWhen::new(when), + operations::IpPoolRangeRemoveThen::new(then), + ) + }) + } + + fn ip_pool_service_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolServiceViewWhen, operations::IpPoolServiceViewThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolServiceViewWhen::new(when), + operations::IpPoolServiceViewThen::new(then), + ) + }) + } + + fn ip_pool_service_range_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolServiceRangeListWhen, operations::IpPoolServiceRangeListThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolServiceRangeListWhen::new(when), + operations::IpPoolServiceRangeListThen::new(then), + ) + }) + } + + fn ip_pool_service_range_add(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::IpPoolServiceRangeAddWhen, operations::IpPoolServiceRangeAddThen), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolServiceRangeAddWhen::new(when), + operations::IpPoolServiceRangeAddThen::new(then), + ) + }) + } + + fn ip_pool_service_range_remove(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::IpPoolServiceRangeRemoveWhen, + operations::IpPoolServiceRangeRemoveThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::IpPoolServiceRangeRemoveWhen::new(when), + operations::IpPoolServiceRangeRemoveThen::new(then), + ) + }) + } + + fn system_metric(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemMetricWhen, operations::SystemMetricThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemMetricWhen::new(when), + operations::SystemMetricThen::new(then), + ) + }) + } + + fn system_policy_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemPolicyViewWhen, operations::SystemPolicyViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemPolicyViewWhen::new(when), + operations::SystemPolicyViewThen::new(then), + ) + }) + } + + fn system_policy_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemPolicyUpdateWhen, operations::SystemPolicyUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemPolicyUpdateWhen::new(when), + operations::SystemPolicyUpdateThen::new(then), + ) + }) + } + + fn saga_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SagaListWhen, operations::SagaListThen), + { + self.mock(|when, then| { + config_fn( + operations::SagaListWhen::new(when), + operations::SagaListThen::new(then), + ) + }) + } + + fn saga_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SagaViewWhen, operations::SagaViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SagaViewWhen::new(when), + operations::SagaViewThen::new(then), + ) + }) + } + + fn silo_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloListWhen, operations::SiloListThen), + { + self.mock(|when, then| { + config_fn( + operations::SiloListWhen::new(when), + operations::SiloListThen::new(then), + ) + }) + } + + fn silo_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloCreateWhen, operations::SiloCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::SiloCreateWhen::new(when), + operations::SiloCreateThen::new(then), + ) + }) + } + + fn silo_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloViewWhen, operations::SiloViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SiloViewWhen::new(when), + operations::SiloViewThen::new(then), + ) + }) + } + + fn silo_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloDeleteWhen, operations::SiloDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::SiloDeleteWhen::new(when), + operations::SiloDeleteThen::new(then), + ) + }) + } + + fn silo_identity_provider_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SiloIdentityProviderListWhen, + operations::SiloIdentityProviderListThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::SiloIdentityProviderListWhen::new(when), + operations::SiloIdentityProviderListThen::new(then), + ) + }) + } + + fn local_idp_user_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LocalIdpUserCreateWhen, operations::LocalIdpUserCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::LocalIdpUserCreateWhen::new(when), + operations::LocalIdpUserCreateThen::new(then), + ) + }) + } + + fn local_idp_user_delete(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LocalIdpUserDeleteWhen, operations::LocalIdpUserDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::LocalIdpUserDeleteWhen::new(when), + operations::LocalIdpUserDeleteThen::new(then), + ) + }) + } + + fn local_idp_user_set_password(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::LocalIdpUserSetPasswordWhen, operations::LocalIdpUserSetPasswordThen), + { + self.mock(|when, then| { + config_fn( + operations::LocalIdpUserSetPasswordWhen::new(when), + operations::LocalIdpUserSetPasswordThen::new(then), + ) + }) + } + + fn saml_identity_provider_create(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SamlIdentityProviderCreateWhen, + operations::SamlIdentityProviderCreateThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::SamlIdentityProviderCreateWhen::new(when), + operations::SamlIdentityProviderCreateThen::new(then), + ) + }) + } + + fn saml_identity_provider_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SamlIdentityProviderViewWhen, + operations::SamlIdentityProviderViewThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::SamlIdentityProviderViewWhen::new(when), + operations::SamlIdentityProviderViewThen::new(then), + ) + }) + } + + fn silo_policy_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloPolicyViewWhen, operations::SiloPolicyViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SiloPolicyViewWhen::new(when), + operations::SiloPolicyViewThen::new(then), + ) + }) + } + + fn silo_policy_update(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloPolicyUpdateWhen, operations::SiloPolicyUpdateThen), + { + self.mock(|when, then| { + config_fn( + operations::SiloPolicyUpdateWhen::new(when), + operations::SiloPolicyUpdateThen::new(then), + ) + }) + } + + fn silo_users_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloUsersListWhen, operations::SiloUsersListThen), + { + self.mock(|when, then| { + config_fn( + operations::SiloUsersListWhen::new(when), + operations::SiloUsersListThen::new(then), + ) + }) + } + + fn silo_user_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SiloUserViewWhen, operations::SiloUserViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SiloUserViewWhen::new(when), + operations::SiloUserViewThen::new(then), + ) + }) + } + + fn system_user_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUserListWhen, operations::SystemUserListThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemUserListWhen::new(when), + operations::SystemUserListThen::new(then), + ) + }) + } + + fn system_user_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUserViewWhen, operations::SystemUserViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemUserViewWhen::new(when), + operations::SystemUserViewThen::new(then), + ) + }) + } + + fn timeseries_schema_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::TimeseriesSchemaGetWhen, operations::TimeseriesSchemaGetThen), + { + self.mock(|when, then| { + config_fn( + operations::TimeseriesSchemaGetWhen::new(when), + operations::TimeseriesSchemaGetThen::new(then), + ) + }) + } + + fn user_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UserListWhen, operations::UserListThen), + { + self.mock(|when, then| { + config_fn( + operations::UserListWhen::new(when), + operations::UserListThen::new(then), + ) + }) + } + + fn disk_list_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskListV1When, operations::DiskListV1Then), + { + self.mock(|when, then| { + config_fn( + operations::DiskListV1When::new(when), + operations::DiskListV1Then::new(then), + ) + }) + } + + fn disk_create_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskCreateV1When, operations::DiskCreateV1Then), + { + self.mock(|when, then| { + config_fn( + operations::DiskCreateV1When::new(when), + operations::DiskCreateV1Then::new(then), + ) + }) + } + + fn disk_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskViewV1When, operations::DiskViewV1Then), + { + self.mock(|when, then| { + config_fn( + operations::DiskViewV1When::new(when), + operations::DiskViewV1Then::new(then), + ) + }) + } + + fn disk_delete_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::DiskDeleteV1When, operations::DiskDeleteV1Then), + { + self.mock(|when, then| { + config_fn( + operations::DiskDeleteV1When::new(when), + operations::DiskDeleteV1Then::new(then), + ) + }) + } + + fn instance_list_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceListV1When, operations::InstanceListV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceListV1When::new(when), + operations::InstanceListV1Then::new(then), + ) + }) + } + + fn instance_create_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceCreateV1When, operations::InstanceCreateV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceCreateV1When::new(when), + operations::InstanceCreateV1Then::new(then), + ) + }) + } + + fn instance_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceViewV1When, operations::InstanceViewV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceViewV1When::new(when), + operations::InstanceViewV1Then::new(then), + ) + }) + } + + fn instance_delete_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDeleteV1When, operations::InstanceDeleteV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceDeleteV1When::new(when), + operations::InstanceDeleteV1Then::new(then), + ) + }) + } + + fn instance_disk_list_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskListV1When, operations::InstanceDiskListV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceDiskListV1When::new(when), + operations::InstanceDiskListV1Then::new(then), + ) + }) + } + + fn instance_disk_attach_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskAttachV1When, operations::InstanceDiskAttachV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceDiskAttachV1When::new(when), + operations::InstanceDiskAttachV1Then::new(then), + ) + }) + } + + fn instance_disk_detach_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceDiskDetachV1When, operations::InstanceDiskDetachV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceDiskDetachV1When::new(when), + operations::InstanceDiskDetachV1Then::new(then), + ) + }) + } + + fn instance_migrate_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceMigrateV1When, operations::InstanceMigrateV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceMigrateV1When::new(when), + operations::InstanceMigrateV1Then::new(then), + ) + }) + } + + fn instance_reboot_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceRebootV1When, operations::InstanceRebootV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceRebootV1When::new(when), + operations::InstanceRebootV1Then::new(then), + ) + }) + } + + fn instance_serial_console_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceSerialConsoleV1When, operations::InstanceSerialConsoleV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceSerialConsoleV1When::new(when), + operations::InstanceSerialConsoleV1Then::new(then), + ) + }) + } + + fn instance_serial_console_stream_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceSerialConsoleStreamV1When, + operations::InstanceSerialConsoleStreamV1Then, + ), + { + self.mock(|when, then| { + config_fn( + operations::InstanceSerialConsoleStreamV1When::new(when), + operations::InstanceSerialConsoleStreamV1Then::new(then), + ) + }) + } + + fn instance_start_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStartV1When, operations::InstanceStartV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceStartV1When::new(when), + operations::InstanceStartV1Then::new(then), + ) + }) + } + + fn instance_stop_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStopV1When, operations::InstanceStopV1Then), + { + self.mock(|when, then| { + config_fn( + operations::InstanceStopV1When::new(when), + operations::InstanceStopV1Then::new(then), + ) + }) + } + + fn organization_list_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationListV1When, operations::OrganizationListV1Then), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationListV1When::new(when), + operations::OrganizationListV1Then::new(then), + ) + }) + } + + fn organization_create_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationCreateV1When, operations::OrganizationCreateV1Then), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationCreateV1When::new(when), + operations::OrganizationCreateV1Then::new(then), + ) + }) + } + + fn organization_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationViewV1When, operations::OrganizationViewV1Then), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationViewV1When::new(when), + operations::OrganizationViewV1Then::new(then), + ) + }) + } + + fn organization_update_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationUpdateV1When, operations::OrganizationUpdateV1Then), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationUpdateV1When::new(when), + operations::OrganizationUpdateV1Then::new(then), + ) + }) + } + + fn organization_delete_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::OrganizationDeleteV1When, operations::OrganizationDeleteV1Then), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationDeleteV1When::new(when), + operations::OrganizationDeleteV1Then::new(then), + ) + }) + } + + fn organization_policy_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::OrganizationPolicyViewV1When, + operations::OrganizationPolicyViewV1Then, + ), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationPolicyViewV1When::new(when), + operations::OrganizationPolicyViewV1Then::new(then), + ) + }) + } + + fn organization_policy_update_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::OrganizationPolicyUpdateV1When, + operations::OrganizationPolicyUpdateV1Then, + ), + { + self.mock(|when, then| { + config_fn( + operations::OrganizationPolicyUpdateV1When::new(when), + operations::OrganizationPolicyUpdateV1Then::new(then), + ) + }) + } + + fn project_list_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectListV1When, operations::ProjectListV1Then), + { + self.mock(|when, then| { + config_fn( + operations::ProjectListV1When::new(when), + operations::ProjectListV1Then::new(then), + ) + }) + } + + fn project_create_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectCreateV1When, operations::ProjectCreateV1Then), + { + self.mock(|when, then| { + config_fn( + operations::ProjectCreateV1When::new(when), + operations::ProjectCreateV1Then::new(then), + ) + }) + } + + fn project_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectViewV1When, operations::ProjectViewV1Then), + { + self.mock(|when, then| { + config_fn( + operations::ProjectViewV1When::new(when), + operations::ProjectViewV1Then::new(then), + ) + }) + } + + fn project_update_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectUpdateV1When, operations::ProjectUpdateV1Then), + { + self.mock(|when, then| { + config_fn( + operations::ProjectUpdateV1When::new(when), + operations::ProjectUpdateV1Then::new(then), + ) + }) + } + + fn project_delete_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectDeleteV1When, operations::ProjectDeleteV1Then), + { + self.mock(|when, then| { + config_fn( + operations::ProjectDeleteV1When::new(when), + operations::ProjectDeleteV1Then::new(then), + ) + }) + } + + fn project_policy_view_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectPolicyViewV1When, operations::ProjectPolicyViewV1Then), + { + self.mock(|when, then| { + config_fn( + operations::ProjectPolicyViewV1When::new(when), + operations::ProjectPolicyViewV1Then::new(then), + ) + }) + } + + fn project_policy_update_v1(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::ProjectPolicyUpdateV1When, operations::ProjectPolicyUpdateV1Then), + { + self.mock(|when, then| { + config_fn( + operations::ProjectPolicyUpdateV1When::new(when), + operations::ProjectPolicyUpdateV1Then::new(then), + ) + }) + } + + fn system_component_version_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SystemComponentVersionListWhen, + operations::SystemComponentVersionListThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::SystemComponentVersionListWhen::new(when), + operations::SystemComponentVersionListThen::new(then), + ) + }) + } + + fn update_deployments_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UpdateDeploymentsListWhen, operations::UpdateDeploymentsListThen), + { + self.mock(|when, then| { + config_fn( + operations::UpdateDeploymentsListWhen::new(when), + operations::UpdateDeploymentsListThen::new(then), + ) + }) + } + + fn update_deployment_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::UpdateDeploymentViewWhen, operations::UpdateDeploymentViewThen), + { + self.mock(|when, then| { + config_fn( + operations::UpdateDeploymentViewWhen::new(when), + operations::UpdateDeploymentViewThen::new(then), + ) + }) + } + + fn system_update_refresh(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUpdateRefreshWhen, operations::SystemUpdateRefreshThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemUpdateRefreshWhen::new(when), + operations::SystemUpdateRefreshThen::new(then), + ) + }) + } + + fn system_update_start(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUpdateStartWhen, operations::SystemUpdateStartThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemUpdateStartWhen::new(when), + operations::SystemUpdateStartThen::new(then), + ) + }) + } + + fn system_update_stop(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUpdateStopWhen, operations::SystemUpdateStopThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemUpdateStopWhen::new(when), + operations::SystemUpdateStopThen::new(then), + ) + }) + } + + fn system_update_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUpdateListWhen, operations::SystemUpdateListThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemUpdateListWhen::new(when), + operations::SystemUpdateListThen::new(then), + ) + }) + } + + fn system_update_view(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemUpdateViewWhen, operations::SystemUpdateViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemUpdateViewWhen::new(when), + operations::SystemUpdateViewThen::new(then), + ) + }) + } + + fn system_update_components_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SystemUpdateComponentsListWhen, + operations::SystemUpdateComponentsListThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::SystemUpdateComponentsListWhen::new(when), + operations::SystemUpdateComponentsListThen::new(then), + ) + }) + } + + fn system_version(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemVersionWhen, operations::SystemVersionThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemVersionWhen::new(when), + operations::SystemVersionThen::new(then), + ) + }) + } +} diff --git a/progenitor-impl/tests/output/param-overrides-httpmock.out b/progenitor-impl/tests/output/param-overrides-httpmock.out new file mode 100644 index 00000000..964395c1 --- /dev/null +++ b/progenitor-impl/tests/output/param-overrides-httpmock.out @@ -0,0 +1,67 @@ +pub mod operations { + #![doc = r" [`When`](httpmock::When) and [`Then`](httpmock::Then)"] + #![doc = r" wrappers for each operation. Each can be converted to"] + #![doc = r" its inner type with a call to `into_inner()`. This can"] + #![doc = r" be used to explicitly deviate from permitted values."] + use sdk::*; + pub struct KeyGetWhen(httpmock::When); + impl KeyGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/key$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn key(self, value: bool) -> Self { + Self(self.0.query_param("key", value.to_string())) + } + + pub fn unique_key(self, value: &str) -> Self { + Self(self.0.query_param("unique_key", value.to_string())) + } + } + + pub struct KeyGetThen(httpmock::Then); + impl KeyGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self) -> Self { + Self(self.0.status(200u16)) + } + } +} + +#[doc = r" An extension trait for [`MockServer`](httpmock::MockServer) that"] +#[doc = r" adds a method for each operation. These are the equivalent of"] +#[doc = r" type-checked [`mock()`](httpmock::MockServer::mock) calls."] +pub trait MockServerExt { + fn key_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::KeyGetWhen, operations::KeyGetThen); +} + +impl MockServerExt for httpmock::MockServer { + fn key_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::KeyGetWhen, operations::KeyGetThen), + { + self.mock(|when, then| { + config_fn( + operations::KeyGetWhen::new(when), + operations::KeyGetThen::new(then), + ) + }) + } +} diff --git a/progenitor-impl/tests/output/propolis-server-httpmock.out b/progenitor-impl/tests/output/propolis-server-httpmock.out new file mode 100644 index 00000000..6fdbeaa0 --- /dev/null +++ b/progenitor-impl/tests/output/propolis-server-httpmock.out @@ -0,0 +1,518 @@ +pub mod operations { + #![doc = r" [`When`](httpmock::When) and [`Then`](httpmock::Then)"] + #![doc = r" wrappers for each operation. Each can be converted to"] + #![doc = r" its inner type with a call to `into_inner()`. This can"] + #![doc = r" be used to explicitly deviate from permitted values."] + use sdk::*; + pub struct InstanceGetWhen(httpmock::When); + impl InstanceGetWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/instance$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct InstanceGetThen(httpmock::Then); + impl InstanceGetThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::InstanceGetResponse) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceEnsureWhen(httpmock::When); + impl InstanceEnsureWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/instance$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::InstanceEnsureRequest) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceEnsureThen(httpmock::Then); + impl InstanceEnsureThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::InstanceEnsureResponse) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceIssueCrucibleSnapshotRequestWhen(httpmock::When); + impl InstanceIssueCrucibleSnapshotRequestWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/instance/disk/.*/snapshot/.*$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/instance/disk/{}/snapshot/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn snapshot_id(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/instance/disk/.*/snapshot/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct InstanceIssueCrucibleSnapshotRequestThen(httpmock::Then); + impl InstanceIssueCrucibleSnapshotRequestThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: ()) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceMigrateStatusWhen(httpmock::When); + impl InstanceMigrateStatusWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/instance/migrate/status$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::InstanceMigrateStatusRequest) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceMigrateStatusThen(httpmock::Then); + impl InstanceMigrateStatusThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::InstanceMigrateStatusResponse) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceSerialWhen(httpmock::When); + impl InstanceSerialWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/instance/serial$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + } + + pub struct InstanceSerialThen(httpmock::Then); + impl InstanceSerialThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16) -> Self { + Self(self.0.status(status)) + } + + pub fn switching_protocols(self) -> Self { + Self(self.0.status(101u16)) + } + } + + pub struct InstanceStatePutWhen(httpmock::When); + impl InstanceStatePutWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::PUT) + .path_matches(regex::Regex::new("^/instance/state$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: types::InstanceStateRequested) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceStatePutThen(httpmock::Then); + impl InstanceStatePutThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct InstanceStateMonitorWhen(httpmock::When); + impl InstanceStateMonitorWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/instance/state-monitor$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::InstanceStateMonitorRequest) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct InstanceStateMonitorThen(httpmock::Then); + impl InstanceStateMonitorThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::InstanceStateMonitorResponse) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } +} + +#[doc = r" An extension trait for [`MockServer`](httpmock::MockServer) that"] +#[doc = r" adds a method for each operation. These are the equivalent of"] +#[doc = r" type-checked [`mock()`](httpmock::MockServer::mock) calls."] +pub trait MockServerExt { + fn instance_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceGetWhen, operations::InstanceGetThen); + fn instance_ensure(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceEnsureWhen, operations::InstanceEnsureThen); + fn instance_issue_crucible_snapshot_request(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceIssueCrucibleSnapshotRequestWhen, + operations::InstanceIssueCrucibleSnapshotRequestThen, + ); + fn instance_migrate_status(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceMigrateStatusWhen, operations::InstanceMigrateStatusThen); + fn instance_serial(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceSerialWhen, operations::InstanceSerialThen); + fn instance_state_put(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStatePutWhen, operations::InstanceStatePutThen); + fn instance_state_monitor(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStateMonitorWhen, operations::InstanceStateMonitorThen); +} + +impl MockServerExt for httpmock::MockServer { + fn instance_get(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceGetWhen, operations::InstanceGetThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceGetWhen::new(when), + operations::InstanceGetThen::new(then), + ) + }) + } + + fn instance_ensure(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceEnsureWhen, operations::InstanceEnsureThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceEnsureWhen::new(when), + operations::InstanceEnsureThen::new(then), + ) + }) + } + + fn instance_issue_crucible_snapshot_request(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::InstanceIssueCrucibleSnapshotRequestWhen, + operations::InstanceIssueCrucibleSnapshotRequestThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::InstanceIssueCrucibleSnapshotRequestWhen::new(when), + operations::InstanceIssueCrucibleSnapshotRequestThen::new(then), + ) + }) + } + + fn instance_migrate_status(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceMigrateStatusWhen, operations::InstanceMigrateStatusThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceMigrateStatusWhen::new(when), + operations::InstanceMigrateStatusThen::new(then), + ) + }) + } + + fn instance_serial(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceSerialWhen, operations::InstanceSerialThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceSerialWhen::new(when), + operations::InstanceSerialThen::new(then), + ) + }) + } + + fn instance_state_put(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStatePutWhen, operations::InstanceStatePutThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceStatePutWhen::new(when), + operations::InstanceStatePutThen::new(then), + ) + }) + } + + fn instance_state_monitor(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::InstanceStateMonitorWhen, operations::InstanceStateMonitorThen), + { + self.mock(|when, then| { + config_fn( + operations::InstanceStateMonitorWhen::new(when), + operations::InstanceStateMonitorThen::new(then), + ) + }) + } +} diff --git a/progenitor-impl/tests/test_output.rs b/progenitor-impl/tests/test_output.rs index 82391693..abad9f80 100644 --- a/progenitor-impl/tests/test_output.rs +++ b/progenitor-impl/tests/test_output.rs @@ -85,6 +85,25 @@ fn verify_apis(openapi_file: &str) { format!("tests/output/{}-cli.out", openapi_stem), &output, ); + + // httpmock generation. + let code = generator.httpmock(&spec, "sdk").unwrap(); + + // TODO pending #368 + let output = rustfmt_wrapper::rustfmt_config( + rustfmt_wrapper::config::Config { + format_strings: Some(true), + ..Default::default() + }, + code, + ) + .unwrap(); + + let output = progenitor_impl::space_out_items(output).unwrap(); + expectorate::assert_contents( + format!("tests/output/{}-httpmock.out", openapi_stem), + &output, + ); } #[test]