diff --git a/Cargo.lock b/Cargo.lock index 4e3412708..51c1b4490 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -321,6 +321,8 @@ checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" name = "bitwarden-api-api" version = "1.0.0" dependencies = [ + "async-trait", + "mockall", "reqwest", "serde", "serde_json", @@ -334,6 +336,8 @@ dependencies = [ name = "bitwarden-api-identity" version = "1.0.0" dependencies = [ + "async-trait", + "mockall", "reqwest", "serde", "serde_json", @@ -609,7 +613,7 @@ name = "bitwarden-state" version = "1.0.0" dependencies = [ "async-trait", - "thiserror 1.0.69", + "thiserror 2.0.12", "tokio", ] @@ -1453,6 +1457,12 @@ dependencies = [ "syn", ] +[[package]] +name = "downcast" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" + [[package]] name = "dyn-clone" version = "1.0.19" @@ -1628,6 +1638,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fragile" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dd6caf6059519a65843af8fe2a3ae298b14b80179855aeb4adc2c1934ee619" + [[package]] name = "fs-err" version = "2.11.0" @@ -2500,6 +2516,32 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "mockall" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39a6bfcc6c8c7eed5ee98b9c3e33adc726054389233e201c95dab2d41a3839d2" +dependencies = [ + "cfg-if", + "downcast", + "fragile", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25ca3004c2efe9011bd4e461bd8256445052b9615405b4f7ea43fc8ca5c20898" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "newline-converter" version = "0.3.0" @@ -2934,6 +2976,32 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "predicates" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" +dependencies = [ + "anstyle", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" + +[[package]] +name = "predicates-tree" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "primeorder" version = "0.13.6" @@ -4002,6 +4070,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "termtree" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" + [[package]] name = "textwrap" version = "0.16.2" diff --git a/bitwarden_license/bitwarden-sm/src/projects/create.rs b/bitwarden_license/bitwarden-sm/src/projects/create.rs index c4a73d363..b70c194e3 100644 --- a/bitwarden_license/bitwarden-sm/src/projects/create.rs +++ b/bitwarden_license/bitwarden-sm/src/projects/create.rs @@ -40,12 +40,11 @@ pub(crate) async fn create_project( }); let config = client.internal.get_api_configurations().await; - let res = bitwarden_api_api::apis::projects_api::organizations_organization_id_projects_post( - &config.api, - input.organization_id, - project, - ) - .await?; + let res = config + .api_client + .projects_api() + .organizations_organization_id_projects_post(input.organization_id, project) + .await?; ProjectResponse::process_response(res, &mut key_store.context()) } diff --git a/bitwarden_license/bitwarden-sm/src/projects/delete.rs b/bitwarden_license/bitwarden-sm/src/projects/delete.rs index b906dab96..f170e61ba 100644 --- a/bitwarden_license/bitwarden-sm/src/projects/delete.rs +++ b/bitwarden_license/bitwarden-sm/src/projects/delete.rs @@ -21,9 +21,11 @@ pub(crate) async fn delete_projects( input: ProjectsDeleteRequest, ) -> Result { let config = client.internal.get_api_configurations().await; - let res = - bitwarden_api_api::apis::projects_api::projects_delete_post(&config.api, Some(input.ids)) - .await?; + let res = config + .api_client + .projects_api() + .projects_delete_post(Some(input.ids)) + .await?; ProjectsDeleteResponse::process_response(res) } diff --git a/bitwarden_license/bitwarden-sm/src/projects/get.rs b/bitwarden_license/bitwarden-sm/src/projects/get.rs index 541e64acc..484592922 100644 --- a/bitwarden_license/bitwarden-sm/src/projects/get.rs +++ b/bitwarden_license/bitwarden-sm/src/projects/get.rs @@ -19,7 +19,11 @@ pub(crate) async fn get_project( ) -> Result { let config = client.internal.get_api_configurations().await; - let res = bitwarden_api_api::apis::projects_api::projects_id_get(&config.api, input.id).await?; + let res = config + .api_client + .projects_api() + .projects_id_get(input.id) + .await?; let key_store = client.internal.get_key_store(); diff --git a/bitwarden_license/bitwarden-sm/src/projects/list.rs b/bitwarden_license/bitwarden-sm/src/projects/list.rs index 4859e371a..8b0b11b91 100644 --- a/bitwarden_license/bitwarden-sm/src/projects/list.rs +++ b/bitwarden_license/bitwarden-sm/src/projects/list.rs @@ -20,11 +20,11 @@ pub(crate) async fn list_projects( input: &ProjectsListRequest, ) -> Result { let config = client.internal.get_api_configurations().await; - let res = bitwarden_api_api::apis::projects_api::organizations_organization_id_projects_get( - &config.api, - input.organization_id, - ) - .await?; + let res = config + .api_client + .projects_api() + .organizations_organization_id_projects_get(input.organization_id) + .await?; let key_store = client.internal.get_key_store(); diff --git a/bitwarden_license/bitwarden-sm/src/projects/update.rs b/bitwarden_license/bitwarden-sm/src/projects/update.rs index f7d318234..4e8486a50 100644 --- a/bitwarden_license/bitwarden-sm/src/projects/update.rs +++ b/bitwarden_license/bitwarden-sm/src/projects/update.rs @@ -42,9 +42,11 @@ pub(crate) async fn update_project( }); let config = client.internal.get_api_configurations().await; - let res = - bitwarden_api_api::apis::projects_api::projects_id_put(&config.api, input.id, project) - .await?; + let res = config + .api_client + .projects_api() + .projects_id_put(input.id, project) + .await?; ProjectResponse::process_response(res, &mut key_store.context()) } diff --git a/bitwarden_license/bitwarden-sm/src/secrets/create.rs b/bitwarden_license/bitwarden-sm/src/secrets/create.rs index ab59568ec..7737e42bd 100644 --- a/bitwarden_license/bitwarden-sm/src/secrets/create.rs +++ b/bitwarden_license/bitwarden-sm/src/secrets/create.rs @@ -55,12 +55,11 @@ pub(crate) async fn create_secret( }; let config = client.internal.get_api_configurations().await; - let res = bitwarden_api_api::apis::secrets_api::organizations_organization_id_secrets_post( - &config.api, - input.organization_id, - secret, - ) - .await?; + let res = config + .api_client + .secrets_api() + .organizations_organization_id_secrets_post(input.organization_id, secret) + .await?; SecretResponse::process_response(res, &mut key_store.context()) } diff --git a/bitwarden_license/bitwarden-sm/src/secrets/delete.rs b/bitwarden_license/bitwarden-sm/src/secrets/delete.rs index 84a4a0993..00d1001ac 100644 --- a/bitwarden_license/bitwarden-sm/src/secrets/delete.rs +++ b/bitwarden_license/bitwarden-sm/src/secrets/delete.rs @@ -21,9 +21,11 @@ pub(crate) async fn delete_secrets( input: SecretsDeleteRequest, ) -> Result { let config = client.internal.get_api_configurations().await; - let res = - bitwarden_api_api::apis::secrets_api::secrets_delete_post(&config.api, Some(input.ids)) - .await?; + let res = config + .api_client + .secrets_api() + .secrets_delete_post(Some(input.ids)) + .await?; SecretsDeleteResponse::process_response(res) } diff --git a/bitwarden_license/bitwarden-sm/src/secrets/get.rs b/bitwarden_license/bitwarden-sm/src/secrets/get.rs index 8c26ee9bf..e7c5eeb3a 100644 --- a/bitwarden_license/bitwarden-sm/src/secrets/get.rs +++ b/bitwarden_license/bitwarden-sm/src/secrets/get.rs @@ -18,7 +18,11 @@ pub(crate) async fn get_secret( input: &SecretGetRequest, ) -> Result { let config = client.internal.get_api_configurations().await; - let res = bitwarden_api_api::apis::secrets_api::secrets_id_get(&config.api, input.id).await?; + let res = config + .api_client + .secrets_api() + .secrets_id_get(input.id) + .await?; let key_store = client.internal.get_key_store(); diff --git a/bitwarden_license/bitwarden-sm/src/secrets/get_by_ids.rs b/bitwarden_license/bitwarden-sm/src/secrets/get_by_ids.rs index 291a97a5a..020fdbae3 100644 --- a/bitwarden_license/bitwarden-sm/src/secrets/get_by_ids.rs +++ b/bitwarden_license/bitwarden-sm/src/secrets/get_by_ids.rs @@ -22,8 +22,11 @@ pub(crate) async fn get_secrets_by_ids( let config = client.internal.get_api_configurations().await; - let res = - bitwarden_api_api::apis::secrets_api::secrets_get_by_ids_post(&config.api, request).await?; + let res = config + .api_client + .secrets_api() + .secrets_get_by_ids_post(request) + .await?; let key_store = client.internal.get_key_store(); diff --git a/bitwarden_license/bitwarden-sm/src/secrets/list.rs b/bitwarden_license/bitwarden-sm/src/secrets/list.rs index 1cbaa73f2..d646d032e 100644 --- a/bitwarden_license/bitwarden-sm/src/secrets/list.rs +++ b/bitwarden_license/bitwarden-sm/src/secrets/list.rs @@ -26,11 +26,11 @@ pub(crate) async fn list_secrets( input: &SecretIdentifiersRequest, ) -> Result { let config = client.internal.get_api_configurations().await; - let res = bitwarden_api_api::apis::secrets_api::organizations_organization_id_secrets_get( - &config.api, - input.organization_id, - ) - .await?; + let res = config + .api_client + .secrets_api() + .organizations_organization_id_secrets_get(input.organization_id) + .await?; let key_store = client.internal.get_key_store(); @@ -50,11 +50,11 @@ pub(crate) async fn list_secrets_by_project( input: &SecretIdentifiersByProjectRequest, ) -> Result { let config = client.internal.get_api_configurations().await; - let res = bitwarden_api_api::apis::secrets_api::projects_project_id_secrets_get( - &config.api, - input.project_id, - ) - .await?; + let res = config + .api_client + .secrets_api() + .projects_project_id_secrets_get(input.project_id) + .await?; let key_store = client.internal.get_key_store(); diff --git a/bitwarden_license/bitwarden-sm/src/secrets/sync.rs b/bitwarden_license/bitwarden-sm/src/secrets/sync.rs index 888ccaef6..e5ee66b12 100644 --- a/bitwarden_license/bitwarden-sm/src/secrets/sync.rs +++ b/bitwarden_license/bitwarden-sm/src/secrets/sync.rs @@ -25,12 +25,11 @@ pub(crate) async fn sync_secrets( let config = client.internal.get_api_configurations().await; let last_synced_date = input.last_synced_date.map(|date| date.to_rfc3339()); - let res = bitwarden_api_api::apis::secrets_api::organizations_organization_id_secrets_sync_get( - &config.api, - input.organization_id, - last_synced_date, - ) - .await?; + let res = config + .api_client + .secrets_api() + .organizations_organization_id_secrets_sync_get(input.organization_id, last_synced_date) + .await?; let key_store = client.internal.get_key_store(); diff --git a/bitwarden_license/bitwarden-sm/src/secrets/update.rs b/bitwarden_license/bitwarden-sm/src/secrets/update.rs index f5422c468..3b03399f1 100644 --- a/bitwarden_license/bitwarden-sm/src/secrets/update.rs +++ b/bitwarden_license/bitwarden-sm/src/secrets/update.rs @@ -54,8 +54,11 @@ pub(crate) async fn update_secret( }; let config = client.internal.get_api_configurations().await; - let res = - bitwarden_api_api::apis::secrets_api::secrets_id_put(&config.api, input.id, secret).await?; + let res = config + .api_client + .secrets_api() + .secrets_id_put(input.id, secret) + .await?; SecretResponse::process_response(res, &mut key_store.context()) } diff --git a/crates/bitwarden-api-api/Cargo.toml b/crates/bitwarden-api-api/Cargo.toml index 1c68a6cf1..30641615e 100644 --- a/crates/bitwarden-api-api/Cargo.toml +++ b/crates/bitwarden-api-api/Cargo.toml @@ -12,7 +12,12 @@ repository.workspace = true license-file.workspace = true keywords.workspace = true +[features] +mockall = ["dep:mockall"] + [dependencies] +async-trait = { workspace = true } +mockall = { version = ">=0.13, <0.14", optional = true } reqwest = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/crates/bitwarden-api-api/README.md b/crates/bitwarden-api-api/README.md index 00d58f9ab..7059b8541 100644 --- a/crates/bitwarden-api-api/README.md +++ b/crates/bitwarden-api-api/README.md @@ -25,7 +25,7 @@ bitwarden-api-api = { path = "./bitwarden-api-api" } ## Documentation for API Endpoints -All URIs are relative to _http://localhost_ +All URIs are relative to *https://api.bitwarden.com* | Class | Method | HTTP request | Description | | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | diff --git a/crates/bitwarden-api-api/src/apis/access_policies_api.rs b/crates/bitwarden-api-api/src/apis/access_policies_api.rs index 19a58c7e0..703cd6df2 100644 --- a/crates/bitwarden-api-api/src/apis/access_policies_api.rs +++ b/crates/bitwarden-api-api/src/apis/access_policies_api.rs @@ -8,14 +8,856 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait AccessPoliciesApi: Send + Sync { + /// GET /organizations/{id}/access-policies/people/potential-grantees + async fn organizations_id_access_policies_people_potential_grantees_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::PotentialGranteeResponseModelListResponseModel, + Error, + >; + + /// GET /organizations/{id}/access-policies/projects/potential-grantees + async fn organizations_id_access_policies_projects_potential_grantees_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::PotentialGranteeResponseModelListResponseModel, + Error, + >; + + /// GET /organizations/{id}/access-policies/service-accounts/potential-grantees + async fn organizations_id_access_policies_service_accounts_potential_grantees_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::PotentialGranteeResponseModelListResponseModel, + Error, + >; + + /// GET /projects/{id}/access-policies/people + async fn projects_id_access_policies_people_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::ProjectPeopleAccessPoliciesResponseModel, + Error, + >; + + /// PUT /projects/{id}/access-policies/people + async fn projects_id_access_policies_people_put<'a>( + &self, + id: uuid::Uuid, + people_access_policies_request_model: Option, + ) -> Result< + models::ProjectPeopleAccessPoliciesResponseModel, + Error, + >; + + /// GET /projects/{id}/access-policies/service-accounts + async fn projects_id_access_policies_service_accounts_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::ProjectServiceAccountsAccessPoliciesResponseModel, + Error, + >; + + /// PUT /projects/{id}/access-policies/service-accounts + async fn projects_id_access_policies_service_accounts_put<'a>( + &self, + id: uuid::Uuid, + project_service_accounts_access_policies_request_model: Option< + models::ProjectServiceAccountsAccessPoliciesRequestModel, + >, + ) -> Result< + models::ProjectServiceAccountsAccessPoliciesResponseModel, + Error, + >; + + /// GET /secrets/{secretId}/access-policies + async fn secrets_secret_id_access_policies_get<'a>( + &self, + secret_id: uuid::Uuid, + ) -> Result< + models::SecretAccessPoliciesResponseModel, + Error, + >; + + /// GET /service-accounts/{id}/access-policies/people + async fn service_accounts_id_access_policies_people_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::ServiceAccountPeopleAccessPoliciesResponseModel, + Error, + >; + + /// PUT /service-accounts/{id}/access-policies/people + async fn service_accounts_id_access_policies_people_put<'a>( + &self, + id: uuid::Uuid, + people_access_policies_request_model: Option, + ) -> Result< + models::ServiceAccountPeopleAccessPoliciesResponseModel, + Error, + >; + + /// GET /service-accounts/{id}/granted-policies + async fn service_accounts_id_granted_policies_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel, + Error, + >; + + /// PUT /service-accounts/{id}/granted-policies + async fn service_accounts_id_granted_policies_put<'a>( + &self, + id: uuid::Uuid, + service_account_granted_policies_request_model: Option< + models::ServiceAccountGrantedPoliciesRequestModel, + >, + ) -> Result< + models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel, + Error, + >; +} + +pub struct AccessPoliciesApiClient { + configuration: Arc, +} + +impl AccessPoliciesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl AccessPoliciesApi for AccessPoliciesApiClient { + async fn organizations_id_access_policies_people_potential_grantees_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::PotentialGranteeResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/access-policies/people/potential-grantees", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option< + OrganizationsIdAccessPoliciesPeoplePotentialGranteesGetError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_access_policies_projects_potential_grantees_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::PotentialGranteeResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/access-policies/projects/potential-grantees", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option< + OrganizationsIdAccessPoliciesProjectsPotentialGranteesGetError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_access_policies_service_accounts_potential_grantees_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::PotentialGranteeResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/access-policies/service-accounts/potential-grantees", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option< + OrganizationsIdAccessPoliciesServiceAccountsPotentialGranteesGetError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn projects_id_access_policies_people_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::ProjectPeopleAccessPoliciesResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/projects/{id}/access-policies/people", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn projects_id_access_policies_people_put<'a>( + &self, + id: uuid::Uuid, + people_access_policies_request_model: Option, + ) -> Result< + models::ProjectPeopleAccessPoliciesResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/projects/{id}/access-policies/people", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&people_access_policies_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn projects_id_access_policies_service_accounts_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::ProjectServiceAccountsAccessPoliciesResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/projects/{id}/access-policies/service-accounts", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn projects_id_access_policies_service_accounts_put<'a>( + &self, + id: uuid::Uuid, + project_service_accounts_access_policies_request_model: Option< + models::ProjectServiceAccountsAccessPoliciesRequestModel, + >, + ) -> Result< + models::ProjectServiceAccountsAccessPoliciesResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/projects/{id}/access-policies/service-accounts", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&project_service_accounts_access_policies_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn secrets_secret_id_access_policies_get<'a>( + &self, + secret_id: uuid::Uuid, + ) -> Result< + models::SecretAccessPoliciesResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/secrets/{secretId}/access-policies", + local_var_configuration.base_path, + secretId = secret_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretAccessPoliciesResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecretAccessPoliciesResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn service_accounts_id_access_policies_people_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::ServiceAccountPeopleAccessPoliciesResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{id}/access-policies/people", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn service_accounts_id_access_policies_people_put<'a>( + &self, + id: uuid::Uuid, + people_access_policies_request_model: Option, + ) -> Result< + models::ServiceAccountPeopleAccessPoliciesResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{id}/access-policies/people", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&people_access_policies_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn service_accounts_id_granted_policies_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{id}/granted-policies", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn service_accounts_id_granted_policies_put<'a>( + &self, + id: uuid::Uuid, + service_account_granted_policies_request_model: Option< + models::ServiceAccountGrantedPoliciesRequestModel, + >, + ) -> Result< + models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{id}/granted-policies", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&service_account_granted_policies_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} /// struct for typed errors of method -/// [`organizations_id_access_policies_people_potential_grantees_get`] +/// [`AccessPoliciesApi::organizations_id_access_policies_people_potential_grantees_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdAccessPoliciesPeoplePotentialGranteesGetError { @@ -23,7 +865,7 @@ pub enum OrganizationsIdAccessPoliciesPeoplePotentialGranteesGetError { } /// struct for typed errors of method -/// [`organizations_id_access_policies_projects_potential_grantees_get`] +/// [`AccessPoliciesApi::organizations_id_access_policies_projects_potential_grantees_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdAccessPoliciesProjectsPotentialGranteesGetError { @@ -31,736 +873,78 @@ pub enum OrganizationsIdAccessPoliciesProjectsPotentialGranteesGetError { } /// struct for typed errors of method -/// [`organizations_id_access_policies_service_accounts_potential_grantees_get`] +/// [`AccessPoliciesApi::organizations_id_access_policies_service_accounts_potential_grantees_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdAccessPoliciesServiceAccountsPotentialGranteesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`projects_id_access_policies_people_get`] +/// struct for typed errors of method [`AccessPoliciesApi::projects_id_access_policies_people_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProjectsIdAccessPoliciesPeopleGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`projects_id_access_policies_people_put`] +/// struct for typed errors of method [`AccessPoliciesApi::projects_id_access_policies_people_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProjectsIdAccessPoliciesPeoplePutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`projects_id_access_policies_service_accounts_get`] +/// struct for typed errors of method +/// [`AccessPoliciesApi::projects_id_access_policies_service_accounts_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProjectsIdAccessPoliciesServiceAccountsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`projects_id_access_policies_service_accounts_put`] +/// struct for typed errors of method +/// [`AccessPoliciesApi::projects_id_access_policies_service_accounts_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProjectsIdAccessPoliciesServiceAccountsPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`secrets_secret_id_access_policies_get`] +/// struct for typed errors of method [`AccessPoliciesApi::secrets_secret_id_access_policies_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SecretsSecretIdAccessPoliciesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_id_access_policies_people_get`] +/// struct for typed errors of method +/// [`AccessPoliciesApi::service_accounts_id_access_policies_people_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsIdAccessPoliciesPeopleGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_id_access_policies_people_put`] +/// struct for typed errors of method +/// [`AccessPoliciesApi::service_accounts_id_access_policies_people_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsIdAccessPoliciesPeoplePutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_id_granted_policies_get`] +/// struct for typed errors of method +/// [`AccessPoliciesApi::service_accounts_id_granted_policies_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsIdGrantedPoliciesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_id_granted_policies_put`] +/// struct for typed errors of method +/// [`AccessPoliciesApi::service_accounts_id_granted_policies_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsIdGrantedPoliciesPutError { UnknownValue(serde_json::Value), } - -pub async fn organizations_id_access_policies_people_potential_grantees_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result< - models::PotentialGranteeResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/access-policies/people/potential-grantees", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_access_policies_projects_potential_grantees_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result< - models::PotentialGranteeResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/access-policies/projects/potential-grantees", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_access_policies_service_accounts_potential_grantees_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result< - models::PotentialGranteeResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/access-policies/service-accounts/potential-grantees", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn projects_id_access_policies_people_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result< - models::ProjectPeopleAccessPoliciesResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/projects/{id}/access-policies/people", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn projects_id_access_policies_people_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - people_access_policies_request_model: Option, -) -> Result< - models::ProjectPeopleAccessPoliciesResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_people_access_policies_request_model = people_access_policies_request_model; - - let uri_str = format!( - "{}/projects/{id}/access-policies/people", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_people_access_policies_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn projects_id_access_policies_service_accounts_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result< - models::ProjectServiceAccountsAccessPoliciesResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/projects/{id}/access-policies/service-accounts", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn projects_id_access_policies_service_accounts_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - project_service_accounts_access_policies_request_model: Option< - models::ProjectServiceAccountsAccessPoliciesRequestModel, - >, -) -> Result< - models::ProjectServiceAccountsAccessPoliciesResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_project_service_accounts_access_policies_request_model = - project_service_accounts_access_policies_request_model; - - let uri_str = format!( - "{}/projects/{id}/access-policies/service-accounts", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_project_service_accounts_access_policies_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn secrets_secret_id_access_policies_get( - configuration: &configuration::Configuration, - secret_id: uuid::Uuid, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_id = secret_id; - - let uri_str = format!( - "{}/secrets/{secretId}/access-policies", - configuration.base_path, - secretId = crate::apis::urlencode(p_secret_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretAccessPoliciesResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecretAccessPoliciesResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_id_access_policies_people_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result< - models::ServiceAccountPeopleAccessPoliciesResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/service-accounts/{id}/access-policies/people", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_id_access_policies_people_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - people_access_policies_request_model: Option, -) -> Result< - models::ServiceAccountPeopleAccessPoliciesResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_people_access_policies_request_model = people_access_policies_request_model; - - let uri_str = format!( - "{}/service-accounts/{id}/access-policies/people", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_people_access_policies_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_id_granted_policies_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result< - models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/service-accounts/{id}/granted-policies", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_id_granted_policies_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - service_account_granted_policies_request_model: Option< - models::ServiceAccountGrantedPoliciesRequestModel, - >, -) -> Result< - models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_service_account_granted_policies_request_model = - service_account_granted_policies_request_model; - - let uri_str = format!( - "{}/service-accounts/{id}/granted-policies", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_service_account_granted_policies_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/accounts_api.rs b/crates/bitwarden-api-api/src/apis/accounts_api.rs index 6bc5ae266..f52759bd7 100644 --- a/crates/bitwarden-api-api/src/apis/accounts_api.rs +++ b/crates/bitwarden-api-api/src/apis/accounts_api.rs @@ -8,2236 +8,2776 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait AccountsApi: Send + Sync { + /// POST /accounts/api-key + async fn accounts_api_key_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result>; + + /// POST /accounts/avatar + async fn accounts_avatar_post<'a>( + &self, + update_avatar_request_model: Option, + ) -> Result>; + + /// PUT /accounts/avatar + async fn accounts_avatar_put<'a>( + &self, + update_avatar_request_model: Option, + ) -> Result>; + + /// POST /accounts/cancel + async fn accounts_cancel_post<'a>( + &self, + subscription_cancellation_request_model: Option< + models::SubscriptionCancellationRequestModel, + >, + ) -> Result<(), Error>; + + /// POST /accounts/convert-to-key-connector + async fn accounts_convert_to_key_connector_post<'a>( + &self, + ) -> Result<(), Error>; + + /// DELETE /accounts + async fn accounts_delete<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/delete + async fn accounts_delete_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/delete-recover + async fn accounts_delete_recover_post<'a>( + &self, + delete_recover_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/delete-recover-token + async fn accounts_delete_recover_token_post<'a>( + &self, + verify_delete_recover_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/email + async fn accounts_email_post<'a>( + &self, + email_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/email-token + async fn accounts_email_token_post<'a>( + &self, + email_token_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/kdf + async fn accounts_kdf_post<'a>( + &self, + kdf_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/key + async fn accounts_key_post<'a>( + &self, + update_key_request_model: Option, + ) -> Result<(), Error>; + + /// GET /accounts/keys + async fn accounts_keys_get<'a>( + &self, + ) -> Result>; + + /// POST /accounts/keys + async fn accounts_keys_post<'a>( + &self, + keys_request_model: Option, + ) -> Result>; + + /// POST /accounts/license + async fn accounts_license_post<'a>( + &self, + license: std::path::PathBuf, + ) -> Result<(), Error>; + + /// GET /accounts/organizations + async fn accounts_organizations_get<'a>( + &self, + ) -> Result< + models::ProfileOrganizationResponseModelListResponseModel, + Error, + >; + + /// POST /accounts/password-hint + async fn accounts_password_hint_post<'a>( + &self, + password_hint_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/password + async fn accounts_password_post<'a>( + &self, + password_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/payment + async fn accounts_payment_post<'a>( + &self, + payment_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/premium + async fn accounts_premium_post<'a>( + &self, + payment_method_type: models::PaymentMethodType, + payment_token: Option<&'a str>, + additional_storage_gb: Option, + country: Option<&'a str>, + postal_code: Option<&'a str>, + license: Option, + ) -> Result>; + + /// GET /accounts/profile + async fn accounts_profile_get<'a>( + &self, + ) -> Result>; + + /// POST /accounts/profile + async fn accounts_profile_post<'a>( + &self, + update_profile_request_model: Option, + ) -> Result>; + + /// PUT /accounts/profile + async fn accounts_profile_put<'a>( + &self, + update_profile_request_model: Option, + ) -> Result>; + + /// POST /accounts/reinstate-premium + async fn accounts_reinstate_premium_post<'a>( + &self, + ) -> Result<(), Error>; + + /// POST /accounts/request-otp + async fn accounts_request_otp_post<'a>(&self) + -> Result<(), Error>; + + /// POST /accounts/resend-new-device-otp + async fn accounts_resend_new_device_otp_post<'a>( + &self, + unauthenticated_secret_verification_request_model: Option< + models::UnauthenticatedSecretVerificationRequestModel, + >, + ) -> Result<(), Error>; + + /// GET /accounts/revision-date + async fn accounts_revision_date_get<'a>( + &self, + ) -> Result>; + + /// POST /accounts/rotate-api-key + async fn accounts_rotate_api_key_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result>; + + /// POST /accounts/security-stamp + async fn accounts_security_stamp_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/set-key-connector-key + async fn accounts_set_key_connector_key_post<'a>( + &self, + set_key_connector_key_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/set-password + async fn accounts_set_password_post<'a>( + &self, + set_password_request_model: Option, + ) -> Result<(), Error>; + + /// DELETE /accounts/sso/{organizationId} + async fn accounts_sso_organization_id_delete<'a>( + &self, + organization_id: &'a str, + ) -> Result<(), Error>; + + /// GET /accounts/sso/user-identifier + async fn accounts_sso_user_identifier_get<'a>( + &self, + ) -> Result>; + + /// POST /accounts/storage + async fn accounts_storage_post<'a>( + &self, + storage_request_model: Option, + ) -> Result>; + + /// GET /accounts/subscription + async fn accounts_subscription_get<'a>( + &self, + ) -> Result>; + + /// GET /accounts/tax + async fn accounts_tax_get<'a>( + &self, + ) -> Result>; + + /// PUT /accounts/tax + async fn accounts_tax_put<'a>( + &self, + tax_info_update_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /accounts/update-tde-offboarding-password + async fn accounts_update_tde_offboarding_password_put<'a>( + &self, + update_tde_offboarding_password_request_model: Option< + models::UpdateTdeOffboardingPasswordRequestModel, + >, + ) -> Result<(), Error>; + + /// PUT /accounts/update-temp-password + async fn accounts_update_temp_password_put<'a>( + &self, + update_temp_password_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/verify-devices + async fn accounts_verify_devices_post<'a>( + &self, + set_verify_devices_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /accounts/verify-devices + async fn accounts_verify_devices_put<'a>( + &self, + set_verify_devices_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/verify-email + async fn accounts_verify_email_post<'a>( + &self, + ) -> Result<(), Error>; + + /// POST /accounts/verify-email-token + async fn accounts_verify_email_token_post<'a>( + &self, + verify_email_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/verify-otp + async fn accounts_verify_otp_post<'a>( + &self, + verify_otp_request_model: Option, + ) -> Result<(), Error>; + + /// POST /accounts/verify-password + async fn accounts_verify_password_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result>; +} + +pub struct AccountsApiClient { + configuration: Arc, +} + +impl AccountsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl AccountsApi for AccountsApiClient { + async fn accounts_api_key_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/accounts/api-key", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ApiKeyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_api_key_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsApiKeyPostError { - UnknownValue(serde_json::Value), -} + async fn accounts_avatar_post<'a>( + &self, + update_avatar_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_avatar_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsAvatarPostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_avatar_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsAvatarPutError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/accounts/avatar", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_cancel_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsCancelPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_avatar_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProfileResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_convert_to_key_connector_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsConvertToKeyConnectorPostError { - UnknownValue(serde_json::Value), -} + async fn accounts_avatar_put<'a>( + &self, + update_avatar_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsDeleteError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsDeletePostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/accounts/avatar", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_delete_recover_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsDeleteRecoverPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_avatar_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProfileResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_delete_recover_token_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsDeleteRecoverTokenPostError { - UnknownValue(serde_json::Value), -} + async fn accounts_cancel_post<'a>( + &self, + subscription_cancellation_request_model: Option< + models::SubscriptionCancellationRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_email_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsEmailPostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_email_token_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsEmailTokenPostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/accounts/cancel", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_kdf_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsKdfPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&subscription_cancellation_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_key_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsKeyPostError { - UnknownValue(serde_json::Value), -} + async fn accounts_convert_to_key_connector_post<'a>( + &self, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_keys_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsKeysGetError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_keys_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsKeysPostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!( + "{}/accounts/convert-to-key-connector", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_license_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsLicensePostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_organizations_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsOrganizationsGetError { - UnknownValue(serde_json::Value), -} + async fn accounts_delete<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_password_hint_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsPasswordHintPostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_password_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsPasswordPostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/accounts", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_payment_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsPaymentPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_premium_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsPremiumPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_profile_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsProfileGetError { - UnknownValue(serde_json::Value), -} + async fn accounts_delete_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_profile_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsProfilePostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_profile_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsProfilePutError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/accounts/delete", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_reinstate_premium_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsReinstatePremiumPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_request_otp_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsRequestOtpPostError { - UnknownValue(serde_json::Value), -} + async fn accounts_delete_recover_post<'a>( + &self, + delete_recover_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_resend_new_device_otp_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsResendNewDeviceOtpPostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_revision_date_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsRevisionDateGetError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!( + "{}/accounts/delete-recover", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_rotate_api_key_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsRotateApiKeyPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&delete_recover_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_security_stamp_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsSecurityStampPostError { - UnknownValue(serde_json::Value), -} + async fn accounts_delete_recover_token_post<'a>( + &self, + verify_delete_recover_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_set_key_connector_key_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsSetKeyConnectorKeyPostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_set_password_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsSetPasswordPostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!( + "{}/accounts/delete-recover-token", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_sso_organization_id_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsSsoOrganizationIdDeleteError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&verify_delete_recover_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_sso_user_identifier_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsSsoUserIdentifierGetError { - UnknownValue(serde_json::Value), -} + async fn accounts_email_post<'a>( + &self, + email_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_storage_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsStoragePostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_subscription_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsSubscriptionGetError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/accounts/email", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_tax_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsTaxGetError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&email_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_tax_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsTaxPutError { - UnknownValue(serde_json::Value), -} + async fn accounts_email_token_post<'a>( + &self, + email_token_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_update_tde_offboarding_password_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsUpdateTdeOffboardingPasswordPutError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_update_temp_password_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsUpdateTempPasswordPutError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = + format!("{}/accounts/email-token", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_verify_devices_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyDevicesPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&email_token_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_verify_devices_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyDevicesPutError { - UnknownValue(serde_json::Value), -} + async fn accounts_kdf_post<'a>( + &self, + kdf_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_verify_email_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyEmailPostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`accounts_verify_email_token_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyEmailTokenPostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/accounts/kdf", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_verify_otp_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyOtpPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&kdf_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`accounts_verify_password_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyPasswordPostError { - UnknownValue(serde_json::Value), -} + async fn accounts_key_post<'a>( + &self, + update_key_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -pub async fn accounts_api_key_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; + let local_var_client = &local_var_configuration.client; - let uri_str = format!("{}/accounts/api-key", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_uri_str = format!("{}/accounts/key", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApiKeyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_key_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_avatar_post( - configuration: &configuration::Configuration, - update_avatar_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_avatar_request_model = update_avatar_request_model; + async fn accounts_keys_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/avatar", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_avatar_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!("{}/accounts/keys", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::KeysResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::KeysResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_avatar_put( - configuration: &configuration::Configuration, - update_avatar_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_avatar_request_model = update_avatar_request_model; + async fn accounts_keys_post<'a>( + &self, + keys_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/avatar", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_avatar_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!("{}/accounts/keys", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&keys_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::KeysResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::KeysResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_cancel_post( - configuration: &configuration::Configuration, - subscription_cancellation_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_subscription_cancellation_request_model = subscription_cancellation_request_model; + async fn accounts_license_post<'a>( + &self, + license: std::path::PathBuf, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/cancel", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_subscription_cancellation_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} + let local_var_uri_str = format!("{}/accounts/license", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -pub async fn accounts_convert_to_key_connector_post( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!( - "{}/accounts/convert-to-key-connector", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + let mut local_var_form = reqwest::multipart::Form::new(); + // TODO: support file upload for 'license' parameter + local_var_req_builder = local_var_req_builder.multipart(local_var_form); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_delete( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; + async fn accounts_organizations_get<'a>( + &self, + ) -> Result< + models::ProfileOrganizationResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!( + "{}/accounts/organizations", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileOrganizationResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProfileOrganizationResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_delete_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; + async fn accounts_password_hint_post<'a>( + &self, + password_hint_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/delete", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!( + "{}/accounts/password-hint", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&password_hint_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_delete_recover_post( - configuration: &configuration::Configuration, - delete_recover_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_delete_recover_request_model = delete_recover_request_model; + async fn accounts_password_post<'a>( + &self, + password_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/delete-recover", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_delete_recover_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!("{}/accounts/password", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&password_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_delete_recover_token_post( - configuration: &configuration::Configuration, - verify_delete_recover_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_verify_delete_recover_request_model = verify_delete_recover_request_model; + async fn accounts_payment_post<'a>( + &self, + payment_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/delete-recover-token", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + let local_var_uri_str = format!("{}/accounts/payment", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&payment_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_verify_delete_recover_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + + async fn accounts_premium_post<'a>( + &self, + payment_method_type: models::PaymentMethodType, + payment_token: Option<&'a str>, + additional_storage_gb: Option, + country: Option<&'a str>, + postal_code: Option<&'a str>, + license: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/accounts/premium", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + local_var_req_builder = + local_var_req_builder.query(&[("paymentMethodType", &payment_method_type.to_string())]); + if let Some(ref param_value) = payment_token { + local_var_req_builder = + local_var_req_builder.query(&[("paymentToken", ¶m_value.to_string())]); + } + if let Some(ref param_value) = additional_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("additionalStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = country { + local_var_req_builder = + local_var_req_builder.query(&[("country", ¶m_value.to_string())]); + } + if let Some(ref param_value) = postal_code { + local_var_req_builder = + local_var_req_builder.query(&[("postalCode", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + let mut local_var_form = reqwest::multipart::Form::new(); + // TODO: support file upload for 'license' parameter + local_var_req_builder = local_var_req_builder.multipart(local_var_form); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PaymentResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_email_post( - configuration: &configuration::Configuration, - email_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_email_request_model = email_request_model; + async fn accounts_profile_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/email", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_email_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!("{}/accounts/profile", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProfileResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_email_token_post( - configuration: &configuration::Configuration, - email_token_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_email_token_request_model = email_token_request_model; + async fn accounts_profile_post<'a>( + &self, + update_profile_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/email-token", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_email_token_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!("{}/accounts/profile", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_profile_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProfileResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_kdf_post( - configuration: &configuration::Configuration, - kdf_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_kdf_request_model = kdf_request_model; + async fn accounts_profile_put<'a>( + &self, + update_profile_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/kdf", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_kdf_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!("{}/accounts/profile", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_profile_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProfileResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_key_post( - configuration: &configuration::Configuration, - update_key_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_key_request_model = update_key_request_model; + async fn accounts_reinstate_premium_post<'a>( + &self, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/key", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_key_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!( + "{}/accounts/reinstate-premium", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_keys_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/accounts/keys", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + async fn accounts_request_otp_post<'a>( + &self, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::KeysResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::KeysResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = + format!("{}/accounts/request-otp", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_keys_post( - configuration: &configuration::Configuration, - keys_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_keys_request_model = keys_request_model; + async fn accounts_resend_new_device_otp_post<'a>( + &self, + unauthenticated_secret_verification_request_model: Option< + models::UnauthenticatedSecretVerificationRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/keys", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_keys_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::KeysResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::KeysResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!( + "{}/accounts/resend-new-device-otp", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&unauthenticated_secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_license_post( - configuration: &configuration::Configuration, - license: std::path::PathBuf, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_license = license; + async fn accounts_revision_date_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/license", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - let mut multipart_form = reqwest::multipart::Form::new(); - // TODO: support file upload for 'license' parameter - req_builder = req_builder.multipart(multipart_form); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} + let local_var_uri_str = format!( + "{}/accounts/revision-date", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); -pub async fn accounts_organizations_get( - configuration: &configuration::Configuration, -) -> Result< - models::ProfileOrganizationResponseModelListResponseModel, - Error, -> { - let uri_str = format!("{}/accounts/organizations", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileOrganizationResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileOrganizationResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `i64`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `i64`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_password_hint_post( - configuration: &configuration::Configuration, - password_hint_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_password_hint_request_model = password_hint_request_model; + async fn accounts_rotate_api_key_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/password-hint", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_password_hint_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!( + "{}/accounts/rotate-api-key", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ApiKeyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_password_post( - configuration: &configuration::Configuration, - password_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_password_request_model = password_request_model; + async fn accounts_security_stamp_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/password", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_password_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!( + "{}/accounts/security-stamp", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_payment_post( - configuration: &configuration::Configuration, - payment_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_payment_request_model = payment_request_model; + async fn accounts_set_key_connector_key_post<'a>( + &self, + set_key_connector_key_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/payment", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_payment_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} + let local_var_uri_str = format!( + "{}/accounts/set-key-connector-key", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -pub async fn accounts_premium_post( - configuration: &configuration::Configuration, - payment_method_type: models::PaymentMethodType, - payment_token: Option<&str>, - additional_storage_gb: Option, - country: Option<&str>, - postal_code: Option<&str>, - license: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_payment_method_type = payment_method_type; - let p_payment_token = payment_token; - let p_additional_storage_gb = additional_storage_gb; - let p_country = country; - let p_postal_code = postal_code; - let p_license = license; - - let uri_str = format!("{}/accounts/premium", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - req_builder = req_builder.query(&[("paymentMethodType", &p_payment_method_type.to_string())]); - if let Some(ref param_value) = p_payment_token { - req_builder = req_builder.query(&[("paymentToken", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_additional_storage_gb { - req_builder = req_builder.query(&[("additionalStorageGb", ¶m_value.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&set_key_connector_key_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref param_value) = p_country { - req_builder = req_builder.query(&[("country", ¶m_value.to_string())]); + + async fn accounts_set_password_post<'a>( + &self, + set_password_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/set-password", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&set_password_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref param_value) = p_postal_code { - req_builder = req_builder.query(&[("postalCode", ¶m_value.to_string())]); + + async fn accounts_sso_organization_id_delete<'a>( + &self, + organization_id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/sso/{organizationId}", + local_var_configuration.base_path, + organizationId = crate::apis::urlencode(organization_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + + async fn accounts_sso_user_identifier_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/sso/user-identifier", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Ok(local_var_content), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `String`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - let mut multipart_form = reqwest::multipart::Form::new(); - // TODO: support file upload for 'license' parameter - req_builder = req_builder.multipart(multipart_form); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaymentResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + + async fn accounts_storage_post<'a>( + &self, + storage_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/accounts/storage", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&storage_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PaymentResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_profile_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/accounts/profile", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + async fn accounts_subscription_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + let local_var_uri_str = format!( + "{}/accounts/subscription", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubscriptionResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SubscriptionResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + + async fn accounts_tax_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/accounts/tax", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TaxInfoResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TaxInfoResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_profile_post( - configuration: &configuration::Configuration, - update_profile_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_profile_request_model = update_profile_request_model; + async fn accounts_tax_put<'a>( + &self, + tax_info_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/accounts/profile", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + let local_var_uri_str = format!("{}/accounts/tax", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&tax_info_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_profile_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + + async fn accounts_update_tde_offboarding_password_put<'a>( + &self, + update_tde_offboarding_password_request_model: Option< + models::UpdateTdeOffboardingPasswordRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/update-tde-offboarding-password", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&update_tde_offboarding_password_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_profile_put( - configuration: &configuration::Configuration, - update_profile_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_profile_request_model = update_profile_request_model; + async fn accounts_update_temp_password_put<'a>( + &self, + update_temp_password_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; - let uri_str = format!("{}/accounts/profile", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + let local_var_uri_str = format!( + "{}/accounts/update-temp-password", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_temp_password_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_profile_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + + async fn accounts_verify_devices_post<'a>( + &self, + set_verify_devices_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/verify-devices", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&set_verify_devices_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_reinstate_premium_post( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/accounts/reinstate-premium", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + async fn accounts_verify_devices_put<'a>( + &self, + set_verify_devices_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + let local_var_uri_str = format!( + "{}/accounts/verify-devices", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&set_verify_devices_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + + async fn accounts_verify_email_post<'a>( + &self, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/verify-email", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_request_otp_post( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/accounts/request-otp", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + async fn accounts_verify_email_token_post<'a>( + &self, + verify_email_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + let local_var_uri_str = format!( + "{}/accounts/verify-email-token", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&verify_email_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + + async fn accounts_verify_otp_post<'a>( + &self, + verify_otp_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = + format!("{}/accounts/verify-otp", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&verify_otp_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn accounts_resend_new_device_otp_post( - configuration: &configuration::Configuration, - unauthenticated_secret_verification_request_model: Option< - models::UnauthenticatedSecretVerificationRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_unauthenticated_secret_verification_request_model = - unauthenticated_secret_verification_request_model; - - let uri_str = format!("{}/accounts/resend-new-device-otp", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_unauthenticated_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} + async fn accounts_verify_password_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; -pub async fn accounts_revision_date_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/accounts/revision-date", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `i64`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `i64`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_uri_str = format!( + "{}/accounts/verify-password", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MasterPasswordPolicyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::MasterPasswordPolicyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } } -pub async fn accounts_rotate_api_key_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_api_key_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsApiKeyPostError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/rotate-api-key", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_avatar_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsAvatarPostError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApiKeyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_avatar_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsAvatarPutError { + UnknownValue(serde_json::Value), } -pub async fn accounts_security_stamp_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_cancel_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsCancelPostError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/security-stamp", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_convert_to_key_connector_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsConvertToKeyConnectorPostError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_delete`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsDeleteError { + UnknownValue(serde_json::Value), } -pub async fn accounts_set_key_connector_key_post( - configuration: &configuration::Configuration, - set_key_connector_key_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_set_key_connector_key_request_model = set_key_connector_key_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_delete_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsDeletePostError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/set-key-connector-key", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_delete_recover_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsDeleteRecoverPostError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_set_key_connector_key_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_delete_recover_token_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsDeleteRecoverTokenPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_set_password_post( - configuration: &configuration::Configuration, - set_password_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_set_password_request_model = set_password_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_email_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsEmailPostError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/set-password", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_email_token_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsEmailTokenPostError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_set_password_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_kdf_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsKdfPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_sso_organization_id_delete( - configuration: &configuration::Configuration, - organization_id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/accounts/sso/{organizationId}", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_key_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsKeyPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_sso_user_identifier_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/accounts/sso/user-identifier", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_keys_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsKeysGetError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Ok(content), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_keys_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsKeysPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_storage_post( - configuration: &configuration::Configuration, - storage_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_storage_request_model = storage_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_license_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsLicensePostError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/storage", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_organizations_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsOrganizationsGetError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_storage_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaymentResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_password_hint_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsPasswordHintPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_subscription_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/accounts/subscription", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_password_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsPasswordPostError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubscriptionResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SubscriptionResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_payment_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsPaymentPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_tax_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/accounts/tax", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_premium_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsPremiumPostError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TaxInfoResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TaxInfoResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_profile_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsProfileGetError { + UnknownValue(serde_json::Value), } -pub async fn accounts_tax_put( - configuration: &configuration::Configuration, - tax_info_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_tax_info_update_request_model = tax_info_update_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_profile_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsProfilePostError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/tax", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_profile_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsProfilePutError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_tax_info_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_reinstate_premium_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsReinstatePremiumPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_update_tde_offboarding_password_put( - configuration: &configuration::Configuration, - update_tde_offboarding_password_request_model: Option< - models::UpdateTdeOffboardingPasswordRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_tde_offboarding_password_request_model = - update_tde_offboarding_password_request_model; - - let uri_str = format!( - "{}/accounts/update-tde-offboarding-password", - configuration.base_path - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_tde_offboarding_password_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_request_otp_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsRequestOtpPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_update_temp_password_put( - configuration: &configuration::Configuration, - update_temp_password_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_temp_password_request_model = update_temp_password_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_resend_new_device_otp_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsResendNewDeviceOtpPostError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/update-temp-password", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_revision_date_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsRevisionDateGetError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_temp_password_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_rotate_api_key_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsRotateApiKeyPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_verify_devices_post( - configuration: &configuration::Configuration, - set_verify_devices_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_set_verify_devices_request_model = set_verify_devices_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_security_stamp_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsSecurityStampPostError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/verify-devices", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_set_key_connector_key_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsSetKeyConnectorKeyPostError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_set_verify_devices_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_set_password_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsSetPasswordPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_verify_devices_put( - configuration: &configuration::Configuration, - set_verify_devices_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_set_verify_devices_request_model = set_verify_devices_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_sso_organization_id_delete`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsSsoOrganizationIdDeleteError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/verify-devices", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_sso_user_identifier_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsSsoUserIdentifierGetError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_set_verify_devices_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_storage_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsStoragePostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_verify_email_post( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/accounts/verify-email", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_subscription_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsSubscriptionGetError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_tax_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsTaxGetError { + UnknownValue(serde_json::Value), } -pub async fn accounts_verify_email_token_post( - configuration: &configuration::Configuration, - verify_email_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_verify_email_request_model = verify_email_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_tax_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsTaxPutError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/verify-email-token", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_update_tde_offboarding_password_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsUpdateTdeOffboardingPasswordPutError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_verify_email_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_update_temp_password_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsUpdateTempPasswordPutError { + UnknownValue(serde_json::Value), } -pub async fn accounts_verify_otp_post( - configuration: &configuration::Configuration, - verify_otp_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_verify_otp_request_model = verify_otp_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_verify_devices_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsVerifyDevicesPostError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/verify-otp", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_verify_devices_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsVerifyDevicesPutError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_verify_otp_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_verify_email_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsVerifyEmailPostError { + UnknownValue(serde_json::Value), } -pub async fn accounts_verify_password_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; +/// struct for typed errors of method [`AccountsApi::accounts_verify_email_token_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsVerifyEmailTokenPostError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/accounts/verify-password", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +/// struct for typed errors of method [`AccountsApi::accounts_verify_otp_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsVerifyOtpPostError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MasterPasswordPolicyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::MasterPasswordPolicyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`AccountsApi::accounts_verify_password_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsVerifyPasswordPostError { + UnknownValue(serde_json::Value), } diff --git a/crates/bitwarden-api-api/src/apis/accounts_billing_api.rs b/crates/bitwarden-api-api/src/apis/accounts_billing_api.rs index 8e6eb0a73..9770ca603 100644 --- a/crates/bitwarden-api-api/src/apis/accounts_billing_api.rs +++ b/crates/bitwarden-api-api/src/apis/accounts_billing_api.rs @@ -8,255 +8,350 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait AccountsBillingApi: Send + Sync { + /// GET /accounts/billing/history + async fn accounts_billing_history_get<'a>( + &self, + ) -> Result>; + + /// GET /accounts/billing/invoices + async fn accounts_billing_invoices_get<'a>( + &self, + status: Option<&'a str>, + start_after: Option<&'a str>, + ) -> Result<(), Error>; + + /// GET /accounts/billing/payment-method + async fn accounts_billing_payment_method_get<'a>( + &self, + ) -> Result>; + + /// POST /accounts/billing/preview-invoice + async fn accounts_billing_preview_invoice_post<'a>( + &self, + preview_individual_invoice_request_body: Option< + models::PreviewIndividualInvoiceRequestBody, + >, + ) -> Result<(), Error>; + + /// GET /accounts/billing/transactions + async fn accounts_billing_transactions_get<'a>( + &self, + start_after: Option, + ) -> Result<(), Error>; +} + +pub struct AccountsBillingApiClient { + configuration: Arc, +} + +impl AccountsBillingApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl AccountsBillingApi for AccountsBillingApiClient { + async fn accounts_billing_history_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/billing/history", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BillingHistoryResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::BillingHistoryResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn accounts_billing_invoices_get<'a>( + &self, + status: Option<&'a str>, + start_after: Option<&'a str>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/billing/invoices", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", ¶m_value.to_string())]); + } + if let Some(ref param_value) = start_after { + local_var_req_builder = + local_var_req_builder.query(&[("startAfter", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn accounts_billing_payment_method_get<'a>( + &self, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/billing/payment-method", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); -/// struct for typed errors of method [`accounts_billing_history_get`] + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BillingPaymentResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::BillingPaymentResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn accounts_billing_preview_invoice_post<'a>( + &self, + preview_individual_invoice_request_body: Option< + models::PreviewIndividualInvoiceRequestBody, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/billing/preview-invoice", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&preview_individual_invoice_request_body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn accounts_billing_transactions_get<'a>( + &self, + start_after: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/billing/transactions", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = start_after { + local_var_req_builder = + local_var_req_builder.query(&[("startAfter", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`AccountsBillingApi::accounts_billing_history_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsBillingHistoryGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_billing_invoices_get`] +/// struct for typed errors of method [`AccountsBillingApi::accounts_billing_invoices_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsBillingInvoicesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_billing_payment_method_get`] +/// struct for typed errors of method [`AccountsBillingApi::accounts_billing_payment_method_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsBillingPaymentMethodGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_billing_preview_invoice_post`] +/// struct for typed errors of method [`AccountsBillingApi::accounts_billing_preview_invoice_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsBillingPreviewInvoicePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_billing_transactions_get`] +/// struct for typed errors of method [`AccountsBillingApi::accounts_billing_transactions_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsBillingTransactionsGetError { UnknownValue(serde_json::Value), } - -pub async fn accounts_billing_history_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/accounts/billing/history", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BillingHistoryResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BillingHistoryResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn accounts_billing_invoices_get( - configuration: &configuration::Configuration, - status: Option<&str>, - start_after: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_status = status; - let p_start_after = start_after; - - let uri_str = format!("{}/accounts/billing/invoices", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_status { - req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_start_after { - req_builder = req_builder.query(&[("startAfter", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn accounts_billing_payment_method_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!( - "{}/accounts/billing/payment-method", - configuration.base_path - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BillingPaymentResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BillingPaymentResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn accounts_billing_preview_invoice_post( - configuration: &configuration::Configuration, - preview_individual_invoice_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_preview_individual_invoice_request_body = preview_individual_invoice_request_body; - - let uri_str = format!( - "{}/accounts/billing/preview-invoice", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_preview_individual_invoice_request_body); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn accounts_billing_transactions_get( - configuration: &configuration::Configuration, - start_after: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_start_after = start_after; - - let uri_str = format!("{}/accounts/billing/transactions", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_start_after { - req_builder = req_builder.query(&[("startAfter", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/accounts_key_management_api.rs b/crates/bitwarden-api-api/src/apis/accounts_key_management_api.rs index fd900b6f8..3bfd2cbbc 100644 --- a/crates/bitwarden-api-api/src/apis/accounts_key_management_api.rs +++ b/crates/bitwarden-api-api/src/apis/accounts_key_management_api.rs @@ -8,57 +8,91 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`accounts_key_management_regenerate_keys_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsKeyManagementRegenerateKeysPostError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait AccountsKeyManagementApi: Send + Sync { + /// POST /accounts/key-management/regenerate-keys + async fn accounts_key_management_regenerate_keys_post<'a>( + &self, + key_regeneration_request_model: Option, + ) -> Result<(), Error>; } -pub async fn accounts_key_management_regenerate_keys_post( - configuration: &configuration::Configuration, - key_regeneration_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_key_regeneration_request_model = key_regeneration_request_model; - - let uri_str = format!( - "{}/accounts/key-management/regenerate-keys", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +pub struct AccountsKeyManagementApiClient { + configuration: Arc, +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +impl AccountsKeyManagementApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_key_regeneration_request_model); +} + +#[async_trait(?Send)] +impl AccountsKeyManagementApi for AccountsKeyManagementApiClient { + async fn accounts_key_management_regenerate_keys_post<'a>( + &self, + key_regeneration_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_client = &local_var_configuration.client; - let status = resp.status(); + let local_var_uri_str = format!( + "{}/accounts/key-management/regenerate-keys", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&key_regeneration_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } } + +/// struct for typed errors of method +/// [`AccountsKeyManagementApi::accounts_key_management_regenerate_keys_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsKeyManagementRegenerateKeysPostError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/auth_requests_api.rs b/crates/bitwarden-api-api/src/apis/auth_requests_api.rs index b210036d5..0ac304ed5 100644 --- a/crates/bitwarden-api-api/src/apis/auth_requests_api.rs +++ b/crates/bitwarden-api-api/src/apis/auth_requests_api.rs @@ -8,348 +8,436 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait AuthRequestsApi: Send + Sync { + /// POST /auth-requests/admin-request + async fn auth_requests_admin_request_post<'a>( + &self, + auth_request_create_request_model: Option, + ) -> Result>; + + /// GET /auth-requests + async fn auth_requests_get<'a>( + &self, + ) -> Result>; + + /// GET /auth-requests/{id} + async fn auth_requests_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// PUT /auth-requests/{id} + async fn auth_requests_id_put<'a>( + &self, + id: uuid::Uuid, + auth_request_update_request_model: Option, + ) -> Result>; + + /// GET /auth-requests/{id}/response + async fn auth_requests_id_response_get<'a>( + &self, + id: uuid::Uuid, + code: Option<&'a str>, + ) -> Result>; + + /// POST /auth-requests + async fn auth_requests_post<'a>( + &self, + auth_request_create_request_model: Option, + ) -> Result>; +} + +pub struct AuthRequestsApiClient { + configuration: Arc, +} + +impl AuthRequestsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl AuthRequestsApi for AuthRequestsApiClient { + async fn auth_requests_admin_request_post<'a>( + &self, + auth_request_create_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/auth-requests/admin-request", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&auth_request_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn auth_requests_get<'a>( + &self, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/auth-requests", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn auth_requests_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/auth-requests/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn auth_requests_id_put<'a>( + &self, + id: uuid::Uuid, + auth_request_update_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/auth-requests/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&auth_request_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`auth_requests_admin_request_post`] + async fn auth_requests_id_response_get<'a>( + &self, + id: uuid::Uuid, + code: Option<&'a str>, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/auth-requests/{id}/response", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = code { + local_var_req_builder = + local_var_req_builder.query(&[("code", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn auth_requests_post<'a>( + &self, + auth_request_create_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/auth-requests", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&auth_request_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`AuthRequestsApi::auth_requests_admin_request_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AuthRequestsAdminRequestPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`auth_requests_get`] +/// struct for typed errors of method [`AuthRequestsApi::auth_requests_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AuthRequestsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`auth_requests_id_get`] +/// struct for typed errors of method [`AuthRequestsApi::auth_requests_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AuthRequestsIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`auth_requests_id_put`] +/// struct for typed errors of method [`AuthRequestsApi::auth_requests_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AuthRequestsIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`auth_requests_id_response_get`] +/// struct for typed errors of method [`AuthRequestsApi::auth_requests_id_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AuthRequestsIdResponseGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`auth_requests_post`] +/// struct for typed errors of method [`AuthRequestsApi::auth_requests_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AuthRequestsPostError { UnknownValue(serde_json::Value), } - -pub async fn auth_requests_admin_request_post( - configuration: &configuration::Configuration, - auth_request_create_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_auth_request_create_request_model = auth_request_create_request_model; - - let uri_str = format!("{}/auth-requests/admin-request", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_auth_request_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn auth_requests_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/auth-requests", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn auth_requests_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/auth-requests/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn auth_requests_id_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - auth_request_update_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_auth_request_update_request_model = auth_request_update_request_model; - - let uri_str = format!( - "{}/auth-requests/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_auth_request_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn auth_requests_id_response_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, - code: Option<&str>, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_code = code; - - let uri_str = format!( - "{}/auth-requests/{id}/response", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_code { - req_builder = req_builder.query(&[("code", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn auth_requests_post( - configuration: &configuration::Configuration, - auth_request_create_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_auth_request_create_request_model = auth_request_create_request_model; - - let uri_str = format!("{}/auth-requests", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_auth_request_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AuthRequestResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/ciphers_api.rs b/crates/bitwarden-api-api/src/apis/ciphers_api.rs index fa69b3654..add3c690d 100644 --- a/crates/bitwarden-api-api/src/apis/ciphers_api.rs +++ b/crates/bitwarden-api-api/src/apis/ciphers_api.rs @@ -8,3169 +8,3770 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait CiphersApi: Send + Sync { + /// DELETE /ciphers/admin + async fn ciphers_admin_delete<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error>; + + /// POST /ciphers/admin + async fn ciphers_admin_post<'a>( + &self, + cipher_create_request_model: Option, + ) -> Result>; + + /// POST /ciphers/attachment/validate/azure + async fn ciphers_attachment_validate_azure_post<'a>( + &self, + ) -> Result<(), Error>; + + /// POST /ciphers/bulk-collections + async fn ciphers_bulk_collections_post<'a>( + &self, + cipher_bulk_update_collections_request_model: Option< + models::CipherBulkUpdateCollectionsRequestModel, + >, + ) -> Result<(), Error>; + + /// POST /ciphers/create + async fn ciphers_create_post<'a>( + &self, + cipher_create_request_model: Option, + ) -> Result>; + + /// DELETE /ciphers + async fn ciphers_delete<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error>; + + /// POST /ciphers/delete-admin + async fn ciphers_delete_admin_post<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /ciphers/delete-admin + async fn ciphers_delete_admin_put<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error>; + + /// POST /ciphers/delete + async fn ciphers_delete_post<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /ciphers/delete + async fn ciphers_delete_put<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error>; + + /// GET /ciphers + async fn ciphers_get<'a>( + &self, + ) -> Result>; + + /// DELETE /ciphers/{id}/admin + async fn ciphers_id_admin_delete<'a>( + &self, + id: &'a str, + ) -> Result<(), Error>; + + /// GET /ciphers/{id}/admin + async fn ciphers_id_admin_get<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// POST /ciphers/{id}/admin + async fn ciphers_id_admin_post<'a>( + &self, + id: uuid::Uuid, + cipher_request_model: Option, + ) -> Result>; + + /// PUT /ciphers/{id}/admin + async fn ciphers_id_admin_put<'a>( + &self, + id: uuid::Uuid, + cipher_request_model: Option, + ) -> Result>; + + /// POST /ciphers/{id}/attachment-admin + async fn ciphers_id_attachment_admin_post<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// DELETE /ciphers/{id}/attachment/{attachmentId}/admin + async fn ciphers_id_attachment_attachment_id_admin_delete<'a>( + &self, + id: &'a str, + attachment_id: &'a str, + ) -> Result<(), Error>; + + /// DELETE /ciphers/{id}/attachment/{attachmentId} + async fn ciphers_id_attachment_attachment_id_delete<'a>( + &self, + id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result< + models::DeleteAttachmentResponseData, + Error, + >; + + /// POST /ciphers/{id}/attachment/{attachmentId}/delete-admin + async fn ciphers_id_attachment_attachment_id_delete_admin_post<'a>( + &self, + id: &'a str, + attachment_id: &'a str, + ) -> Result<(), Error>; + + /// POST /ciphers/{id}/attachment/{attachmentId}/delete + async fn ciphers_id_attachment_attachment_id_delete_post<'a>( + &self, + id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result< + models::DeleteAttachmentResponseData, + Error, + >; + + /// GET /ciphers/{id}/attachment/{attachmentId} + async fn ciphers_id_attachment_attachment_id_get<'a>( + &self, + id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result>; + + /// POST /ciphers/{id}/attachment/{attachmentId} + async fn ciphers_id_attachment_attachment_id_post<'a>( + &self, + id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result<(), Error>; + + /// GET /ciphers/{id}/attachment/{attachmentId}/renew + async fn ciphers_id_attachment_attachment_id_renew_get<'a>( + &self, + id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result< + models::AttachmentUploadDataResponseModel, + Error, + >; + + /// POST /ciphers/{id}/attachment/{attachmentId}/share + async fn ciphers_id_attachment_attachment_id_share_post<'a>( + &self, + id: &'a str, + attachment_id: &'a str, + organization_id: Option, + ) -> Result<(), Error>; + + /// POST /ciphers/{id}/attachment + async fn ciphers_id_attachment_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// POST /ciphers/{id}/attachment/v2 + async fn ciphers_id_attachment_v2_post<'a>( + &self, + id: uuid::Uuid, + attachment_request_model: Option, + ) -> Result>; + + /// POST /ciphers/{id}/collections-admin + async fn ciphers_id_collections_admin_post<'a>( + &self, + id: &'a str, + cipher_collections_request_model: Option, + ) -> Result>; + + /// PUT /ciphers/{id}/collections-admin + async fn ciphers_id_collections_admin_put<'a>( + &self, + id: &'a str, + cipher_collections_request_model: Option, + ) -> Result>; + + /// POST /ciphers/{id}/collections + async fn ciphers_id_collections_post<'a>( + &self, + id: uuid::Uuid, + cipher_collections_request_model: Option, + ) -> Result>; + + /// PUT /ciphers/{id}/collections + async fn ciphers_id_collections_put<'a>( + &self, + id: uuid::Uuid, + cipher_collections_request_model: Option, + ) -> Result>; + + /// POST /ciphers/{id}/collections_v2 + async fn ciphers_id_collections_v2_post<'a>( + &self, + id: uuid::Uuid, + cipher_collections_request_model: Option, + ) -> Result>; + + /// PUT /ciphers/{id}/collections_v2 + async fn ciphers_id_collections_v2_put<'a>( + &self, + id: uuid::Uuid, + cipher_collections_request_model: Option, + ) -> Result>; + + /// DELETE /ciphers/{id} + async fn ciphers_id_delete<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /ciphers/{id}/delete-admin + async fn ciphers_id_delete_admin_post<'a>( + &self, + id: &'a str, + ) -> Result<(), Error>; + + /// PUT /ciphers/{id}/delete-admin + async fn ciphers_id_delete_admin_put<'a>( + &self, + id: &'a str, + ) -> Result<(), Error>; + + /// POST /ciphers/{id}/delete + async fn ciphers_id_delete_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// PUT /ciphers/{id}/delete + async fn ciphers_id_delete_put<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /ciphers/{id}/details + async fn ciphers_id_details_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// GET /ciphers/{id}/full-details + async fn ciphers_id_full_details_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// GET /ciphers/{id} + async fn ciphers_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// POST /ciphers/{id}/partial + async fn ciphers_id_partial_post<'a>( + &self, + id: uuid::Uuid, + cipher_partial_request_model: Option, + ) -> Result>; + + /// PUT /ciphers/{id}/partial + async fn ciphers_id_partial_put<'a>( + &self, + id: uuid::Uuid, + cipher_partial_request_model: Option, + ) -> Result>; + + /// POST /ciphers/{id} + async fn ciphers_id_post<'a>( + &self, + id: uuid::Uuid, + cipher_request_model: Option, + ) -> Result>; + + /// PUT /ciphers/{id} + async fn ciphers_id_put<'a>( + &self, + id: uuid::Uuid, + cipher_request_model: Option, + ) -> Result>; + + /// PUT /ciphers/{id}/restore-admin + async fn ciphers_id_restore_admin_put<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// PUT /ciphers/{id}/restore + async fn ciphers_id_restore_put<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// POST /ciphers/{id}/share + async fn ciphers_id_share_post<'a>( + &self, + id: uuid::Uuid, + cipher_share_request_model: Option, + ) -> Result>; + + /// PUT /ciphers/{id}/share + async fn ciphers_id_share_put<'a>( + &self, + id: uuid::Uuid, + cipher_share_request_model: Option, + ) -> Result>; + + /// POST /ciphers/move + async fn ciphers_move_post<'a>( + &self, + cipher_bulk_move_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /ciphers/move + async fn ciphers_move_put<'a>( + &self, + cipher_bulk_move_request_model: Option, + ) -> Result<(), Error>; + + /// GET /ciphers/organization-details/assigned + async fn ciphers_organization_details_assigned_get<'a>( + &self, + organization_id: Option, + ) -> Result< + models::CipherDetailsResponseModelListResponseModel, + Error, + >; + + /// GET /ciphers/organization-details + async fn ciphers_organization_details_get<'a>( + &self, + organization_id: Option, + ) -> Result< + models::CipherMiniDetailsResponseModelListResponseModel, + Error, + >; + + /// POST /ciphers + async fn ciphers_post<'a>( + &self, + cipher_request_model: Option, + ) -> Result>; + + /// POST /ciphers/purge + async fn ciphers_purge_post<'a>( + &self, + organization_id: Option<&'a str>, + secret_verification_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /ciphers/restore-admin + async fn ciphers_restore_admin_put<'a>( + &self, + cipher_bulk_restore_request_model: Option, + ) -> Result>; + + /// PUT /ciphers/restore + async fn ciphers_restore_put<'a>( + &self, + cipher_bulk_restore_request_model: Option, + ) -> Result>; + + /// POST /ciphers/share + async fn ciphers_share_post<'a>( + &self, + cipher_bulk_share_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /ciphers/share + async fn ciphers_share_put<'a>( + &self, + cipher_bulk_share_request_model: Option, + ) -> Result<(), Error>; +} + +pub struct CiphersApiClient { + configuration: Arc, +} + +impl CiphersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl CiphersApi for CiphersApiClient { + async fn ciphers_admin_delete<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/ciphers/admin", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_delete_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_admin_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersAdminDeleteError { - UnknownValue(serde_json::Value), -} + async fn ciphers_admin_post<'a>( + &self, + cipher_create_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`ciphers_admin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersAdminPostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`ciphers_attachment_validate_azure_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersAttachmentValidateAzurePostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/ciphers/admin", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`ciphers_bulk_collections_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersBulkCollectionsPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_create_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersCreatePostError { - UnknownValue(serde_json::Value), -} + async fn ciphers_attachment_validate_azure_post<'a>( + &self, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`ciphers_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersDeleteError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`ciphers_delete_admin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersDeleteAdminPostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!( + "{}/ciphers/attachment/validate/azure", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`ciphers_delete_admin_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersDeleteAdminPutError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersDeletePostError { - UnknownValue(serde_json::Value), -} + async fn ciphers_bulk_collections_post<'a>( + &self, + cipher_bulk_update_collections_request_model: Option< + models::CipherBulkUpdateCollectionsRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`ciphers_delete_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersDeletePutError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`ciphers_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersGetError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!( + "{}/ciphers/bulk-collections", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`ciphers_id_admin_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAdminDeleteError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&cipher_bulk_update_collections_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_id_admin_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAdminGetError { - UnknownValue(serde_json::Value), -} + async fn ciphers_create_post<'a>( + &self, + cipher_create_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`ciphers_id_admin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAdminPostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`ciphers_id_admin_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAdminPutError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/ciphers/create", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`ciphers_id_attachment_admin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentAdminPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_id_attachment_attachment_id_admin_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentAttachmentIdAdminDeleteError { - UnknownValue(serde_json::Value), -} + async fn ciphers_delete<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`ciphers_id_attachment_attachment_id_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentAttachmentIdDeleteError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`ciphers_id_attachment_attachment_id_delete_admin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentAttachmentIdDeleteAdminPostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/ciphers", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_delete_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_delete_admin_post<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = + format!("{}/ciphers/delete-admin", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_delete_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_delete_admin_put<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = + format!("{}/ciphers/delete-admin", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_delete_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_delete_post<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/ciphers/delete", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_delete_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_delete_put<'a>( + &self, + cipher_bulk_delete_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/ciphers/delete", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_delete_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/ciphers", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_admin_delete<'a>( + &self, + id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/admin", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_admin_get<'a>( + &self, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/admin", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_admin_post<'a>( + &self, + id: uuid::Uuid, + cipher_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/admin", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_admin_put<'a>( + &self, + id: uuid::Uuid, + cipher_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/admin", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_admin_post<'a>( + &self, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment-admin", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_attachment_id_admin_delete<'a>( + &self, + id: &'a str, + attachment_id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment/{attachmentId}/admin", + local_var_configuration.base_path, + id = crate::apis::urlencode(id), + attachmentId = crate::apis::urlencode(attachment_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_attachment_id_delete<'a>( + &self, + id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result< + models::DeleteAttachmentResponseData, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment/{attachmentId}", + local_var_configuration.base_path, + id = id, + attachmentId = crate::apis::urlencode(attachment_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAttachmentResponseData`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeleteAttachmentResponseData`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_attachment_id_delete_admin_post<'a>( + &self, + id: &'a str, + attachment_id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment/{attachmentId}/delete-admin", + local_var_configuration.base_path, + id = crate::apis::urlencode(id), + attachmentId = crate::apis::urlencode(attachment_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_attachment_id_delete_post<'a>( + &self, + id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result< + models::DeleteAttachmentResponseData, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment/{attachmentId}/delete", + local_var_configuration.base_path, + id = id, + attachmentId = crate::apis::urlencode(attachment_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAttachmentResponseData`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeleteAttachmentResponseData`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_attachment_id_get<'a>( + &self, + id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment/{attachmentId}", + local_var_configuration.base_path, + id = id, + attachmentId = crate::apis::urlencode(attachment_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachmentResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AttachmentResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_attachment_id_post<'a>( + &self, + id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment/{attachmentId}", + local_var_configuration.base_path, + id = id, + attachmentId = crate::apis::urlencode(attachment_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_attachment_id_renew_get<'a>( + &self, + id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result< + models::AttachmentUploadDataResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment/{attachmentId}/renew", + local_var_configuration.base_path, + id = id, + attachmentId = crate::apis::urlencode(attachment_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachmentUploadDataResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AttachmentUploadDataResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_attachment_id_share_post<'a>( + &self, + id: &'a str, + attachment_id: &'a str, + organization_id: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment/{attachmentId}/share", + local_var_configuration.base_path, + id = crate::apis::urlencode(id), + attachmentId = crate::apis::urlencode(attachment_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref param_value) = organization_id { + local_var_req_builder = + local_var_req_builder.query(&[("organizationId", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_attachment_v2_post<'a>( + &self, + id: uuid::Uuid, + attachment_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/attachment/v2", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&attachment_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachmentUploadDataResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AttachmentUploadDataResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_collections_admin_post<'a>( + &self, + id: &'a str, + cipher_collections_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/collections-admin", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_collections_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_collections_admin_put<'a>( + &self, + id: &'a str, + cipher_collections_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/collections-admin", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_collections_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_collections_post<'a>( + &self, + id: uuid::Uuid, + cipher_collections_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/collections", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_collections_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_collections_put<'a>( + &self, + id: uuid::Uuid, + cipher_collections_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/collections", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_collections_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_collections_v2_post<'a>( + &self, + id: uuid::Uuid, + cipher_collections_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/collections_v2", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_collections_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionalCipherDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OptionalCipherDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_collections_v2_put<'a>( + &self, + id: uuid::Uuid, + cipher_collections_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/collections_v2", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_collections_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionalCipherDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OptionalCipherDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_delete<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_delete_admin_post<'a>( + &self, + id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/delete-admin", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_delete_admin_put<'a>( + &self, + id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/delete-admin", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_delete_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/delete", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_delete_put<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/delete", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_details_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/details", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_full_details_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/full-details", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_partial_post<'a>( + &self, + id: uuid::Uuid, + cipher_partial_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/partial", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_partial_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_partial_put<'a>( + &self, + id: uuid::Uuid, + cipher_partial_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/partial", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_partial_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_post<'a>( + &self, + id: uuid::Uuid, + cipher_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_put<'a>( + &self, + id: uuid::Uuid, + cipher_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_restore_admin_put<'a>( + &self, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/restore-admin", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_restore_put<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/restore", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_share_post<'a>( + &self, + id: uuid::Uuid, + cipher_share_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/share", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_share_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_id_share_put<'a>( + &self, + id: uuid::Uuid, + cipher_share_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/share", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_share_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_move_post<'a>( + &self, + cipher_bulk_move_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/ciphers/move", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_move_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_move_put<'a>( + &self, + cipher_bulk_move_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/ciphers/move", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_move_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_organization_details_assigned_get<'a>( + &self, + organization_id: Option, + ) -> Result< + models::CipherDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/organization-details/assigned", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = organization_id { + local_var_req_builder = + local_var_req_builder.query(&[("organizationId", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_organization_details_get<'a>( + &self, + organization_id: Option, + ) -> Result< + models::CipherMiniDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/organization-details", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = organization_id { + local_var_req_builder = + local_var_req_builder.query(&[("organizationId", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_id_attachment_attachment_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentAttachmentIdDeletePostError { - UnknownValue(serde_json::Value), -} + async fn ciphers_post<'a>( + &self, + cipher_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`ciphers_id_attachment_attachment_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentAttachmentIdGetError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`ciphers_id_attachment_attachment_id_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentAttachmentIdPostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/ciphers", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`ciphers_id_attachment_attachment_id_renew_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentAttachmentIdRenewGetError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_id_attachment_attachment_id_share_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentAttachmentIdSharePostError { - UnknownValue(serde_json::Value), -} + async fn ciphers_purge_post<'a>( + &self, + organization_id: Option<&'a str>, + secret_verification_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`ciphers_id_attachment_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentPostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`ciphers_id_attachment_v2_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentV2PostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/ciphers/purge", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`ciphers_id_collections_admin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdCollectionsAdminPostError { - UnknownValue(serde_json::Value), -} + if let Some(ref param_value) = organization_id { + local_var_req_builder = + local_var_req_builder.query(&[("organizationId", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_id_collections_admin_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdCollectionsAdminPutError { - UnknownValue(serde_json::Value), -} + async fn ciphers_restore_admin_put<'a>( + &self, + cipher_bulk_restore_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`ciphers_id_collections_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdCollectionsPostError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`ciphers_id_collections_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdCollectionsPutError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!( + "{}/ciphers/restore-admin", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); -/// struct for typed errors of method [`ciphers_id_collections_v2_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdCollectionsV2PostError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_restore_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_id_collections_v2_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdCollectionsV2PutError { - UnknownValue(serde_json::Value), -} + async fn ciphers_restore_put<'a>( + &self, + cipher_bulk_restore_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`ciphers_id_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdDeleteError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`ciphers_id_delete_admin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdDeleteAdminPostError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/ciphers/restore", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); -/// struct for typed errors of method [`ciphers_id_delete_admin_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdDeleteAdminPutError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_restore_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdDeletePostError { - UnknownValue(serde_json::Value), -} + async fn ciphers_share_post<'a>( + &self, + cipher_bulk_share_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`ciphers_id_delete_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdDeletePutError { - UnknownValue(serde_json::Value), -} + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`ciphers_id_details_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdDetailsGetError { - UnknownValue(serde_json::Value), -} + let local_var_uri_str = format!("{}/ciphers/share", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`ciphers_id_full_details_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdFullDetailsGetError { - UnknownValue(serde_json::Value), -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_share_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`ciphers_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdGetError { - UnknownValue(serde_json::Value), + async fn ciphers_share_put<'a>( + &self, + cipher_bulk_share_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/ciphers/share", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&cipher_bulk_share_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } } -/// struct for typed errors of method [`ciphers_id_partial_post`] +/// struct for typed errors of method [`CiphersApi::ciphers_admin_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersIdPartialPostError { +pub enum CiphersAdminDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_id_partial_put`] +/// struct for typed errors of method [`CiphersApi::ciphers_admin_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersIdPartialPutError { +pub enum CiphersAdminPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_id_post`] +/// struct for typed errors of method [`CiphersApi::ciphers_attachment_validate_azure_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersIdPostError { +pub enum CiphersAttachmentValidateAzurePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_id_put`] +/// struct for typed errors of method [`CiphersApi::ciphers_bulk_collections_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersIdPutError { +pub enum CiphersBulkCollectionsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_id_restore_admin_put`] +/// struct for typed errors of method [`CiphersApi::ciphers_create_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersIdRestoreAdminPutError { +pub enum CiphersCreatePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_id_restore_put`] +/// struct for typed errors of method [`CiphersApi::ciphers_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersIdRestorePutError { +pub enum CiphersDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_id_share_post`] +/// struct for typed errors of method [`CiphersApi::ciphers_delete_admin_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersIdSharePostError { +pub enum CiphersDeleteAdminPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_id_share_put`] +/// struct for typed errors of method [`CiphersApi::ciphers_delete_admin_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersIdSharePutError { +pub enum CiphersDeleteAdminPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_move_post`] +/// struct for typed errors of method [`CiphersApi::ciphers_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersMovePostError { +pub enum CiphersDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_move_put`] +/// struct for typed errors of method [`CiphersApi::ciphers_delete_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersMovePutError { +pub enum CiphersDeletePutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_organization_details_assigned_get`] +/// struct for typed errors of method [`CiphersApi::ciphers_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersOrganizationDetailsAssignedGetError { +pub enum CiphersGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_organization_details_get`] +/// struct for typed errors of method [`CiphersApi::ciphers_id_admin_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersOrganizationDetailsGetError { +pub enum CiphersIdAdminDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_post`] +/// struct for typed errors of method [`CiphersApi::ciphers_id_admin_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersPostError { +pub enum CiphersIdAdminGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_purge_post`] +/// struct for typed errors of method [`CiphersApi::ciphers_id_admin_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersPurgePostError { +pub enum CiphersIdAdminPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_restore_admin_put`] +/// struct for typed errors of method [`CiphersApi::ciphers_id_admin_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersRestoreAdminPutError { +pub enum CiphersIdAdminPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_restore_put`] +/// struct for typed errors of method [`CiphersApi::ciphers_id_attachment_admin_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersRestorePutError { +pub enum CiphersIdAttachmentAdminPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_share_post`] +/// struct for typed errors of method +/// [`CiphersApi::ciphers_id_attachment_attachment_id_admin_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersSharePostError { +pub enum CiphersIdAttachmentAttachmentIdAdminDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_share_put`] +/// struct for typed errors of method [`CiphersApi::ciphers_id_attachment_attachment_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum CiphersSharePutError { +pub enum CiphersIdAttachmentAttachmentIdDeleteError { UnknownValue(serde_json::Value), } -pub async fn ciphers_admin_delete( - configuration: &configuration::Configuration, - cipher_bulk_delete_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_delete_request_model = cipher_bulk_delete_request_model; - - let uri_str = format!("{}/ciphers/admin", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_delete_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_admin_post( - configuration: &configuration::Configuration, - cipher_create_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_create_request_model = cipher_create_request_model; - - let uri_str = format!("{}/ciphers/admin", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_attachment_validate_azure_post( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!( - "{}/ciphers/attachment/validate/azure", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_bulk_collections_post( - configuration: &configuration::Configuration, - cipher_bulk_update_collections_request_model: Option< - models::CipherBulkUpdateCollectionsRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_update_collections_request_model = - cipher_bulk_update_collections_request_model; - - let uri_str = format!("{}/ciphers/bulk-collections", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_update_collections_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_create_post( - configuration: &configuration::Configuration, - cipher_create_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_create_request_model = cipher_create_request_model; - - let uri_str = format!("{}/ciphers/create", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_delete( - configuration: &configuration::Configuration, - cipher_bulk_delete_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_delete_request_model = cipher_bulk_delete_request_model; - - let uri_str = format!("{}/ciphers", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_delete_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_delete_admin_post( - configuration: &configuration::Configuration, - cipher_bulk_delete_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_delete_request_model = cipher_bulk_delete_request_model; - - let uri_str = format!("{}/ciphers/delete-admin", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_delete_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_delete_admin_put( - configuration: &configuration::Configuration, - cipher_bulk_delete_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_delete_request_model = cipher_bulk_delete_request_model; - - let uri_str = format!("{}/ciphers/delete-admin", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_delete_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_delete_post( - configuration: &configuration::Configuration, - cipher_bulk_delete_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_delete_request_model = cipher_bulk_delete_request_model; - - let uri_str = format!("{}/ciphers/delete", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_delete_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_delete_put( - configuration: &configuration::Configuration, - cipher_bulk_delete_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_delete_request_model = cipher_bulk_delete_request_model; - - let uri_str = format!("{}/ciphers/delete", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_delete_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/ciphers", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_id_admin_delete( - configuration: &configuration::Configuration, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/admin", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_id_admin_get( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/admin", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_id_admin_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_request_model = cipher_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/admin", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_id_admin_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_request_model = cipher_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/admin", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_id_attachment_admin_post( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/attachment-admin", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_id_attachment_attachment_id_admin_delete( - configuration: &configuration::Configuration, - id: &str, - attachment_id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_attachment_id = attachment_id; - - let uri_str = format!( - "{}/ciphers/{id}/attachment/{attachmentId}/admin", - configuration.base_path, - id = crate::apis::urlencode(p_id), - attachmentId = crate::apis::urlencode(p_attachment_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_id_attachment_attachment_id_delete( - configuration: &configuration::Configuration, - id: uuid::Uuid, - attachment_id: &str, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_attachment_id = attachment_id; - - let uri_str = format!( - "{}/ciphers/{id}/attachment/{attachmentId}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()), - attachmentId = crate::apis::urlencode(p_attachment_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAttachmentResponseData`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteAttachmentResponseData`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_id_attachment_attachment_id_delete_admin_post( - configuration: &configuration::Configuration, - id: &str, - attachment_id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_attachment_id = attachment_id; - - let uri_str = format!( - "{}/ciphers/{id}/attachment/{attachmentId}/delete-admin", - configuration.base_path, - id = crate::apis::urlencode(p_id), - attachmentId = crate::apis::urlencode(p_attachment_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_id_attachment_attachment_id_delete_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - attachment_id: &str, -) -> Result< - models::DeleteAttachmentResponseData, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_attachment_id = attachment_id; - - let uri_str = format!( - "{}/ciphers/{id}/attachment/{attachmentId}/delete", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()), - attachmentId = crate::apis::urlencode(p_attachment_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAttachmentResponseData`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteAttachmentResponseData`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method +/// [`CiphersApi::ciphers_id_attachment_attachment_id_delete_admin_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdAttachmentAttachmentIdDeleteAdminPostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_attachment_attachment_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, - attachment_id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_attachment_id = attachment_id; - - let uri_str = format!( - "{}/ciphers/{id}/attachment/{attachmentId}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()), - attachmentId = crate::apis::urlencode(p_attachment_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachmentResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AttachmentResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method +/// [`CiphersApi::ciphers_id_attachment_attachment_id_delete_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdAttachmentAttachmentIdDeletePostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_attachment_attachment_id_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - attachment_id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_attachment_id = attachment_id; - - let uri_str = format!( - "{}/ciphers/{id}/attachment/{attachmentId}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()), - attachmentId = crate::apis::urlencode(p_attachment_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_attachment_attachment_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdAttachmentAttachmentIdGetError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_attachment_attachment_id_renew_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, - attachment_id: &str, -) -> Result< - models::AttachmentUploadDataResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_attachment_id = attachment_id; - - let uri_str = format!( - "{}/ciphers/{id}/attachment/{attachmentId}/renew", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()), - attachmentId = crate::apis::urlencode(p_attachment_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachmentUploadDataResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AttachmentUploadDataResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_attachment_attachment_id_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdAttachmentAttachmentIdPostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_attachment_attachment_id_share_post( - configuration: &configuration::Configuration, - id: &str, - attachment_id: &str, - organization_id: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_attachment_id = attachment_id; - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/ciphers/{id}/attachment/{attachmentId}/share", - configuration.base_path, - id = crate::apis::urlencode(p_id), - attachmentId = crate::apis::urlencode(p_attachment_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref param_value) = p_organization_id { - req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_attachment_attachment_id_renew_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdAttachmentAttachmentIdRenewGetError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_attachment_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/attachment", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_attachment_attachment_id_share_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdAttachmentAttachmentIdSharePostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_attachment_v2_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - attachment_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_attachment_request_model = attachment_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/attachment/v2", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_attachment_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachmentUploadDataResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AttachmentUploadDataResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_attachment_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdAttachmentPostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_collections_admin_post( - configuration: &configuration::Configuration, - id: &str, - cipher_collections_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_collections_request_model = cipher_collections_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/collections-admin", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_collections_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_attachment_v2_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdAttachmentV2PostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_collections_admin_put( - configuration: &configuration::Configuration, - id: &str, - cipher_collections_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_collections_request_model = cipher_collections_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/collections-admin", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_collections_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_collections_admin_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdCollectionsAdminPostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_collections_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_collections_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_collections_request_model = cipher_collections_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/collections", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_collections_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_collections_admin_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdCollectionsAdminPutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_collections_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_collections_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_collections_request_model = cipher_collections_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/collections", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_collections_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_collections_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdCollectionsPostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_collections_v2_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_collections_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_collections_request_model = cipher_collections_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/collections_v2", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_collections_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionalCipherDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OptionalCipherDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_collections_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdCollectionsPutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_collections_v2_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_collections_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_collections_request_model = cipher_collections_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/collections_v2", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_collections_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionalCipherDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OptionalCipherDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_collections_v2_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdCollectionsV2PostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_delete( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_collections_v2_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdCollectionsV2PutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_delete_admin_post( - configuration: &configuration::Configuration, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/delete-admin", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_delete`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdDeleteError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_delete_admin_put( - configuration: &configuration::Configuration, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/delete-admin", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_delete_admin_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdDeleteAdminPostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_delete_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/delete", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_delete_admin_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdDeleteAdminPutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_delete_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/delete", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_delete_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdDeletePostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_details_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/details", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_delete_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdDeletePutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_full_details_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/full-details", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_details_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdDetailsGetError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_full_details_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdFullDetailsGetError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_partial_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_partial_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_partial_request_model = cipher_partial_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/partial", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_partial_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdGetError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_partial_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_partial_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_partial_request_model = cipher_partial_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/partial", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_partial_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_partial_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdPartialPostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_request_model = cipher_request_model; - - let uri_str = format!( - "{}/ciphers/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_partial_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdPartialPutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_request_model = cipher_request_model; - - let uri_str = format!( - "{}/ciphers/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdPostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_restore_admin_put( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/restore-admin", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdPutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_restore_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/ciphers/{id}/restore", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_restore_admin_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdRestoreAdminPutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_share_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_share_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_share_request_model = cipher_share_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/share", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_share_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_restore_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdRestorePutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_id_share_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_share_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_share_request_model = cipher_share_request_model; - - let uri_str = format!( - "{}/ciphers/{id}/share", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_share_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_share_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdSharePostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_move_post( - configuration: &configuration::Configuration, - cipher_bulk_move_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_move_request_model = cipher_bulk_move_request_model; - - let uri_str = format!("{}/ciphers/move", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_move_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_id_share_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersIdSharePutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_move_put( - configuration: &configuration::Configuration, - cipher_bulk_move_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_move_request_model = cipher_bulk_move_request_model; - - let uri_str = format!("{}/ciphers/move", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_move_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_move_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersMovePostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_organization_details_assigned_get( - configuration: &configuration::Configuration, - organization_id: Option, -) -> Result< - models::CipherDetailsResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/ciphers/organization-details/assigned", - configuration.base_path - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_organization_id { - req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_move_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersMovePutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_organization_details_get( - configuration: &configuration::Configuration, - organization_id: Option, -) -> Result< - models::CipherMiniDetailsResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!("{}/ciphers/organization-details", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_organization_id { - req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_organization_details_assigned_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersOrganizationDetailsAssignedGetError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_post( - configuration: &configuration::Configuration, - cipher_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_request_model = cipher_request_model; - - let uri_str = format!("{}/ciphers", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_organization_details_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersOrganizationDetailsGetError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_purge_post( - configuration: &configuration::Configuration, - organization_id: Option<&str>, - secret_verification_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!("{}/ciphers/purge", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref param_value) = p_organization_id { - req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersPostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_restore_admin_put( - configuration: &configuration::Configuration, - cipher_bulk_restore_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_restore_request_model = cipher_bulk_restore_request_model; - - let uri_str = format!("{}/ciphers/restore-admin", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_restore_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_purge_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersPurgePostError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_restore_put( - configuration: &configuration::Configuration, - cipher_bulk_restore_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_restore_request_model = cipher_bulk_restore_request_model; - - let uri_str = format!("{}/ciphers/restore", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_restore_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CipherMiniResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CipherMiniResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_restore_admin_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersRestoreAdminPutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_share_post( - configuration: &configuration::Configuration, - cipher_bulk_share_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_share_request_model = cipher_bulk_share_request_model; - - let uri_str = format!("{}/ciphers/share", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_share_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_restore_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersRestorePutError { + UnknownValue(serde_json::Value), } -pub async fn ciphers_share_put( - configuration: &configuration::Configuration, - cipher_bulk_share_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_cipher_bulk_share_request_model = cipher_bulk_share_request_model; - - let uri_str = format!("{}/ciphers/share", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); +/// struct for typed errors of method [`CiphersApi::ciphers_share_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersSharePostError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_cipher_bulk_share_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`CiphersApi::ciphers_share_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CiphersSharePutError { + UnknownValue(serde_json::Value), } diff --git a/crates/bitwarden-api-api/src/apis/collections_api.rs b/crates/bitwarden-api-api/src/apis/collections_api.rs index 39ac46228..ab35078db 100644 --- a/crates/bitwarden-api-api/src/apis/collections_api.rs +++ b/crates/bitwarden-api-api/src/apis/collections_api.rs @@ -8,62 +8,1112 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait CollectionsApi: Send + Sync { + /// GET /collections + async fn collections_get<'a>( + &self, + ) -> Result>; + + /// POST /organizations/{orgId}/collections/bulk-access + async fn organizations_org_id_collections_bulk_access_post<'a>( + &self, + org_id: uuid::Uuid, + bulk_collection_access_request_model: Option, + ) -> Result<(), Error>; + + /// DELETE /organizations/{orgId}/collections + async fn organizations_org_id_collections_delete<'a>( + &self, + org_id: uuid::Uuid, + collection_bulk_delete_request_model: Option, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/collections/delete + async fn organizations_org_id_collections_delete_post<'a>( + &self, + org_id: uuid::Uuid, + collection_bulk_delete_request_model: Option, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/collections/details + async fn organizations_org_id_collections_details_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::CollectionAccessDetailsResponseModelListResponseModel, + Error, + >; + + /// GET /organizations/{orgId}/collections + async fn organizations_org_id_collections_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::CollectionResponseModelListResponseModel, + Error, + >; + + /// DELETE /organizations/{orgId}/collections/{id} + async fn organizations_org_id_collections_id_delete<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/collections/{id}/delete + async fn organizations_org_id_collections_id_delete_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/collections/{id}/delete-user/{orgUserId} + async fn organizations_org_id_collections_id_delete_user_org_user_id_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + org_user_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/collections/{id}/details + async fn organizations_org_id_collections_id_details_get<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result< + models::CollectionAccessDetailsResponseModel, + Error, + >; + + /// GET /organizations/{orgId}/collections/{id} + async fn organizations_org_id_collections_id_get<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result>; + + /// POST /organizations/{orgId}/collections/{id} + async fn organizations_org_id_collections_id_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + collection_request_model: Option, + ) -> Result>; + + /// PUT /organizations/{orgId}/collections/{id} + async fn organizations_org_id_collections_id_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + collection_request_model: Option, + ) -> Result>; + + /// DELETE /organizations/{orgId}/collections/{id}/user/{orgUserId} + async fn organizations_org_id_collections_id_user_org_user_id_delete<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + org_user_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/collections/{id}/users + async fn organizations_org_id_collections_id_users_get<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result< + Vec, + Error, + >; + + /// PUT /organizations/{orgId}/collections/{id}/users + async fn organizations_org_id_collections_id_users_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + selection_read_only_request_model: Option>, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/collections + async fn organizations_org_id_collections_post<'a>( + &self, + org_id: uuid::Uuid, + collection_request_model: Option, + ) -> Result>; +} + +pub struct CollectionsApiClient { + configuration: Arc, +} + +impl CollectionsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl CollectionsApi for CollectionsApiClient { + async fn collections_get<'a>( + &self, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/collections", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_bulk_access_post<'a>( + &self, + org_id: uuid::Uuid, + bulk_collection_access_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/bulk-access", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&bulk_collection_access_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_delete<'a>( + &self, + org_id: uuid::Uuid, + collection_bulk_delete_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&collection_bulk_delete_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_delete_post<'a>( + &self, + org_id: uuid::Uuid, + collection_bulk_delete_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/delete", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&collection_bulk_delete_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_details_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::CollectionAccessDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/details", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::CollectionResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_id_delete<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_id_delete_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/{id}/delete", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_id_delete_user_org_user_id_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + org_user_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/{id}/delete-user/{orgUserId}", + local_var_configuration.base_path, + orgId = org_id, + id = id, + orgUserId = org_user_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationsOrgIdCollectionsIdDeleteUserOrgUserIdPostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_id_details_get<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result< + models::CollectionAccessDetailsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/{id}/details", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_id_get<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`collections_get`] + async fn organizations_org_id_collections_id_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + collection_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&collection_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_id_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + collection_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&collection_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_id_user_org_user_id_delete<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + org_user_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/{id}/user/{orgUserId}", + local_var_configuration.base_path, + orgId = org_id, + id = id, + orgUserId = org_user_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_id_users_get<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result< + Vec, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/{id}/users", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SelectionReadOnlyResponseModel>`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::SelectionReadOnlyResponseModel>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_id_users_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + selection_read_only_request_model: Option>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections/{id}/users", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&selection_read_only_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_collections_post<'a>( + &self, + org_id: uuid::Uuid, + collection_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/collections", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&collection_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`CollectionsApi::collections_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CollectionsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_bulk_access_post`] +/// struct for typed errors of method +/// [`CollectionsApi::organizations_org_id_collections_bulk_access_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsBulkAccessPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_delete`] +/// struct for typed errors of method [`CollectionsApi::organizations_org_id_collections_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_delete_post`] +/// struct for typed errors of method +/// [`CollectionsApi::organizations_org_id_collections_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_details_get`] +/// struct for typed errors of method +/// [`CollectionsApi::organizations_org_id_collections_details_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsDetailsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_get`] +/// struct for typed errors of method [`CollectionsApi::organizations_org_id_collections_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_id_delete`] +/// struct for typed errors of method [`CollectionsApi::organizations_org_id_collections_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_id_delete_post`] +/// struct for typed errors of method +/// [`CollectionsApi::organizations_org_id_collections_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdDeletePostError { @@ -71,35 +1121,36 @@ pub enum OrganizationsOrgIdCollectionsIdDeletePostError { } /// struct for typed errors of method -/// [`organizations_org_id_collections_id_delete_user_org_user_id_post`] +/// [`CollectionsApi::organizations_org_id_collections_id_delete_user_org_user_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdDeleteUserOrgUserIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_id_details_get`] +/// struct for typed errors of method +/// [`CollectionsApi::organizations_org_id_collections_id_details_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdDetailsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_id_get`] +/// struct for typed errors of method [`CollectionsApi::organizations_org_id_collections_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_id_post`] +/// struct for typed errors of method [`CollectionsApi::organizations_org_id_collections_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_id_put`] +/// struct for typed errors of method [`CollectionsApi::organizations_org_id_collections_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdPutError { @@ -107,887 +1158,32 @@ pub enum OrganizationsOrgIdCollectionsIdPutError { } /// struct for typed errors of method -/// [`organizations_org_id_collections_id_user_org_user_id_delete`] +/// [`CollectionsApi::organizations_org_id_collections_id_user_org_user_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdUserOrgUserIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_id_users_get`] +/// struct for typed errors of method +/// [`CollectionsApi::organizations_org_id_collections_id_users_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdUsersGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_id_users_put`] +/// struct for typed errors of method +/// [`CollectionsApi::organizations_org_id_collections_id_users_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdUsersPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_post`] +/// struct for typed errors of method [`CollectionsApi::organizations_org_id_collections_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsPostError { UnknownValue(serde_json::Value), } - -pub async fn collections_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/collections", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CollectionDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_bulk_access_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - bulk_collection_access_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_bulk_collection_access_request_model = bulk_collection_access_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/bulk-access", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_bulk_collection_access_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_delete( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - collection_bulk_delete_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_collection_bulk_delete_request_model = collection_bulk_delete_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/collections", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_collection_bulk_delete_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_delete_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - collection_bulk_delete_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_collection_bulk_delete_request_model = collection_bulk_delete_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/delete", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_collection_bulk_delete_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_details_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result< - models::CollectionAccessDetailsResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/details", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result< - models::CollectionResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/organizations/{orgId}/collections", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CollectionResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_id_delete( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_id_delete_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/{id}/delete", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_id_delete_user_org_user_id_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, - org_user_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_org_user_id = org_user_id; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/{id}/delete-user/{orgUserId}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()), - orgUserId = crate::apis::urlencode(p_org_user_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_id_details_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result< - models::CollectionAccessDetailsResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/{id}/details", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_id_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_id_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, - collection_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_collection_request_model = collection_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_collection_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_id_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, - collection_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_collection_request_model = collection_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_collection_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_id_user_org_user_id_delete( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, - org_user_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_org_user_id = org_user_id; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/{id}/user/{orgUserId}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()), - orgUserId = crate::apis::urlencode(p_org_user_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_id_users_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result< - Vec, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/{id}/users", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SelectionReadOnlyResponseModel>`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::SelectionReadOnlyResponseModel>`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_id_users_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, - selection_read_only_request_model: Option>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_selection_read_only_request_model = selection_read_only_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/collections/{id}/users", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_selection_read_only_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_collections_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - collection_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_collection_request_model = collection_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/collections", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_collection_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/config_api.rs b/crates/bitwarden-api-api/src/apis/config_api.rs index 2e87e555e..5eb39659f 100644 --- a/crates/bitwarden-api-api/src/apis/config_api.rs +++ b/crates/bitwarden-api-api/src/apis/config_api.rs @@ -8,57 +8,90 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`config_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ConfigGetError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait ConfigApi: Send + Sync { + /// GET /config + async fn config_get<'a>(&self) -> Result>; } -pub async fn config_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/config", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +pub struct ConfigApiClient { + configuration: Arc, +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +impl ConfigApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; +} + +#[async_trait(?Send)] +impl ConfigApi for ConfigApiClient { + async fn config_get<'a>(&self) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_uri_str = format!("{}/config", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ConfigResponseModel`")))), + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ConfigResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } + +/// struct for typed errors of method [`ConfigApi::config_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ConfigGetError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/configuration.rs b/crates/bitwarden-api-api/src/apis/configuration.rs index faa9e6f6d..c184fc18f 100644 --- a/crates/bitwarden-api-api/src/apis/configuration.rs +++ b/crates/bitwarden-api-api/src/apis/configuration.rs @@ -36,7 +36,7 @@ impl Configuration { impl Default for Configuration { fn default() -> Self { Configuration { - base_path: "http://localhost".to_owned(), + base_path: "https://api.bitwarden.com".to_owned(), user_agent: Some("OpenAPI-Generator/latest/rust".to_owned()), client: reqwest::Client::new(), basic_auth: None, diff --git a/crates/bitwarden-api-api/src/apis/counts_api.rs b/crates/bitwarden-api-api/src/apis/counts_api.rs index 0604e46e8..4d22eab1b 100644 --- a/crates/bitwarden-api-api/src/apis/counts_api.rs +++ b/crates/bitwarden-api-api/src/apis/counts_api.rs @@ -8,187 +8,247 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait CountsApi: Send + Sync { + /// GET /organizations/{organizationId}/sm-counts + async fn organizations_organization_id_sm_counts_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result< + models::OrganizationCountsResponseModel, + Error, + >; + + /// GET /projects/{projectId}/sm-counts + async fn projects_project_id_sm_counts_get<'a>( + &self, + project_id: uuid::Uuid, + ) -> Result>; + + /// GET /service-accounts/{serviceAccountId}/sm-counts + async fn service_accounts_service_account_id_sm_counts_get<'a>( + &self, + service_account_id: uuid::Uuid, + ) -> Result< + models::ServiceAccountCountsResponseModel, + Error, + >; +} + +pub struct CountsApiClient { + configuration: Arc, +} + +impl CountsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl CountsApi for CountsApiClient { + async fn organizations_organization_id_sm_counts_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result< + models::OrganizationCountsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/sm-counts", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationCountsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationCountsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn projects_project_id_sm_counts_get<'a>( + &self, + project_id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/projects/{projectId}/sm-counts", + local_var_configuration.base_path, + projectId = project_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectCountsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectCountsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`organizations_organization_id_sm_counts_get`] + async fn service_accounts_service_account_id_sm_counts_get<'a>( + &self, + service_account_id: uuid::Uuid, + ) -> Result< + models::ServiceAccountCountsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{serviceAccountId}/sm-counts", + local_var_configuration.base_path, + serviceAccountId = service_account_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountCountsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountCountsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`CountsApi::organizations_organization_id_sm_counts_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdSmCountsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`projects_project_id_sm_counts_get`] +/// struct for typed errors of method [`CountsApi::projects_project_id_sm_counts_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProjectsProjectIdSmCountsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_service_account_id_sm_counts_get`] +/// struct for typed errors of method +/// [`CountsApi::service_accounts_service_account_id_sm_counts_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsServiceAccountIdSmCountsGetError { UnknownValue(serde_json::Value), } - -pub async fn organizations_organization_id_sm_counts_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result< - models::OrganizationCountsResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/sm-counts", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationCountsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationCountsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn projects_project_id_sm_counts_get( - configuration: &configuration::Configuration, - project_id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_project_id = project_id; - - let uri_str = format!( - "{}/projects/{projectId}/sm-counts", - configuration.base_path, - projectId = crate::apis::urlencode(p_project_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectCountsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectCountsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_service_account_id_sm_counts_get( - configuration: &configuration::Configuration, - service_account_id: uuid::Uuid, -) -> Result< - models::ServiceAccountCountsResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_service_account_id = service_account_id; - - let uri_str = format!( - "{}/service-accounts/{serviceAccountId}/sm-counts", - configuration.base_path, - serviceAccountId = crate::apis::urlencode(p_service_account_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountCountsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountCountsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/devices_api.rs b/crates/bitwarden-api-api/src/apis/devices_api.rs index c13c63ed0..09348c702 100644 --- a/crates/bitwarden-api-api/src/apis/devices_api.rs +++ b/crates/bitwarden-api-api/src/apis/devices_api.rs @@ -8,1134 +8,1350 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait DevicesApi: Send + Sync { + /// GET /devices + async fn devices_get<'a>( + &self, + ) -> Result>; + + /// POST /devices/{id}/deactivate + async fn devices_id_deactivate_post<'a>( + &self, + id: &'a str, + ) -> Result<(), Error>; + + /// DELETE /devices/{id} + async fn devices_id_delete<'a>(&self, id: &'a str) -> Result<(), Error>; + + /// GET /devices/{id} + async fn devices_id_get<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// POST /devices/{id} + async fn devices_id_post<'a>( + &self, + id: &'a str, + device_request_model: Option, + ) -> Result>; + + /// PUT /devices/{id} + async fn devices_id_put<'a>( + &self, + id: &'a str, + device_request_model: Option, + ) -> Result>; + + /// POST /devices/identifier/{identifier}/clear-token + async fn devices_identifier_identifier_clear_token_post<'a>( + &self, + identifier: &'a str, + ) -> Result<(), Error>; + + /// PUT /devices/identifier/{identifier}/clear-token + async fn devices_identifier_identifier_clear_token_put<'a>( + &self, + identifier: &'a str, + ) -> Result<(), Error>; + + /// GET /devices/identifier/{identifier} + async fn devices_identifier_identifier_get<'a>( + &self, + identifier: &'a str, + ) -> Result>; + + /// POST /devices/identifier/{identifier}/token + async fn devices_identifier_identifier_token_post<'a>( + &self, + identifier: &'a str, + device_token_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /devices/identifier/{identifier}/token + async fn devices_identifier_identifier_token_put<'a>( + &self, + identifier: &'a str, + device_token_request_model: Option, + ) -> Result<(), Error>; + + /// POST /devices/identifier/{identifier}/web-push-auth + async fn devices_identifier_identifier_web_push_auth_post<'a>( + &self, + identifier: &'a str, + web_push_auth_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /devices/identifier/{identifier}/web-push-auth + async fn devices_identifier_identifier_web_push_auth_put<'a>( + &self, + identifier: &'a str, + web_push_auth_request_model: Option, + ) -> Result<(), Error>; + + /// POST /devices/{identifier}/keys + async fn devices_identifier_keys_post<'a>( + &self, + identifier: &'a str, + device_keys_request_model: Option, + ) -> Result>; + + /// PUT /devices/{identifier}/keys + async fn devices_identifier_keys_put<'a>( + &self, + identifier: &'a str, + device_keys_request_model: Option, + ) -> Result>; + + /// POST /devices/{identifier}/retrieve-keys + async fn devices_identifier_retrieve_keys_post<'a>( + &self, + identifier: &'a str, + secret_verification_request_model: Option, + ) -> Result>; + + /// GET /devices/knowndevice/{email}/{identifier} + async fn devices_knowndevice_email_identifier_get<'a>( + &self, + email: &'a str, + identifier: &'a str, + ) -> Result>; + + /// GET /devices/knowndevice + async fn devices_knowndevice_get<'a>( + &self, + x_request_email: &'a str, + x_device_identifier: &'a str, + ) -> Result>; + + /// POST /devices/lost-trust + async fn devices_lost_trust_post<'a>(&self) -> Result<(), Error>; + + /// POST /devices + async fn devices_post<'a>( + &self, + device_request_model: Option, + ) -> Result>; + + /// POST /devices/update-trust + async fn devices_update_trust_post<'a>( + &self, + update_devices_trust_request_model: Option, + ) -> Result<(), Error>; +} + +pub struct DevicesApiClient { + configuration: Arc, +} + +impl DevicesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl DevicesApi for DevicesApiClient { + async fn devices_get<'a>( + &self, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/devices", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceAuthRequestResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceAuthRequestResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_id_deactivate_post<'a>( + &self, + id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/{id}/deactivate", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_id_delete<'a>(&self, id: &'a str) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_id_get<'a>( + &self, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_id_post<'a>( + &self, + id: &'a str, + device_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_id_put<'a>( + &self, + id: &'a str, + device_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_identifier_identifier_clear_token_post<'a>( + &self, + identifier: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/identifier/{identifier}/clear-token", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`devices_get`] + async fn devices_identifier_identifier_clear_token_put<'a>( + &self, + identifier: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/identifier/{identifier}/clear-token", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_identifier_identifier_get<'a>( + &self, + identifier: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/identifier/{identifier}", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_identifier_identifier_token_post<'a>( + &self, + identifier: &'a str, + device_token_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/identifier/{identifier}/token", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_token_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_identifier_identifier_token_put<'a>( + &self, + identifier: &'a str, + device_token_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/identifier/{identifier}/token", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_token_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_identifier_identifier_web_push_auth_post<'a>( + &self, + identifier: &'a str, + web_push_auth_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/identifier/{identifier}/web-push-auth", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&web_push_auth_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_identifier_identifier_web_push_auth_put<'a>( + &self, + identifier: &'a str, + web_push_auth_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/identifier/{identifier}/web-push-auth", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&web_push_auth_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_identifier_keys_post<'a>( + &self, + identifier: &'a str, + device_keys_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/{identifier}/keys", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_keys_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_identifier_keys_put<'a>( + &self, + identifier: &'a str, + device_keys_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/{identifier}/keys", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_keys_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_identifier_retrieve_keys_post<'a>( + &self, + identifier: &'a str, + secret_verification_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/{identifier}/retrieve-keys", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProtectedDeviceResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProtectedDeviceResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_knowndevice_email_identifier_get<'a>( + &self, + email: &'a str, + identifier: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/devices/knowndevice/{email}/{identifier}", + local_var_configuration.base_path, + email = crate::apis::urlencode(email), + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `bool`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `bool`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_knowndevice_get<'a>( + &self, + x_request_email: &'a str, + x_device_identifier: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = + format!("{}/devices/knowndevice", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = + local_var_req_builder.header("x-Request-Email", x_request_email.to_string()); + local_var_req_builder = + local_var_req_builder.header("x-Device-Identifier", x_device_identifier.to_string()); + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `bool`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `bool`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_lost_trust_post<'a>(&self) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/devices/lost-trust", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_post<'a>( + &self, + device_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/devices", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn devices_update_trust_post<'a>( + &self, + update_devices_trust_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = + format!("{}/devices/update-trust", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_devices_trust_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`DevicesApi::devices_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_id_deactivate_post`] +/// struct for typed errors of method [`DevicesApi::devices_id_deactivate_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdDeactivatePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_id_delete`] +/// struct for typed errors of method [`DevicesApi::devices_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_id_get`] +/// struct for typed errors of method [`DevicesApi::devices_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_id_post`] +/// struct for typed errors of method [`DevicesApi::devices_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_id_put`] +/// struct for typed errors of method [`DevicesApi::devices_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_identifier_identifier_clear_token_post`] +/// struct for typed errors of method [`DevicesApi::devices_identifier_identifier_clear_token_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdentifierIdentifierClearTokenPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_identifier_identifier_clear_token_put`] +/// struct for typed errors of method [`DevicesApi::devices_identifier_identifier_clear_token_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdentifierIdentifierClearTokenPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_identifier_identifier_get`] +/// struct for typed errors of method [`DevicesApi::devices_identifier_identifier_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdentifierIdentifierGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_identifier_identifier_token_post`] +/// struct for typed errors of method [`DevicesApi::devices_identifier_identifier_token_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdentifierIdentifierTokenPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_identifier_identifier_token_put`] +/// struct for typed errors of method [`DevicesApi::devices_identifier_identifier_token_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdentifierIdentifierTokenPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_identifier_identifier_web_push_auth_post`] +/// struct for typed errors of method +/// [`DevicesApi::devices_identifier_identifier_web_push_auth_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdentifierIdentifierWebPushAuthPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_identifier_identifier_web_push_auth_put`] +/// struct for typed errors of method +/// [`DevicesApi::devices_identifier_identifier_web_push_auth_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdentifierIdentifierWebPushAuthPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_identifier_keys_post`] +/// struct for typed errors of method [`DevicesApi::devices_identifier_keys_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdentifierKeysPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_identifier_keys_put`] +/// struct for typed errors of method [`DevicesApi::devices_identifier_keys_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdentifierKeysPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_identifier_retrieve_keys_post`] +/// struct for typed errors of method [`DevicesApi::devices_identifier_retrieve_keys_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesIdentifierRetrieveKeysPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_knowndevice_email_identifier_get`] +/// struct for typed errors of method [`DevicesApi::devices_knowndevice_email_identifier_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesKnowndeviceEmailIdentifierGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_knowndevice_get`] +/// struct for typed errors of method [`DevicesApi::devices_knowndevice_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesKnowndeviceGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_lost_trust_post`] +/// struct for typed errors of method [`DevicesApi::devices_lost_trust_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesLostTrustPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_post`] +/// struct for typed errors of method [`DevicesApi::devices_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`devices_update_trust_post`] +/// struct for typed errors of method [`DevicesApi::devices_update_trust_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DevicesUpdateTrustPostError { UnknownValue(serde_json::Value), } - -pub async fn devices_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/devices", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceAuthRequestResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceAuthRequestResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_id_deactivate_post( - configuration: &configuration::Configuration, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/devices/{id}/deactivate", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_id_delete( - configuration: &configuration::Configuration, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/devices/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_id_get( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/devices/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_id_post( - configuration: &configuration::Configuration, - id: &str, - device_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_device_request_model = device_request_model; - - let uri_str = format!( - "{}/devices/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_device_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_id_put( - configuration: &configuration::Configuration, - id: &str, - device_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_device_request_model = device_request_model; - - let uri_str = format!( - "{}/devices/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_device_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_identifier_identifier_clear_token_post( - configuration: &configuration::Configuration, - identifier: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - - let uri_str = format!( - "{}/devices/identifier/{identifier}/clear-token", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_identifier_identifier_clear_token_put( - configuration: &configuration::Configuration, - identifier: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - - let uri_str = format!( - "{}/devices/identifier/{identifier}/clear-token", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_identifier_identifier_get( - configuration: &configuration::Configuration, - identifier: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - - let uri_str = format!( - "{}/devices/identifier/{identifier}", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_identifier_identifier_token_post( - configuration: &configuration::Configuration, - identifier: &str, - device_token_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - let p_device_token_request_model = device_token_request_model; - - let uri_str = format!( - "{}/devices/identifier/{identifier}/token", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_device_token_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_identifier_identifier_token_put( - configuration: &configuration::Configuration, - identifier: &str, - device_token_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - let p_device_token_request_model = device_token_request_model; - - let uri_str = format!( - "{}/devices/identifier/{identifier}/token", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_device_token_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_identifier_identifier_web_push_auth_post( - configuration: &configuration::Configuration, - identifier: &str, - web_push_auth_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - let p_web_push_auth_request_model = web_push_auth_request_model; - - let uri_str = format!( - "{}/devices/identifier/{identifier}/web-push-auth", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_web_push_auth_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_identifier_identifier_web_push_auth_put( - configuration: &configuration::Configuration, - identifier: &str, - web_push_auth_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - let p_web_push_auth_request_model = web_push_auth_request_model; - - let uri_str = format!( - "{}/devices/identifier/{identifier}/web-push-auth", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_web_push_auth_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_identifier_keys_post( - configuration: &configuration::Configuration, - identifier: &str, - device_keys_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - let p_device_keys_request_model = device_keys_request_model; - - let uri_str = format!( - "{}/devices/{identifier}/keys", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_device_keys_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_identifier_keys_put( - configuration: &configuration::Configuration, - identifier: &str, - device_keys_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - let p_device_keys_request_model = device_keys_request_model; - - let uri_str = format!( - "{}/devices/{identifier}/keys", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_device_keys_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_identifier_retrieve_keys_post( - configuration: &configuration::Configuration, - identifier: &str, - secret_verification_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!( - "{}/devices/{identifier}/retrieve-keys", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProtectedDeviceResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProtectedDeviceResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_knowndevice_email_identifier_get( - configuration: &configuration::Configuration, - email: &str, - identifier: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_email = email; - let p_identifier = identifier; - - let uri_str = format!( - "{}/devices/knowndevice/{email}/{identifier}", - configuration.base_path, - email = crate::apis::urlencode(p_email), - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `bool`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `bool`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_knowndevice_get( - configuration: &configuration::Configuration, - x_request_email: &str, - x_device_identifier: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_x_request_email = x_request_email; - let p_x_device_identifier = x_device_identifier; - - let uri_str = format!("{}/devices/knowndevice", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - req_builder = req_builder.header("x-Request-Email", p_x_request_email.to_string()); - req_builder = req_builder.header("x-Device-Identifier", p_x_device_identifier.to_string()); - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `bool`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `bool`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_lost_trust_post( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/devices/lost-trust", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_post( - configuration: &configuration::Configuration, - device_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_device_request_model = device_request_model; - - let uri_str = format!("{}/devices", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_device_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn devices_update_trust_post( - configuration: &configuration::Configuration, - update_devices_trust_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_devices_trust_request_model = update_devices_trust_request_model; - - let uri_str = format!("{}/devices/update-trust", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_devices_trust_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/emergency_access_api.rs b/crates/bitwarden-api-api/src/apis/emergency_access_api.rs index 748f436b1..efc9dac05 100644 --- a/crates/bitwarden-api-api/src/apis/emergency_access_api.rs +++ b/crates/bitwarden-api-api/src/apis/emergency_access_api.rs @@ -8,1003 +8,1244 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait EmergencyAccessApi: Send + Sync { + /// GET /emergency-access/granted + async fn emergency_access_granted_get<'a>( + &self, + ) -> Result< + models::EmergencyAccessGrantorDetailsResponseModelListResponseModel, + Error, + >; + + /// POST /emergency-access/{id}/accept + async fn emergency_access_id_accept_post<'a>( + &self, + id: uuid::Uuid, + organization_user_accept_request_model: Option, + ) -> Result<(), Error>; + + /// POST /emergency-access/{id}/approve + async fn emergency_access_id_approve_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /emergency-access/{id}/{cipherId}/attachment/{attachmentId} + async fn emergency_access_id_cipher_id_attachment_attachment_id_get<'a>( + &self, + id: uuid::Uuid, + cipher_id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result< + models::AttachmentResponseModel, + Error, + >; + + /// POST /emergency-access/{id}/confirm + async fn emergency_access_id_confirm_post<'a>( + &self, + id: uuid::Uuid, + organization_user_confirm_request_model: Option< + models::OrganizationUserConfirmRequestModel, + >, + ) -> Result<(), Error>; + + /// DELETE /emergency-access/{id} + async fn emergency_access_id_delete<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /emergency-access/{id}/delete + async fn emergency_access_id_delete_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /emergency-access/{id} + async fn emergency_access_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// POST /emergency-access/{id}/initiate + async fn emergency_access_id_initiate_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /emergency-access/{id}/password + async fn emergency_access_id_password_post<'a>( + &self, + id: uuid::Uuid, + emergency_access_password_request_model: Option< + models::EmergencyAccessPasswordRequestModel, + >, + ) -> Result<(), Error>; + + /// GET /emergency-access/{id}/policies + async fn emergency_access_id_policies_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::PolicyResponseModelListResponseModel, + Error, + >; + + /// POST /emergency-access/{id} + async fn emergency_access_id_post<'a>( + &self, + id: uuid::Uuid, + emergency_access_update_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /emergency-access/{id} + async fn emergency_access_id_put<'a>( + &self, + id: uuid::Uuid, + emergency_access_update_request_model: Option, + ) -> Result<(), Error>; + + /// POST /emergency-access/{id}/reinvite + async fn emergency_access_id_reinvite_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /emergency-access/{id}/reject + async fn emergency_access_id_reject_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /emergency-access/{id}/takeover + async fn emergency_access_id_takeover_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::EmergencyAccessTakeoverResponseModel, + Error, + >; + + /// POST /emergency-access/{id}/view + async fn emergency_access_id_view_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// POST /emergency-access/invite + async fn emergency_access_invite_post<'a>( + &self, + emergency_access_invite_request_model: Option, + ) -> Result<(), Error>; + + /// GET /emergency-access/trusted + async fn emergency_access_trusted_get<'a>( + &self, + ) -> Result< + models::EmergencyAccessGranteeDetailsResponseModelListResponseModel, + Error, + >; +} + +pub struct EmergencyAccessApiClient { + configuration: Arc, +} + +impl EmergencyAccessApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl EmergencyAccessApi for EmergencyAccessApiClient { + async fn emergency_access_granted_get<'a>( + &self, + ) -> Result< + models::EmergencyAccessGrantorDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/granted", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGrantorDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGrantorDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_accept_post<'a>( + &self, + id: uuid::Uuid, + organization_user_accept_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/accept", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_accept_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_approve_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/approve", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_cipher_id_attachment_attachment_id_get<'a>( + &self, + id: uuid::Uuid, + cipher_id: uuid::Uuid, + attachment_id: &'a str, + ) -> Result< + models::AttachmentResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/{cipherId}/attachment/{attachmentId}", + local_var_configuration.base_path, + id = id, + cipherId = cipher_id, + attachmentId = crate::apis::urlencode(attachment_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachmentResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AttachmentResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_confirm_post<'a>( + &self, + id: uuid::Uuid, + organization_user_confirm_request_model: Option< + models::OrganizationUserConfirmRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/confirm", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_user_confirm_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`emergency_access_granted_get`] + async fn emergency_access_id_delete<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_delete_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/delete", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_initiate_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/initiate", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_password_post<'a>( + &self, + id: uuid::Uuid, + emergency_access_password_request_model: Option< + models::EmergencyAccessPasswordRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/password", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&emergency_access_password_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_policies_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::PolicyResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/policies", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_post<'a>( + &self, + id: uuid::Uuid, + emergency_access_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&emergency_access_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_put<'a>( + &self, + id: uuid::Uuid, + emergency_access_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&emergency_access_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_reinvite_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/reinvite", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_reject_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/reject", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_takeover_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::EmergencyAccessTakeoverResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/takeover", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessTakeoverResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessTakeoverResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_id_view_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/{id}/view", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessViewResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessViewResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_invite_post<'a>( + &self, + emergency_access_invite_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/invite", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&emergency_access_invite_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn emergency_access_trusted_get<'a>( + &self, + ) -> Result< + models::EmergencyAccessGranteeDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/emergency-access/trusted", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_granted_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessGrantedGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_accept_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_accept_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdAcceptPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_approve_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_approve_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdApprovePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_cipher_id_attachment_attachment_id_get`] +/// struct for typed errors of method +/// [`EmergencyAccessApi::emergency_access_id_cipher_id_attachment_attachment_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdCipherIdAttachmentAttachmentIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_confirm_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_confirm_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdConfirmPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_delete`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_delete_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_get`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_initiate_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_initiate_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdInitiatePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_password_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_password_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdPasswordPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_policies_get`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_policies_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdPoliciesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_put`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_reinvite_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_reinvite_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdReinvitePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_reject_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_reject_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdRejectPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_takeover_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_takeover_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdTakeoverPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_id_view_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_id_view_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessIdViewPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_invite_post`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_invite_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessInvitePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`emergency_access_trusted_get`] +/// struct for typed errors of method [`EmergencyAccessApi::emergency_access_trusted_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EmergencyAccessTrustedGetError { UnknownValue(serde_json::Value), } - -pub async fn emergency_access_granted_get( - configuration: &configuration::Configuration, -) -> Result< - models::EmergencyAccessGrantorDetailsResponseModelListResponseModel, - Error, -> { - let uri_str = format!("{}/emergency-access/granted", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGrantorDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGrantorDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_accept_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - organization_user_accept_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_user_accept_request_model = organization_user_accept_request_model; - - let uri_str = format!( - "{}/emergency-access/{id}/accept", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_accept_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_approve_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/emergency-access/{id}/approve", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_cipher_id_attachment_attachment_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, - cipher_id: uuid::Uuid, - attachment_id: &str, -) -> Result< - models::AttachmentResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_cipher_id = cipher_id; - let p_attachment_id = attachment_id; - - let uri_str = format!( - "{}/emergency-access/{id}/{cipherId}/attachment/{attachmentId}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()), - cipherId = crate::apis::urlencode(p_cipher_id.to_string()), - attachmentId = crate::apis::urlencode(p_attachment_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachmentResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AttachmentResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_confirm_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - organization_user_confirm_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_user_confirm_request_model = organization_user_confirm_request_model; - - let uri_str = format!( - "{}/emergency-access/{id}/confirm", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_confirm_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_delete( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/emergency-access/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_delete_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/emergency-access/{id}/delete", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/emergency-access/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_initiate_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/emergency-access/{id}/initiate", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_password_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - emergency_access_password_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_emergency_access_password_request_model = emergency_access_password_request_model; - - let uri_str = format!( - "{}/emergency-access/{id}/password", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_emergency_access_password_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_policies_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/emergency-access/{id}/policies", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - emergency_access_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_emergency_access_update_request_model = emergency_access_update_request_model; - - let uri_str = format!( - "{}/emergency-access/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_emergency_access_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - emergency_access_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_emergency_access_update_request_model = emergency_access_update_request_model; - - let uri_str = format!( - "{}/emergency-access/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_emergency_access_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_reinvite_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/emergency-access/{id}/reinvite", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_reject_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/emergency-access/{id}/reject", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_takeover_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/emergency-access/{id}/takeover", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessTakeoverResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EmergencyAccessTakeoverResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_id_view_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/emergency-access/{id}/view", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessViewResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EmergencyAccessViewResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_invite_post( - configuration: &configuration::Configuration, - emergency_access_invite_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_emergency_access_invite_request_model = emergency_access_invite_request_model; - - let uri_str = format!("{}/emergency-access/invite", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_emergency_access_invite_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn emergency_access_trusted_get( - configuration: &configuration::Configuration, -) -> Result< - models::EmergencyAccessGranteeDetailsResponseModelListResponseModel, - Error, -> { - let uri_str = format!("{}/emergency-access/trusted", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/events_api.rs b/crates/bitwarden-api-api/src/apis/events_api.rs index 8cd8fcc4b..969d3b143 100644 --- a/crates/bitwarden-api-api/src/apis/events_api.rs +++ b/crates/bitwarden-api-api/src/apis/events_api.rs @@ -8,448 +8,557 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait EventsApi: Send + Sync { + /// GET /ciphers/{id}/events + async fn ciphers_id_events_get<'a>( + &self, + id: &'a str, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result>; + + /// GET /events + async fn events_get<'a>( + &self, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result>; + + /// GET /organizations/{id}/events + async fn organizations_id_events_get<'a>( + &self, + id: &'a str, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result>; + + /// GET /organizations/{orgId}/users/{id}/events + async fn organizations_org_id_users_id_events_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result< + models::EventResponseModelListResponseModel, + Error, + >; + + /// GET /providers/{providerId}/events + async fn providers_provider_id_events_get<'a>( + &self, + provider_id: uuid::Uuid, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result>; + + /// GET /providers/{providerId}/users/{id}/events + async fn providers_provider_id_users_id_events_get<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result< + models::EventResponseModelListResponseModel, + Error, + >; +} + +pub struct EventsApiClient { + configuration: Arc, +} + +impl EventsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl EventsApi for EventsApiClient { + async fn ciphers_id_events_get<'a>( + &self, + id: &'a str, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/{id}/events", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", ¶m_value.to_string())]); + } + if let Some(ref param_value) = end { + local_var_req_builder = + local_var_req_builder.query(&[("end", ¶m_value.to_string())]); + } + if let Some(ref param_value) = continuation_token { + local_var_req_builder = + local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn events_get<'a>( + &self, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/events", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); -/// struct for typed errors of method [`ciphers_id_events_get`] + if let Some(ref param_value) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", ¶m_value.to_string())]); + } + if let Some(ref param_value) = end { + local_var_req_builder = + local_var_req_builder.query(&[("end", ¶m_value.to_string())]); + } + if let Some(ref param_value) = continuation_token { + local_var_req_builder = + local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_events_get<'a>( + &self, + id: &'a str, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/events", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", ¶m_value.to_string())]); + } + if let Some(ref param_value) = end { + local_var_req_builder = + local_var_req_builder.query(&[("end", ¶m_value.to_string())]); + } + if let Some(ref param_value) = continuation_token { + local_var_req_builder = + local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_events_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result< + models::EventResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/events", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", ¶m_value.to_string())]); + } + if let Some(ref param_value) = end { + local_var_req_builder = + local_var_req_builder.query(&[("end", ¶m_value.to_string())]); + } + if let Some(ref param_value) = continuation_token { + local_var_req_builder = + local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_events_get<'a>( + &self, + provider_id: uuid::Uuid, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/events", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", ¶m_value.to_string())]); + } + if let Some(ref param_value) = end { + local_var_req_builder = + local_var_req_builder.query(&[("end", ¶m_value.to_string())]); + } + if let Some(ref param_value) = continuation_token { + local_var_req_builder = + local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_id_events_get<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result< + models::EventResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/{id}/events", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", ¶m_value.to_string())]); + } + if let Some(ref param_value) = end { + local_var_req_builder = + local_var_req_builder.query(&[("end", ¶m_value.to_string())]); + } + if let Some(ref param_value) = continuation_token { + local_var_req_builder = + local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`EventsApi::ciphers_id_events_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CiphersIdEventsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`events_get`] +/// struct for typed errors of method [`EventsApi::events_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum EventsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_events_get`] +/// struct for typed errors of method [`EventsApi::organizations_id_events_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdEventsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_events_get`] +/// struct for typed errors of method [`EventsApi::organizations_org_id_users_id_events_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdEventsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_events_get`] +/// struct for typed errors of method [`EventsApi::providers_provider_id_events_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdEventsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_id_events_get`] +/// struct for typed errors of method [`EventsApi::providers_provider_id_users_id_events_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersIdEventsGetError { UnknownValue(serde_json::Value), } - -pub async fn ciphers_id_events_get( - configuration: &configuration::Configuration, - id: &str, - start: Option, - end: Option, - continuation_token: Option<&str>, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_start = start; - let p_end = end; - let p_continuation_token = continuation_token; - - let uri_str = format!( - "{}/ciphers/{id}/events", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_start { - req_builder = req_builder.query(&[("start", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_end { - req_builder = req_builder.query(&[("end", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_continuation_token { - req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn events_get( - configuration: &configuration::Configuration, - start: Option, - end: Option, - continuation_token: Option<&str>, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_start = start; - let p_end = end; - let p_continuation_token = continuation_token; - - let uri_str = format!("{}/events", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_start { - req_builder = req_builder.query(&[("start", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_end { - req_builder = req_builder.query(&[("end", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_continuation_token { - req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_events_get( - configuration: &configuration::Configuration, - id: &str, - start: Option, - end: Option, - continuation_token: Option<&str>, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_start = start; - let p_end = end; - let p_continuation_token = continuation_token; - - let uri_str = format!( - "{}/organizations/{id}/events", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_start { - req_builder = req_builder.query(&[("start", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_end { - req_builder = req_builder.query(&[("end", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_continuation_token { - req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_events_get( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, - start: Option, - end: Option, - continuation_token: Option<&str>, -) -> Result< - models::EventResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_start = start; - let p_end = end; - let p_continuation_token = continuation_token; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/events", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_start { - req_builder = req_builder.query(&[("start", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_end { - req_builder = req_builder.query(&[("end", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_continuation_token { - req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_events_get( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - start: Option, - end: Option, - continuation_token: Option<&str>, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_start = start; - let p_end = end; - let p_continuation_token = continuation_token; - - let uri_str = format!( - "{}/providers/{providerId}/events", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_start { - req_builder = req_builder.query(&[("start", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_end { - req_builder = req_builder.query(&[("end", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_continuation_token { - req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_id_events_get( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, - start: Option, - end: Option, - continuation_token: Option<&str>, -) -> Result< - models::EventResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - let p_start = start; - let p_end = end; - let p_continuation_token = continuation_token; - - let uri_str = format!( - "{}/providers/{providerId}/users/{id}/events", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_start { - req_builder = req_builder.query(&[("start", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_end { - req_builder = req_builder.query(&[("end", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_continuation_token { - req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/folders_api.rs b/crates/bitwarden-api-api/src/apis/folders_api.rs index e48e0f34c..b722bc238 100644 --- a/crates/bitwarden-api-api/src/apis/folders_api.rs +++ b/crates/bitwarden-api-api/src/apis/folders_api.rs @@ -8,428 +8,520 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait FoldersApi: Send + Sync { + /// DELETE /folders/all + async fn folders_all_delete<'a>(&self) -> Result<(), Error>; + + /// GET /folders + async fn folders_get<'a>( + &self, + ) -> Result>; + + /// DELETE /folders/{id} + async fn folders_id_delete<'a>(&self, id: &'a str) -> Result<(), Error>; + + /// POST /folders/{id}/delete + async fn folders_id_delete_post<'a>( + &self, + id: &'a str, + ) -> Result<(), Error>; + + /// GET /folders/{id} + async fn folders_id_get<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// POST /folders/{id} + async fn folders_id_post<'a>( + &self, + id: &'a str, + folder_request_model: Option, + ) -> Result>; + + /// PUT /folders/{id} + async fn folders_id_put<'a>( + &self, + id: &'a str, + folder_request_model: Option, + ) -> Result>; + + /// POST /folders + async fn folders_post<'a>( + &self, + folder_request_model: Option, + ) -> Result>; +} + +pub struct FoldersApiClient { + configuration: Arc, +} + +impl FoldersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl FoldersApi for FoldersApiClient { + async fn folders_all_delete<'a>(&self) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/folders/all", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn folders_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/folders", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::FolderResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn folders_id_delete<'a>(&self, id: &'a str) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/folders/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn folders_id_delete_post<'a>( + &self, + id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/folders/{id}/delete", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn folders_id_get<'a>( + &self, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/folders/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::FolderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn folders_id_post<'a>( + &self, + id: &'a str, + folder_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/folders/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&folder_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::FolderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn folders_id_put<'a>( + &self, + id: &'a str, + folder_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/folders/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&folder_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::FolderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn folders_post<'a>( + &self, + folder_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/folders", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`folders_all_delete`] + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&folder_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::FolderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`FoldersApi::folders_all_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FoldersAllDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`folders_get`] +/// struct for typed errors of method [`FoldersApi::folders_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FoldersGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`folders_id_delete`] +/// struct for typed errors of method [`FoldersApi::folders_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FoldersIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`folders_id_delete_post`] +/// struct for typed errors of method [`FoldersApi::folders_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FoldersIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`folders_id_get`] +/// struct for typed errors of method [`FoldersApi::folders_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FoldersIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`folders_id_post`] +/// struct for typed errors of method [`FoldersApi::folders_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FoldersIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`folders_id_put`] +/// struct for typed errors of method [`FoldersApi::folders_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FoldersIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`folders_post`] +/// struct for typed errors of method [`FoldersApi::folders_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FoldersPostError { UnknownValue(serde_json::Value), } - -pub async fn folders_all_delete( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/folders/all", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn folders_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/folders", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FolderResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn folders_id_delete( - configuration: &configuration::Configuration, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/folders/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn folders_id_delete_post( - configuration: &configuration::Configuration, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/folders/{id}/delete", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn folders_id_get( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/folders/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FolderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn folders_id_post( - configuration: &configuration::Configuration, - id: &str, - folder_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_folder_request_model = folder_request_model; - - let uri_str = format!( - "{}/folders/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_folder_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FolderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn folders_id_put( - configuration: &configuration::Configuration, - id: &str, - folder_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_folder_request_model = folder_request_model; - - let uri_str = format!( - "{}/folders/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_folder_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FolderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn folders_post( - configuration: &configuration::Configuration, - folder_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_folder_request_model = folder_request_model; - - let uri_str = format!("{}/folders", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_folder_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FolderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/groups_api.rs b/crates/bitwarden-api-api/src/apis/groups_api.rs index 2adc32ce6..622c94400 100644 --- a/crates/bitwarden-api-api/src/apis/groups_api.rs +++ b/crates/bitwarden-api-api/src/apis/groups_api.rs @@ -8,48 +8,909 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait GroupsApi: Send + Sync { + /// DELETE /organizations/{orgId}/groups + async fn organizations_org_id_groups_delete<'a>( + &self, + org_id: &'a str, + group_bulk_request_model: Option, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/groups/delete + async fn organizations_org_id_groups_delete_post<'a>( + &self, + org_id: &'a str, + group_bulk_request_model: Option, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/groups/details + async fn organizations_org_id_groups_details_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::GroupDetailsResponseModelListResponseModel, + Error, + >; + + /// GET /organizations/{orgId}/groups + async fn organizations_org_id_groups_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result>; + + /// DELETE /organizations/{orgId}/groups/{id} + async fn organizations_org_id_groups_id_delete<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/groups/{id}/delete + async fn organizations_org_id_groups_id_delete_post<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/groups/{id}/delete-user/{orgUserId} + async fn organizations_org_id_groups_id_delete_user_org_user_id_post<'a>( + &self, + org_id: &'a str, + id: &'a str, + org_user_id: &'a str, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/groups/{id}/details + async fn organizations_org_id_groups_id_details_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result>; + + /// GET /organizations/{orgId}/groups/{id} + async fn organizations_org_id_groups_id_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result>; + + /// POST /organizations/{orgId}/groups/{id} + async fn organizations_org_id_groups_id_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + group_request_model: Option, + ) -> Result>; + + /// PUT /organizations/{orgId}/groups/{id} + async fn organizations_org_id_groups_id_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + group_request_model: Option, + ) -> Result>; + + /// DELETE /organizations/{orgId}/groups/{id}/user/{orgUserId} + async fn organizations_org_id_groups_id_user_org_user_id_delete<'a>( + &self, + org_id: &'a str, + id: &'a str, + org_user_id: &'a str, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/groups/{id}/users + async fn organizations_org_id_groups_id_users_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result, Error>; + + /// POST /organizations/{orgId}/groups + async fn organizations_org_id_groups_post<'a>( + &self, + org_id: uuid::Uuid, + group_request_model: Option, + ) -> Result>; +} -/// struct for typed errors of method [`organizations_org_id_groups_delete`] +pub struct GroupsApiClient { + configuration: Arc, +} + +impl GroupsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl GroupsApi for GroupsApiClient { + async fn organizations_org_id_groups_delete<'a>( + &self, + org_id: &'a str, + group_bulk_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&group_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_delete_post<'a>( + &self, + org_id: &'a str, + group_bulk_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/delete", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&group_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_details_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::GroupDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/details", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::GroupDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::GroupResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_id_delete<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/{id}", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_id_delete_post<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/{id}/delete", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_id_delete_user_org_user_id_post<'a>( + &self, + org_id: &'a str, + id: &'a str, + org_user_id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/{id}/delete-user/{orgUserId}", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id), + orgUserId = crate::apis::urlencode(org_user_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_id_details_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/{id}/details", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::GroupDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_id_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/{id}", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::GroupResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_id_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + group_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&group_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::GroupResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_id_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + group_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&group_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::GroupResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_id_user_org_user_id_delete<'a>( + &self, + org_id: &'a str, + id: &'a str, + org_user_id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/{id}/user/{orgUserId}", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id), + orgUserId = crate::apis::urlencode(org_user_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_id_users_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result, Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups/{id}/users", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<uuid::Uuid>`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<uuid::Uuid>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_groups_post<'a>( + &self, + org_id: uuid::Uuid, + group_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/groups", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&group_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::GroupResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_delete_post`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_details_get`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_details_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsDetailsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_get`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_id_delete`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_id_delete_post`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsIdDeletePostError { @@ -57,771 +918,59 @@ pub enum OrganizationsOrgIdGroupsIdDeletePostError { } /// struct for typed errors of method -/// [`organizations_org_id_groups_id_delete_user_org_user_id_post`] +/// [`GroupsApi::organizations_org_id_groups_id_delete_user_org_user_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsIdDeleteUserOrgUserIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_id_details_get`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_id_details_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsIdDetailsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_id_get`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_id_post`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_id_put`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_id_user_org_user_id_delete`] +/// struct for typed errors of method +/// [`GroupsApi::organizations_org_id_groups_id_user_org_user_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsIdUserOrgUserIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_id_users_get`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_id_users_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsIdUsersGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_post`] +/// struct for typed errors of method [`GroupsApi::organizations_org_id_groups_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsPostError { UnknownValue(serde_json::Value), } - -pub async fn organizations_org_id_groups_delete( - configuration: &configuration::Configuration, - org_id: &str, - group_bulk_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_group_bulk_request_model = group_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/groups", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_group_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_delete_post( - configuration: &configuration::Configuration, - org_id: &str, - group_bulk_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_group_bulk_request_model = group_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/delete", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_group_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_details_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result< - models::GroupDetailsResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/details", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/organizations/{orgId}/groups", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_id_delete( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_id_delete_post( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/{id}/delete", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_id_delete_user_org_user_id_post( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, - org_user_id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_org_user_id = org_user_id; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/{id}/delete-user/{orgUserId}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id), - orgUserId = crate::apis::urlencode(p_org_user_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_id_details_get( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/{id}/details", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_id_get( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_id_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, - group_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_group_request_model = group_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_group_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_id_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, - group_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_group_request_model = group_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_group_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_id_user_org_user_id_delete( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, - org_user_id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_org_user_id = org_user_id; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/{id}/user/{orgUserId}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id), - orgUserId = crate::apis::urlencode(p_org_user_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_id_users_get( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, -) -> Result, Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/groups/{id}/users", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<uuid::Uuid>`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<uuid::Uuid>`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_groups_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - group_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_group_request_model = group_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/groups", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_group_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/hibp_api.rs b/crates/bitwarden-api-api/src/apis/hibp_api.rs index 75a0a1fcc..d3c5838dc 100644 --- a/crates/bitwarden-api-api/src/apis/hibp_api.rs +++ b/crates/bitwarden-api-api/src/apis/hibp_api.rs @@ -8,53 +8,90 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`hibp_breach_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum HibpBreachGetError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait HibpApi: Send + Sync { + /// GET /hibp/breach + async fn hibp_breach_get<'a>( + &self, + username: Option<&'a str>, + ) -> Result<(), Error>; } -pub async fn hibp_breach_get( - configuration: &configuration::Configuration, - username: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_username = username; - - let uri_str = format!("{}/hibp/breach", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +pub struct HibpApiClient { + configuration: Arc, +} - if let Some(ref param_value) = p_username { - req_builder = req_builder.query(&[("username", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +impl HibpApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) +} + +#[async_trait(?Send)] +impl HibpApi for HibpApiClient { + async fn hibp_breach_get<'a>( + &self, + username: Option<&'a str>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/hibp/breach", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = username { + local_var_req_builder = + local_var_req_builder.query(&[("username", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } } + +/// struct for typed errors of method [`HibpApi::hibp_breach_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum HibpBreachGetError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/import_ciphers_api.rs b/crates/bitwarden-api-api/src/apis/import_ciphers_api.rs index e6f767748..a6d973f08 100644 --- a/crates/bitwarden-api-api/src/apis/import_ciphers_api.rs +++ b/crates/bitwarden-api-api/src/apis/import_ciphers_api.rs @@ -8,106 +8,155 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait ImportCiphersApi: Send + Sync { + /// POST /ciphers/import-organization + async fn ciphers_import_organization_post<'a>( + &self, + organization_id: Option<&'a str>, + import_organization_ciphers_request_model: Option< + models::ImportOrganizationCiphersRequestModel, + >, + ) -> Result<(), Error>; + + /// POST /ciphers/import + async fn ciphers_import_post<'a>( + &self, + import_ciphers_request_model: Option, + ) -> Result<(), Error>; +} + +pub struct ImportCiphersApiClient { + configuration: Arc, +} + +impl ImportCiphersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl ImportCiphersApi for ImportCiphersApiClient { + async fn ciphers_import_organization_post<'a>( + &self, + organization_id: Option<&'a str>, + import_organization_ciphers_request_model: Option< + models::ImportOrganizationCiphersRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/ciphers/import-organization", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref param_value) = organization_id { + local_var_req_builder = + local_var_req_builder.query(&[("organizationId", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&import_organization_ciphers_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn ciphers_import_post<'a>( + &self, + import_ciphers_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/ciphers/import", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&import_ciphers_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`ciphers_import_organization_post`] +/// struct for typed errors of method [`ImportCiphersApi::ciphers_import_organization_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CiphersImportOrganizationPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_import_post`] +/// struct for typed errors of method [`ImportCiphersApi::ciphers_import_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CiphersImportPostError { UnknownValue(serde_json::Value), } - -pub async fn ciphers_import_organization_post( - configuration: &configuration::Configuration, - organization_id: Option<&str>, - import_organization_ciphers_request_model: Option< - models::ImportOrganizationCiphersRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_import_organization_ciphers_request_model = import_organization_ciphers_request_model; - - let uri_str = format!("{}/ciphers/import-organization", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref param_value) = p_organization_id { - req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_import_organization_ciphers_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn ciphers_import_post( - configuration: &configuration::Configuration, - import_ciphers_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_import_ciphers_request_model = import_ciphers_request_model; - - let uri_str = format!("{}/ciphers/import", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_import_ciphers_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/info_api.rs b/crates/bitwarden-api-api/src/apis/info_api.rs index c3511a58e..384372e91 100644 --- a/crates/bitwarden-api-api/src/apis/info_api.rs +++ b/crates/bitwarden-api-api/src/apis/info_api.rs @@ -8,144 +8,194 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`alive_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AliveGetError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait InfoApi: Send + Sync { + /// GET /alive + async fn alive_get<'a>(&self) -> Result>; + + /// GET /now + async fn now_get<'a>(&self) -> Result>; + + /// GET /version + async fn version_get<'a>(&self) -> Result<(), Error>; } -/// struct for typed errors of method [`now_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum NowGetError { - UnknownValue(serde_json::Value), +pub struct InfoApiClient { + configuration: Arc, } -/// struct for typed errors of method [`version_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum VersionGetError { - UnknownValue(serde_json::Value), +impl InfoApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn alive_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/alive", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +#[async_trait(?Send)] +impl InfoApi for InfoApiClient { + async fn alive_get<'a>(&self) -> Result> { + let local_var_configuration = &self.configuration; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Ok(content), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))), + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/alive", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Ok(local_var_content), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `String`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } -} -pub async fn now_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/now", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + async fn now_get<'a>(&self) -> Result> { + let local_var_configuration = &self.configuration; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/now", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Ok(local_var_content), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `String`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Ok(content), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))), + + async fn version_get<'a>(&self) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/version", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } -pub async fn version_get( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/version", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +/// struct for typed errors of method [`InfoApi::alive_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AliveGetError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`InfoApi::now_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum NowGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`InfoApi::version_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum VersionGetError { + UnknownValue(serde_json::Value), } diff --git a/crates/bitwarden-api-api/src/apis/installations_api.rs b/crates/bitwarden-api-api/src/apis/installations_api.rs index 38d362f42..a67da17e2 100644 --- a/crates/bitwarden-api-api/src/apis/installations_api.rs +++ b/crates/bitwarden-api-api/src/apis/installations_api.rs @@ -8,121 +8,164 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; - -/// struct for typed errors of method [`installations_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum InstallationsIdGetError { - UnknownValue(serde_json::Value), +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait InstallationsApi: Send + Sync { + /// GET /installations/{id} + async fn installations_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// POST /installations + async fn installations_post<'a>( + &self, + installation_request_model: Option, + ) -> Result>; } -/// struct for typed errors of method [`installations_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum InstallationsPostError { - UnknownValue(serde_json::Value), +pub struct InstallationsApiClient { + configuration: Arc, } -pub async fn installations_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/installations/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +impl InstallationsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InstallationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InstallationResponseModel`")))), +} + +#[async_trait(?Send)] +impl InstallationsApi for InstallationsApiClient { + async fn installations_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/installations/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InstallationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::InstallationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } -} -pub async fn installations_post( - configuration: &configuration::Configuration, - installation_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_installation_request_model = installation_request_model; + async fn installations_post<'a>( + &self, + installation_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/installations", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_installation_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InstallationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InstallationResponseModel`")))), + let local_var_uri_str = format!("{}/installations", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&installation_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InstallationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::InstallationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } + +/// struct for typed errors of method [`InstallationsApi::installations_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum InstallationsIdGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`InstallationsApi::installations_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum InstallationsPostError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/invoices_api.rs b/crates/bitwarden-api-api/src/apis/invoices_api.rs index 30742faf8..141577509 100644 --- a/crates/bitwarden-api-api/src/apis/invoices_api.rs +++ b/crates/bitwarden-api-api/src/apis/invoices_api.rs @@ -8,56 +8,95 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`invoices_preview_organization_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum InvoicesPreviewOrganizationPostError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait InvoicesApi: Send + Sync { + /// POST /invoices/preview-organization + async fn invoices_preview_organization_post<'a>( + &self, + preview_organization_invoice_request_body: Option< + models::PreviewOrganizationInvoiceRequestBody, + >, + ) -> Result<(), Error>; } -pub async fn invoices_preview_organization_post( - configuration: &configuration::Configuration, - preview_organization_invoice_request_body: Option< - models::PreviewOrganizationInvoiceRequestBody, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_preview_organization_invoice_request_body = preview_organization_invoice_request_body; - - let uri_str = format!("{}/invoices/preview-organization", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +pub struct InvoicesApiClient { + configuration: Arc, +} + +impl InvoicesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_preview_organization_invoice_request_body); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) +} + +#[async_trait(?Send)] +impl InvoicesApi for InvoicesApiClient { + async fn invoices_preview_organization_post<'a>( + &self, + preview_organization_invoice_request_body: Option< + models::PreviewOrganizationInvoiceRequestBody, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/invoices/preview-organization", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&preview_organization_invoice_request_body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } } + +/// struct for typed errors of method [`InvoicesApi::invoices_preview_organization_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum InvoicesPreviewOrganizationPostError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/licenses_api.rs b/crates/bitwarden-api-api/src/apis/licenses_api.rs index c6018738d..7c8ed0809 100644 --- a/crates/bitwarden-api-api/src/apis/licenses_api.rs +++ b/crates/bitwarden-api-api/src/apis/licenses_api.rs @@ -8,133 +8,181 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait LicensesApi: Send + Sync { + /// GET /licenses/organization/{id} + async fn licenses_organization_id_get<'a>( + &self, + id: &'a str, + self_hosted_organization_license_request_model: Option< + models::SelfHostedOrganizationLicenseRequestModel, + >, + ) -> Result>; + + /// GET /licenses/user/{id} + async fn licenses_user_id_get<'a>( + &self, + id: &'a str, + key: Option<&'a str>, + ) -> Result>; +} + +pub struct LicensesApiClient { + configuration: Arc, +} + +impl LicensesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl LicensesApi for LicensesApiClient { + async fn licenses_organization_id_get<'a>( + &self, + id: &'a str, + self_hosted_organization_license_request_model: Option< + models::SelfHostedOrganizationLicenseRequestModel, + >, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/licenses/organization/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&self_hosted_organization_license_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationLicense`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationLicense`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn licenses_user_id_get<'a>( + &self, + id: &'a str, + key: Option<&'a str>, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/licenses/user/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = key { + local_var_req_builder = + local_var_req_builder.query(&[("key", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserLicense`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::UserLicense`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`licenses_organization_id_get`] +/// struct for typed errors of method [`LicensesApi::licenses_organization_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum LicensesOrganizationIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`licenses_user_id_get`] +/// struct for typed errors of method [`LicensesApi::licenses_user_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum LicensesUserIdGetError { UnknownValue(serde_json::Value), } - -pub async fn licenses_organization_id_get( - configuration: &configuration::Configuration, - id: &str, - self_hosted_organization_license_request_model: Option< - models::SelfHostedOrganizationLicenseRequestModel, - >, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_self_hosted_organization_license_request_model = - self_hosted_organization_license_request_model; - - let uri_str = format!( - "{}/licenses/organization/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_self_hosted_organization_license_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationLicense`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationLicense`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn licenses_user_id_get( - configuration: &configuration::Configuration, - id: &str, - key: Option<&str>, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_key = key; - - let uri_str = format!( - "{}/licenses/user/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_key { - req_builder = req_builder.query(&[("key", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserLicense`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserLicense`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/misc_api.rs b/crates/bitwarden-api-api/src/apis/misc_api.rs index cfa45a822..5f379cc05 100644 --- a/crates/bitwarden-api-api/src/apis/misc_api.rs +++ b/crates/bitwarden-api-api/src/apis/misc_api.rs @@ -8,115 +8,154 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`bitpay_invoice_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum BitpayInvoicePostError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait MiscApi: Send + Sync { + /// POST /bitpay-invoice + async fn bitpay_invoice_post<'a>( + &self, + bit_pay_invoice_request_model: Option, + ) -> Result>; + + /// POST /setup-payment + async fn setup_payment_post<'a>(&self) -> Result>; } -/// struct for typed errors of method [`setup_payment_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SetupPaymentPostError { - UnknownValue(serde_json::Value), +pub struct MiscApiClient { + configuration: Arc, } -pub async fn bitpay_invoice_post( - configuration: &configuration::Configuration, - bit_pay_invoice_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_bit_pay_invoice_request_model = bit_pay_invoice_request_model; +impl MiscApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} - let uri_str = format!("{}/bitpay-invoice", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +#[async_trait(?Send)] +impl MiscApi for MiscApiClient { + async fn bitpay_invoice_post<'a>( + &self, + bit_pay_invoice_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_bit_pay_invoice_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Ok(content), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))), + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/bitpay-invoice", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&bit_pay_invoice_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; -pub async fn setup_payment_post( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/setup-payment", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Ok(local_var_content), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `String`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Ok(content), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))), + + async fn setup_payment_post<'a>(&self) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/setup-payment", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Ok(local_var_content), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `String`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } + +/// struct for typed errors of method [`MiscApi::bitpay_invoice_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum BitpayInvoicePostError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`MiscApi::setup_payment_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SetupPaymentPostError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/mod.rs b/crates/bitwarden-api-api/src/apis/mod.rs index 310cfeb68..fc25a2ba7 100644 --- a/crates/bitwarden-api-api/src/apis/mod.rs +++ b/crates/bitwarden-api-api/src/apis/mod.rs @@ -170,3 +170,716 @@ pub mod users_api; pub mod web_authn_api; pub mod configuration; + +use std::sync::Arc; + +pub trait Api { + fn access_policies_api(&self) -> &dyn access_policies_api::AccessPoliciesApi; + fn accounts_api(&self) -> &dyn accounts_api::AccountsApi; + fn accounts_billing_api(&self) -> &dyn accounts_billing_api::AccountsBillingApi; + fn accounts_key_management_api( + &self, + ) -> &dyn accounts_key_management_api::AccountsKeyManagementApi; + fn auth_requests_api(&self) -> &dyn auth_requests_api::AuthRequestsApi; + fn ciphers_api(&self) -> &dyn ciphers_api::CiphersApi; + fn collections_api(&self) -> &dyn collections_api::CollectionsApi; + fn config_api(&self) -> &dyn config_api::ConfigApi; + fn counts_api(&self) -> &dyn counts_api::CountsApi; + fn devices_api(&self) -> &dyn devices_api::DevicesApi; + fn emergency_access_api(&self) -> &dyn emergency_access_api::EmergencyAccessApi; + fn events_api(&self) -> &dyn events_api::EventsApi; + fn folders_api(&self) -> &dyn folders_api::FoldersApi; + fn groups_api(&self) -> &dyn groups_api::GroupsApi; + fn hibp_api(&self) -> &dyn hibp_api::HibpApi; + fn import_ciphers_api(&self) -> &dyn import_ciphers_api::ImportCiphersApi; + fn info_api(&self) -> &dyn info_api::InfoApi; + fn installations_api(&self) -> &dyn installations_api::InstallationsApi; + fn invoices_api(&self) -> &dyn invoices_api::InvoicesApi; + fn licenses_api(&self) -> &dyn licenses_api::LicensesApi; + fn misc_api(&self) -> &dyn misc_api::MiscApi; + fn notifications_api(&self) -> &dyn notifications_api::NotificationsApi; + fn organization_auth_requests_api( + &self, + ) -> &dyn organization_auth_requests_api::OrganizationAuthRequestsApi; + fn organization_billing_api(&self) -> &dyn organization_billing_api::OrganizationBillingApi; + fn organization_connections_api( + &self, + ) -> &dyn organization_connections_api::OrganizationConnectionsApi; + fn organization_domain_api(&self) -> &dyn organization_domain_api::OrganizationDomainApi; + fn organization_export_api(&self) -> &dyn organization_export_api::OrganizationExportApi; + fn organization_sponsorships_api( + &self, + ) -> &dyn organization_sponsorships_api::OrganizationSponsorshipsApi; + fn organization_users_api(&self) -> &dyn organization_users_api::OrganizationUsersApi; + fn organizations_api(&self) -> &dyn organizations_api::OrganizationsApi; + fn plans_api(&self) -> &dyn plans_api::PlansApi; + fn policies_api(&self) -> &dyn policies_api::PoliciesApi; + fn projects_api(&self) -> &dyn projects_api::ProjectsApi; + fn provider_billing_api(&self) -> &dyn provider_billing_api::ProviderBillingApi; + fn provider_clients_api(&self) -> &dyn provider_clients_api::ProviderClientsApi; + fn provider_organizations_api( + &self, + ) -> &dyn provider_organizations_api::ProviderOrganizationsApi; + fn provider_users_api(&self) -> &dyn provider_users_api::ProviderUsersApi; + fn providers_api(&self) -> &dyn providers_api::ProvidersApi; + fn push_api(&self) -> &dyn push_api::PushApi; + fn reports_api(&self) -> &dyn reports_api::ReportsApi; + fn request_sm_access_api(&self) -> &dyn request_sm_access_api::RequestSmAccessApi; + fn secrets_api(&self) -> &dyn secrets_api::SecretsApi; + fn secrets_manager_events_api( + &self, + ) -> &dyn secrets_manager_events_api::SecretsManagerEventsApi; + fn secrets_manager_porting_api( + &self, + ) -> &dyn secrets_manager_porting_api::SecretsManagerPortingApi; + fn security_task_api(&self) -> &dyn security_task_api::SecurityTaskApi; + fn self_hosted_organization_licenses_api( + &self, + ) -> &dyn self_hosted_organization_licenses_api::SelfHostedOrganizationLicensesApi; + fn self_hosted_organization_sponsorships_api( + &self, + ) -> &dyn self_hosted_organization_sponsorships_api::SelfHostedOrganizationSponsorshipsApi; + fn sends_api(&self) -> &dyn sends_api::SendsApi; + fn service_accounts_api(&self) -> &dyn service_accounts_api::ServiceAccountsApi; + fn settings_api(&self) -> &dyn settings_api::SettingsApi; + fn stripe_api(&self) -> &dyn stripe_api::StripeApi; + fn sync_api(&self) -> &dyn sync_api::SyncApi; + fn trash_api(&self) -> &dyn trash_api::TrashApi; + fn two_factor_api(&self) -> &dyn two_factor_api::TwoFactorApi; + fn users_api(&self) -> &dyn users_api::UsersApi; + fn web_authn_api(&self) -> &dyn web_authn_api::WebAuthnApi; +} + +pub struct ApiClient { + access_policies_api: Box, + accounts_api: Box, + accounts_billing_api: Box, + accounts_key_management_api: Box, + auth_requests_api: Box, + ciphers_api: Box, + collections_api: Box, + config_api: Box, + counts_api: Box, + devices_api: Box, + emergency_access_api: Box, + events_api: Box, + folders_api: Box, + groups_api: Box, + hibp_api: Box, + import_ciphers_api: Box, + info_api: Box, + installations_api: Box, + invoices_api: Box, + licenses_api: Box, + misc_api: Box, + notifications_api: Box, + organization_auth_requests_api: + Box, + organization_billing_api: Box, + organization_connections_api: Box, + organization_domain_api: Box, + organization_export_api: Box, + organization_sponsorships_api: + Box, + organization_users_api: Box, + organizations_api: Box, + plans_api: Box, + policies_api: Box, + projects_api: Box, + provider_billing_api: Box, + provider_clients_api: Box, + provider_organizations_api: Box, + provider_users_api: Box, + providers_api: Box, + push_api: Box, + reports_api: Box, + request_sm_access_api: Box, + secrets_api: Box, + secrets_manager_events_api: Box, + secrets_manager_porting_api: Box, + security_task_api: Box, + self_hosted_organization_licenses_api: + Box, + self_hosted_organization_sponsorships_api: + Box, + sends_api: Box, + service_accounts_api: Box, + settings_api: Box, + stripe_api: Box, + sync_api: Box, + trash_api: Box, + two_factor_api: Box, + users_api: Box, + web_authn_api: Box, +} + +impl ApiClient { + pub fn new(configuration: Arc) -> Self { + Self { + access_policies_api: Box::new(access_policies_api::AccessPoliciesApiClient::new(configuration.clone())), + accounts_api: Box::new(accounts_api::AccountsApiClient::new(configuration.clone())), + accounts_billing_api: Box::new(accounts_billing_api::AccountsBillingApiClient::new(configuration.clone())), + accounts_key_management_api: Box::new(accounts_key_management_api::AccountsKeyManagementApiClient::new(configuration.clone())), + auth_requests_api: Box::new(auth_requests_api::AuthRequestsApiClient::new(configuration.clone())), + ciphers_api: Box::new(ciphers_api::CiphersApiClient::new(configuration.clone())), + collections_api: Box::new(collections_api::CollectionsApiClient::new(configuration.clone())), + config_api: Box::new(config_api::ConfigApiClient::new(configuration.clone())), + counts_api: Box::new(counts_api::CountsApiClient::new(configuration.clone())), + devices_api: Box::new(devices_api::DevicesApiClient::new(configuration.clone())), + emergency_access_api: Box::new(emergency_access_api::EmergencyAccessApiClient::new(configuration.clone())), + events_api: Box::new(events_api::EventsApiClient::new(configuration.clone())), + folders_api: Box::new(folders_api::FoldersApiClient::new(configuration.clone())), + groups_api: Box::new(groups_api::GroupsApiClient::new(configuration.clone())), + hibp_api: Box::new(hibp_api::HibpApiClient::new(configuration.clone())), + import_ciphers_api: Box::new(import_ciphers_api::ImportCiphersApiClient::new(configuration.clone())), + info_api: Box::new(info_api::InfoApiClient::new(configuration.clone())), + installations_api: Box::new(installations_api::InstallationsApiClient::new(configuration.clone())), + invoices_api: Box::new(invoices_api::InvoicesApiClient::new(configuration.clone())), + licenses_api: Box::new(licenses_api::LicensesApiClient::new(configuration.clone())), + misc_api: Box::new(misc_api::MiscApiClient::new(configuration.clone())), + notifications_api: Box::new(notifications_api::NotificationsApiClient::new(configuration.clone())), + organization_auth_requests_api: Box::new(organization_auth_requests_api::OrganizationAuthRequestsApiClient::new(configuration.clone())), + organization_billing_api: Box::new(organization_billing_api::OrganizationBillingApiClient::new(configuration.clone())), + organization_connections_api: Box::new(organization_connections_api::OrganizationConnectionsApiClient::new(configuration.clone())), + organization_domain_api: Box::new(organization_domain_api::OrganizationDomainApiClient::new(configuration.clone())), + organization_export_api: Box::new(organization_export_api::OrganizationExportApiClient::new(configuration.clone())), + organization_sponsorships_api: Box::new(organization_sponsorships_api::OrganizationSponsorshipsApiClient::new(configuration.clone())), + organization_users_api: Box::new(organization_users_api::OrganizationUsersApiClient::new(configuration.clone())), + organizations_api: Box::new(organizations_api::OrganizationsApiClient::new(configuration.clone())), + plans_api: Box::new(plans_api::PlansApiClient::new(configuration.clone())), + policies_api: Box::new(policies_api::PoliciesApiClient::new(configuration.clone())), + projects_api: Box::new(projects_api::ProjectsApiClient::new(configuration.clone())), + provider_billing_api: Box::new(provider_billing_api::ProviderBillingApiClient::new(configuration.clone())), + provider_clients_api: Box::new(provider_clients_api::ProviderClientsApiClient::new(configuration.clone())), + provider_organizations_api: Box::new(provider_organizations_api::ProviderOrganizationsApiClient::new(configuration.clone())), + provider_users_api: Box::new(provider_users_api::ProviderUsersApiClient::new(configuration.clone())), + providers_api: Box::new(providers_api::ProvidersApiClient::new(configuration.clone())), + push_api: Box::new(push_api::PushApiClient::new(configuration.clone())), + reports_api: Box::new(reports_api::ReportsApiClient::new(configuration.clone())), + request_sm_access_api: Box::new(request_sm_access_api::RequestSmAccessApiClient::new(configuration.clone())), + secrets_api: Box::new(secrets_api::SecretsApiClient::new(configuration.clone())), + secrets_manager_events_api: Box::new(secrets_manager_events_api::SecretsManagerEventsApiClient::new(configuration.clone())), + secrets_manager_porting_api: Box::new(secrets_manager_porting_api::SecretsManagerPortingApiClient::new(configuration.clone())), + security_task_api: Box::new(security_task_api::SecurityTaskApiClient::new(configuration.clone())), + self_hosted_organization_licenses_api: Box::new(self_hosted_organization_licenses_api::SelfHostedOrganizationLicensesApiClient::new(configuration.clone())), + self_hosted_organization_sponsorships_api: Box::new(self_hosted_organization_sponsorships_api::SelfHostedOrganizationSponsorshipsApiClient::new(configuration.clone())), + sends_api: Box::new(sends_api::SendsApiClient::new(configuration.clone())), + service_accounts_api: Box::new(service_accounts_api::ServiceAccountsApiClient::new(configuration.clone())), + settings_api: Box::new(settings_api::SettingsApiClient::new(configuration.clone())), + stripe_api: Box::new(stripe_api::StripeApiClient::new(configuration.clone())), + sync_api: Box::new(sync_api::SyncApiClient::new(configuration.clone())), + trash_api: Box::new(trash_api::TrashApiClient::new(configuration.clone())), + two_factor_api: Box::new(two_factor_api::TwoFactorApiClient::new(configuration.clone())), + users_api: Box::new(users_api::UsersApiClient::new(configuration.clone())), + web_authn_api: Box::new(web_authn_api::WebAuthnApiClient::new(configuration.clone())), + } + } +} + +impl Api for ApiClient { + fn access_policies_api(&self) -> &dyn access_policies_api::AccessPoliciesApi { + self.access_policies_api.as_ref() + } + fn accounts_api(&self) -> &dyn accounts_api::AccountsApi { + self.accounts_api.as_ref() + } + fn accounts_billing_api(&self) -> &dyn accounts_billing_api::AccountsBillingApi { + self.accounts_billing_api.as_ref() + } + fn accounts_key_management_api( + &self, + ) -> &dyn accounts_key_management_api::AccountsKeyManagementApi { + self.accounts_key_management_api.as_ref() + } + fn auth_requests_api(&self) -> &dyn auth_requests_api::AuthRequestsApi { + self.auth_requests_api.as_ref() + } + fn ciphers_api(&self) -> &dyn ciphers_api::CiphersApi { + self.ciphers_api.as_ref() + } + fn collections_api(&self) -> &dyn collections_api::CollectionsApi { + self.collections_api.as_ref() + } + fn config_api(&self) -> &dyn config_api::ConfigApi { + self.config_api.as_ref() + } + fn counts_api(&self) -> &dyn counts_api::CountsApi { + self.counts_api.as_ref() + } + fn devices_api(&self) -> &dyn devices_api::DevicesApi { + self.devices_api.as_ref() + } + fn emergency_access_api(&self) -> &dyn emergency_access_api::EmergencyAccessApi { + self.emergency_access_api.as_ref() + } + fn events_api(&self) -> &dyn events_api::EventsApi { + self.events_api.as_ref() + } + fn folders_api(&self) -> &dyn folders_api::FoldersApi { + self.folders_api.as_ref() + } + fn groups_api(&self) -> &dyn groups_api::GroupsApi { + self.groups_api.as_ref() + } + fn hibp_api(&self) -> &dyn hibp_api::HibpApi { + self.hibp_api.as_ref() + } + fn import_ciphers_api(&self) -> &dyn import_ciphers_api::ImportCiphersApi { + self.import_ciphers_api.as_ref() + } + fn info_api(&self) -> &dyn info_api::InfoApi { + self.info_api.as_ref() + } + fn installations_api(&self) -> &dyn installations_api::InstallationsApi { + self.installations_api.as_ref() + } + fn invoices_api(&self) -> &dyn invoices_api::InvoicesApi { + self.invoices_api.as_ref() + } + fn licenses_api(&self) -> &dyn licenses_api::LicensesApi { + self.licenses_api.as_ref() + } + fn misc_api(&self) -> &dyn misc_api::MiscApi { + self.misc_api.as_ref() + } + fn notifications_api(&self) -> &dyn notifications_api::NotificationsApi { + self.notifications_api.as_ref() + } + fn organization_auth_requests_api( + &self, + ) -> &dyn organization_auth_requests_api::OrganizationAuthRequestsApi { + self.organization_auth_requests_api.as_ref() + } + fn organization_billing_api(&self) -> &dyn organization_billing_api::OrganizationBillingApi { + self.organization_billing_api.as_ref() + } + fn organization_connections_api( + &self, + ) -> &dyn organization_connections_api::OrganizationConnectionsApi { + self.organization_connections_api.as_ref() + } + fn organization_domain_api(&self) -> &dyn organization_domain_api::OrganizationDomainApi { + self.organization_domain_api.as_ref() + } + fn organization_export_api(&self) -> &dyn organization_export_api::OrganizationExportApi { + self.organization_export_api.as_ref() + } + fn organization_sponsorships_api( + &self, + ) -> &dyn organization_sponsorships_api::OrganizationSponsorshipsApi { + self.organization_sponsorships_api.as_ref() + } + fn organization_users_api(&self) -> &dyn organization_users_api::OrganizationUsersApi { + self.organization_users_api.as_ref() + } + fn organizations_api(&self) -> &dyn organizations_api::OrganizationsApi { + self.organizations_api.as_ref() + } + fn plans_api(&self) -> &dyn plans_api::PlansApi { + self.plans_api.as_ref() + } + fn policies_api(&self) -> &dyn policies_api::PoliciesApi { + self.policies_api.as_ref() + } + fn projects_api(&self) -> &dyn projects_api::ProjectsApi { + self.projects_api.as_ref() + } + fn provider_billing_api(&self) -> &dyn provider_billing_api::ProviderBillingApi { + self.provider_billing_api.as_ref() + } + fn provider_clients_api(&self) -> &dyn provider_clients_api::ProviderClientsApi { + self.provider_clients_api.as_ref() + } + fn provider_organizations_api( + &self, + ) -> &dyn provider_organizations_api::ProviderOrganizationsApi { + self.provider_organizations_api.as_ref() + } + fn provider_users_api(&self) -> &dyn provider_users_api::ProviderUsersApi { + self.provider_users_api.as_ref() + } + fn providers_api(&self) -> &dyn providers_api::ProvidersApi { + self.providers_api.as_ref() + } + fn push_api(&self) -> &dyn push_api::PushApi { + self.push_api.as_ref() + } + fn reports_api(&self) -> &dyn reports_api::ReportsApi { + self.reports_api.as_ref() + } + fn request_sm_access_api(&self) -> &dyn request_sm_access_api::RequestSmAccessApi { + self.request_sm_access_api.as_ref() + } + fn secrets_api(&self) -> &dyn secrets_api::SecretsApi { + self.secrets_api.as_ref() + } + fn secrets_manager_events_api( + &self, + ) -> &dyn secrets_manager_events_api::SecretsManagerEventsApi { + self.secrets_manager_events_api.as_ref() + } + fn secrets_manager_porting_api( + &self, + ) -> &dyn secrets_manager_porting_api::SecretsManagerPortingApi { + self.secrets_manager_porting_api.as_ref() + } + fn security_task_api(&self) -> &dyn security_task_api::SecurityTaskApi { + self.security_task_api.as_ref() + } + fn self_hosted_organization_licenses_api( + &self, + ) -> &dyn self_hosted_organization_licenses_api::SelfHostedOrganizationLicensesApi { + self.self_hosted_organization_licenses_api.as_ref() + } + fn self_hosted_organization_sponsorships_api( + &self, + ) -> &dyn self_hosted_organization_sponsorships_api::SelfHostedOrganizationSponsorshipsApi { + self.self_hosted_organization_sponsorships_api.as_ref() + } + fn sends_api(&self) -> &dyn sends_api::SendsApi { + self.sends_api.as_ref() + } + fn service_accounts_api(&self) -> &dyn service_accounts_api::ServiceAccountsApi { + self.service_accounts_api.as_ref() + } + fn settings_api(&self) -> &dyn settings_api::SettingsApi { + self.settings_api.as_ref() + } + fn stripe_api(&self) -> &dyn stripe_api::StripeApi { + self.stripe_api.as_ref() + } + fn sync_api(&self) -> &dyn sync_api::SyncApi { + self.sync_api.as_ref() + } + fn trash_api(&self) -> &dyn trash_api::TrashApi { + self.trash_api.as_ref() + } + fn two_factor_api(&self) -> &dyn two_factor_api::TwoFactorApi { + self.two_factor_api.as_ref() + } + fn users_api(&self) -> &dyn users_api::UsersApi { + self.users_api.as_ref() + } + fn web_authn_api(&self) -> &dyn web_authn_api::WebAuthnApi { + self.web_authn_api.as_ref() + } +} + +#[cfg(feature = "mockall")] +pub struct MockApiClient { + pub access_policies_api_mock: access_policies_api::MockAccessPoliciesApi, + pub accounts_api_mock: accounts_api::MockAccountsApi, + pub accounts_billing_api_mock: accounts_billing_api::MockAccountsBillingApi, + pub accounts_key_management_api_mock: accounts_key_management_api::MockAccountsKeyManagementApi, + pub auth_requests_api_mock: auth_requests_api::MockAuthRequestsApi, + pub ciphers_api_mock: ciphers_api::MockCiphersApi, + pub collections_api_mock: collections_api::MockCollectionsApi, + pub config_api_mock: config_api::MockConfigApi, + pub counts_api_mock: counts_api::MockCountsApi, + pub devices_api_mock: devices_api::MockDevicesApi, + pub emergency_access_api_mock: emergency_access_api::MockEmergencyAccessApi, + pub events_api_mock: events_api::MockEventsApi, + pub folders_api_mock: folders_api::MockFoldersApi, + pub groups_api_mock: groups_api::MockGroupsApi, + pub hibp_api_mock: hibp_api::MockHibpApi, + pub import_ciphers_api_mock: import_ciphers_api::MockImportCiphersApi, + pub info_api_mock: info_api::MockInfoApi, + pub installations_api_mock: installations_api::MockInstallationsApi, + pub invoices_api_mock: invoices_api::MockInvoicesApi, + pub licenses_api_mock: licenses_api::MockLicensesApi, + pub misc_api_mock: misc_api::MockMiscApi, + pub notifications_api_mock: notifications_api::MockNotificationsApi, + pub organization_auth_requests_api_mock: + organization_auth_requests_api::MockOrganizationAuthRequestsApi, + pub organization_billing_api_mock: organization_billing_api::MockOrganizationBillingApi, + pub organization_connections_api_mock: + organization_connections_api::MockOrganizationConnectionsApi, + pub organization_domain_api_mock: organization_domain_api::MockOrganizationDomainApi, + pub organization_export_api_mock: organization_export_api::MockOrganizationExportApi, + pub organization_sponsorships_api_mock: + organization_sponsorships_api::MockOrganizationSponsorshipsApi, + pub organization_users_api_mock: organization_users_api::MockOrganizationUsersApi, + pub organizations_api_mock: organizations_api::MockOrganizationsApi, + pub plans_api_mock: plans_api::MockPlansApi, + pub policies_api_mock: policies_api::MockPoliciesApi, + pub projects_api_mock: projects_api::MockProjectsApi, + pub provider_billing_api_mock: provider_billing_api::MockProviderBillingApi, + pub provider_clients_api_mock: provider_clients_api::MockProviderClientsApi, + pub provider_organizations_api_mock: provider_organizations_api::MockProviderOrganizationsApi, + pub provider_users_api_mock: provider_users_api::MockProviderUsersApi, + pub providers_api_mock: providers_api::MockProvidersApi, + pub push_api_mock: push_api::MockPushApi, + pub reports_api_mock: reports_api::MockReportsApi, + pub request_sm_access_api_mock: request_sm_access_api::MockRequestSmAccessApi, + pub secrets_api_mock: secrets_api::MockSecretsApi, + pub secrets_manager_events_api_mock: secrets_manager_events_api::MockSecretsManagerEventsApi, + pub secrets_manager_porting_api_mock: secrets_manager_porting_api::MockSecretsManagerPortingApi, + pub security_task_api_mock: security_task_api::MockSecurityTaskApi, + pub self_hosted_organization_licenses_api_mock: + self_hosted_organization_licenses_api::MockSelfHostedOrganizationLicensesApi, + pub self_hosted_organization_sponsorships_api_mock: + self_hosted_organization_sponsorships_api::MockSelfHostedOrganizationSponsorshipsApi, + pub sends_api_mock: sends_api::MockSendsApi, + pub service_accounts_api_mock: service_accounts_api::MockServiceAccountsApi, + pub settings_api_mock: settings_api::MockSettingsApi, + pub stripe_api_mock: stripe_api::MockStripeApi, + pub sync_api_mock: sync_api::MockSyncApi, + pub trash_api_mock: trash_api::MockTrashApi, + pub two_factor_api_mock: two_factor_api::MockTwoFactorApi, + pub users_api_mock: users_api::MockUsersApi, + pub web_authn_api_mock: web_authn_api::MockWebAuthnApi, +} + +#[cfg(feature = "mockall")] +impl MockApiClient { + pub fn new() -> Self { + Self { + access_policies_api_mock: access_policies_api::MockAccessPoliciesApi::new(), + accounts_api_mock: accounts_api::MockAccountsApi::new(), + accounts_billing_api_mock: accounts_billing_api::MockAccountsBillingApi::new(), + accounts_key_management_api_mock: accounts_key_management_api::MockAccountsKeyManagementApi::new(), + auth_requests_api_mock: auth_requests_api::MockAuthRequestsApi::new(), + ciphers_api_mock: ciphers_api::MockCiphersApi::new(), + collections_api_mock: collections_api::MockCollectionsApi::new(), + config_api_mock: config_api::MockConfigApi::new(), + counts_api_mock: counts_api::MockCountsApi::new(), + devices_api_mock: devices_api::MockDevicesApi::new(), + emergency_access_api_mock: emergency_access_api::MockEmergencyAccessApi::new(), + events_api_mock: events_api::MockEventsApi::new(), + folders_api_mock: folders_api::MockFoldersApi::new(), + groups_api_mock: groups_api::MockGroupsApi::new(), + hibp_api_mock: hibp_api::MockHibpApi::new(), + import_ciphers_api_mock: import_ciphers_api::MockImportCiphersApi::new(), + info_api_mock: info_api::MockInfoApi::new(), + installations_api_mock: installations_api::MockInstallationsApi::new(), + invoices_api_mock: invoices_api::MockInvoicesApi::new(), + licenses_api_mock: licenses_api::MockLicensesApi::new(), + misc_api_mock: misc_api::MockMiscApi::new(), + notifications_api_mock: notifications_api::MockNotificationsApi::new(), + organization_auth_requests_api_mock: organization_auth_requests_api::MockOrganizationAuthRequestsApi::new(), + organization_billing_api_mock: organization_billing_api::MockOrganizationBillingApi::new(), + organization_connections_api_mock: organization_connections_api::MockOrganizationConnectionsApi::new(), + organization_domain_api_mock: organization_domain_api::MockOrganizationDomainApi::new(), + organization_export_api_mock: organization_export_api::MockOrganizationExportApi::new(), + organization_sponsorships_api_mock: organization_sponsorships_api::MockOrganizationSponsorshipsApi::new(), + organization_users_api_mock: organization_users_api::MockOrganizationUsersApi::new(), + organizations_api_mock: organizations_api::MockOrganizationsApi::new(), + plans_api_mock: plans_api::MockPlansApi::new(), + policies_api_mock: policies_api::MockPoliciesApi::new(), + projects_api_mock: projects_api::MockProjectsApi::new(), + provider_billing_api_mock: provider_billing_api::MockProviderBillingApi::new(), + provider_clients_api_mock: provider_clients_api::MockProviderClientsApi::new(), + provider_organizations_api_mock: provider_organizations_api::MockProviderOrganizationsApi::new(), + provider_users_api_mock: provider_users_api::MockProviderUsersApi::new(), + providers_api_mock: providers_api::MockProvidersApi::new(), + push_api_mock: push_api::MockPushApi::new(), + reports_api_mock: reports_api::MockReportsApi::new(), + request_sm_access_api_mock: request_sm_access_api::MockRequestSmAccessApi::new(), + secrets_api_mock: secrets_api::MockSecretsApi::new(), + secrets_manager_events_api_mock: secrets_manager_events_api::MockSecretsManagerEventsApi::new(), + secrets_manager_porting_api_mock: secrets_manager_porting_api::MockSecretsManagerPortingApi::new(), + security_task_api_mock: security_task_api::MockSecurityTaskApi::new(), + self_hosted_organization_licenses_api_mock: self_hosted_organization_licenses_api::MockSelfHostedOrganizationLicensesApi::new(), + self_hosted_organization_sponsorships_api_mock: self_hosted_organization_sponsorships_api::MockSelfHostedOrganizationSponsorshipsApi::new(), + sends_api_mock: sends_api::MockSendsApi::new(), + service_accounts_api_mock: service_accounts_api::MockServiceAccountsApi::new(), + settings_api_mock: settings_api::MockSettingsApi::new(), + stripe_api_mock: stripe_api::MockStripeApi::new(), + sync_api_mock: sync_api::MockSyncApi::new(), + trash_api_mock: trash_api::MockTrashApi::new(), + two_factor_api_mock: two_factor_api::MockTwoFactorApi::new(), + users_api_mock: users_api::MockUsersApi::new(), + web_authn_api_mock: web_authn_api::MockWebAuthnApi::new(), + } + } +} + +#[cfg(feature = "mockall")] +impl Api for MockApiClient { + fn access_policies_api(&self) -> &dyn access_policies_api::AccessPoliciesApi { + &self.access_policies_api_mock + } + fn accounts_api(&self) -> &dyn accounts_api::AccountsApi { + &self.accounts_api_mock + } + fn accounts_billing_api(&self) -> &dyn accounts_billing_api::AccountsBillingApi { + &self.accounts_billing_api_mock + } + fn accounts_key_management_api( + &self, + ) -> &dyn accounts_key_management_api::AccountsKeyManagementApi { + &self.accounts_key_management_api_mock + } + fn auth_requests_api(&self) -> &dyn auth_requests_api::AuthRequestsApi { + &self.auth_requests_api_mock + } + fn ciphers_api(&self) -> &dyn ciphers_api::CiphersApi { + &self.ciphers_api_mock + } + fn collections_api(&self) -> &dyn collections_api::CollectionsApi { + &self.collections_api_mock + } + fn config_api(&self) -> &dyn config_api::ConfigApi { + &self.config_api_mock + } + fn counts_api(&self) -> &dyn counts_api::CountsApi { + &self.counts_api_mock + } + fn devices_api(&self) -> &dyn devices_api::DevicesApi { + &self.devices_api_mock + } + fn emergency_access_api(&self) -> &dyn emergency_access_api::EmergencyAccessApi { + &self.emergency_access_api_mock + } + fn events_api(&self) -> &dyn events_api::EventsApi { + &self.events_api_mock + } + fn folders_api(&self) -> &dyn folders_api::FoldersApi { + &self.folders_api_mock + } + fn groups_api(&self) -> &dyn groups_api::GroupsApi { + &self.groups_api_mock + } + fn hibp_api(&self) -> &dyn hibp_api::HibpApi { + &self.hibp_api_mock + } + fn import_ciphers_api(&self) -> &dyn import_ciphers_api::ImportCiphersApi { + &self.import_ciphers_api_mock + } + fn info_api(&self) -> &dyn info_api::InfoApi { + &self.info_api_mock + } + fn installations_api(&self) -> &dyn installations_api::InstallationsApi { + &self.installations_api_mock + } + fn invoices_api(&self) -> &dyn invoices_api::InvoicesApi { + &self.invoices_api_mock + } + fn licenses_api(&self) -> &dyn licenses_api::LicensesApi { + &self.licenses_api_mock + } + fn misc_api(&self) -> &dyn misc_api::MiscApi { + &self.misc_api_mock + } + fn notifications_api(&self) -> &dyn notifications_api::NotificationsApi { + &self.notifications_api_mock + } + fn organization_auth_requests_api( + &self, + ) -> &dyn organization_auth_requests_api::OrganizationAuthRequestsApi { + &self.organization_auth_requests_api_mock + } + fn organization_billing_api(&self) -> &dyn organization_billing_api::OrganizationBillingApi { + &self.organization_billing_api_mock + } + fn organization_connections_api( + &self, + ) -> &dyn organization_connections_api::OrganizationConnectionsApi { + &self.organization_connections_api_mock + } + fn organization_domain_api(&self) -> &dyn organization_domain_api::OrganizationDomainApi { + &self.organization_domain_api_mock + } + fn organization_export_api(&self) -> &dyn organization_export_api::OrganizationExportApi { + &self.organization_export_api_mock + } + fn organization_sponsorships_api( + &self, + ) -> &dyn organization_sponsorships_api::OrganizationSponsorshipsApi { + &self.organization_sponsorships_api_mock + } + fn organization_users_api(&self) -> &dyn organization_users_api::OrganizationUsersApi { + &self.organization_users_api_mock + } + fn organizations_api(&self) -> &dyn organizations_api::OrganizationsApi { + &self.organizations_api_mock + } + fn plans_api(&self) -> &dyn plans_api::PlansApi { + &self.plans_api_mock + } + fn policies_api(&self) -> &dyn policies_api::PoliciesApi { + &self.policies_api_mock + } + fn projects_api(&self) -> &dyn projects_api::ProjectsApi { + &self.projects_api_mock + } + fn provider_billing_api(&self) -> &dyn provider_billing_api::ProviderBillingApi { + &self.provider_billing_api_mock + } + fn provider_clients_api(&self) -> &dyn provider_clients_api::ProviderClientsApi { + &self.provider_clients_api_mock + } + fn provider_organizations_api( + &self, + ) -> &dyn provider_organizations_api::ProviderOrganizationsApi { + &self.provider_organizations_api_mock + } + fn provider_users_api(&self) -> &dyn provider_users_api::ProviderUsersApi { + &self.provider_users_api_mock + } + fn providers_api(&self) -> &dyn providers_api::ProvidersApi { + &self.providers_api_mock + } + fn push_api(&self) -> &dyn push_api::PushApi { + &self.push_api_mock + } + fn reports_api(&self) -> &dyn reports_api::ReportsApi { + &self.reports_api_mock + } + fn request_sm_access_api(&self) -> &dyn request_sm_access_api::RequestSmAccessApi { + &self.request_sm_access_api_mock + } + fn secrets_api(&self) -> &dyn secrets_api::SecretsApi { + &self.secrets_api_mock + } + fn secrets_manager_events_api( + &self, + ) -> &dyn secrets_manager_events_api::SecretsManagerEventsApi { + &self.secrets_manager_events_api_mock + } + fn secrets_manager_porting_api( + &self, + ) -> &dyn secrets_manager_porting_api::SecretsManagerPortingApi { + &self.secrets_manager_porting_api_mock + } + fn security_task_api(&self) -> &dyn security_task_api::SecurityTaskApi { + &self.security_task_api_mock + } + fn self_hosted_organization_licenses_api( + &self, + ) -> &dyn self_hosted_organization_licenses_api::SelfHostedOrganizationLicensesApi { + &self.self_hosted_organization_licenses_api_mock + } + fn self_hosted_organization_sponsorships_api( + &self, + ) -> &dyn self_hosted_organization_sponsorships_api::SelfHostedOrganizationSponsorshipsApi { + &self.self_hosted_organization_sponsorships_api_mock + } + fn sends_api(&self) -> &dyn sends_api::SendsApi { + &self.sends_api_mock + } + fn service_accounts_api(&self) -> &dyn service_accounts_api::ServiceAccountsApi { + &self.service_accounts_api_mock + } + fn settings_api(&self) -> &dyn settings_api::SettingsApi { + &self.settings_api_mock + } + fn stripe_api(&self) -> &dyn stripe_api::StripeApi { + &self.stripe_api_mock + } + fn sync_api(&self) -> &dyn sync_api::SyncApi { + &self.sync_api_mock + } + fn trash_api(&self) -> &dyn trash_api::TrashApi { + &self.trash_api_mock + } + fn two_factor_api(&self) -> &dyn two_factor_api::TwoFactorApi { + &self.two_factor_api_mock + } + fn users_api(&self) -> &dyn users_api::UsersApi { + &self.users_api_mock + } + fn web_authn_api(&self) -> &dyn web_authn_api::WebAuthnApi { + &self.web_authn_api_mock + } +} diff --git a/crates/bitwarden-api-api/src/apis/notifications_api.rs b/crates/bitwarden-api-api/src/apis/notifications_api.rs index 23524dc14..370772433 100644 --- a/crates/bitwarden-api-api/src/apis/notifications_api.rs +++ b/crates/bitwarden-api-api/src/apis/notifications_api.rs @@ -8,175 +8,233 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait NotificationsApi: Send + Sync { + /// GET /notifications + async fn notifications_get<'a>( + &self, + read_status_filter: Option, + deleted_status_filter: Option, + continuation_token: Option<&'a str>, + page_size: Option, + ) -> Result>; + + /// PATCH /notifications/{id}/delete + async fn notifications_id_delete_patch<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// PATCH /notifications/{id}/read + async fn notifications_id_read_patch<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; +} + +pub struct NotificationsApiClient { + configuration: Arc, +} -/// struct for typed errors of method [`notifications_get`] +impl NotificationsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl NotificationsApi for NotificationsApiClient { + async fn notifications_get<'a>( + &self, + read_status_filter: Option, + deleted_status_filter: Option, + continuation_token: Option<&'a str>, + page_size: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/notifications", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = read_status_filter { + local_var_req_builder = + local_var_req_builder.query(&[("readStatusFilter", ¶m_value.to_string())]); + } + if let Some(ref param_value) = deleted_status_filter { + local_var_req_builder = + local_var_req_builder.query(&[("deletedStatusFilter", ¶m_value.to_string())]); + } + if let Some(ref param_value) = continuation_token { + local_var_req_builder = + local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]); + } + if let Some(ref param_value) = page_size { + local_var_req_builder = + local_var_req_builder.query(&[("pageSize", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::NotificationResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn notifications_id_delete_patch<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/notifications/{id}/delete", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn notifications_id_read_patch<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/notifications/{id}/read", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`NotificationsApi::notifications_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum NotificationsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`notifications_id_delete_patch`] +/// struct for typed errors of method [`NotificationsApi::notifications_id_delete_patch`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum NotificationsIdDeletePatchError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`notifications_id_read_patch`] +/// struct for typed errors of method [`NotificationsApi::notifications_id_read_patch`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum NotificationsIdReadPatchError { UnknownValue(serde_json::Value), } - -pub async fn notifications_get( - configuration: &configuration::Configuration, - read_status_filter: Option, - deleted_status_filter: Option, - continuation_token: Option<&str>, - page_size: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_read_status_filter = read_status_filter; - let p_deleted_status_filter = deleted_status_filter; - let p_continuation_token = continuation_token; - let p_page_size = page_size; - - let uri_str = format!("{}/notifications", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_read_status_filter { - req_builder = req_builder.query(&[("readStatusFilter", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_deleted_status_filter { - req_builder = req_builder.query(&[("deletedStatusFilter", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_continuation_token { - req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_page_size { - req_builder = req_builder.query(&[("pageSize", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NotificationResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn notifications_id_delete_patch( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/notifications/{id}/delete", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::PATCH, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn notifications_id_read_patch( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/notifications/{id}/read", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::PATCH, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs b/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs index 50138e8b3..b2590dbf2 100644 --- a/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs @@ -8,233 +8,304 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait OrganizationAuthRequestsApi: Send + Sync { + /// POST /organizations/{orgId}/auth-requests/deny + async fn organizations_org_id_auth_requests_deny_post<'a>( + &self, + org_id: uuid::Uuid, + bulk_deny_admin_auth_request_request_model: Option< + models::BulkDenyAdminAuthRequestRequestModel, + >, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/auth-requests + async fn organizations_org_id_auth_requests_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::PendingOrganizationAuthRequestResponseModelListResponseModel, + Error, + >; + + /// POST /organizations/{orgId}/auth-requests + async fn organizations_org_id_auth_requests_post<'a>( + &self, + org_id: uuid::Uuid, + organization_auth_request_update_many_request_model: Option< + Vec, + >, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/auth-requests/{requestId} + async fn organizations_org_id_auth_requests_request_id_post<'a>( + &self, + org_id: uuid::Uuid, + request_id: uuid::Uuid, + admin_auth_request_update_request_model: Option, + ) -> Result<(), Error>; +} + +pub struct OrganizationAuthRequestsApiClient { + configuration: Arc, +} + +impl OrganizationAuthRequestsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl OrganizationAuthRequestsApi for OrganizationAuthRequestsApiClient { + async fn organizations_org_id_auth_requests_deny_post<'a>( + &self, + org_id: uuid::Uuid, + bulk_deny_admin_auth_request_request_model: Option< + models::BulkDenyAdminAuthRequestRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/auth-requests/deny", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&bulk_deny_admin_auth_request_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; -/// struct for typed errors of method [`organizations_org_id_auth_requests_deny_post`] + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_auth_requests_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::PendingOrganizationAuthRequestResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/auth-requests", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PendingOrganizationAuthRequestResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PendingOrganizationAuthRequestResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_auth_requests_post<'a>( + &self, + org_id: uuid::Uuid, + organization_auth_request_update_many_request_model: Option< + Vec, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/auth-requests", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_auth_request_update_many_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_auth_requests_request_id_post<'a>( + &self, + org_id: uuid::Uuid, + request_id: uuid::Uuid, + admin_auth_request_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/auth-requests/{requestId}", + local_var_configuration.base_path, + orgId = org_id, + requestId = request_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&admin_auth_request_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method +/// [`OrganizationAuthRequestsApi::organizations_org_id_auth_requests_deny_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdAuthRequestsDenyPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_auth_requests_get`] +/// struct for typed errors of method +/// [`OrganizationAuthRequestsApi::organizations_org_id_auth_requests_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdAuthRequestsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_auth_requests_post`] +/// struct for typed errors of method +/// [`OrganizationAuthRequestsApi::organizations_org_id_auth_requests_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdAuthRequestsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_auth_requests_request_id_post`] +/// struct for typed errors of method +/// [`OrganizationAuthRequestsApi::organizations_org_id_auth_requests_request_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdAuthRequestsRequestIdPostError { UnknownValue(serde_json::Value), } - -pub async fn organizations_org_id_auth_requests_deny_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - bulk_deny_admin_auth_request_request_model: Option< - models::BulkDenyAdminAuthRequestRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_bulk_deny_admin_auth_request_request_model = bulk_deny_admin_auth_request_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/auth-requests/deny", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_bulk_deny_admin_auth_request_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_auth_requests_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result< - models::PendingOrganizationAuthRequestResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/organizations/{orgId}/auth-requests", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PendingOrganizationAuthRequestResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PendingOrganizationAuthRequestResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_auth_requests_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_auth_request_update_many_request_model: Option< - Vec, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_auth_request_update_many_request_model = - organization_auth_request_update_many_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/auth-requests", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_auth_request_update_many_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_auth_requests_request_id_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - request_id: uuid::Uuid, - admin_auth_request_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_request_id = request_id; - let p_admin_auth_request_update_request_model = admin_auth_request_update_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/auth-requests/{requestId}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - requestId = crate::apis::urlencode(p_request_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_admin_auth_request_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/organization_billing_api.rs b/crates/bitwarden-api-api/src/apis/organization_billing_api.rs index ab4b33b10..f5637ac96 100644 --- a/crates/bitwarden-api-api/src/apis/organization_billing_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_billing_api.rs @@ -8,48 +8,662 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait OrganizationBillingApi: Send + Sync { + /// GET /organizations/{organizationId}/billing + async fn organizations_organization_id_billing_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/history + async fn organizations_organization_id_billing_history_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/invoices + async fn organizations_organization_id_billing_invoices_get<'a>( + &self, + organization_id: uuid::Uuid, + status: Option<&'a str>, + start_after: Option<&'a str>, + ) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/metadata + async fn organizations_organization_id_billing_metadata_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/payment-method + async fn organizations_organization_id_billing_payment_method_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// PUT /organizations/{organizationId}/billing/payment-method + async fn organizations_organization_id_billing_payment_method_put<'a>( + &self, + organization_id: uuid::Uuid, + update_payment_method_request_body: Option, + ) -> Result<(), Error>; + + /// POST /organizations/{organizationId}/billing/payment-method/verify-bank-account + async fn organizations_organization_id_billing_payment_method_verify_bank_account_post<'a>( + &self, + organization_id: uuid::Uuid, + verify_bank_account_request_body: Option, + ) -> Result<(), Error>; + + /// POST /organizations/{organizationId}/billing/restart-subscription + async fn organizations_organization_id_billing_restart_subscription_post<'a>( + &self, + organization_id: uuid::Uuid, + organization_create_request_model: Option, + ) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/tax-information + async fn organizations_organization_id_billing_tax_information_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// PUT /organizations/{organizationId}/billing/tax-information + async fn organizations_organization_id_billing_tax_information_put<'a>( + &self, + organization_id: uuid::Uuid, + tax_information_request_body: Option, + ) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/transactions + async fn organizations_organization_id_billing_transactions_get<'a>( + &self, + organization_id: uuid::Uuid, + start_after: Option, + ) -> Result<(), Error>; +} + +pub struct OrganizationBillingApiClient { + configuration: Arc, +} + +impl OrganizationBillingApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl OrganizationBillingApi for OrganizationBillingApiClient { + async fn organizations_organization_id_billing_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_billing_history_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/history", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_billing_invoices_get<'a>( + &self, + organization_id: uuid::Uuid, + status: Option<&'a str>, + start_after: Option<&'a str>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/invoices", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", ¶m_value.to_string())]); + } + if let Some(ref param_value) = start_after { + local_var_req_builder = + local_var_req_builder.query(&[("startAfter", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_billing_metadata_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/metadata", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_billing_payment_method_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/payment-method", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`organizations_organization_id_billing_get`] + async fn organizations_organization_id_billing_payment_method_put<'a>( + &self, + organization_id: uuid::Uuid, + update_payment_method_request_body: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/payment-method", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_payment_method_request_body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_billing_payment_method_verify_bank_account_post<'a>( + &self, + organization_id: uuid::Uuid, + verify_bank_account_request_body: Option, + ) -> Result<(), Error> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/payment-method/verify-bank-account", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&verify_bank_account_request_body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationsOrganizationIdBillingPaymentMethodVerifyBankAccountPostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_billing_restart_subscription_post<'a>( + &self, + organization_id: uuid::Uuid, + organization_create_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/restart-subscription", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationsOrganizationIdBillingRestartSubscriptionPostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_billing_tax_information_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/tax-information", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_billing_tax_information_put<'a>( + &self, + organization_id: uuid::Uuid, + tax_information_request_body: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/tax-information", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&tax_information_request_body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_billing_transactions_get<'a>( + &self, + organization_id: uuid::Uuid, + start_after: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/transactions", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = start_after { + local_var_req_builder = + local_var_req_builder.query(&[("startAfter", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method +/// [`OrganizationBillingApi::organizations_organization_id_billing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_billing_history_get`] +/// struct for typed errors of method +/// [`OrganizationBillingApi::organizations_organization_id_billing_history_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingHistoryGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_billing_invoices_get`] +/// struct for typed errors of method +/// [`OrganizationBillingApi::organizations_organization_id_billing_invoices_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingInvoicesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_billing_metadata_get`] +/// struct for typed errors of method +/// [`OrganizationBillingApi::organizations_organization_id_billing_metadata_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingMetadataGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_billing_payment_method_get`] +/// struct for typed errors of method +/// [`OrganizationBillingApi::organizations_organization_id_billing_payment_method_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingPaymentMethodGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_billing_payment_method_put`] +/// struct for typed errors of method +/// [`OrganizationBillingApi::organizations_organization_id_billing_payment_method_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingPaymentMethodPutError { @@ -57,7 +671,7 @@ pub enum OrganizationsOrganizationIdBillingPaymentMethodPutError { } /// struct for typed errors of method -/// [`organizations_organization_id_billing_payment_method_verify_bank_account_post`] +/// [`OrganizationBillingApi::organizations_organization_id_billing_payment_method_verify_bank_account_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingPaymentMethodVerifyBankAccountPostError { @@ -65,502 +679,33 @@ pub enum OrganizationsOrganizationIdBillingPaymentMethodVerifyBankAccountPostErr } /// struct for typed errors of method -/// [`organizations_organization_id_billing_restart_subscription_post`] +/// [`OrganizationBillingApi::organizations_organization_id_billing_restart_subscription_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingRestartSubscriptionPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_billing_tax_information_get`] +/// struct for typed errors of method +/// [`OrganizationBillingApi::organizations_organization_id_billing_tax_information_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingTaxInformationGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_billing_tax_information_put`] +/// struct for typed errors of method +/// [`OrganizationBillingApi::organizations_organization_id_billing_tax_information_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingTaxInformationPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_billing_transactions_get`] +/// struct for typed errors of method +/// [`OrganizationBillingApi::organizations_organization_id_billing_transactions_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdBillingTransactionsGetError { UnknownValue(serde_json::Value), } - -pub async fn organizations_organization_id_billing_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_billing_history_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/history", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_billing_invoices_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - status: Option<&str>, - start_after: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_status = status; - let p_start_after = start_after; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/invoices", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_status { - req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_start_after { - req_builder = req_builder.query(&[("startAfter", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_billing_metadata_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/metadata", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_billing_payment_method_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/payment-method", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_billing_payment_method_put( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - update_payment_method_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_update_payment_method_request_body = update_payment_method_request_body; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/payment-method", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_payment_method_request_body); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_billing_payment_method_verify_bank_account_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - verify_bank_account_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_verify_bank_account_request_body = verify_bank_account_request_body; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/payment-method/verify-bank-account", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_verify_bank_account_request_body); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option< - OrganizationsOrganizationIdBillingPaymentMethodVerifyBankAccountPostError, - > = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_billing_restart_subscription_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - organization_create_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_organization_create_request_model = organization_create_request_model; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/restart-subscription", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_billing_tax_information_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/tax-information", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_billing_tax_information_put( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - tax_information_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_tax_information_request_body = tax_information_request_body; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/tax-information", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_tax_information_request_body); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_billing_transactions_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - start_after: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_start_after = start_after; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/transactions", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_start_after { - req_builder = req_builder.query(&[("startAfter", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/organization_connections_api.rs b/crates/bitwarden-api-api/src/apis/organization_connections_api.rs index a67bca081..1c37479f3 100644 --- a/crates/bitwarden-api-api/src/apis/organization_connections_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_connections_api.rs @@ -8,13 +8,392 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait OrganizationConnectionsApi: Send + Sync { + /// GET /organizations/connections/enabled + async fn organizations_connections_enabled_get<'a>( + &self, + ) -> Result>; + + /// DELETE /organizations/connections/{organizationConnectionId} + async fn organizations_connections_organization_connection_id_delete<'a>( + &self, + organization_connection_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organizations/connections/{organizationConnectionId}/delete + async fn organizations_connections_organization_connection_id_delete_post<'a>( + &self, + organization_connection_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// PUT /organizations/connections/{organizationConnectionId} + async fn organizations_connections_organization_connection_id_put<'a>( + &self, + organization_connection_id: uuid::Uuid, + organization_connection_request_model: Option, + ) -> Result< + models::OrganizationConnectionResponseModel, + Error, + >; + + /// GET /organizations/connections/{organizationId}/{type} + async fn organizations_connections_organization_id_type_get<'a>( + &self, + organization_id: uuid::Uuid, + r#type: models::OrganizationConnectionType, + ) -> Result< + models::OrganizationConnectionResponseModel, + Error, + >; + + /// POST /organizations/connections + async fn organizations_connections_post<'a>( + &self, + organization_connection_request_model: Option, + ) -> Result>; +} -/// struct for typed errors of method [`organizations_connections_enabled_get`] +pub struct OrganizationConnectionsApiClient { + configuration: Arc, +} + +impl OrganizationConnectionsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl OrganizationConnectionsApi for OrganizationConnectionsApiClient { + async fn organizations_connections_enabled_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/connections/enabled", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `bool`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `bool`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_connections_organization_connection_id_delete<'a>( + &self, + organization_connection_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/connections/{organizationConnectionId}", + local_var_configuration.base_path, + organizationConnectionId = organization_connection_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationsConnectionsOrganizationConnectionIdDeleteError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_connections_organization_connection_id_delete_post<'a>( + &self, + organization_connection_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/connections/{organizationConnectionId}/delete", + local_var_configuration.base_path, + organizationConnectionId = organization_connection_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationsConnectionsOrganizationConnectionIdDeletePostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_connections_organization_connection_id_put<'a>( + &self, + organization_connection_id: uuid::Uuid, + organization_connection_request_model: Option, + ) -> Result< + models::OrganizationConnectionResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/connections/{organizationConnectionId}", + local_var_configuration.base_path, + organizationConnectionId = organization_connection_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_connection_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_connections_organization_id_type_get<'a>( + &self, + organization_id: uuid::Uuid, + r#type: models::OrganizationConnectionType, + ) -> Result< + models::OrganizationConnectionResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/organizations/connections/{organizationId}/{type}", local_var_configuration.base_path, organizationId=organization_id, type=r#type.to_string()); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_connections_post<'a>( + &self, + organization_connection_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/connections", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_connection_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method +/// [`OrganizationConnectionsApi::organizations_connections_enabled_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsConnectionsEnabledGetError { @@ -22,7 +401,7 @@ pub enum OrganizationsConnectionsEnabledGetError { } /// struct for typed errors of method -/// [`organizations_connections_organization_connection_id_delete`] +/// [`OrganizationConnectionsApi::organizations_connections_organization_connection_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsConnectionsOrganizationConnectionIdDeleteError { @@ -30,318 +409,32 @@ pub enum OrganizationsConnectionsOrganizationConnectionIdDeleteError { } /// struct for typed errors of method -/// [`organizations_connections_organization_connection_id_delete_post`] +/// [`OrganizationConnectionsApi::organizations_connections_organization_connection_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsConnectionsOrganizationConnectionIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_connections_organization_connection_id_put`] +/// struct for typed errors of method +/// [`OrganizationConnectionsApi::organizations_connections_organization_connection_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsConnectionsOrganizationConnectionIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_connections_organization_id_type_get`] +/// struct for typed errors of method +/// [`OrganizationConnectionsApi::organizations_connections_organization_id_type_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsConnectionsOrganizationIdTypeGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_connections_post`] +/// struct for typed errors of method [`OrganizationConnectionsApi::organizations_connections_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsConnectionsPostError { UnknownValue(serde_json::Value), } - -pub async fn organizations_connections_enabled_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!( - "{}/organizations/connections/enabled", - configuration.base_path - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `bool`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `bool`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_connections_organization_connection_id_delete( - configuration: &configuration::Configuration, - organization_connection_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_connection_id = organization_connection_id; - - let uri_str = format!( - "{}/organizations/connections/{organizationConnectionId}", - configuration.base_path, - organizationConnectionId = crate::apis::urlencode(p_organization_connection_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_connections_organization_connection_id_delete_post( - configuration: &configuration::Configuration, - organization_connection_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_connection_id = organization_connection_id; - - let uri_str = format!( - "{}/organizations/connections/{organizationConnectionId}/delete", - configuration.base_path, - organizationConnectionId = crate::apis::urlencode(p_organization_connection_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_connections_organization_connection_id_put( - configuration: &configuration::Configuration, - organization_connection_id: uuid::Uuid, - organization_connection_request_model: Option, -) -> Result< - models::OrganizationConnectionResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_connection_id = organization_connection_id; - let p_organization_connection_request_model = organization_connection_request_model; - - let uri_str = format!( - "{}/organizations/connections/{organizationConnectionId}", - configuration.base_path, - organizationConnectionId = crate::apis::urlencode(p_organization_connection_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_connection_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_connections_organization_id_type_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - r#type: models::OrganizationConnectionType, -) -> Result< - models::OrganizationConnectionResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_type = r#type; - - let uri_str = format!("{}/organizations/connections/{organizationId}/{type}", configuration.base_path, organizationId=crate::apis::urlencode(p_organization_id.to_string()), type=p_type.to_string()); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_connections_post( - configuration: &configuration::Configuration, - organization_connection_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_connection_request_model = organization_connection_request_model; - - let uri_str = format!("{}/organizations/connections", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_connection_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/organization_domain_api.rs b/crates/bitwarden-api-api/src/apis/organization_domain_api.rs index b5f8c6ea3..70b3631c2 100644 --- a/crates/bitwarden-api-api/src/apis/organization_domain_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_domain_api.rs @@ -8,491 +8,605 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait OrganizationDomainApi: Send + Sync { + /// POST /organizations/domain/sso/details + async fn organizations_domain_sso_details_post<'a>( + &self, + organization_domain_sso_details_request_model: Option< + models::OrganizationDomainSsoDetailsRequestModel, + >, + ) -> Result< + models::OrganizationDomainSsoDetailsResponseModel, + Error, + >; + + /// POST /organizations/domain/sso/verified + async fn organizations_domain_sso_verified_post<'a>( + &self, + organization_domain_sso_details_request_model: Option< + models::OrganizationDomainSsoDetailsRequestModel, + >, + ) -> Result< + models::VerifiedOrganizationDomainSsoDetailsResponseModel, + Error, + >; + + /// GET /organizations/{orgId}/domain + async fn organizations_org_id_domain_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::OrganizationDomainResponseModelListResponseModel, + Error, + >; + + /// DELETE /organizations/{orgId}/domain/{id} + async fn organizations_org_id_domain_id_delete<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/domain/{id} + async fn organizations_org_id_domain_id_get<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result>; + + /// POST /organizations/{orgId}/domain/{id}/remove + async fn organizations_org_id_domain_id_remove_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/domain/{id}/verify + async fn organizations_org_id_domain_id_verify_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result< + models::OrganizationDomainResponseModel, + Error, + >; + + /// POST /organizations/{orgId}/domain + async fn organizations_org_id_domain_post<'a>( + &self, + org_id: uuid::Uuid, + organization_domain_request_model: Option, + ) -> Result>; +} + +pub struct OrganizationDomainApiClient { + configuration: Arc, +} + +impl OrganizationDomainApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl OrganizationDomainApi for OrganizationDomainApiClient { + async fn organizations_domain_sso_details_post<'a>( + &self, + organization_domain_sso_details_request_model: Option< + models::OrganizationDomainSsoDetailsRequestModel, + >, + ) -> Result< + models::OrganizationDomainSsoDetailsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/domain/sso/details", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_domain_sso_details_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainSsoDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationDomainSsoDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_domain_sso_verified_post<'a>( + &self, + organization_domain_sso_details_request_model: Option< + models::OrganizationDomainSsoDetailsRequestModel, + >, + ) -> Result< + models::VerifiedOrganizationDomainSsoDetailsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/domain/sso/verified", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_domain_sso_details_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerifiedOrganizationDomainSsoDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::VerifiedOrganizationDomainSsoDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_domain_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::OrganizationDomainResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/domain", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_domain_id_delete<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/domain/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_domain_id_get<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/domain/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_domain_id_remove_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/domain/{id}/remove", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_domain_id_verify_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result< + models::OrganizationDomainResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/domain/{id}/verify", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_domain_post<'a>( + &self, + org_id: uuid::Uuid, + organization_domain_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/domain", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_domain_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`organizations_domain_sso_details_post`] +/// struct for typed errors of method +/// [`OrganizationDomainApi::organizations_domain_sso_details_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsDomainSsoDetailsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_domain_sso_verified_post`] +/// struct for typed errors of method +/// [`OrganizationDomainApi::organizations_domain_sso_verified_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsDomainSsoVerifiedPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_domain_get`] +/// struct for typed errors of method [`OrganizationDomainApi::organizations_org_id_domain_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdDomainGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_domain_id_delete`] +/// struct for typed errors of method +/// [`OrganizationDomainApi::organizations_org_id_domain_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdDomainIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_domain_id_get`] +/// struct for typed errors of method [`OrganizationDomainApi::organizations_org_id_domain_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdDomainIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_domain_id_remove_post`] +/// struct for typed errors of method +/// [`OrganizationDomainApi::organizations_org_id_domain_id_remove_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdDomainIdRemovePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_domain_id_verify_post`] +/// struct for typed errors of method +/// [`OrganizationDomainApi::organizations_org_id_domain_id_verify_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdDomainIdVerifyPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_domain_post`] +/// struct for typed errors of method [`OrganizationDomainApi::organizations_org_id_domain_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdDomainPostError { UnknownValue(serde_json::Value), } - -pub async fn organizations_domain_sso_details_post( - configuration: &configuration::Configuration, - organization_domain_sso_details_request_model: Option< - models::OrganizationDomainSsoDetailsRequestModel, - >, -) -> Result< - models::OrganizationDomainSsoDetailsResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_domain_sso_details_request_model = - organization_domain_sso_details_request_model; - - let uri_str = format!( - "{}/organizations/domain/sso/details", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_domain_sso_details_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainSsoDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationDomainSsoDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_domain_sso_verified_post( - configuration: &configuration::Configuration, - organization_domain_sso_details_request_model: Option< - models::OrganizationDomainSsoDetailsRequestModel, - >, -) -> Result< - models::VerifiedOrganizationDomainSsoDetailsResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_domain_sso_details_request_model = - organization_domain_sso_details_request_model; - - let uri_str = format!( - "{}/organizations/domain/sso/verified", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_domain_sso_details_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerifiedOrganizationDomainSsoDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerifiedOrganizationDomainSsoDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_domain_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result< - models::OrganizationDomainResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/organizations/{orgId}/domain", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_domain_id_delete( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/domain/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_domain_id_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/domain/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_domain_id_remove_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/domain/{id}/remove", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_domain_id_verify_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/domain/{id}/verify", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_domain_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_domain_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_domain_request_model = organization_domain_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/domain", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_domain_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/organization_export_api.rs b/crates/bitwarden-api-api/src/apis/organization_export_api.rs index fa0e79e2f..7cc2ffac6 100644 --- a/crates/bitwarden-api-api/src/apis/organization_export_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_export_api.rs @@ -8,55 +8,91 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`organizations_organization_id_export_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdExportGetError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait OrganizationExportApi: Send + Sync { + /// GET /organizations/{organizationId}/export + async fn organizations_organization_id_export_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error>; } -pub async fn organizations_organization_id_export_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/export", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +pub struct OrganizationExportApiClient { + configuration: Arc, +} + +impl OrganizationExportApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) +} + +#[async_trait(?Send)] +impl OrganizationExportApi for OrganizationExportApiClient { + async fn organizations_organization_id_export_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/export", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } } + +/// struct for typed errors of method +/// [`OrganizationExportApi::organizations_organization_id_export_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum OrganizationsOrganizationIdExportGetError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/organization_sponsorships_api.rs b/crates/bitwarden-api-api/src/apis/organization_sponsorships_api.rs index 0c0ed85c4..fe92a9831 100644 --- a/crates/bitwarden-api-api/src/apis/organization_sponsorships_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_sponsorships_api.rs @@ -8,20 +8,614 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait OrganizationSponsorshipsApi: Send + Sync { + /// POST /organization/sponsorship/redeem + async fn organization_sponsorship_redeem_post<'a>( + &self, + sponsorship_token: Option<&'a str>, + organization_sponsorship_redeem_request_model: Option< + models::OrganizationSponsorshipRedeemRequestModel, + >, + ) -> Result<(), Error>; + + /// DELETE /organization/sponsorship/sponsored/{sponsoredOrgId} + async fn organization_sponsorship_sponsored_sponsored_org_id_delete<'a>( + &self, + sponsored_org_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organization/sponsorship/sponsored/{sponsoredOrgId}/remove + async fn organization_sponsorship_sponsored_sponsored_org_id_remove_post<'a>( + &self, + sponsored_org_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organization/sponsorship/{sponsoringOrgId}/families-for-enterprise + async fn organization_sponsorship_sponsoring_org_id_families_for_enterprise_post<'a>( + &self, + sponsoring_org_id: uuid::Uuid, + organization_sponsorship_create_request_model: Option< + models::OrganizationSponsorshipCreateRequestModel, + >, + ) -> Result<(), Error>; + + /// POST /organization/sponsorship/{sponsoringOrgId}/families-for-enterprise/resend + async fn organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post<'a>( + &self, + sponsoring_org_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /organization/sponsorship/{sponsoringOrgId}/sync-status + async fn organization_sponsorship_sponsoring_org_id_sync_status_get<'a>( + &self, + sponsoring_org_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// DELETE /organization/sponsorship/{sponsoringOrganizationId} + async fn organization_sponsorship_sponsoring_organization_id_delete<'a>( + &self, + sponsoring_organization_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organization/sponsorship/{sponsoringOrganizationId}/delete + async fn organization_sponsorship_sponsoring_organization_id_delete_post<'a>( + &self, + sponsoring_organization_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organization/sponsorship/sync + async fn organization_sponsorship_sync_post<'a>( + &self, + organization_sponsorship_sync_request_model: Option< + models::OrganizationSponsorshipSyncRequestModel, + >, + ) -> Result< + models::OrganizationSponsorshipSyncResponseModel, + Error, + >; + + /// POST /organization/sponsorship/validate-token + async fn organization_sponsorship_validate_token_post<'a>( + &self, + sponsorship_token: Option<&'a str>, + ) -> Result< + models::PreValidateSponsorshipResponseModel, + Error, + >; +} + +pub struct OrganizationSponsorshipsApiClient { + configuration: Arc, +} + +impl OrganizationSponsorshipsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl OrganizationSponsorshipsApi for OrganizationSponsorshipsApiClient { + async fn organization_sponsorship_redeem_post<'a>( + &self, + sponsorship_token: Option<&'a str>, + organization_sponsorship_redeem_request_model: Option< + models::OrganizationSponsorshipRedeemRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/redeem", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref param_value) = sponsorship_token { + local_var_req_builder = + local_var_req_builder.query(&[("sponsorshipToken", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_sponsorship_redeem_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_sponsored_sponsored_org_id_delete<'a>( + &self, + sponsored_org_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/sponsored/{sponsoredOrgId}", + local_var_configuration.base_path, + sponsoredOrgId = sponsored_org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationSponsorshipSponsoredSponsoredOrgIdDeleteError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_sponsored_sponsored_org_id_remove_post<'a>( + &self, + sponsored_org_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/sponsored/{sponsoredOrgId}/remove", + local_var_configuration.base_path, + sponsoredOrgId = sponsored_org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationSponsorshipSponsoredSponsoredOrgIdRemovePostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_sponsoring_org_id_families_for_enterprise_post<'a>( + &self, + sponsoring_org_id: uuid::Uuid, + organization_sponsorship_create_request_model: Option< + models::OrganizationSponsorshipCreateRequestModel, + >, + ) -> Result<(), Error> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/{sponsoringOrgId}/families-for-enterprise", + local_var_configuration.base_path, + sponsoringOrgId = sponsoring_org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_sponsorship_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterprisePostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post<'a>( + &self, + sponsoring_org_id: uuid::Uuid, + ) -> Result<(), Error> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/{sponsoringOrgId}/families-for-enterprise/resend", + local_var_configuration.base_path, + sponsoringOrgId = sponsoring_org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterpriseResendPostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_sponsoring_org_id_sync_status_get<'a>( + &self, + sponsoring_org_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/{sponsoringOrgId}/sync-status", + local_var_configuration.base_path, + sponsoringOrgId = sponsoring_org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_sponsoring_organization_id_delete<'a>( + &self, + sponsoring_organization_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/{sponsoringOrganizationId}", + local_var_configuration.base_path, + sponsoringOrganizationId = sponsoring_organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationSponsorshipSponsoringOrganizationIdDeleteError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_sponsoring_organization_id_delete_post<'a>( + &self, + sponsoring_organization_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/{sponsoringOrganizationId}/delete", + local_var_configuration.base_path, + sponsoringOrganizationId = sponsoring_organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationSponsorshipSponsoringOrganizationIdDeletePostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_sync_post<'a>( + &self, + organization_sponsorship_sync_request_model: Option< + models::OrganizationSponsorshipSyncRequestModel, + >, + ) -> Result< + models::OrganizationSponsorshipSyncResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/sync", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_sponsorship_sync_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSponsorshipSyncResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationSponsorshipSyncResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_validate_token_post<'a>( + &self, + sponsorship_token: Option<&'a str>, + ) -> Result< + models::PreValidateSponsorshipResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/validate-token", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref param_value) = sponsorship_token { + local_var_req_builder = + local_var_req_builder.query(&[("sponsorshipToken", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PreValidateSponsorshipResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PreValidateSponsorshipResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`organization_sponsorship_redeem_post`] +/// struct for typed errors of method +/// [`OrganizationSponsorshipsApi::organization_sponsorship_redeem_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipRedeemPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_sponsored_sponsored_org_id_delete`] +/// struct for typed errors of method +/// [`OrganizationSponsorshipsApi::organization_sponsorship_sponsored_sponsored_org_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdDeleteError { @@ -29,7 +623,7 @@ pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdDeleteError { } /// struct for typed errors of method -/// [`organization_sponsorship_sponsored_sponsored_org_id_remove_post`] +/// [`OrganizationSponsorshipsApi::organization_sponsorship_sponsored_sponsored_org_id_remove_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdRemovePostError { @@ -37,7 +631,7 @@ pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdRemovePostError { } /// struct for typed errors of method -/// [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_post`] +/// [`OrganizationSponsorshipsApi::organization_sponsorship_sponsoring_org_id_families_for_enterprise_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterprisePostError { @@ -45,21 +639,23 @@ pub enum OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterprisePostError { } /// struct for typed errors of method -/// [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post`] +/// [`OrganizationSponsorshipsApi::organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterpriseResendPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_sponsoring_org_id_sync_status_get`] +/// struct for typed errors of method +/// [`OrganizationSponsorshipsApi::organization_sponsorship_sponsoring_org_id_sync_status_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoringOrgIdSyncStatusGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_sponsoring_organization_id_delete`] +/// struct for typed errors of method +/// [`OrganizationSponsorshipsApi::organization_sponsorship_sponsoring_organization_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoringOrganizationIdDeleteError { @@ -67,485 +663,25 @@ pub enum OrganizationSponsorshipSponsoringOrganizationIdDeleteError { } /// struct for typed errors of method -/// [`organization_sponsorship_sponsoring_organization_id_delete_post`] +/// [`OrganizationSponsorshipsApi::organization_sponsorship_sponsoring_organization_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoringOrganizationIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_sync_post`] +/// struct for typed errors of method +/// [`OrganizationSponsorshipsApi::organization_sponsorship_sync_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSyncPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_validate_token_post`] +/// struct for typed errors of method +/// [`OrganizationSponsorshipsApi::organization_sponsorship_validate_token_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipValidateTokenPostError { UnknownValue(serde_json::Value), } - -pub async fn organization_sponsorship_redeem_post( - configuration: &configuration::Configuration, - sponsorship_token: Option<&str>, - organization_sponsorship_redeem_request_model: Option< - models::OrganizationSponsorshipRedeemRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsorship_token = sponsorship_token; - let p_organization_sponsorship_redeem_request_model = - organization_sponsorship_redeem_request_model; - - let uri_str = format!( - "{}/organization/sponsorship/redeem", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref param_value) = p_sponsorship_token { - req_builder = req_builder.query(&[("sponsorshipToken", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_sponsorship_redeem_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_sponsored_sponsored_org_id_delete( - configuration: &configuration::Configuration, - sponsored_org_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsored_org_id = sponsored_org_id; - - let uri_str = format!( - "{}/organization/sponsorship/sponsored/{sponsoredOrgId}", - configuration.base_path, - sponsoredOrgId = crate::apis::urlencode(p_sponsored_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_sponsored_sponsored_org_id_remove_post( - configuration: &configuration::Configuration, - sponsored_org_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsored_org_id = sponsored_org_id; - - let uri_str = format!( - "{}/organization/sponsorship/sponsored/{sponsoredOrgId}/remove", - configuration.base_path, - sponsoredOrgId = crate::apis::urlencode(p_sponsored_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_sponsoring_org_id_families_for_enterprise_post( - configuration: &configuration::Configuration, - sponsoring_org_id: uuid::Uuid, - organization_sponsorship_create_request_model: Option< - models::OrganizationSponsorshipCreateRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_org_id = sponsoring_org_id; - let p_organization_sponsorship_create_request_model = - organization_sponsorship_create_request_model; - - let uri_str = format!( - "{}/organization/sponsorship/{sponsoringOrgId}/families-for-enterprise", - configuration.base_path, - sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_sponsorship_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post( - configuration: &configuration::Configuration, - sponsoring_org_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_org_id = sponsoring_org_id; - - let uri_str = format!( - "{}/organization/sponsorship/{sponsoringOrgId}/families-for-enterprise/resend", - configuration.base_path, - sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option< - OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterpriseResendPostError, - > = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_sponsoring_org_id_sync_status_get( - configuration: &configuration::Configuration, - sponsoring_org_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_org_id = sponsoring_org_id; - - let uri_str = format!( - "{}/organization/sponsorship/{sponsoringOrgId}/sync-status", - configuration.base_path, - sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_sponsoring_organization_id_delete( - configuration: &configuration::Configuration, - sponsoring_organization_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_organization_id = sponsoring_organization_id; - - let uri_str = format!( - "{}/organization/sponsorship/{sponsoringOrganizationId}", - configuration.base_path, - sponsoringOrganizationId = crate::apis::urlencode(p_sponsoring_organization_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_sponsoring_organization_id_delete_post( - configuration: &configuration::Configuration, - sponsoring_organization_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_organization_id = sponsoring_organization_id; - - let uri_str = format!( - "{}/organization/sponsorship/{sponsoringOrganizationId}/delete", - configuration.base_path, - sponsoringOrganizationId = crate::apis::urlencode(p_sponsoring_organization_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_sync_post( - configuration: &configuration::Configuration, - organization_sponsorship_sync_request_model: Option< - models::OrganizationSponsorshipSyncRequestModel, - >, -) -> Result< - models::OrganizationSponsorshipSyncResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_sponsorship_sync_request_model = organization_sponsorship_sync_request_model; - - let uri_str = format!("{}/organization/sponsorship/sync", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_sponsorship_sync_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSponsorshipSyncResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationSponsorshipSyncResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_validate_token_post( - configuration: &configuration::Configuration, - sponsorship_token: Option<&str>, -) -> Result< - models::PreValidateSponsorshipResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsorship_token = sponsorship_token; - - let uri_str = format!( - "{}/organization/sponsorship/validate-token", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref param_value) = p_sponsorship_token { - req_builder = req_builder.query(&[("sponsorshipToken", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PreValidateSponsorshipResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PreValidateSponsorshipResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/organization_users_api.rs b/crates/bitwarden-api-api/src/apis/organization_users_api.rs index 6a3430a0d..512e42a8c 100644 --- a/crates/bitwarden-api-api/src/apis/organization_users_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_users_api.rs @@ -8,188 +8,2467 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait OrganizationUsersApi: Send + Sync { + /// POST /organizations/{orgId}/users/account-recovery-details + async fn organizations_org_id_users_account_recovery_details_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserResetPasswordDetailsResponseModelListResponseModel, + Error, + >; + + /// POST /organizations/{orgId}/users/confirm + async fn organizations_org_id_users_confirm_post<'a>( + &self, + org_id: &'a str, + organization_user_bulk_confirm_request_model: Option< + models::OrganizationUserBulkConfirmRequestModel, + >, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + >; + + /// DELETE /organizations/{orgId}/users + async fn organizations_org_id_users_delete<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + >; + + /// DELETE /organizations/{orgId}/users/delete-account + async fn organizations_org_id_users_delete_account_delete<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + >; + + /// POST /organizations/{orgId}/users/delete-account + async fn organizations_org_id_users_delete_account_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + >; + + /// PATCH /organizations/{orgId}/users/enable-secrets-manager + async fn organizations_org_id_users_enable_secrets_manager_patch<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /organizations/{orgId}/users/enable-secrets-manager + async fn organizations_org_id_users_enable_secrets_manager_put<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/users + async fn organizations_org_id_users_get<'a>( + &self, + org_id: uuid::Uuid, + include_groups: Option, + include_collections: Option, + ) -> Result< + models::OrganizationUserUserDetailsResponseModelListResponseModel, + Error, + >; + + /// POST /organizations/{orgId}/users/{id}/confirm + async fn organizations_org_id_users_id_confirm_post<'a>( + &self, + org_id: &'a str, + id: &'a str, + organization_user_confirm_request_model: Option< + models::OrganizationUserConfirmRequestModel, + >, + ) -> Result<(), Error>; + + /// DELETE /organizations/{orgId}/users/{id} + async fn organizations_org_id_users_id_delete<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// DELETE /organizations/{orgId}/users/{id}/delete-account + async fn organizations_org_id_users_id_delete_account_delete<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/users/{id}/delete-account + async fn organizations_org_id_users_id_delete_account_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/users/{id} + async fn organizations_org_id_users_id_get<'a>( + &self, + id: uuid::Uuid, + org_id: &'a str, + include_groups: Option, + ) -> Result< + models::OrganizationUserDetailsResponseModel, + Error, + >; + + /// GET /organizations/{orgId}/users/{id}/groups + async fn organizations_org_id_users_id_groups_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result, Error>; + + /// POST /organizations/{orgId}/users/{id} + async fn organizations_org_id_users_id_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + organization_user_update_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /organizations/{orgId}/users/{id} + async fn organizations_org_id_users_id_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + organization_user_update_request_model: Option, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/users/{id}/reinvite + async fn organizations_org_id_users_id_reinvite_post<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/users/{id}/remove + async fn organizations_org_id_users_id_remove_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/users/{id}/reset-password-details + async fn organizations_org_id_users_id_reset_password_details_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result< + models::OrganizationUserResetPasswordDetailsResponseModel, + Error, + >; + + /// PUT /organizations/{orgId}/users/{id}/reset-password + async fn organizations_org_id_users_id_reset_password_put<'a>( + &self, + org_id: &'a str, + id: &'a str, + organization_user_reset_password_request_model: Option< + models::OrganizationUserResetPasswordRequestModel, + >, + ) -> Result<(), Error>; + + /// PATCH /organizations/{orgId}/users/{id}/restore + async fn organizations_org_id_users_id_restore_patch<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// PUT /organizations/{orgId}/users/{id}/restore + async fn organizations_org_id_users_id_restore_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// PATCH /organizations/{orgId}/users/{id}/revoke + async fn organizations_org_id_users_id_revoke_patch<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// PUT /organizations/{orgId}/users/{id}/revoke + async fn organizations_org_id_users_id_revoke_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/users/invite + async fn organizations_org_id_users_invite_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_invite_request_model: Option, + ) -> Result<(), Error>; + + /// GET /organizations/{orgId}/users/mini-details + async fn organizations_org_id_users_mini_details_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::OrganizationUserUserMiniDetailsResponseModelListResponseModel, + Error, + >; + + /// POST /organizations/{orgId}/users/{organizationUserId}/accept-init + async fn organizations_org_id_users_organization_user_id_accept_init_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_id: uuid::Uuid, + organization_user_accept_init_request_model: Option< + models::OrganizationUserAcceptInitRequestModel, + >, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/users/{organizationUserId}/accept + async fn organizations_org_id_users_organization_user_id_accept_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_id: uuid::Uuid, + organization_user_accept_request_model: Option, + ) -> Result<(), Error>; + + /// POST /organizations/{orgId}/users/public-keys + async fn organizations_org_id_users_public_keys_post<'a>( + &self, + org_id: &'a str, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserPublicKeyResponseModelListResponseModel, + Error, + >; + + /// POST /organizations/{orgId}/users/reinvite + async fn organizations_org_id_users_reinvite_post<'a>( + &self, + org_id: &'a str, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + >; + + /// POST /organizations/{orgId}/users/remove + async fn organizations_org_id_users_remove_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + >; + + /// PATCH /organizations/{orgId}/users/restore + async fn organizations_org_id_users_restore_patch<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + >; + + /// PUT /organizations/{orgId}/users/restore + async fn organizations_org_id_users_restore_put<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + >; + + /// PATCH /organizations/{orgId}/users/revoke + async fn organizations_org_id_users_revoke_patch<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + >; + + /// PUT /organizations/{orgId}/users/revoke + async fn organizations_org_id_users_revoke_put<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + >; + + /// PUT /organizations/{orgId}/users/{userId}/reset-password-enrollment + async fn organizations_org_id_users_user_id_reset_password_enrollment_put<'a>( + &self, + org_id: uuid::Uuid, + user_id: uuid::Uuid, + organization_user_reset_password_enrollment_request_model: Option< + models::OrganizationUserResetPasswordEnrollmentRequestModel, + >, + ) -> Result<(), Error>; +} + +pub struct OrganizationUsersApiClient { + configuration: Arc, +} + +impl OrganizationUsersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl OrganizationUsersApi for OrganizationUsersApiClient { + async fn organizations_org_id_users_account_recovery_details_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserResetPasswordDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/account-recovery-details", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserResetPasswordDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserResetPasswordDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_confirm_post<'a>( + &self, + org_id: &'a str, + organization_user_bulk_confirm_request_model: Option< + models::OrganizationUserBulkConfirmRequestModel, + >, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/confirm", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_user_bulk_confirm_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_delete<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_delete_account_delete<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/delete-account", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_delete_account_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/delete-account", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_enable_secrets_manager_patch<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/enable-secrets-manager", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_enable_secrets_manager_put<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/enable-secrets-manager", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_get<'a>( + &self, + org_id: uuid::Uuid, + include_groups: Option, + include_collections: Option, + ) -> Result< + models::OrganizationUserUserDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = include_groups { + local_var_req_builder = + local_var_req_builder.query(&[("includeGroups", ¶m_value.to_string())]); + } + if let Some(ref param_value) = include_collections { + local_var_req_builder = + local_var_req_builder.query(&[("includeCollections", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserUserDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserUserDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_confirm_post<'a>( + &self, + org_id: &'a str, + id: &'a str, + organization_user_confirm_request_model: Option< + models::OrganizationUserConfirmRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/confirm", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_user_confirm_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_delete<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`organizations_org_id_users_account_recovery_details_post`] + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_delete_account_delete<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/delete-account", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_delete_account_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/delete-account", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_get<'a>( + &self, + id: uuid::Uuid, + org_id: &'a str, + include_groups: Option, + ) -> Result< + models::OrganizationUserDetailsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}", + local_var_configuration.base_path, + id = id, + orgId = crate::apis::urlencode(org_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = include_groups { + local_var_req_builder = + local_var_req_builder.query(&[("includeGroups", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_groups_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result, Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/groups", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<String>`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<String>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + organization_user_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + organization_user_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_reinvite_post<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/reinvite", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_remove_post<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/remove", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_reset_password_details_get<'a>( + &self, + org_id: &'a str, + id: &'a str, + ) -> Result< + models::OrganizationUserResetPasswordDetailsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/reset-password-details", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserResetPasswordDetailsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserResetPasswordDetailsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_reset_password_put<'a>( + &self, + org_id: &'a str, + id: &'a str, + organization_user_reset_password_request_model: Option< + models::OrganizationUserResetPasswordRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/reset-password", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id), + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_user_reset_password_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_restore_patch<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/restore", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_restore_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/restore", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_revoke_patch<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/revoke", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_id_revoke_put<'a>( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{id}/revoke", + local_var_configuration.base_path, + orgId = org_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_invite_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_invite_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/invite", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_invite_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_mini_details_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + models::OrganizationUserUserMiniDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/mini-details", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserUserMiniDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserUserMiniDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_organization_user_id_accept_init_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_id: uuid::Uuid, + organization_user_accept_init_request_model: Option< + models::OrganizationUserAcceptInitRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{organizationUserId}/accept-init", + local_var_configuration.base_path, + orgId = org_id, + organizationUserId = organization_user_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_user_accept_init_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationsOrgIdUsersOrganizationUserIdAcceptInitPostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_organization_user_id_accept_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_id: uuid::Uuid, + organization_user_accept_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{organizationUserId}/accept", + local_var_configuration.base_path, + orgId = org_id, + organizationUserId = organization_user_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_accept_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_public_keys_post<'a>( + &self, + org_id: &'a str, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserPublicKeyResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/public-keys", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserPublicKeyResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserPublicKeyResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_reinvite_post<'a>( + &self, + org_id: &'a str, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/reinvite", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_remove_post<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/remove", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_restore_patch<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/restore", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_restore_put<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/restore", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_revoke_patch<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/revoke", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_revoke_put<'a>( + &self, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, + ) -> Result< + models::OrganizationUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/revoke", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_users_user_id_reset_password_enrollment_put<'a>( + &self, + org_id: uuid::Uuid, + user_id: uuid::Uuid, + organization_user_reset_password_enrollment_request_model: Option< + models::OrganizationUserResetPasswordEnrollmentRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/{userId}/reset-password-enrollment", + local_var_configuration.base_path, + orgId = org_id, + userId = user_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_user_reset_password_enrollment_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationsOrgIdUsersUserIdResetPasswordEnrollmentPutError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_account_recovery_details_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersAccountRecoveryDetailsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_confirm_post`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_confirm_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersConfirmPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_delete`] +/// struct for typed errors of method [`OrganizationUsersApi::organizations_org_id_users_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_delete_account_delete`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_delete_account_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersDeleteAccountDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_delete_account_post`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_delete_account_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersDeleteAccountPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_enable_secrets_manager_patch`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_enable_secrets_manager_patch`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersEnableSecretsManagerPatchError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_enable_secrets_manager_put`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_enable_secrets_manager_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersEnableSecretsManagerPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_get`] +/// struct for typed errors of method [`OrganizationUsersApi::organizations_org_id_users_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_confirm_post`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_confirm_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdConfirmPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_delete`] +/// struct for typed errors of method [`OrganizationUsersApi::organizations_org_id_users_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_delete_account_delete`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_delete_account_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdDeleteAccountDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_delete_account_post`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_delete_account_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdDeleteAccountPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_get`] +/// struct for typed errors of method [`OrganizationUsersApi::organizations_org_id_users_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_groups_get`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_groups_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdGroupsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_post`] +/// struct for typed errors of method [`OrganizationUsersApi::organizations_org_id_users_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_put`] +/// struct for typed errors of method [`OrganizationUsersApi::organizations_org_id_users_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_reinvite_post`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_reinvite_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdReinvitePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_remove_post`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_remove_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdRemovePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_reset_password_details_get`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_reset_password_details_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdResetPasswordDetailsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_reset_password_put`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_reset_password_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdResetPasswordPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_restore_patch`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_restore_patch`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdRestorePatchError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_restore_put`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_restore_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdRestorePutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_revoke_patch`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_revoke_patch`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdRevokePatchError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_id_revoke_put`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_id_revoke_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersIdRevokePutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_invite_post`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_invite_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersInvitePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_mini_details_get`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_mini_details_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersMiniDetailsGetError { @@ -197,7 +2476,7 @@ pub enum OrganizationsOrgIdUsersMiniDetailsGetError { } /// struct for typed errors of method -/// [`organizations_org_id_users_organization_user_id_accept_init_post`] +/// [`OrganizationUsersApi::organizations_org_id_users_organization_user_id_accept_init_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersOrganizationUserIdAcceptInitPostError { @@ -205,56 +2484,63 @@ pub enum OrganizationsOrgIdUsersOrganizationUserIdAcceptInitPostError { } /// struct for typed errors of method -/// [`organizations_org_id_users_organization_user_id_accept_post`] +/// [`OrganizationUsersApi::organizations_org_id_users_organization_user_id_accept_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersOrganizationUserIdAcceptPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_public_keys_post`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_public_keys_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersPublicKeysPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_reinvite_post`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_reinvite_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersReinvitePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_remove_post`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_remove_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersRemovePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_restore_patch`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_restore_patch`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersRestorePatchError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_restore_put`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_restore_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersRestorePutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_revoke_patch`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_revoke_patch`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersRevokePatchError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_revoke_put`] +/// struct for typed errors of method +/// [`OrganizationUsersApi::organizations_org_id_users_revoke_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersRevokePutError { @@ -262,1874 +2548,9 @@ pub enum OrganizationsOrgIdUsersRevokePutError { } /// struct for typed errors of method -/// [`organizations_org_id_users_user_id_reset_password_enrollment_put`] +/// [`OrganizationUsersApi::organizations_org_id_users_user_id_reset_password_enrollment_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersUserIdResetPasswordEnrollmentPutError { UnknownValue(serde_json::Value), } - -pub async fn organizations_org_id_users_account_recovery_details_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserResetPasswordDetailsResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/account-recovery-details", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserResetPasswordDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserResetPasswordDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_confirm_post( - configuration: &configuration::Configuration, - org_id: &str, - organization_user_bulk_confirm_request_model: Option< - models::OrganizationUserBulkConfirmRequestModel, - >, -) -> Result< - models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_confirm_request_model = - organization_user_bulk_confirm_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/confirm", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_confirm_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_delete( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_delete_account_delete( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/delete-account", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_delete_account_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/delete-account", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_enable_secrets_manager_patch( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/enable-secrets-manager", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::PATCH, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_enable_secrets_manager_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/enable-secrets-manager", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - include_groups: Option, - include_collections: Option, -) -> Result< - models::OrganizationUserUserDetailsResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_include_groups = include_groups; - let p_include_collections = include_collections; - - let uri_str = format!( - "{}/organizations/{orgId}/users", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_include_groups { - req_builder = req_builder.query(&[("includeGroups", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_include_collections { - req_builder = req_builder.query(&[("includeCollections", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserUserDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserUserDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_confirm_post( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, - organization_user_confirm_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_organization_user_confirm_request_model = organization_user_confirm_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/confirm", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_confirm_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_delete( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_delete_account_delete( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/delete-account", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_delete_account_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/delete-account", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, - org_id: &str, - include_groups: Option, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_org_id = org_id; - let p_include_groups = include_groups; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()), - orgId = crate::apis::urlencode(p_org_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_include_groups { - req_builder = req_builder.query(&[("includeGroups", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_groups_get( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, -) -> Result, Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/groups", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<String>`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<String>`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, - organization_user_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_organization_user_update_request_model = organization_user_update_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, - organization_user_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_organization_user_update_request_model = organization_user_update_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_reinvite_post( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/reinvite", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_remove_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/remove", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_reset_password_details_get( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, -) -> Result< - models::OrganizationUserResetPasswordDetailsResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/reset-password-details", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserResetPasswordDetailsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserResetPasswordDetailsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_reset_password_put( - configuration: &configuration::Configuration, - org_id: &str, - id: &str, - organization_user_reset_password_request_model: Option< - models::OrganizationUserResetPasswordRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_organization_user_reset_password_request_model = - organization_user_reset_password_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/reset-password", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id), - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_reset_password_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_restore_patch( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/restore", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::PATCH, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_restore_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/restore", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_revoke_patch( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/revoke", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::PATCH, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_id_revoke_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{id}/revoke", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_invite_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_invite_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_invite_request_model = organization_user_invite_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/invite", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_invite_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_mini_details_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result< - models::OrganizationUserUserMiniDetailsResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/organizations/{orgId}/users/mini-details", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserUserMiniDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserUserMiniDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_organization_user_id_accept_init_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_id: uuid::Uuid, - organization_user_accept_init_request_model: Option< - models::OrganizationUserAcceptInitRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_id = organization_user_id; - let p_organization_user_accept_init_request_model = organization_user_accept_init_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{organizationUserId}/accept-init", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - organizationUserId = crate::apis::urlencode(p_organization_user_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_accept_init_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_organization_user_id_accept_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_id: uuid::Uuid, - organization_user_accept_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_id = organization_user_id; - let p_organization_user_accept_request_model = organization_user_accept_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{organizationUserId}/accept", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - organizationUserId = crate::apis::urlencode(p_organization_user_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_accept_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_public_keys_post( - configuration: &configuration::Configuration, - org_id: &str, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserPublicKeyResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/public-keys", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserPublicKeyResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserPublicKeyResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_reinvite_post( - configuration: &configuration::Configuration, - org_id: &str, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/reinvite", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_remove_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/remove", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_restore_patch( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/restore", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::PATCH, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_restore_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/restore", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_revoke_patch( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/revoke", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::PATCH, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_revoke_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - organization_user_bulk_request_model: Option, -) -> Result< - models::OrganizationUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_organization_user_bulk_request_model = organization_user_bulk_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/revoke", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_users_user_id_reset_password_enrollment_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - user_id: uuid::Uuid, - organization_user_reset_password_enrollment_request_model: Option< - models::OrganizationUserResetPasswordEnrollmentRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_user_id = user_id; - let p_organization_user_reset_password_enrollment_request_model = - organization_user_reset_password_enrollment_request_model; - - let uri_str = format!( - "{}/organizations/{orgId}/users/{userId}/reset-password-enrollment", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()), - userId = crate::apis::urlencode(p_user_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_user_reset_password_enrollment_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/organizations_api.rs b/crates/bitwarden-api-api/src/apis/organizations_api.rs index 766e403db..9b92534e5 100644 --- a/crates/bitwarden-api-api/src/apis/organizations_api.rs +++ b/crates/bitwarden-api-api/src/apis/organizations_api.rs @@ -8,2033 +8,2420 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait OrganizationsApi: Send + Sync { + /// POST /organizations/create-without-payment + async fn organizations_create_without_payment_post<'a>( + &self, + organization_no_payment_create_request: Option, + ) -> Result>; + + /// GET /organizations + async fn organizations_get<'a>( + &self, + ) -> Result< + models::ProfileOrganizationResponseModelListResponseModel, + Error, + >; + + /// GET /organizations/{id}/api-key-information/{type} + async fn organizations_id_api_key_information_type_get<'a>( + &self, + id: uuid::Uuid, + r#type: models::OrganizationApiKeyType, + ) -> Result< + models::OrganizationApiKeyInformationListResponseModel, + Error, + >; + + /// POST /organizations/{id}/api-key + async fn organizations_id_api_key_post<'a>( + &self, + id: &'a str, + organization_api_key_request_model: Option, + ) -> Result>; + + /// POST /organizations/{id}/cancel + async fn organizations_id_cancel_post<'a>( + &self, + id: uuid::Uuid, + subscription_cancellation_request_model: Option< + models::SubscriptionCancellationRequestModel, + >, + ) -> Result<(), Error>; + + /// PUT /organizations/{id}/collection-management + async fn organizations_id_collection_management_put<'a>( + &self, + id: uuid::Uuid, + organization_collection_management_update_request_model: Option< + models::OrganizationCollectionManagementUpdateRequestModel, + >, + ) -> Result>; + + /// DELETE /organizations/{id} + async fn organizations_id_delete<'a>( + &self, + id: &'a str, + secret_verification_request_model: Option, + ) -> Result<(), Error>; + + /// POST /organizations/{id}/delete + async fn organizations_id_delete_post<'a>( + &self, + id: &'a str, + secret_verification_request_model: Option, + ) -> Result<(), Error>; + + /// POST /organizations/{id}/delete-recover-token + async fn organizations_id_delete_recover_token_post<'a>( + &self, + id: uuid::Uuid, + organization_verify_delete_recover_request_model: Option< + models::OrganizationVerifyDeleteRecoverRequestModel, + >, + ) -> Result<(), Error>; + + /// GET /organizations/{id} + async fn organizations_id_get<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// GET /organizations/{id}/keys + async fn organizations_id_keys_get<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// POST /organizations/{id}/keys + async fn organizations_id_keys_post<'a>( + &self, + id: &'a str, + organization_keys_request_model: Option, + ) -> Result>; + + /// POST /organizations/{id}/leave + async fn organizations_id_leave_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /organizations/{id}/license + async fn organizations_id_license_get<'a>( + &self, + id: uuid::Uuid, + installation_id: Option, + ) -> Result>; + + /// POST /organizations/{id}/payment + async fn organizations_id_payment_post<'a>( + &self, + id: uuid::Uuid, + payment_request_model: Option, + ) -> Result<(), Error>; + + /// GET /organizations/{id}/plan-type + async fn organizations_id_plan_type_get<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// POST /organizations/{id} + async fn organizations_id_post<'a>( + &self, + id: &'a str, + organization_update_request_model: Option, + ) -> Result>; + + /// GET /organizations/{id}/public-key + async fn organizations_id_public_key_get<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// PUT /organizations/{id} + async fn organizations_id_put<'a>( + &self, + id: &'a str, + organization_update_request_model: Option, + ) -> Result>; + + /// POST /organizations/{id}/reinstate + async fn organizations_id_reinstate_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organizations/{id}/rotate-api-key + async fn organizations_id_rotate_api_key_post<'a>( + &self, + id: &'a str, + organization_api_key_request_model: Option, + ) -> Result>; + + /// POST /organizations/{id}/seat + async fn organizations_id_seat_post<'a>( + &self, + id: uuid::Uuid, + organization_seat_request_model: Option, + ) -> Result>; + + /// POST /organizations/{id}/sm-subscription + async fn organizations_id_sm_subscription_post<'a>( + &self, + id: uuid::Uuid, + secrets_manager_subscription_update_request_model: Option< + models::SecretsManagerSubscriptionUpdateRequestModel, + >, + ) -> Result< + models::ProfileOrganizationResponseModel, + Error, + >; + + /// GET /organizations/{id}/sso + async fn organizations_id_sso_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// POST /organizations/{id}/sso + async fn organizations_id_sso_post<'a>( + &self, + id: uuid::Uuid, + organization_sso_request_model: Option, + ) -> Result>; + + /// POST /organizations/{id}/storage + async fn organizations_id_storage_post<'a>( + &self, + id: &'a str, + storage_request_model: Option, + ) -> Result>; + + /// POST /organizations/{id}/subscribe-secrets-manager + async fn organizations_id_subscribe_secrets_manager_post<'a>( + &self, + id: uuid::Uuid, + secrets_manager_subscribe_request_model: Option< + models::SecretsManagerSubscribeRequestModel, + >, + ) -> Result< + models::ProfileOrganizationResponseModel, + Error, + >; + + /// GET /organizations/{id}/subscription + async fn organizations_id_subscription_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::OrganizationSubscriptionResponseModel, + Error, + >; + + /// POST /organizations/{id}/subscription + async fn organizations_id_subscription_post<'a>( + &self, + id: uuid::Uuid, + organization_subscription_update_request_model: Option< + models::OrganizationSubscriptionUpdateRequestModel, + >, + ) -> Result>; + + /// GET /organizations/{id}/tax + async fn organizations_id_tax_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// PUT /organizations/{id}/tax + async fn organizations_id_tax_put<'a>( + &self, + id: uuid::Uuid, + expanded_tax_info_update_request_model: Option, + ) -> Result<(), Error>; + + /// POST /organizations/{id}/upgrade + async fn organizations_id_upgrade_post<'a>( + &self, + id: uuid::Uuid, + organization_upgrade_request_model: Option, + ) -> Result>; + + /// POST /organizations/{id}/verify-bank + async fn organizations_id_verify_bank_post<'a>( + &self, + id: uuid::Uuid, + organization_verify_bank_request_model: Option, + ) -> Result<(), Error>; + + /// GET /organizations/{identifier}/auto-enroll-status + async fn organizations_identifier_auto_enroll_status_get<'a>( + &self, + identifier: &'a str, + ) -> Result< + models::OrganizationAutoEnrollStatusResponseModel, + Error, + >; + + /// POST /organizations + async fn organizations_post<'a>( + &self, + organization_create_request_model: Option, + ) -> Result>; +} + +pub struct OrganizationsApiClient { + configuration: Arc, +} + +impl OrganizationsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl OrganizationsApi for OrganizationsApiClient { + async fn organizations_create_without_payment_post<'a>( + &self, + organization_no_payment_create_request: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/create-without-payment", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_no_payment_create_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_get<'a>( + &self, + ) -> Result< + models::ProfileOrganizationResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/organizations", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileOrganizationResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProfileOrganizationResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_api_key_information_type_get<'a>( + &self, + id: uuid::Uuid, + r#type: models::OrganizationApiKeyType, + ) -> Result< + models::OrganizationApiKeyInformationListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/organizations/{id}/api-key-information/{type}", local_var_configuration.base_path, id=id, type=r#type.to_string()); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationApiKeyInformationListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationApiKeyInformationListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_api_key_post<'a>( + &self, + id: &'a str, + organization_api_key_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/api-key", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_api_key_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ApiKeyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_cancel_post<'a>( + &self, + id: uuid::Uuid, + subscription_cancellation_request_model: Option< + models::SubscriptionCancellationRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/cancel", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&subscription_cancellation_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_collection_management_put<'a>( + &self, + id: uuid::Uuid, + organization_collection_management_update_request_model: Option< + models::OrganizationCollectionManagementUpdateRequestModel, + >, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/collection-management", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_collection_management_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_delete<'a>( + &self, + id: &'a str, + secret_verification_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_delete_post<'a>( + &self, + id: &'a str, + secret_verification_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/delete", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_delete_recover_token_post<'a>( + &self, + id: uuid::Uuid, + organization_verify_delete_recover_request_model: Option< + models::OrganizationVerifyDeleteRecoverRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/delete-recover-token", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_verify_delete_recover_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_get<'a>( + &self, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_keys_get<'a>( + &self, + id: &'a str, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/keys", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationPublicKeyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationPublicKeyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_keys_post<'a>( + &self, + id: &'a str, + organization_keys_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/keys", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_keys_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationKeysResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationKeysResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_leave_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/leave", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_license_get<'a>( + &self, + id: uuid::Uuid, + installation_id: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/license", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = installation_id { + local_var_req_builder = + local_var_req_builder.query(&[("installationId", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationLicense`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationLicense`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_payment_post<'a>( + &self, + id: uuid::Uuid, + payment_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/payment", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&payment_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_plan_type_get<'a>( + &self, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/plan-type", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PlanType`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PlanType`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_post<'a>( + &self, + id: &'a str, + organization_update_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_public_key_get<'a>( + &self, + id: &'a str, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/public-key", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationPublicKeyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationPublicKeyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_put<'a>( + &self, + id: &'a str, + organization_update_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_reinstate_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/reinstate", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_rotate_api_key_post<'a>( + &self, + id: &'a str, + organization_api_key_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/rotate-api-key", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_api_key_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ApiKeyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_seat_post<'a>( + &self, + id: uuid::Uuid, + organization_seat_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/seat", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_seat_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PaymentResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_sm_subscription_post<'a>( + &self, + id: uuid::Uuid, + secrets_manager_subscription_update_request_model: Option< + models::SecretsManagerSubscriptionUpdateRequestModel, + >, + ) -> Result< + models::ProfileOrganizationResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/sm-subscription", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&secrets_manager_subscription_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_sso_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/sso", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSsoResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationSsoResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_sso_post<'a>( + &self, + id: uuid::Uuid, + organization_sso_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/sso", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_sso_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSsoResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationSsoResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_storage_post<'a>( + &self, + id: &'a str, + storage_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/storage", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&storage_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PaymentResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_subscribe_secrets_manager_post<'a>( + &self, + id: uuid::Uuid, + secrets_manager_subscribe_request_model: Option< + models::SecretsManagerSubscribeRequestModel, + >, + ) -> Result< + models::ProfileOrganizationResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/subscribe-secrets-manager", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&secrets_manager_subscribe_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_subscription_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::OrganizationSubscriptionResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/subscription", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSubscriptionResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationSubscriptionResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_subscription_post<'a>( + &self, + id: uuid::Uuid, + organization_subscription_update_request_model: Option< + models::OrganizationSubscriptionUpdateRequestModel, + >, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/subscription", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_subscription_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_tax_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`organizations_create_without_payment_post`] + let local_var_uri_str = format!( + "{}/organizations/{id}/tax", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TaxInfoResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TaxInfoResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_tax_put<'a>( + &self, + id: uuid::Uuid, + expanded_tax_info_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/tax", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&expanded_tax_info_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_upgrade_post<'a>( + &self, + id: uuid::Uuid, + organization_upgrade_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/upgrade", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_upgrade_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PaymentResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_verify_bank_post<'a>( + &self, + id: uuid::Uuid, + organization_verify_bank_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/verify-bank", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_verify_bank_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_identifier_auto_enroll_status_get<'a>( + &self, + identifier: &'a str, + ) -> Result< + models::OrganizationAutoEnrollStatusResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{identifier}/auto-enroll-status", + local_var_configuration.base_path, + identifier = crate::apis::urlencode(identifier) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationAutoEnrollStatusResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationAutoEnrollStatusResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_post<'a>( + &self, + organization_create_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/organizations", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method +/// [`OrganizationsApi::organizations_create_without_payment_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsCreateWithoutPaymentPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_get`] +/// struct for typed errors of method [`OrganizationsApi::organizations_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_api_key_information_type_get`] +/// struct for typed errors of method +/// [`OrganizationsApi::organizations_id_api_key_information_type_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdApiKeyInformationTypeGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_api_key_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_api_key_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdApiKeyPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_cancel_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_cancel_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdCancelPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_collection_management_put`] +/// struct for typed errors of method +/// [`OrganizationsApi::organizations_id_collection_management_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdCollectionManagementPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_delete`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_delete_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_delete_recover_token_post`] +/// struct for typed errors of method +/// [`OrganizationsApi::organizations_id_delete_recover_token_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdDeleteRecoverTokenPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_get`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_keys_get`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_keys_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdKeysGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_keys_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_keys_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdKeysPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_leave_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_leave_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdLeavePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_license_get`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_license_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdLicenseGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_payment_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_payment_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdPaymentPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_plan_type_get`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_plan_type_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdPlanTypeGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_public_key_get`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_public_key_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdPublicKeyGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_put`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_reinstate_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_reinstate_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdReinstatePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_rotate_api_key_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_rotate_api_key_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdRotateApiKeyPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_seat_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_seat_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdSeatPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_sm_subscription_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_sm_subscription_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdSmSubscriptionPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_sso_get`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_sso_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdSsoGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_sso_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_sso_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdSsoPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_storage_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_storage_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdStoragePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_subscribe_secrets_manager_post`] +/// struct for typed errors of method +/// [`OrganizationsApi::organizations_id_subscribe_secrets_manager_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdSubscribeSecretsManagerPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_subscription_get`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_subscription_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdSubscriptionGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_subscription_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_subscription_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdSubscriptionPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_tax_get`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_tax_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdTaxGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_tax_put`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_tax_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdTaxPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_upgrade_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_upgrade_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdUpgradePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_verify_bank_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_id_verify_bank_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdVerifyBankPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_identifier_auto_enroll_status_get`] +/// struct for typed errors of method +/// [`OrganizationsApi::organizations_identifier_auto_enroll_status_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdentifierAutoEnrollStatusGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_post`] +/// struct for typed errors of method [`OrganizationsApi::organizations_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsPostError { UnknownValue(serde_json::Value), } - -pub async fn organizations_create_without_payment_post( - configuration: &configuration::Configuration, - organization_no_payment_create_request: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_no_payment_create_request = organization_no_payment_create_request; - - let uri_str = format!( - "{}/organizations/create-without-payment", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_no_payment_create_request); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_get( - configuration: &configuration::Configuration, -) -> Result> -{ - let uri_str = format!("{}/organizations", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileOrganizationResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileOrganizationResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_api_key_information_type_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, - r#type: models::OrganizationApiKeyType, -) -> Result< - models::OrganizationApiKeyInformationListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_type = r#type; - - let uri_str = format!("{}/organizations/{id}/api-key-information/{type}", configuration.base_path, id=crate::apis::urlencode(p_id.to_string()), type=p_type.to_string()); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationApiKeyInformationListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationApiKeyInformationListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_api_key_post( - configuration: &configuration::Configuration, - id: &str, - organization_api_key_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_api_key_request_model = organization_api_key_request_model; - - let uri_str = format!( - "{}/organizations/{id}/api-key", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_api_key_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApiKeyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_cancel_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - subscription_cancellation_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_subscription_cancellation_request_model = subscription_cancellation_request_model; - - let uri_str = format!( - "{}/organizations/{id}/cancel", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_subscription_cancellation_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_collection_management_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - organization_collection_management_update_request_model: Option< - models::OrganizationCollectionManagementUpdateRequestModel, - >, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_collection_management_update_request_model = - organization_collection_management_update_request_model; - - let uri_str = format!( - "{}/organizations/{id}/collection-management", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_collection_management_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_delete( - configuration: &configuration::Configuration, - id: &str, - secret_verification_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!( - "{}/organizations/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_delete_post( - configuration: &configuration::Configuration, - id: &str, - secret_verification_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!( - "{}/organizations/{id}/delete", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_delete_recover_token_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - organization_verify_delete_recover_request_model: Option< - models::OrganizationVerifyDeleteRecoverRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_verify_delete_recover_request_model = - organization_verify_delete_recover_request_model; - - let uri_str = format!( - "{}/organizations/{id}/delete-recover-token", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_verify_delete_recover_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_get( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_keys_get( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/keys", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationPublicKeyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationPublicKeyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_keys_post( - configuration: &configuration::Configuration, - id: &str, - organization_keys_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_keys_request_model = organization_keys_request_model; - - let uri_str = format!( - "{}/organizations/{id}/keys", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_keys_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationKeysResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationKeysResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_leave_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/leave", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_license_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, - installation_id: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_installation_id = installation_id; - - let uri_str = format!( - "{}/organizations/{id}/license", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_installation_id { - req_builder = req_builder.query(&[("installationId", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationLicense`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationLicense`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_payment_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - payment_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_payment_request_model = payment_request_model; - - let uri_str = format!( - "{}/organizations/{id}/payment", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_payment_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_plan_type_get( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/plan-type", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PlanType`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PlanType`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_post( - configuration: &configuration::Configuration, - id: &str, - organization_update_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_update_request_model = organization_update_request_model; - - let uri_str = format!( - "{}/organizations/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_public_key_get( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/public-key", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationPublicKeyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationPublicKeyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_put( - configuration: &configuration::Configuration, - id: &str, - organization_update_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_update_request_model = organization_update_request_model; - - let uri_str = format!( - "{}/organizations/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_reinstate_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/reinstate", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_rotate_api_key_post( - configuration: &configuration::Configuration, - id: &str, - organization_api_key_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_api_key_request_model = organization_api_key_request_model; - - let uri_str = format!( - "{}/organizations/{id}/rotate-api-key", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_api_key_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApiKeyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_seat_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - organization_seat_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_seat_request_model = organization_seat_request_model; - - let uri_str = format!( - "{}/organizations/{id}/seat", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_seat_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaymentResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_sm_subscription_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - secrets_manager_subscription_update_request_model: Option< - models::SecretsManagerSubscriptionUpdateRequestModel, - >, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_secrets_manager_subscription_update_request_model = - secrets_manager_subscription_update_request_model; - - let uri_str = format!( - "{}/organizations/{id}/sm-subscription", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secrets_manager_subscription_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_sso_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/sso", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSsoResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationSsoResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_sso_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - organization_sso_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_sso_request_model = organization_sso_request_model; - - let uri_str = format!( - "{}/organizations/{id}/sso", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_sso_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSsoResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationSsoResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_storage_post( - configuration: &configuration::Configuration, - id: &str, - storage_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_storage_request_model = storage_request_model; - - let uri_str = format!( - "{}/organizations/{id}/storage", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_storage_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaymentResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_subscribe_secrets_manager_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - secrets_manager_subscribe_request_model: Option, -) -> Result< - models::ProfileOrganizationResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_secrets_manager_subscribe_request_model = secrets_manager_subscribe_request_model; - - let uri_str = format!( - "{}/organizations/{id}/subscribe-secrets-manager", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secrets_manager_subscribe_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_subscription_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/subscription", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSubscriptionResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationSubscriptionResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_subscription_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - organization_subscription_update_request_model: Option< - models::OrganizationSubscriptionUpdateRequestModel, - >, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_subscription_update_request_model = - organization_subscription_update_request_model; - - let uri_str = format!( - "{}/organizations/{id}/subscription", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_subscription_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileOrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_tax_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/tax", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TaxInfoResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TaxInfoResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_tax_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - expanded_tax_info_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_expanded_tax_info_update_request_model = expanded_tax_info_update_request_model; - - let uri_str = format!( - "{}/organizations/{id}/tax", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_expanded_tax_info_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_upgrade_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - organization_upgrade_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_upgrade_request_model = organization_upgrade_request_model; - - let uri_str = format!( - "{}/organizations/{id}/upgrade", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_upgrade_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaymentResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_verify_bank_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - organization_verify_bank_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_organization_verify_bank_request_model = organization_verify_bank_request_model; - - let uri_str = format!( - "{}/organizations/{id}/verify-bank", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_verify_bank_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_identifier_auto_enroll_status_get( - configuration: &configuration::Configuration, - identifier: &str, -) -> Result< - models::OrganizationAutoEnrollStatusResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - - let uri_str = format!( - "{}/organizations/{identifier}/auto-enroll-status", - configuration.base_path, - identifier = crate::apis::urlencode(p_identifier) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationAutoEnrollStatusResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationAutoEnrollStatusResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_post( - configuration: &configuration::Configuration, - organization_create_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_create_request_model = organization_create_request_model; - - let uri_str = format!("{}/organizations", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/plans_api.rs b/crates/bitwarden-api-api/src/apis/plans_api.rs index 7fccf0bac..079a21f1b 100644 --- a/crates/bitwarden-api-api/src/apis/plans_api.rs +++ b/crates/bitwarden-api-api/src/apis/plans_api.rs @@ -8,57 +8,94 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`plans_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PlansGetError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait PlansApi: Send + Sync { + /// GET /plans + async fn plans_get<'a>( + &self, + ) -> Result>; } -pub async fn plans_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/plans", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +pub struct PlansApiClient { + configuration: Arc, +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +impl PlansApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; +} + +#[async_trait(?Send)] +impl PlansApi for PlansApiClient { + async fn plans_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_uri_str = format!("{}/plans", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PlanResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PlanResponseModelListResponseModel`")))), + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PlanResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PlanResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } + +/// struct for typed errors of method [`PlansApi::plans_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PlansGetError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/policies_api.rs b/crates/bitwarden-api-api/src/apis/policies_api.rs index 0418f6fa9..2e7339fa6 100644 --- a/crates/bitwarden-api-api/src/apis/policies_api.rs +++ b/crates/bitwarden-api-api/src/apis/policies_api.rs @@ -8,382 +8,480 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait PoliciesApi: Send + Sync { + /// GET /organizations/{orgId}/policies + async fn organizations_org_id_policies_get<'a>( + &self, + org_id: &'a str, + ) -> Result< + models::PolicyResponseModelListResponseModel, + Error, + >; + + /// GET /organizations/{orgId}/policies/invited-user + async fn organizations_org_id_policies_invited_user_get<'a>( + &self, + org_id: uuid::Uuid, + user_id: Option, + ) -> Result< + models::PolicyResponseModelListResponseModel, + Error, + >; + + /// GET /organizations/{orgId}/policies/master-password + async fn organizations_org_id_policies_master_password_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result>; + + /// GET /organizations/{orgId}/policies/token + async fn organizations_org_id_policies_token_get<'a>( + &self, + org_id: uuid::Uuid, + email: Option<&'a str>, + token: Option<&'a str>, + organization_user_id: Option, + ) -> Result< + models::PolicyResponseModelListResponseModel, + Error, + >; + + /// GET /organizations/{orgId}/policies/{type} + async fn organizations_org_id_policies_type_get<'a>( + &self, + org_id: uuid::Uuid, + r#type: i32, + ) -> Result>; + + /// PUT /organizations/{orgId}/policies/{type} + async fn organizations_org_id_policies_type_put<'a>( + &self, + org_id: uuid::Uuid, + r#type: models::PolicyType, + policy_request_model: Option, + ) -> Result>; +} + +pub struct PoliciesApiClient { + configuration: Arc, +} + +impl PoliciesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl PoliciesApi for PoliciesApiClient { + async fn organizations_org_id_policies_get<'a>( + &self, + org_id: &'a str, + ) -> Result< + models::PolicyResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/policies", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_policies_invited_user_get<'a>( + &self, + org_id: uuid::Uuid, + user_id: Option, + ) -> Result< + models::PolicyResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/policies/invited-user", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = user_id { + local_var_req_builder = + local_var_req_builder.query(&[("userId", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_policies_master_password_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/policies/master-password", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PolicyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_policies_token_get<'a>( + &self, + org_id: uuid::Uuid, + email: Option<&'a str>, + token: Option<&'a str>, + organization_user_id: Option, + ) -> Result< + models::PolicyResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/policies/token", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = email { + local_var_req_builder = + local_var_req_builder.query(&[("email", ¶m_value.to_string())]); + } + if let Some(ref param_value) = token { + local_var_req_builder = + local_var_req_builder.query(&[("token", ¶m_value.to_string())]); + } + if let Some(ref param_value) = organization_user_id { + local_var_req_builder = + local_var_req_builder.query(&[("organizationUserId", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_policies_type_get<'a>( + &self, + org_id: uuid::Uuid, + r#type: i32, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/organizations/{orgId}/policies/{type}", local_var_configuration.base_path, orgId=org_id, type=r#type); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyDetailResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PolicyDetailResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_org_id_policies_type_put<'a>( + &self, + org_id: uuid::Uuid, + r#type: models::PolicyType, + policy_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/organizations/{orgId}/policies/{type}", local_var_configuration.base_path, orgId=org_id, type=r#type.to_string()); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&policy_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PolicyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`organizations_org_id_policies_get`] +/// struct for typed errors of method [`PoliciesApi::organizations_org_id_policies_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdPoliciesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_policies_invited_user_get`] +/// struct for typed errors of method +/// [`PoliciesApi::organizations_org_id_policies_invited_user_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdPoliciesInvitedUserGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_policies_master_password_get`] +/// struct for typed errors of method +/// [`PoliciesApi::organizations_org_id_policies_master_password_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdPoliciesMasterPasswordGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_policies_token_get`] +/// struct for typed errors of method [`PoliciesApi::organizations_org_id_policies_token_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdPoliciesTokenGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_policies_type_get`] +/// struct for typed errors of method [`PoliciesApi::organizations_org_id_policies_type_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdPoliciesTypeGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_policies_type_put`] +/// struct for typed errors of method [`PoliciesApi::organizations_org_id_policies_type_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdPoliciesTypePutError { UnknownValue(serde_json::Value), } - -pub async fn organizations_org_id_policies_get( - configuration: &configuration::Configuration, - org_id: &str, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/organizations/{orgId}/policies", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_policies_invited_user_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - user_id: Option, -) -> Result< - models::PolicyResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_user_id = user_id; - - let uri_str = format!( - "{}/organizations/{orgId}/policies/invited-user", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_user_id { - req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_policies_master_password_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/organizations/{orgId}/policies/master-password", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PolicyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_policies_token_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - email: Option<&str>, - token: Option<&str>, - organization_user_id: Option, -) -> Result< - models::PolicyResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_email = email; - let p_token = token; - let p_organization_user_id = organization_user_id; - - let uri_str = format!( - "{}/organizations/{orgId}/policies/token", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_email { - req_builder = req_builder.query(&[("email", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_token { - req_builder = req_builder.query(&[("token", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_organization_user_id { - req_builder = req_builder.query(&[("organizationUserId", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_policies_type_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - r#type: i32, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_type = r#type; - - let uri_str = format!("{}/organizations/{orgId}/policies/{type}", configuration.base_path, orgId=crate::apis::urlencode(p_org_id.to_string()), type=p_type); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyDetailResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PolicyDetailResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_org_id_policies_type_put( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - r#type: models::PolicyType, - policy_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_type = r#type; - let p_policy_request_model = policy_request_model; - - let uri_str = format!("{}/organizations/{orgId}/policies/{type}", configuration.base_path, orgId=crate::apis::urlencode(p_org_id.to_string()), type=p_type.to_string()); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_policy_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PolicyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/projects_api.rs b/crates/bitwarden-api-api/src/apis/projects_api.rs index 685b8ade9..4dd9f9962 100644 --- a/crates/bitwarden-api-api/src/apis/projects_api.rs +++ b/crates/bitwarden-api-api/src/apis/projects_api.rs @@ -8,305 +8,379 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait ProjectsApi: Send + Sync { + /// GET /organizations/{organizationId}/projects + async fn organizations_organization_id_projects_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result< + models::ProjectResponseModelListResponseModel, + Error, + >; + + /// POST /organizations/{organizationId}/projects + async fn organizations_organization_id_projects_post<'a>( + &self, + organization_id: uuid::Uuid, + project_create_request_model: Option, + ) -> Result>; + + /// POST /projects/delete + async fn projects_delete_post<'a>( + &self, + uuid_colon_colon_uuid: Option>, + ) -> Result>; + + /// GET /projects/{id} + async fn projects_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// PUT /projects/{id} + async fn projects_id_put<'a>( + &self, + id: uuid::Uuid, + project_update_request_model: Option, + ) -> Result>; +} + +pub struct ProjectsApiClient { + configuration: Arc, +} + +impl ProjectsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl ProjectsApi for ProjectsApiClient { + async fn organizations_organization_id_projects_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result< + models::ProjectResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/projects", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_projects_post<'a>( + &self, + organization_id: uuid::Uuid, + project_create_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/projects", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&project_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn projects_delete_post<'a>( + &self, + uuid_colon_colon_uuid: Option>, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/projects/delete", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn projects_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/projects/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn projects_id_put<'a>( + &self, + id: uuid::Uuid, + project_update_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/projects/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&project_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`organizations_organization_id_projects_get`] +/// struct for typed errors of method [`ProjectsApi::organizations_organization_id_projects_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdProjectsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_projects_post`] +/// struct for typed errors of method [`ProjectsApi::organizations_organization_id_projects_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdProjectsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`projects_delete_post`] +/// struct for typed errors of method [`ProjectsApi::projects_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProjectsDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`projects_id_get`] +/// struct for typed errors of method [`ProjectsApi::projects_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProjectsIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`projects_id_put`] +/// struct for typed errors of method [`ProjectsApi::projects_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProjectsIdPutError { UnknownValue(serde_json::Value), } - -pub async fn organizations_organization_id_projects_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result< - models::ProjectResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/projects", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_projects_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - project_create_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_project_create_request_model = project_create_request_model; - - let uri_str = format!( - "{}/organizations/{organizationId}/projects", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_project_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn projects_delete_post( - configuration: &configuration::Configuration, - uuid_colon_colon_uuid: Option>, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_uuid_colon_colon_uuid = uuid_colon_colon_uuid; - - let uri_str = format!("{}/projects/delete", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_uuid_colon_colon_uuid); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn projects_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/projects/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn projects_id_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - project_update_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_project_update_request_model = project_update_request_model; - - let uri_str = format!( - "{}/projects/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_project_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/provider_billing_api.rs b/crates/bitwarden-api-api/src/apis/provider_billing_api.rs index e2e0533a5..b390e54b6 100644 --- a/crates/bitwarden-api-api/src/apis/provider_billing_api.rs +++ b/crates/bitwarden-api-api/src/apis/provider_billing_api.rs @@ -8,202 +8,271 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait ProviderBillingApi: Send + Sync { + /// GET /providers/{providerId}/billing/invoices + async fn providers_provider_id_billing_invoices_get<'a>( + &self, + provider_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /providers/{providerId}/billing/invoices/{invoiceId} + async fn providers_provider_id_billing_invoices_invoice_id_get<'a>( + &self, + provider_id: uuid::Uuid, + invoice_id: &'a str, + ) -> Result<(), Error>; + + /// GET /providers/{providerId}/billing/subscription + async fn providers_provider_id_billing_subscription_get<'a>( + &self, + provider_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// PUT /providers/{providerId}/billing/tax-information + async fn providers_provider_id_billing_tax_information_put<'a>( + &self, + provider_id: uuid::Uuid, + tax_information_request_body: Option, + ) -> Result<(), Error>; +} + +pub struct ProviderBillingApiClient { + configuration: Arc, +} + +impl ProviderBillingApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl ProviderBillingApi for ProviderBillingApiClient { + async fn providers_provider_id_billing_invoices_get<'a>( + &self, + provider_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/invoices", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_billing_invoices_invoice_id_get<'a>( + &self, + provider_id: uuid::Uuid, + invoice_id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/invoices/{invoiceId}", + local_var_configuration.base_path, + providerId = provider_id, + invoiceId = crate::apis::urlencode(invoice_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_billing_subscription_get<'a>( + &self, + provider_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/subscription", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); -/// struct for typed errors of method [`providers_provider_id_billing_invoices_get`] + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_billing_tax_information_put<'a>( + &self, + provider_id: uuid::Uuid, + tax_information_request_body: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/tax-information", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&tax_information_request_body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method +/// [`ProviderBillingApi::providers_provider_id_billing_invoices_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdBillingInvoicesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_billing_invoices_invoice_id_get`] +/// struct for typed errors of method +/// [`ProviderBillingApi::providers_provider_id_billing_invoices_invoice_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdBillingInvoicesInvoiceIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_billing_subscription_get`] +/// struct for typed errors of method +/// [`ProviderBillingApi::providers_provider_id_billing_subscription_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdBillingSubscriptionGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_billing_tax_information_put`] +/// struct for typed errors of method +/// [`ProviderBillingApi::providers_provider_id_billing_tax_information_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdBillingTaxInformationPutError { UnknownValue(serde_json::Value), } - -pub async fn providers_provider_id_billing_invoices_get( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - - let uri_str = format!( - "{}/providers/{providerId}/billing/invoices", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_billing_invoices_invoice_id_get( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - invoice_id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_invoice_id = invoice_id; - - let uri_str = format!( - "{}/providers/{providerId}/billing/invoices/{invoiceId}", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - invoiceId = crate::apis::urlencode(p_invoice_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_billing_subscription_get( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - - let uri_str = format!( - "{}/providers/{providerId}/billing/subscription", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_billing_tax_information_put( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - tax_information_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_tax_information_request_body = tax_information_request_body; - - let uri_str = format!( - "{}/providers/{providerId}/billing/tax-information", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_tax_information_request_body); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/provider_clients_api.rs b/crates/bitwarden-api-api/src/apis/provider_clients_api.rs index 4548086b6..f75a9bb6a 100644 --- a/crates/bitwarden-api-api/src/apis/provider_clients_api.rs +++ b/crates/bitwarden-api-api/src/apis/provider_clients_api.rs @@ -8,212 +8,286 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait ProviderClientsApi: Send + Sync { + /// GET /providers/{providerId}/clients/addable + async fn providers_provider_id_clients_addable_get<'a>( + &self, + provider_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /providers/{providerId}/clients/existing + async fn providers_provider_id_clients_existing_post<'a>( + &self, + provider_id: uuid::Uuid, + add_existing_organization_request_body: Option, + ) -> Result<(), Error>; + + /// POST /providers/{providerId}/clients + async fn providers_provider_id_clients_post<'a>( + &self, + provider_id: uuid::Uuid, + create_client_organization_request_body: Option< + models::CreateClientOrganizationRequestBody, + >, + ) -> Result<(), Error>; + + /// PUT /providers/{providerId}/clients/{providerOrganizationId} + async fn providers_provider_id_clients_provider_organization_id_put<'a>( + &self, + provider_id: uuid::Uuid, + provider_organization_id: uuid::Uuid, + update_client_organization_request_body: Option< + models::UpdateClientOrganizationRequestBody, + >, + ) -> Result<(), Error>; +} + +pub struct ProviderClientsApiClient { + configuration: Arc, +} + +impl ProviderClientsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl ProviderClientsApi for ProviderClientsApiClient { + async fn providers_provider_id_clients_addable_get<'a>( + &self, + provider_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/clients/addable", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_clients_existing_post<'a>( + &self, + provider_id: uuid::Uuid, + add_existing_organization_request_body: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/clients/existing", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&add_existing_organization_request_body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_clients_post<'a>( + &self, + provider_id: uuid::Uuid, + create_client_organization_request_body: Option< + models::CreateClientOrganizationRequestBody, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/clients", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`providers_provider_id_clients_addable_get`] + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&create_client_organization_request_body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_clients_provider_organization_id_put<'a>( + &self, + provider_id: uuid::Uuid, + provider_organization_id: uuid::Uuid, + update_client_organization_request_body: Option< + models::UpdateClientOrganizationRequestBody, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/clients/{providerOrganizationId}", + local_var_configuration.base_path, + providerId = provider_id, + providerOrganizationId = provider_organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&update_client_organization_request_body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method +/// [`ProviderClientsApi::providers_provider_id_clients_addable_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdClientsAddableGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_clients_existing_post`] +/// struct for typed errors of method +/// [`ProviderClientsApi::providers_provider_id_clients_existing_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdClientsExistingPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_clients_post`] +/// struct for typed errors of method [`ProviderClientsApi::providers_provider_id_clients_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdClientsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_clients_provider_organization_id_put`] +/// struct for typed errors of method +/// [`ProviderClientsApi::providers_provider_id_clients_provider_organization_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdClientsProviderOrganizationIdPutError { UnknownValue(serde_json::Value), } - -pub async fn providers_provider_id_clients_addable_get( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - - let uri_str = format!( - "{}/providers/{providerId}/clients/addable", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_clients_existing_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - add_existing_organization_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_add_existing_organization_request_body = add_existing_organization_request_body; - - let uri_str = format!( - "{}/providers/{providerId}/clients/existing", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_add_existing_organization_request_body); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_clients_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - create_client_organization_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_create_client_organization_request_body = create_client_organization_request_body; - - let uri_str = format!( - "{}/providers/{providerId}/clients", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_create_client_organization_request_body); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_clients_provider_organization_id_put( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - provider_organization_id: uuid::Uuid, - update_client_organization_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_provider_organization_id = provider_organization_id; - let p_update_client_organization_request_body = update_client_organization_request_body; - - let uri_str = format!( - "{}/providers/{providerId}/clients/{providerOrganizationId}", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - providerOrganizationId = crate::apis::urlencode(p_provider_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_client_organization_request_body); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/provider_organizations_api.rs b/crates/bitwarden-api-api/src/apis/provider_organizations_api.rs index 6b7306ed7..0bf6e0656 100644 --- a/crates/bitwarden-api-api/src/apis/provider_organizations_api.rs +++ b/crates/bitwarden-api-api/src/apis/provider_organizations_api.rs @@ -8,293 +8,377 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait ProviderOrganizationsApi: Send + Sync { + /// POST /providers/{providerId}/organizations/add + async fn providers_provider_id_organizations_add_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_organization_add_request_model: Option< + models::ProviderOrganizationAddRequestModel, + >, + ) -> Result<(), Error>; + + /// GET /providers/{providerId}/organizations + async fn providers_provider_id_organizations_get<'a>( + &self, + provider_id: uuid::Uuid, + ) -> Result< + models::ProviderOrganizationOrganizationDetailsResponseModelListResponseModel, + Error, + >; + + /// DELETE /providers/{providerId}/organizations/{id} + async fn providers_provider_id_organizations_id_delete<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /providers/{providerId}/organizations/{id}/delete + async fn providers_provider_id_organizations_id_delete_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /providers/{providerId}/organizations + async fn providers_provider_id_organizations_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_organization_create_request_model: Option< + models::ProviderOrganizationCreateRequestModel, + >, + ) -> Result< + models::ProviderOrganizationResponseModel, + Error, + >; +} + +pub struct ProviderOrganizationsApiClient { + configuration: Arc, +} + +impl ProviderOrganizationsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl ProviderOrganizationsApi for ProviderOrganizationsApiClient { + async fn providers_provider_id_organizations_add_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_organization_add_request_model: Option< + models::ProviderOrganizationAddRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/organizations/add", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&provider_organization_add_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_organizations_get<'a>( + &self, + provider_id: uuid::Uuid, + ) -> Result< + models::ProviderOrganizationOrganizationDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/organizations", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderOrganizationOrganizationDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderOrganizationOrganizationDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_organizations_id_delete<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/organizations/{id}", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_organizations_id_delete_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/organizations/{id}/delete", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_organizations_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_organization_create_request_model: Option< + models::ProviderOrganizationCreateRequestModel, + >, + ) -> Result< + models::ProviderOrganizationResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/organizations", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&provider_organization_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderOrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderOrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`providers_provider_id_organizations_add_post`] +/// struct for typed errors of method +/// [`ProviderOrganizationsApi::providers_provider_id_organizations_add_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdOrganizationsAddPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_organizations_get`] +/// struct for typed errors of method +/// [`ProviderOrganizationsApi::providers_provider_id_organizations_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdOrganizationsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_organizations_id_delete`] +/// struct for typed errors of method +/// [`ProviderOrganizationsApi::providers_provider_id_organizations_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdOrganizationsIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_organizations_id_delete_post`] +/// struct for typed errors of method +/// [`ProviderOrganizationsApi::providers_provider_id_organizations_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdOrganizationsIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_organizations_post`] +/// struct for typed errors of method +/// [`ProviderOrganizationsApi::providers_provider_id_organizations_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdOrganizationsPostError { UnknownValue(serde_json::Value), } - -pub async fn providers_provider_id_organizations_add_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - provider_organization_add_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_provider_organization_add_request_model = provider_organization_add_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/organizations/add", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_organization_add_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_organizations_get( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, -) -> Result< - models::ProviderOrganizationOrganizationDetailsResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - - let uri_str = format!( - "{}/providers/{providerId}/organizations", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderOrganizationOrganizationDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderOrganizationOrganizationDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_organizations_id_delete( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - - let uri_str = format!( - "{}/providers/{providerId}/organizations/{id}", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_organizations_id_delete_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - - let uri_str = format!( - "{}/providers/{providerId}/organizations/{id}/delete", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_organizations_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - provider_organization_create_request_model: Option< - models::ProviderOrganizationCreateRequestModel, - >, -) -> Result< - models::ProviderOrganizationResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_provider_organization_create_request_model = provider_organization_create_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/organizations", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_organization_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderOrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderOrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/provider_users_api.rs b/crates/bitwarden-api-api/src/apis/provider_users_api.rs index 63a30f89e..7affa0044 100644 --- a/crates/bitwarden-api-api/src/apis/provider_users_api.rs +++ b/crates/bitwarden-api-api/src/apis/provider_users_api.rs @@ -8,885 +8,1059 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait ProviderUsersApi: Send + Sync { + /// POST /providers/{providerId}/users/confirm + async fn providers_provider_id_users_confirm_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_confirm_request_model: Option< + models::ProviderUserBulkConfirmRequestModel, + >, + ) -> Result< + models::ProviderUserBulkResponseModelListResponseModel, + Error, + >; + + /// DELETE /providers/{providerId}/users + async fn providers_provider_id_users_delete<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_request_model: Option, + ) -> Result< + models::ProviderUserBulkResponseModelListResponseModel, + Error, + >; + + /// POST /providers/{providerId}/users/delete + async fn providers_provider_id_users_delete_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_request_model: Option, + ) -> Result< + models::ProviderUserBulkResponseModelListResponseModel, + Error, + >; + + /// GET /providers/{providerId}/users + async fn providers_provider_id_users_get<'a>( + &self, + provider_id: uuid::Uuid, + ) -> Result< + models::ProviderUserUserDetailsResponseModelListResponseModel, + Error, + >; + + /// POST /providers/{providerId}/users/{id}/accept + async fn providers_provider_id_users_id_accept_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + provider_user_accept_request_model: Option, + ) -> Result<(), Error>; + + /// POST /providers/{providerId}/users/{id}/confirm + async fn providers_provider_id_users_id_confirm_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + provider_user_confirm_request_model: Option, + ) -> Result<(), Error>; + + /// DELETE /providers/{providerId}/users/{id} + async fn providers_provider_id_users_id_delete<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /providers/{providerId}/users/{id}/delete + async fn providers_provider_id_users_id_delete_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// GET /providers/{providerId}/users/{id} + async fn providers_provider_id_users_id_get<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result>; + + /// POST /providers/{providerId}/users/{id} + async fn providers_provider_id_users_id_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + provider_user_update_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /providers/{providerId}/users/{id} + async fn providers_provider_id_users_id_put<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + provider_user_update_request_model: Option, + ) -> Result<(), Error>; + + /// POST /providers/{providerId}/users/{id}/reinvite + async fn providers_provider_id_users_id_reinvite_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /providers/{providerId}/users/invite + async fn providers_provider_id_users_invite_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_invite_request_model: Option, + ) -> Result<(), Error>; + + /// POST /providers/{providerId}/users/public-keys + async fn providers_provider_id_users_public_keys_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_request_model: Option, + ) -> Result< + models::ProviderUserPublicKeyResponseModelListResponseModel, + Error, + >; + + /// POST /providers/{providerId}/users/reinvite + async fn providers_provider_id_users_reinvite_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_request_model: Option, + ) -> Result< + models::ProviderUserBulkResponseModelListResponseModel, + Error, + >; +} + +pub struct ProviderUsersApiClient { + configuration: Arc, +} + +impl ProviderUsersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl ProviderUsersApi for ProviderUsersApiClient { + async fn providers_provider_id_users_confirm_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_confirm_request_model: Option< + models::ProviderUserBulkConfirmRequestModel, + >, + ) -> Result< + models::ProviderUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/confirm", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&provider_user_bulk_confirm_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_delete<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_request_model: Option, + ) -> Result< + models::ProviderUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_delete_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_request_model: Option, + ) -> Result< + models::ProviderUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/delete", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_get<'a>( + &self, + provider_id: uuid::Uuid, + ) -> Result< + models::ProviderUserUserDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserUserDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderUserUserDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_id_accept_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + provider_user_accept_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/{id}/accept", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_user_accept_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_id_confirm_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + provider_user_confirm_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/{id}/confirm", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_user_confirm_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_id_delete<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/{id}", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_id_delete_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/{id}/delete", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_id_get<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/{id}", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderUserResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_id_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + provider_user_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/{id}", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_user_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_id_put<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + provider_user_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/{id}", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_user_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_id_reinvite_post<'a>( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/{id}/reinvite", + local_var_configuration.base_path, + providerId = provider_id, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_invite_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_invite_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/invite", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_user_invite_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_public_keys_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_request_model: Option, + ) -> Result< + models::ProviderUserPublicKeyResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/public-keys", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserPublicKeyResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderUserPublicKeyResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_provider_id_users_reinvite_post<'a>( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_request_model: Option, + ) -> Result< + models::ProviderUserBulkResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/users/reinvite", + local_var_configuration.base_path, + providerId = provider_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`providers_provider_id_users_confirm_post`] +/// struct for typed errors of method [`ProviderUsersApi::providers_provider_id_users_confirm_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersConfirmPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_delete`] +/// struct for typed errors of method [`ProviderUsersApi::providers_provider_id_users_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_delete_post`] +/// struct for typed errors of method [`ProviderUsersApi::providers_provider_id_users_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_get`] +/// struct for typed errors of method [`ProviderUsersApi::providers_provider_id_users_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_id_accept_post`] +/// struct for typed errors of method +/// [`ProviderUsersApi::providers_provider_id_users_id_accept_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersIdAcceptPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_id_confirm_post`] +/// struct for typed errors of method +/// [`ProviderUsersApi::providers_provider_id_users_id_confirm_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersIdConfirmPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_id_delete`] +/// struct for typed errors of method [`ProviderUsersApi::providers_provider_id_users_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_id_delete_post`] +/// struct for typed errors of method +/// [`ProviderUsersApi::providers_provider_id_users_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_id_get`] +/// struct for typed errors of method [`ProviderUsersApi::providers_provider_id_users_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_id_post`] +/// struct for typed errors of method [`ProviderUsersApi::providers_provider_id_users_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_id_put`] +/// struct for typed errors of method [`ProviderUsersApi::providers_provider_id_users_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_id_reinvite_post`] +/// struct for typed errors of method +/// [`ProviderUsersApi::providers_provider_id_users_id_reinvite_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersIdReinvitePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_invite_post`] +/// struct for typed errors of method [`ProviderUsersApi::providers_provider_id_users_invite_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersInvitePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_public_keys_post`] +/// struct for typed errors of method +/// [`ProviderUsersApi::providers_provider_id_users_public_keys_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersPublicKeysPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_provider_id_users_reinvite_post`] +/// struct for typed errors of method +/// [`ProviderUsersApi::providers_provider_id_users_reinvite_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersProviderIdUsersReinvitePostError { UnknownValue(serde_json::Value), } - -pub async fn providers_provider_id_users_confirm_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - provider_user_bulk_confirm_request_model: Option, -) -> Result< - models::ProviderUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_provider_user_bulk_confirm_request_model = provider_user_bulk_confirm_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/users/confirm", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_user_bulk_confirm_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_delete( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - provider_user_bulk_request_model: Option, -) -> Result< - models::ProviderUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_provider_user_bulk_request_model = provider_user_bulk_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/users", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_delete_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - provider_user_bulk_request_model: Option, -) -> Result< - models::ProviderUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_provider_user_bulk_request_model = provider_user_bulk_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/users/delete", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_get( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, -) -> Result< - models::ProviderUserUserDetailsResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - - let uri_str = format!( - "{}/providers/{providerId}/users", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserUserDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderUserUserDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_id_accept_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, - provider_user_accept_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - let p_provider_user_accept_request_model = provider_user_accept_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/users/{id}/accept", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_user_accept_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_id_confirm_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, - provider_user_confirm_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - let p_provider_user_confirm_request_model = provider_user_confirm_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/users/{id}/confirm", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_user_confirm_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_id_delete( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - - let uri_str = format!( - "{}/providers/{providerId}/users/{id}", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_id_delete_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - - let uri_str = format!( - "{}/providers/{providerId}/users/{id}/delete", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_id_get( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - - let uri_str = format!( - "{}/providers/{providerId}/users/{id}", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderUserResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_id_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, - provider_user_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - let p_provider_user_update_request_model = provider_user_update_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/users/{id}", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_user_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_id_put( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, - provider_user_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - let p_provider_user_update_request_model = provider_user_update_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/users/{id}", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_user_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_id_reinvite_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - - let uri_str = format!( - "{}/providers/{providerId}/users/{id}/reinvite", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()), - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_invite_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - provider_user_invite_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_provider_user_invite_request_model = provider_user_invite_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/users/invite", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_user_invite_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_public_keys_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - provider_user_bulk_request_model: Option, -) -> Result< - models::ProviderUserPublicKeyResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_provider_user_bulk_request_model = provider_user_bulk_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/users/public-keys", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserPublicKeyResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderUserPublicKeyResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_provider_id_users_reinvite_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - provider_user_bulk_request_model: Option, -) -> Result< - models::ProviderUserBulkResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_provider_user_bulk_request_model = provider_user_bulk_request_model; - - let uri_str = format!( - "{}/providers/{providerId}/users/reinvite", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_user_bulk_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderUserBulkResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/providers_api.rs b/crates/bitwarden-api-api/src/apis/providers_api.rs index 0c68114f6..5732ec73e 100644 --- a/crates/bitwarden-api-api/src/apis/providers_api.rs +++ b/crates/bitwarden-api-api/src/apis/providers_api.rs @@ -8,400 +8,489 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait ProvidersApi: Send + Sync { + /// DELETE /providers/{id} + async fn providers_id_delete<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /providers/{id}/delete + async fn providers_id_delete_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /providers/{id}/delete-recover-token + async fn providers_id_delete_recover_token_post<'a>( + &self, + id: uuid::Uuid, + provider_verify_delete_recover_request_model: Option< + models::ProviderVerifyDeleteRecoverRequestModel, + >, + ) -> Result<(), Error>; + + /// GET /providers/{id} + async fn providers_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// POST /providers/{id} + async fn providers_id_post<'a>( + &self, + id: uuid::Uuid, + provider_update_request_model: Option, + ) -> Result>; + + /// PUT /providers/{id} + async fn providers_id_put<'a>( + &self, + id: uuid::Uuid, + provider_update_request_model: Option, + ) -> Result>; + + /// POST /providers/{id}/setup + async fn providers_id_setup_post<'a>( + &self, + id: uuid::Uuid, + provider_setup_request_model: Option, + ) -> Result>; +} + +pub struct ProvidersApiClient { + configuration: Arc, +} + +impl ProvidersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl ProvidersApi for ProvidersApiClient { + async fn providers_id_delete<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_id_delete_post<'a>( + &self, + id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{id}/delete", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_id_delete_recover_token_post<'a>( + &self, + id: uuid::Uuid, + provider_verify_delete_recover_request_model: Option< + models::ProviderVerifyDeleteRecoverRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{id}/delete-recover-token", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&provider_verify_delete_recover_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_id_post<'a>( + &self, + id: uuid::Uuid, + provider_update_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_id_put<'a>( + &self, + id: uuid::Uuid, + provider_update_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn providers_id_setup_post<'a>( + &self, + id: uuid::Uuid, + provider_setup_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{id}/setup", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&provider_setup_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProviderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`providers_id_delete`] +/// struct for typed errors of method [`ProvidersApi::providers_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_id_delete_post`] +/// struct for typed errors of method [`ProvidersApi::providers_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_id_delete_recover_token_post`] +/// struct for typed errors of method [`ProvidersApi::providers_id_delete_recover_token_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersIdDeleteRecoverTokenPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_id_get`] +/// struct for typed errors of method [`ProvidersApi::providers_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_id_post`] +/// struct for typed errors of method [`ProvidersApi::providers_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_id_put`] +/// struct for typed errors of method [`ProvidersApi::providers_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`providers_id_setup_post`] +/// struct for typed errors of method [`ProvidersApi::providers_id_setup_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProvidersIdSetupPostError { UnknownValue(serde_json::Value), } - -pub async fn providers_id_delete( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/providers/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_id_delete_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/providers/{id}/delete", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_id_delete_recover_token_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - provider_verify_delete_recover_request_model: Option< - models::ProviderVerifyDeleteRecoverRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_provider_verify_delete_recover_request_model = - provider_verify_delete_recover_request_model; - - let uri_str = format!( - "{}/providers/{id}/delete-recover-token", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_verify_delete_recover_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/providers/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_id_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - provider_update_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_provider_update_request_model = provider_update_request_model; - - let uri_str = format!( - "{}/providers/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_id_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - provider_update_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_provider_update_request_model = provider_update_request_model; - - let uri_str = format!( - "{}/providers/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn providers_id_setup_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - provider_setup_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_provider_setup_request_model = provider_setup_request_model; - - let uri_str = format!( - "{}/providers/{id}/setup", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_provider_setup_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProviderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProviderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/push_api.rs b/crates/bitwarden-api-api/src/apis/push_api.rs index ffb97bf11..1ea9dde2b 100644 --- a/crates/bitwarden-api-api/src/apis/push_api.rs +++ b/crates/bitwarden-api-api/src/apis/push_api.rs @@ -8,229 +8,309 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait PushApi: Send + Sync { + /// PUT /push/add-organization + async fn push_add_organization_put<'a>( + &self, + push_update_request_model: Option, + ) -> Result<(), Error>; + + /// PUT /push/delete-organization + async fn push_delete_organization_put<'a>( + &self, + push_update_request_model: Option, + ) -> Result<(), Error>; + + /// POST /push/delete + async fn push_delete_post<'a>( + &self, + push_device_request_model: Option, + ) -> Result<(), Error>; + + /// POST /push/register + async fn push_register_post<'a>( + &self, + push_registration_request_model: Option, + ) -> Result<(), Error>; + + /// POST /push/send + async fn push_send_post<'a>( + &self, + push_send_request_model: Option, + ) -> Result<(), Error>; +} + +pub struct PushApiClient { + configuration: Arc, +} + +impl PushApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl PushApi for PushApiClient { + async fn push_add_organization_put<'a>( + &self, + push_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/push/add-organization", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&push_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn push_delete_organization_put<'a>( + &self, + push_update_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/push/delete-organization", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&push_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn push_delete_post<'a>( + &self, + push_device_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/push/delete", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&push_device_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn push_register_post<'a>( + &self, + push_registration_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/push/register", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&push_registration_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn push_send_post<'a>( + &self, + push_send_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/push/send", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&push_send_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`push_add_organization_put`] +/// struct for typed errors of method [`PushApi::push_add_organization_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum PushAddOrganizationPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`push_delete_organization_put`] +/// struct for typed errors of method [`PushApi::push_delete_organization_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum PushDeleteOrganizationPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`push_delete_post`] +/// struct for typed errors of method [`PushApi::push_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum PushDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`push_register_post`] +/// struct for typed errors of method [`PushApi::push_register_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum PushRegisterPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`push_send_post`] +/// struct for typed errors of method [`PushApi::push_send_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum PushSendPostError { UnknownValue(serde_json::Value), } - -pub async fn push_add_organization_put( - configuration: &configuration::Configuration, - push_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_push_update_request_model = push_update_request_model; - - let uri_str = format!("{}/push/add-organization", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_push_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn push_delete_organization_put( - configuration: &configuration::Configuration, - push_update_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_push_update_request_model = push_update_request_model; - - let uri_str = format!("{}/push/delete-organization", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_push_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn push_delete_post( - configuration: &configuration::Configuration, - push_device_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_push_device_request_model = push_device_request_model; - - let uri_str = format!("{}/push/delete", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_push_device_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn push_register_post( - configuration: &configuration::Configuration, - push_registration_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_push_registration_request_model = push_registration_request_model; - - let uri_str = format!("{}/push/register", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_push_registration_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn push_send_post( - configuration: &configuration::Configuration, - push_send_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_push_send_request_model = push_send_request_model; - - let uri_str = format!("{}/push/send", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_push_send_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/reports_api.rs b/crates/bitwarden-api-api/src/apis/reports_api.rs index e30bccd89..e9cfd410b 100644 --- a/crates/bitwarden-api-api/src/apis/reports_api.rs +++ b/crates/bitwarden-api-api/src/apis/reports_api.rs @@ -8,367 +8,469 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait ReportsApi: Send + Sync { + /// GET /reports/member-access/{orgId} + async fn reports_member_access_org_id_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result, Error>; + + /// GET /reports/member-cipher-details/{orgId} + async fn reports_member_cipher_details_org_id_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + Vec, + Error, + >; + + /// DELETE /reports/password-health-report-application + async fn reports_password_health_report_application_delete<'a>( + &self, + drop_password_health_report_application_request: Option< + models::DropPasswordHealthReportApplicationRequest, + >, + ) -> Result<(), Error>; + + /// POST /reports/password-health-report-application + async fn reports_password_health_report_application_post<'a>( + &self, + password_health_report_application_model: Option< + models::PasswordHealthReportApplicationModel, + >, + ) -> Result< + models::PasswordHealthReportApplication, + Error, + >; + + /// GET /reports/password-health-report-applications/{orgId} + async fn reports_password_health_report_applications_org_id_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + Vec, + Error, + >; + + /// POST /reports/password-health-report-applications + async fn reports_password_health_report_applications_post<'a>( + &self, + password_health_report_application_model: Option< + Vec, + >, + ) -> Result< + Vec, + Error, + >; +} + +pub struct ReportsApiClient { + configuration: Arc, +} + +impl ReportsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl ReportsApi for ReportsApiClient { + async fn reports_member_access_org_id_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result, Error> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/reports/member-access/{orgId}", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::MemberAccessReportResponseModel>`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::MemberAccessReportResponseModel>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn reports_member_cipher_details_org_id_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + Vec, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/reports/member-cipher-details/{orgId}", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::MemberCipherDetailsResponseModel>`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::MemberCipherDetailsResponseModel>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`reports_member_access_org_id_get`] + async fn reports_password_health_report_application_delete<'a>( + &self, + drop_password_health_report_application_request: Option< + models::DropPasswordHealthReportApplicationRequest, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/reports/password-health-report-application", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&drop_password_health_report_application_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn reports_password_health_report_application_post<'a>( + &self, + password_health_report_application_model: Option< + models::PasswordHealthReportApplicationModel, + >, + ) -> Result< + models::PasswordHealthReportApplication, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/reports/password-health-report-application", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&password_health_report_application_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PasswordHealthReportApplication`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PasswordHealthReportApplication`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn reports_password_health_report_applications_org_id_get<'a>( + &self, + org_id: uuid::Uuid, + ) -> Result< + Vec, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/reports/password-health-report-applications/{orgId}", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn reports_password_health_report_applications_post<'a>( + &self, + password_health_report_application_model: Option< + Vec, + >, + ) -> Result< + Vec, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/reports/password-health-report-applications", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&password_health_report_application_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`ReportsApi::reports_member_access_org_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ReportsMemberAccessOrgIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`reports_member_cipher_details_org_id_get`] +/// struct for typed errors of method [`ReportsApi::reports_member_cipher_details_org_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ReportsMemberCipherDetailsOrgIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`reports_password_health_report_application_delete`] +/// struct for typed errors of method +/// [`ReportsApi::reports_password_health_report_application_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ReportsPasswordHealthReportApplicationDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`reports_password_health_report_application_post`] +/// struct for typed errors of method +/// [`ReportsApi::reports_password_health_report_application_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ReportsPasswordHealthReportApplicationPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`reports_password_health_report_applications_org_id_get`] +/// struct for typed errors of method +/// [`ReportsApi::reports_password_health_report_applications_org_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ReportsPasswordHealthReportApplicationsOrgIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`reports_password_health_report_applications_post`] +/// struct for typed errors of method +/// [`ReportsApi::reports_password_health_report_applications_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ReportsPasswordHealthReportApplicationsPostError { UnknownValue(serde_json::Value), } - -pub async fn reports_member_access_org_id_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result, Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/reports/member-access/{orgId}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::MemberAccessReportResponseModel>`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::MemberAccessReportResponseModel>`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn reports_member_cipher_details_org_id_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result< - Vec, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/reports/member-cipher-details/{orgId}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::MemberCipherDetailsResponseModel>`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::MemberCipherDetailsResponseModel>`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn reports_password_health_report_application_delete( - configuration: &configuration::Configuration, - drop_password_health_report_application_request: Option< - models::DropPasswordHealthReportApplicationRequest, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_drop_password_health_report_application_request = - drop_password_health_report_application_request; - - let uri_str = format!( - "{}/reports/password-health-report-application", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_drop_password_health_report_application_request); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn reports_password_health_report_application_post( - configuration: &configuration::Configuration, - password_health_report_application_model: Option, -) -> Result< - models::PasswordHealthReportApplication, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_password_health_report_application_model = password_health_report_application_model; - - let uri_str = format!( - "{}/reports/password-health-report-application", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_password_health_report_application_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PasswordHealthReportApplication`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PasswordHealthReportApplication`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn reports_password_health_report_applications_org_id_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result< - Vec, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/reports/password-health-report-applications/{orgId}", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn reports_password_health_report_applications_post( - configuration: &configuration::Configuration, - password_health_report_application_model: Option< - Vec, - >, -) -> Result< - Vec, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_password_health_report_application_model = password_health_report_application_model; - - let uri_str = format!( - "{}/reports/password-health-report-applications", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_password_health_report_application_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::PasswordHealthReportApplication>`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/request_sm_access_api.rs b/crates/bitwarden-api-api/src/apis/request_sm_access_api.rs index 0c3ec8aef..2892abfab 100644 --- a/crates/bitwarden-api-api/src/apis/request_sm_access_api.rs +++ b/crates/bitwarden-api-api/src/apis/request_sm_access_api.rs @@ -8,57 +8,90 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`request_access_request_sm_access_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum RequestAccessRequestSmAccessPostError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait RequestSmAccessApi: Send + Sync { + /// POST /request-access/request-sm-access + async fn request_access_request_sm_access_post<'a>( + &self, + request_sm_access_request_model: Option, + ) -> Result<(), Error>; } -pub async fn request_access_request_sm_access_post( - configuration: &configuration::Configuration, - request_sm_access_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_request_sm_access_request_model = request_sm_access_request_model; - - let uri_str = format!( - "{}/request-access/request-sm-access", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +pub struct RequestSmAccessApiClient { + configuration: Arc, +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +impl RequestSmAccessApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_request_sm_access_request_model); +} + +#[async_trait(?Send)] +impl RequestSmAccessApi for RequestSmAccessApiClient { + async fn request_access_request_sm_access_post<'a>( + &self, + request_sm_access_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_client = &local_var_configuration.client; - let status = resp.status(); + let local_var_uri_str = format!( + "{}/request-access/request-sm-access", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&request_sm_access_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } } + +/// struct for typed errors of method [`RequestSmAccessApi::request_access_request_sm_access_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RequestAccessRequestSmAccessPostError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/secrets_api.rs b/crates/bitwarden-api-api/src/apis/secrets_api.rs index a75c7d8c4..b2c07c40f 100644 --- a/crates/bitwarden-api-api/src/apis/secrets_api.rs +++ b/crates/bitwarden-api-api/src/apis/secrets_api.rs @@ -8,482 +8,591 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait SecretsApi: Send + Sync { + /// GET /organizations/{organizationId}/secrets + async fn organizations_organization_id_secrets_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result< + models::SecretWithProjectsListResponseModel, + Error, + >; + + /// POST /organizations/{organizationId}/secrets + async fn organizations_organization_id_secrets_post<'a>( + &self, + organization_id: uuid::Uuid, + secret_create_request_model: Option, + ) -> Result>; + + /// GET /organizations/{organizationId}/secrets/sync + async fn organizations_organization_id_secrets_sync_get<'a>( + &self, + organization_id: uuid::Uuid, + last_synced_date: Option, + ) -> Result< + models::SecretsSyncResponseModel, + Error, + >; + + /// GET /projects/{projectId}/secrets + async fn projects_project_id_secrets_get<'a>( + &self, + project_id: uuid::Uuid, + ) -> Result>; + + /// POST /secrets/delete + async fn secrets_delete_post<'a>( + &self, + uuid_colon_colon_uuid: Option>, + ) -> Result>; + + /// POST /secrets/get-by-ids + async fn secrets_get_by_ids_post<'a>( + &self, + get_secrets_request_model: Option, + ) -> Result>; + + /// GET /secrets/{id} + async fn secrets_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// PUT /secrets/{id} + async fn secrets_id_put<'a>( + &self, + id: uuid::Uuid, + secret_update_request_model: Option, + ) -> Result>; +} + +pub struct SecretsApiClient { + configuration: Arc, +} + +impl SecretsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl SecretsApi for SecretsApiClient { + async fn organizations_organization_id_secrets_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result< + models::SecretWithProjectsListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/secrets", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_secrets_post<'a>( + &self, + organization_id: uuid::Uuid, + secret_create_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/secrets", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecretResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_secrets_sync_get<'a>( + &self, + organization_id: uuid::Uuid, + last_synced_date: Option, + ) -> Result< + models::SecretsSyncResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/secrets/sync", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = last_synced_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastSyncedDate", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretsSyncResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecretsSyncResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn projects_project_id_secrets_get<'a>( + &self, + project_id: uuid::Uuid, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/projects/{projectId}/secrets", + local_var_configuration.base_path, + projectId = project_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn secrets_delete_post<'a>( + &self, + uuid_colon_colon_uuid: Option>, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/secrets/delete", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn secrets_get_by_ids_post<'a>( + &self, + get_secrets_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/secrets/get-by-ids", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&get_secrets_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BaseSecretResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::BaseSecretResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn secrets_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/secrets/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecretResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn secrets_id_put<'a>( + &self, + id: uuid::Uuid, + secret_update_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/secrets/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecretResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`organizations_organization_id_secrets_get`] +/// struct for typed errors of method [`SecretsApi::organizations_organization_id_secrets_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdSecretsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_secrets_post`] +/// struct for typed errors of method [`SecretsApi::organizations_organization_id_secrets_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdSecretsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_secrets_sync_get`] +/// struct for typed errors of method [`SecretsApi::organizations_organization_id_secrets_sync_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdSecretsSyncGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`projects_project_id_secrets_get`] +/// struct for typed errors of method [`SecretsApi::projects_project_id_secrets_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ProjectsProjectIdSecretsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`secrets_delete_post`] +/// struct for typed errors of method [`SecretsApi::secrets_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SecretsDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`secrets_get_by_ids_post`] +/// struct for typed errors of method [`SecretsApi::secrets_get_by_ids_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SecretsGetByIdsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`secrets_id_get`] +/// struct for typed errors of method [`SecretsApi::secrets_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SecretsIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`secrets_id_put`] +/// struct for typed errors of method [`SecretsApi::secrets_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SecretsIdPutError { UnknownValue(serde_json::Value), } - -pub async fn organizations_organization_id_secrets_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result< - models::SecretWithProjectsListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/secrets", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_secrets_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - secret_create_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_secret_create_request_model = secret_create_request_model; - - let uri_str = format!( - "{}/organizations/{organizationId}/secrets", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecretResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_secrets_sync_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - last_synced_date: Option, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_last_synced_date = last_synced_date; - - let uri_str = format!( - "{}/organizations/{organizationId}/secrets/sync", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_last_synced_date { - req_builder = req_builder.query(&[("lastSyncedDate", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretsSyncResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecretsSyncResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn projects_project_id_secrets_get( - configuration: &configuration::Configuration, - project_id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_project_id = project_id; - - let uri_str = format!( - "{}/projects/{projectId}/secrets", - configuration.base_path, - projectId = crate::apis::urlencode(p_project_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn secrets_delete_post( - configuration: &configuration::Configuration, - uuid_colon_colon_uuid: Option>, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_uuid_colon_colon_uuid = uuid_colon_colon_uuid; - - let uri_str = format!("{}/secrets/delete", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_uuid_colon_colon_uuid); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn secrets_get_by_ids_post( - configuration: &configuration::Configuration, - get_secrets_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_get_secrets_request_model = get_secrets_request_model; - - let uri_str = format!("{}/secrets/get-by-ids", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_get_secrets_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BaseSecretResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BaseSecretResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn secrets_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/secrets/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecretResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn secrets_id_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - secret_update_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_secret_update_request_model = secret_update_request_model; - - let uri_str = format!( - "{}/secrets/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecretResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/secrets_manager_events_api.rs b/crates/bitwarden-api-api/src/apis/secrets_manager_events_api.rs index f83b19ec5..7431672d8 100644 --- a/crates/bitwarden-api-api/src/apis/secrets_manager_events_api.rs +++ b/crates/bitwarden-api-api/src/apis/secrets_manager_events_api.rs @@ -8,84 +8,125 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`sm_events_service_accounts_service_account_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SmEventsServiceAccountsServiceAccountIdGetError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait SecretsManagerEventsApi: Send + Sync { + /// GET /sm/events/service-accounts/{serviceAccountId} + async fn sm_events_service_accounts_service_account_id_get<'a>( + &self, + service_account_id: uuid::Uuid, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result< + models::EventResponseModelListResponseModel, + Error, + >; } -pub async fn sm_events_service_accounts_service_account_id_get( - configuration: &configuration::Configuration, - service_account_id: uuid::Uuid, - start: Option, - end: Option, - continuation_token: Option<&str>, -) -> Result< - models::EventResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_service_account_id = service_account_id; - let p_start = start; - let p_end = end; - let p_continuation_token = continuation_token; - - let uri_str = format!( - "{}/sm/events/service-accounts/{serviceAccountId}", - configuration.base_path, - serviceAccountId = crate::apis::urlencode(p_service_account_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +pub struct SecretsManagerEventsApiClient { + configuration: Arc, +} - if let Some(ref param_value) = p_start { - req_builder = req_builder.query(&[("start", ¶m_value.to_string())]); +impl SecretsManagerEventsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref param_value) = p_end { - req_builder = req_builder.query(&[("end", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_continuation_token { - req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; +} + +#[async_trait(?Send)] +impl SecretsManagerEventsApi for SecretsManagerEventsApiClient { + async fn sm_events_service_accounts_service_account_id_get<'a>( + &self, + service_account_id: uuid::Uuid, + start: Option, + end: Option, + continuation_token: Option<&'a str>, + ) -> Result< + models::EventResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_client = &local_var_configuration.client; - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); + let local_var_uri_str = format!( + "{}/sm/events/service-accounts/{serviceAccountId}", + local_var_configuration.base_path, + serviceAccountId = service_account_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), + if let Some(ref param_value) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", ¶m_value.to_string())]); + } + if let Some(ref param_value) = end { + local_var_req_builder = + local_var_req_builder.query(&[("end", ¶m_value.to_string())]); + } + if let Some(ref param_value) = continuation_token { + local_var_req_builder = + local_var_req_builder.query(&[("continuationToken", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EventResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } + +/// struct for typed errors of method +/// [`SecretsManagerEventsApi::sm_events_service_accounts_service_account_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SmEventsServiceAccountsServiceAccountIdGetError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/secrets_manager_porting_api.rs b/crates/bitwarden-api-api/src/apis/secrets_manager_porting_api.rs index 077432717..3b6d858c4 100644 --- a/crates/bitwarden-api-api/src/apis/secrets_manager_porting_api.rs +++ b/crates/bitwarden-api-api/src/apis/secrets_manager_porting_api.rs @@ -8,116 +8,160 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait SecretsManagerPortingApi: Send + Sync { + /// GET /sm/{organizationId}/export + async fn sm_organization_id_export_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result>; + + /// POST /sm/{organizationId}/import + async fn sm_organization_id_import_post<'a>( + &self, + organization_id: uuid::Uuid, + sm_import_request_model: Option, + ) -> Result<(), Error>; +} + +pub struct SecretsManagerPortingApiClient { + configuration: Arc, +} + +impl SecretsManagerPortingApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} -/// struct for typed errors of method [`sm_organization_id_export_get`] +#[async_trait(?Send)] +impl SecretsManagerPortingApi for SecretsManagerPortingApiClient { + async fn sm_organization_id_export_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sm/{organizationId}/export", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SmExportResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SmExportResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sm_organization_id_import_post<'a>( + &self, + organization_id: uuid::Uuid, + sm_import_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sm/{organizationId}/import", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&sm_import_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`SecretsManagerPortingApi::sm_organization_id_export_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SmOrganizationIdExportGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sm_organization_id_import_post`] +/// struct for typed errors of method [`SecretsManagerPortingApi::sm_organization_id_import_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SmOrganizationIdImportPostError { UnknownValue(serde_json::Value), } - -pub async fn sm_organization_id_export_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/sm/{organizationId}/export", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SmExportResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SmExportResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sm_organization_id_import_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - sm_import_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_sm_import_request_model = sm_import_request_model; - - let uri_str = format!( - "{}/sm/{organizationId}/import", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_sm_import_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/security_task_api.rs b/crates/bitwarden-api-api/src/apis/security_task_api.rs index 9dd3d1743..f22610035 100644 --- a/crates/bitwarden-api-api/src/apis/security_task_api.rs +++ b/crates/bitwarden-api-api/src/apis/security_task_api.rs @@ -8,236 +8,312 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`tasks_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TasksGetError { - UnknownValue(serde_json::Value), -} +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait SecurityTaskApi: Send + Sync { + /// GET /tasks + async fn tasks_get<'a>( + &self, + status: Option, + ) -> Result>; -/// struct for typed errors of method [`tasks_org_id_bulk_create_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TasksOrgIdBulkCreatePostError { - UnknownValue(serde_json::Value), + /// POST /tasks/{orgId}/bulk-create + async fn tasks_org_id_bulk_create_post<'a>( + &self, + org_id: uuid::Uuid, + bulk_create_security_tasks_request_model: Option< + models::BulkCreateSecurityTasksRequestModel, + >, + ) -> Result< + models::SecurityTasksResponseModelListResponseModel, + Error, + >; + + /// GET /tasks/organization + async fn tasks_organization_get<'a>( + &self, + organization_id: Option, + status: Option, + ) -> Result>; + + /// PATCH /tasks/{taskId}/complete + async fn tasks_task_id_complete_patch<'a>( + &self, + task_id: uuid::Uuid, + ) -> Result<(), Error>; } -/// struct for typed errors of method [`tasks_organization_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TasksOrganizationGetError { - UnknownValue(serde_json::Value), +pub struct SecurityTaskApiClient { + configuration: Arc, } -/// struct for typed errors of method [`tasks_task_id_complete_patch`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TasksTaskIdCompletePatchError { - UnknownValue(serde_json::Value), +impl SecurityTaskApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn tasks_get( - configuration: &configuration::Configuration, - status: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_status = status; +#[async_trait(?Send)] +impl SecurityTaskApi for SecurityTaskApiClient { + async fn tasks_get<'a>( + &self, + status: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/tasks", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref param_value) = p_status { - req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`")))), + let local_var_uri_str = format!("{}/tasks", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", ¶m_value.to_string())]); } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; -pub async fn tasks_org_id_bulk_create_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - bulk_create_security_tasks_request_model: Option, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_bulk_create_security_tasks_request_model = bulk_create_security_tasks_request_model; - - let uri_str = format!( - "{}/tasks/{orgId}/bulk-create", - configuration.base_path, - orgId = crate::apis::urlencode(p_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_bulk_create_security_tasks_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`")))), + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } -} -pub async fn tasks_organization_get( - configuration: &configuration::Configuration, - organization_id: Option, - status: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_status = status; + async fn tasks_org_id_bulk_create_post<'a>( + &self, + org_id: uuid::Uuid, + bulk_create_security_tasks_request_model: Option< + models::BulkCreateSecurityTasksRequestModel, + >, + ) -> Result< + models::SecurityTasksResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/tasks/organization", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref param_value) = p_organization_id { - req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_status { - req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + let local_var_uri_str = format!( + "{}/tasks/{orgId}/bulk-create", + local_var_configuration.base_path, + orgId = org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&bulk_create_security_tasks_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + + async fn tasks_organization_get<'a>( + &self, + organization_id: Option, + status: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tasks/organization", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = organization_id { + local_var_req_builder = + local_var_req_builder.query(&[("organizationId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`")))), + + async fn tasks_task_id_complete_patch<'a>( + &self, + task_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/tasks/{taskId}/complete", + local_var_configuration.base_path, + taskId = task_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } -pub async fn tasks_task_id_complete_patch( - configuration: &configuration::Configuration, - task_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_task_id = task_id; - - let uri_str = format!( - "{}/tasks/{taskId}/complete", - configuration.base_path, - taskId = crate::apis::urlencode(p_task_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::PATCH, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`SecurityTaskApi::tasks_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TasksGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`SecurityTaskApi::tasks_org_id_bulk_create_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TasksOrgIdBulkCreatePostError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`SecurityTaskApi::tasks_organization_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TasksOrganizationGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`SecurityTaskApi::tasks_task_id_complete_patch`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TasksTaskIdCompletePatchError { + UnknownValue(serde_json::Value), } diff --git a/crates/bitwarden-api-api/src/apis/self_hosted_organization_licenses_api.rs b/crates/bitwarden-api-api/src/apis/self_hosted_organization_licenses_api.rs index 52b1dd702..57c8bb2a9 100644 --- a/crates/bitwarden-api-api/src/apis/self_hosted_organization_licenses_api.rs +++ b/crates/bitwarden-api-api/src/apis/self_hosted_organization_licenses_api.rs @@ -8,190 +8,244 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait SelfHostedOrganizationLicensesApi: Send + Sync { + /// POST /organizations/licenses/self-hosted/{id} + async fn organizations_licenses_self_hosted_id_post<'a>( + &self, + id: &'a str, + license: std::path::PathBuf, + ) -> Result<(), Error>; + + /// POST /organizations/licenses/self-hosted/{id}/sync + async fn organizations_licenses_self_hosted_id_sync_post<'a>( + &self, + id: &'a str, + ) -> Result<(), Error>; + + /// POST /organizations/licenses/self-hosted + async fn organizations_licenses_self_hosted_post<'a>( + &self, + key: &'a str, + keys_period_public_key: &'a str, + keys_period_encrypted_private_key: &'a str, + license: std::path::PathBuf, + collection_name: Option<&'a str>, + ) -> Result>; +} + +pub struct SelfHostedOrganizationLicensesApiClient { + configuration: Arc, +} + +impl SelfHostedOrganizationLicensesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl SelfHostedOrganizationLicensesApi for SelfHostedOrganizationLicensesApiClient { + async fn organizations_licenses_self_hosted_id_post<'a>( + &self, + id: &'a str, + license: std::path::PathBuf, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/licenses/self-hosted/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + let mut local_var_form = reqwest::multipart::Form::new(); + // TODO: support file upload for 'license' parameter + local_var_req_builder = local_var_req_builder.multipart(local_var_form); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_licenses_self_hosted_id_sync_post<'a>( + &self, + id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/licenses/self-hosted/{id}/sync", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`organizations_licenses_self_hosted_id_post`] + async fn organizations_licenses_self_hosted_post<'a>( + &self, + key: &'a str, + keys_period_public_key: &'a str, + keys_period_encrypted_private_key: &'a str, + license: std::path::PathBuf, + collection_name: Option<&'a str>, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/licenses/self-hosted", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("key", &key.to_string())]); + if let Some(ref param_value) = collection_name { + local_var_req_builder = + local_var_req_builder.query(&[("collectionName", ¶m_value.to_string())]); + } + local_var_req_builder = + local_var_req_builder.query(&[("keys.publicKey", &keys_period_public_key.to_string())]); + local_var_req_builder = local_var_req_builder.query(&[( + "keys.encryptedPrivateKey", + &keys_period_encrypted_private_key.to_string(), + )]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + let mut local_var_form = reqwest::multipart::Form::new(); + // TODO: support file upload for 'license' parameter + local_var_req_builder = local_var_req_builder.multipart(local_var_form); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method +/// [`SelfHostedOrganizationLicensesApi::organizations_licenses_self_hosted_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsLicensesSelfHostedIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_licenses_self_hosted_id_sync_post`] +/// struct for typed errors of method +/// [`SelfHostedOrganizationLicensesApi::organizations_licenses_self_hosted_id_sync_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsLicensesSelfHostedIdSyncPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_licenses_self_hosted_post`] +/// struct for typed errors of method +/// [`SelfHostedOrganizationLicensesApi::organizations_licenses_self_hosted_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsLicensesSelfHostedPostError { UnknownValue(serde_json::Value), } - -pub async fn organizations_licenses_self_hosted_id_post( - configuration: &configuration::Configuration, - id: &str, - license: std::path::PathBuf, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_license = license; - - let uri_str = format!( - "{}/organizations/licenses/self-hosted/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - let mut multipart_form = reqwest::multipart::Form::new(); - // TODO: support file upload for 'license' parameter - req_builder = req_builder.multipart(multipart_form); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_licenses_self_hosted_id_sync_post( - configuration: &configuration::Configuration, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/licenses/self-hosted/{id}/sync", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_licenses_self_hosted_post( - configuration: &configuration::Configuration, - key: &str, - keys_period_public_key: &str, - keys_period_encrypted_private_key: &str, - license: std::path::PathBuf, - collection_name: Option<&str>, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_key = key; - let p_keys_period_public_key = keys_period_public_key; - let p_keys_period_encrypted_private_key = keys_period_encrypted_private_key; - let p_license = license; - let p_collection_name = collection_name; - - let uri_str = format!( - "{}/organizations/licenses/self-hosted", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - req_builder = req_builder.query(&[("key", &p_key.to_string())]); - if let Some(ref param_value) = p_collection_name { - req_builder = req_builder.query(&[("collectionName", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("keys.publicKey", &p_keys_period_public_key.to_string())]); - req_builder = req_builder.query(&[( - "keys.encryptedPrivateKey", - &p_keys_period_encrypted_private_key.to_string(), - )]); - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - let mut multipart_form = reqwest::multipart::Form::new(); - // TODO: support file upload for 'license' parameter - req_builder = req_builder.multipart(multipart_form); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/self_hosted_organization_sponsorships_api.rs b/crates/bitwarden-api-api/src/apis/self_hosted_organization_sponsorships_api.rs index 1ea7e408c..57e3e094c 100644 --- a/crates/bitwarden-api-api/src/apis/self_hosted_organization_sponsorships_api.rs +++ b/crates/bitwarden-api-api/src/apis/self_hosted_organization_sponsorships_api.rs @@ -8,14 +8,210 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait SelfHostedOrganizationSponsorshipsApi: Send + Sync { + /// DELETE /organization/sponsorship/self-hosted/{sponsoringOrgId} + async fn organization_sponsorship_self_hosted_sponsoring_org_id_delete<'a>( + &self, + sponsoring_org_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organization/sponsorship/self-hosted/{sponsoringOrgId}/delete + async fn organization_sponsorship_self_hosted_sponsoring_org_id_delete_post<'a>( + &self, + sponsoring_org_id: uuid::Uuid, + ) -> Result<(), Error>; + + /// POST /organization/sponsorship/self-hosted/{sponsoringOrgId}/families-for-enterprise + async fn organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post< + 'a, + >( + &self, + sponsoring_org_id: uuid::Uuid, + organization_sponsorship_create_request_model: Option< + models::OrganizationSponsorshipCreateRequestModel, + >, + ) -> Result< + (), + Error, + >; +} + +pub struct SelfHostedOrganizationSponsorshipsApiClient { + configuration: Arc, +} + +impl SelfHostedOrganizationSponsorshipsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl SelfHostedOrganizationSponsorshipsApi for SelfHostedOrganizationSponsorshipsApiClient { + async fn organization_sponsorship_self_hosted_sponsoring_org_id_delete<'a>( + &self, + sponsoring_org_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}", + local_var_configuration.base_path, + sponsoringOrgId = sponsoring_org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationSponsorshipSelfHostedSponsoringOrgIdDeleteError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_self_hosted_sponsoring_org_id_delete_post<'a>( + &self, + sponsoring_org_id: uuid::Uuid, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}/delete", + local_var_configuration.base_path, + sponsoringOrgId = sponsoring_org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationSponsorshipSelfHostedSponsoringOrgIdDeletePostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post< + 'a, + >( + &self, + sponsoring_org_id: uuid::Uuid, + organization_sponsorship_create_request_model: Option< + models::OrganizationSponsorshipCreateRequestModel, + >, + ) -> Result< + (), + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}/families-for-enterprise", + local_var_configuration.base_path, + sponsoringOrgId = sponsoring_org_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_sponsorship_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option< + OrganizationSponsorshipSelfHostedSponsoringOrgIdFamiliesForEnterprisePostError, + > = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} /// struct for typed errors of method -/// [`organization_sponsorship_self_hosted_sponsoring_org_id_delete`] +/// [`SelfHostedOrganizationSponsorshipsApi::organization_sponsorship_self_hosted_sponsoring_org_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeleteError { @@ -23,7 +219,7 @@ pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeleteError { } /// struct for typed errors of method -/// [`organization_sponsorship_self_hosted_sponsoring_org_id_delete_post`] +/// [`SelfHostedOrganizationSponsorshipsApi::organization_sponsorship_self_hosted_sponsoring_org_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeletePostError { @@ -31,143 +227,9 @@ pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeletePostError { } /// struct for typed errors of method -/// [`organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post`] +/// [`SelfHostedOrganizationSponsorshipsApi::organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdFamiliesForEnterprisePostError { UnknownValue(serde_json::Value), } - -pub async fn organization_sponsorship_self_hosted_sponsoring_org_id_delete( - configuration: &configuration::Configuration, - sponsoring_org_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_org_id = sponsoring_org_id; - - let uri_str = format!( - "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}", - configuration.base_path, - sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_self_hosted_sponsoring_org_id_delete_post( - configuration: &configuration::Configuration, - sponsoring_org_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_org_id = sponsoring_org_id; - - let uri_str = format!( - "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}/delete", - configuration.base_path, - sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post( - configuration: &configuration::Configuration, - sponsoring_org_id: uuid::Uuid, - organization_sponsorship_create_request_model: Option< - models::OrganizationSponsorshipCreateRequestModel, - >, -) -> Result<(), Error> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_org_id = sponsoring_org_id; - let p_organization_sponsorship_create_request_model = - organization_sponsorship_create_request_model; - - let uri_str = format!( - "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}/families-for-enterprise", - configuration.base_path, - sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_organization_sponsorship_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option< - OrganizationSponsorshipSelfHostedSponsoringOrgIdFamiliesForEnterprisePostError, - > = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/sends_api.rs b/crates/bitwarden-api-api/src/apis/sends_api.rs index dadbcecd2..031d4923a 100644 --- a/crates/bitwarden-api-api/src/apis/sends_api.rs +++ b/crates/bitwarden-api-api/src/apis/sends_api.rs @@ -8,648 +8,784 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait SendsApi: Send + Sync { + /// POST /sends/access/{id} + async fn sends_access_id_post<'a>( + &self, + id: &'a str, + send_access_request_model: Option, + ) -> Result<(), Error>; + + /// POST /sends/{encodedSendId}/access/file/{fileId} + async fn sends_encoded_send_id_access_file_file_id_post<'a>( + &self, + encoded_send_id: &'a str, + file_id: &'a str, + send_access_request_model: Option, + ) -> Result<(), Error>; + + /// POST /sends/file/v2 + async fn sends_file_v2_post<'a>( + &self, + send_request_model: Option, + ) -> Result>; + + /// POST /sends/file/validate/azure + async fn sends_file_validate_azure_post<'a>( + &self, + ) -> Result<(), Error>; + + /// GET /sends + async fn sends_get<'a>( + &self, + ) -> Result>; + + /// DELETE /sends/{id} + async fn sends_id_delete<'a>(&self, id: &'a str) -> Result<(), Error>; + + /// GET /sends/{id}/file/{fileId} + async fn sends_id_file_file_id_get<'a>( + &self, + id: &'a str, + file_id: &'a str, + ) -> Result>; + + /// POST /sends/{id}/file/{fileId} + async fn sends_id_file_file_id_post<'a>( + &self, + id: &'a str, + file_id: &'a str, + ) -> Result<(), Error>; + + /// GET /sends/{id} + async fn sends_id_get<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// PUT /sends/{id} + async fn sends_id_put<'a>( + &self, + id: &'a str, + send_request_model: Option, + ) -> Result>; + + /// PUT /sends/{id}/remove-password + async fn sends_id_remove_password_put<'a>( + &self, + id: &'a str, + ) -> Result>; + + /// POST /sends + async fn sends_post<'a>( + &self, + send_request_model: Option, + ) -> Result>; +} + +pub struct SendsApiClient { + configuration: Arc, +} + +impl SendsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl SendsApi for SendsApiClient { + async fn sends_access_id_post<'a>( + &self, + id: &'a str, + send_access_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sends/access/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&send_access_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_encoded_send_id_access_file_file_id_post<'a>( + &self, + encoded_send_id: &'a str, + file_id: &'a str, + send_access_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sends/{encodedSendId}/access/file/{fileId}", + local_var_configuration.base_path, + encodedSendId = crate::apis::urlencode(encoded_send_id), + fileId = crate::apis::urlencode(file_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&send_access_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_file_v2_post<'a>( + &self, + send_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/sends/file/v2", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&send_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_file_validate_azure_post<'a>( + &self, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sends/file/validate/azure", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_get<'a>( + &self, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/sends", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_id_delete<'a>(&self, id: &'a str) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sends/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_id_file_file_id_get<'a>( + &self, + id: &'a str, + file_id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sends/{id}/file/{fileId}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id), + fileId = crate::apis::urlencode(file_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_id_file_file_id_post<'a>( + &self, + id: &'a str, + file_id: &'a str, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sends/{id}/file/{fileId}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id), + fileId = crate::apis::urlencode(file_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_id_get<'a>( + &self, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sends/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_id_put<'a>( + &self, + id: &'a str, + send_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sends/{id}", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&send_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_id_remove_password_put<'a>( + &self, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sends/{id}/remove-password", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn sends_post<'a>( + &self, + send_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/sends", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); -/// struct for typed errors of method [`sends_access_id_post`] + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&send_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`SendsApi::sends_access_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsAccessIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_encoded_send_id_access_file_file_id_post`] +/// struct for typed errors of method [`SendsApi::sends_encoded_send_id_access_file_file_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsEncodedSendIdAccessFileFileIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_file_v2_post`] +/// struct for typed errors of method [`SendsApi::sends_file_v2_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsFileV2PostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_file_validate_azure_post`] +/// struct for typed errors of method [`SendsApi::sends_file_validate_azure_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsFileValidateAzurePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_get`] +/// struct for typed errors of method [`SendsApi::sends_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_id_delete`] +/// struct for typed errors of method [`SendsApi::sends_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_id_file_file_id_get`] +/// struct for typed errors of method [`SendsApi::sends_id_file_file_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsIdFileFileIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_id_file_file_id_post`] +/// struct for typed errors of method [`SendsApi::sends_id_file_file_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsIdFileFileIdPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_id_get`] +/// struct for typed errors of method [`SendsApi::sends_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_id_put`] +/// struct for typed errors of method [`SendsApi::sends_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_id_remove_password_put`] +/// struct for typed errors of method [`SendsApi::sends_id_remove_password_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsIdRemovePasswordPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`sends_post`] +/// struct for typed errors of method [`SendsApi::sends_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SendsPostError { UnknownValue(serde_json::Value), } - -pub async fn sends_access_id_post( - configuration: &configuration::Configuration, - id: &str, - send_access_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_send_access_request_model = send_access_request_model; - - let uri_str = format!( - "{}/sends/access/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_send_access_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_encoded_send_id_access_file_file_id_post( - configuration: &configuration::Configuration, - encoded_send_id: &str, - file_id: &str, - send_access_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_encoded_send_id = encoded_send_id; - let p_file_id = file_id; - let p_send_access_request_model = send_access_request_model; - - let uri_str = format!( - "{}/sends/{encodedSendId}/access/file/{fileId}", - configuration.base_path, - encodedSendId = crate::apis::urlencode(p_encoded_send_id), - fileId = crate::apis::urlencode(p_file_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_send_access_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_file_v2_post( - configuration: &configuration::Configuration, - send_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_send_request_model = send_request_model; - - let uri_str = format!("{}/sends/file/v2", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_send_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_file_validate_azure_post( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/sends/file/validate/azure", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/sends", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_id_delete( - configuration: &configuration::Configuration, - id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/sends/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_id_file_file_id_get( - configuration: &configuration::Configuration, - id: &str, - file_id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_file_id = file_id; - - let uri_str = format!( - "{}/sends/{id}/file/{fileId}", - configuration.base_path, - id = crate::apis::urlencode(p_id), - fileId = crate::apis::urlencode(p_file_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_id_file_file_id_post( - configuration: &configuration::Configuration, - id: &str, - file_id: &str, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_file_id = file_id; - - let uri_str = format!( - "{}/sends/{id}/file/{fileId}", - configuration.base_path, - id = crate::apis::urlencode(p_id), - fileId = crate::apis::urlencode(p_file_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_id_get( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/sends/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_id_put( - configuration: &configuration::Configuration, - id: &str, - send_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_send_request_model = send_request_model; - - let uri_str = format!( - "{}/sends/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_send_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_id_remove_password_put( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/sends/{id}/remove-password", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn sends_post( - configuration: &configuration::Configuration, - send_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_send_request_model = send_request_model; - - let uri_str = format!("{}/sends", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_send_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/service_accounts_api.rs b/crates/bitwarden-api-api/src/apis/service_accounts_api.rs index 90c612460..a45618794 100644 --- a/crates/bitwarden-api-api/src/apis/service_accounts_api.rs +++ b/crates/bitwarden-api-api/src/apis/service_accounts_api.rs @@ -8,491 +8,610 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait ServiceAccountsApi: Send + Sync { + /// GET /organizations/{organizationId}/service-accounts + async fn organizations_organization_id_service_accounts_get<'a>( + &self, + organization_id: uuid::Uuid, + include_access_to_secrets: Option, + ) -> Result< + models::ServiceAccountSecretsDetailsResponseModelListResponseModel, + Error, + >; + + /// POST /organizations/{organizationId}/service-accounts + async fn organizations_organization_id_service_accounts_post<'a>( + &self, + organization_id: uuid::Uuid, + service_account_create_request_model: Option, + ) -> Result< + models::ServiceAccountResponseModel, + Error, + >; + + /// POST /service-accounts/delete + async fn service_accounts_delete_post<'a>( + &self, + uuid_colon_colon_uuid: Option>, + ) -> Result< + models::BulkDeleteResponseModelListResponseModel, + Error, + >; + + /// GET /service-accounts/{id}/access-tokens + async fn service_accounts_id_access_tokens_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::AccessTokenResponseModelListResponseModel, + Error, + >; + + /// POST /service-accounts/{id}/access-tokens + async fn service_accounts_id_access_tokens_post<'a>( + &self, + id: uuid::Uuid, + access_token_create_request_model: Option, + ) -> Result< + models::AccessTokenCreationResponseModel, + Error, + >; + + /// POST /service-accounts/{id}/access-tokens/revoke + async fn service_accounts_id_access_tokens_revoke_post<'a>( + &self, + id: uuid::Uuid, + revoke_access_tokens_request: Option, + ) -> Result<(), Error>; + + /// GET /service-accounts/{id} + async fn service_accounts_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result>; + + /// PUT /service-accounts/{id} + async fn service_accounts_id_put<'a>( + &self, + id: uuid::Uuid, + service_account_update_request_model: Option, + ) -> Result>; +} + +pub struct ServiceAccountsApiClient { + configuration: Arc, +} + +impl ServiceAccountsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl ServiceAccountsApi for ServiceAccountsApiClient { + async fn organizations_organization_id_service_accounts_get<'a>( + &self, + organization_id: uuid::Uuid, + include_access_to_secrets: Option, + ) -> Result< + models::ServiceAccountSecretsDetailsResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/service-accounts", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = include_access_to_secrets { + local_var_req_builder = local_var_req_builder + .query(&[("includeAccessToSecrets", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountSecretsDetailsResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountSecretsDetailsResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_organization_id_service_accounts_post<'a>( + &self, + organization_id: uuid::Uuid, + service_account_create_request_model: Option, + ) -> Result< + models::ServiceAccountResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/service-accounts", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&service_account_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn service_accounts_delete_post<'a>( + &self, + uuid_colon_colon_uuid: Option>, + ) -> Result< + models::BulkDeleteResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/delete", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn service_accounts_id_access_tokens_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result< + models::AccessTokenResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{id}/access-tokens", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessTokenResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AccessTokenResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn service_accounts_id_access_tokens_post<'a>( + &self, + id: uuid::Uuid, + access_token_create_request_model: Option, + ) -> Result< + models::AccessTokenCreationResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{id}/access-tokens", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&access_token_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessTokenCreationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AccessTokenCreationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn service_accounts_id_access_tokens_revoke_post<'a>( + &self, + id: uuid::Uuid, + revoke_access_tokens_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{id}/access-tokens/revoke", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&revoke_access_tokens_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn service_accounts_id_get<'a>( + &self, + id: uuid::Uuid, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn service_accounts_id_put<'a>( + &self, + id: uuid::Uuid, + service_account_update_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{id}", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&service_account_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`organizations_organization_id_service_accounts_get`] +/// struct for typed errors of method +/// [`ServiceAccountsApi::organizations_organization_id_service_accounts_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdServiceAccountsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_organization_id_service_accounts_post`] +/// struct for typed errors of method +/// [`ServiceAccountsApi::organizations_organization_id_service_accounts_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrganizationIdServiceAccountsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_delete_post`] +/// struct for typed errors of method [`ServiceAccountsApi::service_accounts_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_id_access_tokens_get`] +/// struct for typed errors of method [`ServiceAccountsApi::service_accounts_id_access_tokens_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsIdAccessTokensGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_id_access_tokens_post`] +/// struct for typed errors of method [`ServiceAccountsApi::service_accounts_id_access_tokens_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsIdAccessTokensPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_id_access_tokens_revoke_post`] +/// struct for typed errors of method +/// [`ServiceAccountsApi::service_accounts_id_access_tokens_revoke_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsIdAccessTokensRevokePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_id_get`] +/// struct for typed errors of method [`ServiceAccountsApi::service_accounts_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsIdGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`service_accounts_id_put`] +/// struct for typed errors of method [`ServiceAccountsApi::service_accounts_id_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ServiceAccountsIdPutError { UnknownValue(serde_json::Value), } - -pub async fn organizations_organization_id_service_accounts_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - include_access_to_secrets: Option, -) -> Result< - models::ServiceAccountSecretsDetailsResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_include_access_to_secrets = include_access_to_secrets; - - let uri_str = format!( - "{}/organizations/{organizationId}/service-accounts", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_include_access_to_secrets { - req_builder = req_builder.query(&[("includeAccessToSecrets", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountSecretsDetailsResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountSecretsDetailsResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_organization_id_service_accounts_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - service_account_create_request_model: Option, -) -> Result< - models::ServiceAccountResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_service_account_create_request_model = service_account_create_request_model; - - let uri_str = format!( - "{}/organizations/{organizationId}/service-accounts", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_service_account_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_delete_post( - configuration: &configuration::Configuration, - uuid_colon_colon_uuid: Option>, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_uuid_colon_colon_uuid = uuid_colon_colon_uuid; - - let uri_str = format!("{}/service-accounts/delete", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_uuid_colon_colon_uuid); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BulkDeleteResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_id_access_tokens_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result< - models::AccessTokenResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/service-accounts/{id}/access-tokens", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessTokenResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessTokenResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_id_access_tokens_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - access_token_create_request_model: Option, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_access_token_create_request_model = access_token_create_request_model; - - let uri_str = format!( - "{}/service-accounts/{id}/access-tokens", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_access_token_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessTokenCreationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessTokenCreationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_id_access_tokens_revoke_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - revoke_access_tokens_request: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_revoke_access_tokens_request = revoke_access_tokens_request; - - let uri_str = format!( - "{}/service-accounts/{id}/access-tokens/revoke", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_revoke_access_tokens_request); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_id_get( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/service-accounts/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn service_accounts_id_put( - configuration: &configuration::Configuration, - id: uuid::Uuid, - service_account_update_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_service_account_update_request_model = service_account_update_request_model; - - let uri_str = format!( - "{}/service-accounts/{id}", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_service_account_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/settings_api.rs b/crates/bitwarden-api-api/src/apis/settings_api.rs index 0217d0d61..a78384768 100644 --- a/crates/bitwarden-api-api/src/apis/settings_api.rs +++ b/crates/bitwarden-api-api/src/apis/settings_api.rs @@ -8,174 +8,228 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; - -/// struct for typed errors of method [`settings_domains_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SettingsDomainsGetError { - UnknownValue(serde_json::Value), +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait SettingsApi: Send + Sync { + /// GET /settings/domains + async fn settings_domains_get<'a>( + &self, + excluded: Option, + ) -> Result>; + + /// POST /settings/domains + async fn settings_domains_post<'a>( + &self, + update_domains_request_model: Option, + ) -> Result>; + + /// PUT /settings/domains + async fn settings_domains_put<'a>( + &self, + update_domains_request_model: Option, + ) -> Result>; } -/// struct for typed errors of method [`settings_domains_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SettingsDomainsPostError { - UnknownValue(serde_json::Value), +pub struct SettingsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`settings_domains_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SettingsDomainsPutError { - UnknownValue(serde_json::Value), +impl SettingsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn settings_domains_get( - configuration: &configuration::Configuration, - excluded: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_excluded = excluded; +#[async_trait(?Send)] +impl SettingsApi for SettingsApiClient { + async fn settings_domains_get<'a>( + &self, + excluded: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/settings/domains", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref param_value) = p_excluded { - req_builder = req_builder.query(&[("excluded", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DomainsResponseModel`")))), + let local_var_uri_str = format!("{}/settings/domains", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = excluded { + local_var_req_builder = + local_var_req_builder.query(&[("excluded", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DomainsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } -} -pub async fn settings_domains_post( - configuration: &configuration::Configuration, - update_domains_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_domains_request_model = update_domains_request_model; + async fn settings_domains_post<'a>( + &self, + update_domains_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/settings/domains", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_domains_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DomainsResponseModel`")))), + let local_var_uri_str = format!("{}/settings/domains", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_domains_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DomainsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } -} -pub async fn settings_domains_put( - configuration: &configuration::Configuration, - update_domains_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_domains_request_model = update_domains_request_model; + async fn settings_domains_put<'a>( + &self, + update_domains_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/settings/domains", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + let local_var_client = &local_var_configuration.client; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_domains_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DomainsResponseModel`")))), + let local_var_uri_str = format!("{}/settings/domains", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_domains_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DomainsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } + +/// struct for typed errors of method [`SettingsApi::settings_domains_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SettingsDomainsGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`SettingsApi::settings_domains_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SettingsDomainsPostError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`SettingsApi::settings_domains_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SettingsDomainsPutError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/stripe_api.rs b/crates/bitwarden-api-api/src/apis/stripe_api.rs index 7585964ea..1eb1108d5 100644 --- a/crates/bitwarden-api-api/src/apis/stripe_api.rs +++ b/crates/bitwarden-api-api/src/apis/stripe_api.rs @@ -8,133 +8,194 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait StripeApi: Send + Sync { + /// POST /setup-intent/bank-account + async fn setup_intent_bank_account_post<'a>( + &self, + ) -> Result<(), Error>; + + /// POST /setup-intent/card + async fn setup_intent_card_post<'a>(&self) -> Result<(), Error>; + + /// GET /tax/is-country-supported + async fn tax_is_country_supported_get<'a>( + &self, + country: Option<&'a str>, + ) -> Result<(), Error>; +} + +pub struct StripeApiClient { + configuration: Arc, +} + +impl StripeApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl StripeApi for StripeApiClient { + async fn setup_intent_bank_account_post<'a>( + &self, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/setup-intent/bank-account", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn setup_intent_card_post<'a>(&self) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/setup-intent/card", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn tax_is_country_supported_get<'a>( + &self, + country: Option<&'a str>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/tax/is-country-supported", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = country { + local_var_req_builder = + local_var_req_builder.query(&[("country", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} -/// struct for typed errors of method [`setup_intent_bank_account_post`] +/// struct for typed errors of method [`StripeApi::setup_intent_bank_account_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SetupIntentBankAccountPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`setup_intent_card_post`] +/// struct for typed errors of method [`StripeApi::setup_intent_card_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SetupIntentCardPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`tax_is_country_supported_get`] +/// struct for typed errors of method [`StripeApi::tax_is_country_supported_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TaxIsCountrySupportedGetError { UnknownValue(serde_json::Value), } - -pub async fn setup_intent_bank_account_post( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/setup-intent/bank-account", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn setup_intent_card_post( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/setup-intent/card", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn tax_is_country_supported_get( - configuration: &configuration::Configuration, - country: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_country = country; - - let uri_str = format!("{}/tax/is-country-supported", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_country { - req_builder = req_builder.query(&[("country", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/sync_api.rs b/crates/bitwarden-api-api/src/apis/sync_api.rs index 4cf9f4d73..f71929a8f 100644 --- a/crates/bitwarden-api-api/src/apis/sync_api.rs +++ b/crates/bitwarden-api-api/src/apis/sync_api.rs @@ -8,64 +8,100 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`sync_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SyncGetError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait SyncApi: Send + Sync { + /// GET /sync + async fn sync_get<'a>( + &self, + exclude_domains: Option, + ) -> Result>; } -pub async fn sync_get( - configuration: &configuration::Configuration, - exclude_domains: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_exclude_domains = exclude_domains; - - let uri_str = format!("{}/sync", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +pub struct SyncApiClient { + configuration: Arc, +} - if let Some(ref param_value) = p_exclude_domains { - req_builder = req_builder.query(&[("excludeDomains", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +impl SyncApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; +} - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; +#[async_trait(?Send)] +impl SyncApi for SyncApiClient { + async fn sync_get<'a>( + &self, + exclude_domains: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); + let local_var_client = &local_var_configuration.client; - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SyncResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SyncResponseModel`")))), + let local_var_uri_str = format!("{}/sync", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = exclude_domains { + local_var_req_builder = + local_var_req_builder.query(&[("excludeDomains", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SyncResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SyncResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } + +/// struct for typed errors of method [`SyncApi::sync_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SyncGetError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/trash_api.rs b/crates/bitwarden-api-api/src/apis/trash_api.rs index 88f1b8950..c7d52da10 100644 --- a/crates/bitwarden-api-api/src/apis/trash_api.rs +++ b/crates/bitwarden-api-api/src/apis/trash_api.rs @@ -8,171 +8,226 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait TrashApi: Send + Sync { + /// POST /secrets/{organizationId}/trash/empty + async fn secrets_organization_id_trash_empty_post<'a>( + &self, + organization_id: uuid::Uuid, + uuid_colon_colon_uuid: Option>, + ) -> Result<(), Error>; + + /// GET /secrets/{organizationId}/trash + async fn secrets_organization_id_trash_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result< + models::SecretWithProjectsListResponseModel, + Error, + >; + + /// POST /secrets/{organizationId}/trash/restore + async fn secrets_organization_id_trash_restore_post<'a>( + &self, + organization_id: uuid::Uuid, + uuid_colon_colon_uuid: Option>, + ) -> Result<(), Error>; +} -/// struct for typed errors of method [`secrets_organization_id_trash_empty_post`] +pub struct TrashApiClient { + configuration: Arc, +} + +impl TrashApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl TrashApi for TrashApiClient { + async fn secrets_organization_id_trash_empty_post<'a>( + &self, + organization_id: uuid::Uuid, + uuid_colon_colon_uuid: Option>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/secrets/{organizationId}/trash/empty", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn secrets_organization_id_trash_get<'a>( + &self, + organization_id: uuid::Uuid, + ) -> Result< + models::SecretWithProjectsListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/secrets/{organizationId}/trash", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn secrets_organization_id_trash_restore_post<'a>( + &self, + organization_id: uuid::Uuid, + uuid_colon_colon_uuid: Option>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/secrets/{organizationId}/trash/restore", + local_var_configuration.base_path, + organizationId = organization_id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`TrashApi::secrets_organization_id_trash_empty_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SecretsOrganizationIdTrashEmptyPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`secrets_organization_id_trash_get`] +/// struct for typed errors of method [`TrashApi::secrets_organization_id_trash_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SecretsOrganizationIdTrashGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`secrets_organization_id_trash_restore_post`] +/// struct for typed errors of method [`TrashApi::secrets_organization_id_trash_restore_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum SecretsOrganizationIdTrashRestorePostError { UnknownValue(serde_json::Value), } - -pub async fn secrets_organization_id_trash_empty_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - uuid_colon_colon_uuid: Option>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_uuid_colon_colon_uuid = uuid_colon_colon_uuid; - - let uri_str = format!( - "{}/secrets/{organizationId}/trash/empty", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_uuid_colon_colon_uuid); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn secrets_organization_id_trash_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/secrets/{organizationId}/trash", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecretWithProjectsListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn secrets_organization_id_trash_restore_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - uuid_colon_colon_uuid: Option>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_uuid_colon_colon_uuid = uuid_colon_colon_uuid; - - let uri_str = format!( - "{}/secrets/{organizationId}/trash/restore", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_uuid_colon_colon_uuid); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/two_factor_api.rs b/crates/bitwarden-api-api/src/apis/two_factor_api.rs index 3ef1e16fc..2e7f3089b 100644 --- a/crates/bitwarden-api-api/src/apis/two_factor_api.rs +++ b/crates/bitwarden-api-api/src/apis/two_factor_api.rs @@ -8,1805 +8,2188 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait TwoFactorApi: Send + Sync { + /// POST /organizations/{id}/two-factor/disable + async fn organizations_id_two_factor_disable_post<'a>( + &self, + id: &'a str, + two_factor_provider_request_model: Option, + ) -> Result< + models::TwoFactorProviderResponseModel, + Error, + >; + + /// PUT /organizations/{id}/two-factor/disable + async fn organizations_id_two_factor_disable_put<'a>( + &self, + id: &'a str, + two_factor_provider_request_model: Option, + ) -> Result< + models::TwoFactorProviderResponseModel, + Error, + >; + + /// POST /organizations/{id}/two-factor/duo + async fn organizations_id_two_factor_duo_post<'a>( + &self, + id: &'a str, + update_two_factor_duo_request_model: Option, + ) -> Result>; + + /// PUT /organizations/{id}/two-factor/duo + async fn organizations_id_two_factor_duo_put<'a>( + &self, + id: &'a str, + update_two_factor_duo_request_model: Option, + ) -> Result>; + + /// GET /organizations/{id}/two-factor + async fn organizations_id_two_factor_get<'a>( + &self, + id: &'a str, + ) -> Result< + models::TwoFactorProviderResponseModelListResponseModel, + Error, + >; + + /// POST /organizations/{id}/two-factor/get-duo + async fn organizations_id_two_factor_get_duo_post<'a>( + &self, + id: &'a str, + secret_verification_request_model: Option, + ) -> Result>; + + /// DELETE /two-factor/authenticator + async fn two_factor_authenticator_delete<'a>( + &self, + two_factor_authenticator_disable_request_model: Option< + models::TwoFactorAuthenticatorDisableRequestModel, + >, + ) -> Result>; + + /// POST /two-factor/authenticator + async fn two_factor_authenticator_post<'a>( + &self, + update_two_factor_authenticator_request_model: Option< + models::UpdateTwoFactorAuthenticatorRequestModel, + >, + ) -> Result>; + + /// PUT /two-factor/authenticator + async fn two_factor_authenticator_put<'a>( + &self, + update_two_factor_authenticator_request_model: Option< + models::UpdateTwoFactorAuthenticatorRequestModel, + >, + ) -> Result>; + + /// PUT /two-factor/device-verification-settings + async fn two_factor_device_verification_settings_put<'a>( + &self, + device_verification_request_model: Option, + ) -> Result< + models::DeviceVerificationResponseModel, + Error, + >; + + /// POST /two-factor/disable + async fn two_factor_disable_post<'a>( + &self, + two_factor_provider_request_model: Option, + ) -> Result>; + + /// PUT /two-factor/disable + async fn two_factor_disable_put<'a>( + &self, + two_factor_provider_request_model: Option, + ) -> Result>; + + /// POST /two-factor/duo + async fn two_factor_duo_post<'a>( + &self, + update_two_factor_duo_request_model: Option, + ) -> Result>; + + /// PUT /two-factor/duo + async fn two_factor_duo_put<'a>( + &self, + update_two_factor_duo_request_model: Option, + ) -> Result>; + + /// POST /two-factor/email + async fn two_factor_email_post<'a>( + &self, + update_two_factor_email_request_model: Option, + ) -> Result>; + + /// PUT /two-factor/email + async fn two_factor_email_put<'a>( + &self, + update_two_factor_email_request_model: Option, + ) -> Result>; + + /// GET /two-factor + async fn two_factor_get<'a>( + &self, + ) -> Result>; + + /// POST /two-factor/get-authenticator + async fn two_factor_get_authenticator_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result< + models::TwoFactorAuthenticatorResponseModel, + Error, + >; + + /// GET /two-factor/get-device-verification-settings + async fn two_factor_get_device_verification_settings_get<'a>( + &self, + ) -> Result< + models::DeviceVerificationResponseModel, + Error, + >; + + /// POST /two-factor/get-duo + async fn two_factor_get_duo_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result>; + + /// POST /two-factor/get-email + async fn two_factor_get_email_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result>; + + /// POST /two-factor/get-recover + async fn two_factor_get_recover_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result>; + + /// POST /two-factor/get-webauthn + async fn two_factor_get_webauthn_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result>; + + /// POST /two-factor/get-yubikey + async fn two_factor_get_yubikey_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result>; + + /// POST /two-factor/recover + async fn two_factor_recover_post<'a>( + &self, + two_factor_recovery_request_model: Option, + ) -> Result<(), Error>; + + /// POST /two-factor/send-email-login + async fn two_factor_send_email_login_post<'a>( + &self, + two_factor_email_request_model: Option, + ) -> Result<(), Error>; + + /// POST /two-factor/send-email + async fn two_factor_send_email_post<'a>( + &self, + two_factor_email_request_model: Option, + ) -> Result<(), Error>; + + /// DELETE /two-factor/webauthn + async fn two_factor_webauthn_delete<'a>( + &self, + two_factor_web_authn_delete_request_model: Option< + models::TwoFactorWebAuthnDeleteRequestModel, + >, + ) -> Result>; + + /// POST /two-factor/webauthn + async fn two_factor_webauthn_post<'a>( + &self, + two_factor_web_authn_request_model: Option, + ) -> Result>; + + /// PUT /two-factor/webauthn + async fn two_factor_webauthn_put<'a>( + &self, + two_factor_web_authn_request_model: Option, + ) -> Result>; + + /// POST /two-factor/yubikey + async fn two_factor_yubikey_post<'a>( + &self, + update_two_factor_yubico_otp_request_model: Option< + models::UpdateTwoFactorYubicoOtpRequestModel, + >, + ) -> Result>; + + /// PUT /two-factor/yubikey + async fn two_factor_yubikey_put<'a>( + &self, + update_two_factor_yubico_otp_request_model: Option< + models::UpdateTwoFactorYubicoOtpRequestModel, + >, + ) -> Result>; +} + +pub struct TwoFactorApiClient { + configuration: Arc, +} + +impl TwoFactorApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl TwoFactorApi for TwoFactorApiClient { + async fn organizations_id_two_factor_disable_post<'a>( + &self, + id: &'a str, + two_factor_provider_request_model: Option, + ) -> Result< + models::TwoFactorProviderResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/two-factor/disable", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&two_factor_provider_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_two_factor_disable_put<'a>( + &self, + id: &'a str, + two_factor_provider_request_model: Option, + ) -> Result< + models::TwoFactorProviderResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/two-factor/disable", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&two_factor_provider_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_two_factor_duo_post<'a>( + &self, + id: &'a str, + update_two_factor_duo_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/two-factor/duo", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_two_factor_duo_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_two_factor_duo_put<'a>( + &self, + id: &'a str, + update_two_factor_duo_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/two-factor/duo", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_two_factor_duo_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_two_factor_get<'a>( + &self, + id: &'a str, + ) -> Result< + models::TwoFactorProviderResponseModelListResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/two-factor", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn organizations_id_two_factor_get_duo_post<'a>( + &self, + id: &'a str, + secret_verification_request_model: Option, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{id}/two-factor/get-duo", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_authenticator_delete<'a>( + &self, + two_factor_authenticator_disable_request_model: Option< + models::TwoFactorAuthenticatorDisableRequestModel, + >, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/authenticator", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&two_factor_authenticator_disable_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_authenticator_post<'a>( + &self, + update_two_factor_authenticator_request_model: Option< + models::UpdateTwoFactorAuthenticatorRequestModel, + >, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/authenticator", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&update_two_factor_authenticator_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_authenticator_put<'a>( + &self, + update_two_factor_authenticator_request_model: Option< + models::UpdateTwoFactorAuthenticatorRequestModel, + >, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/authenticator", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&update_two_factor_authenticator_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_device_verification_settings_put<'a>( + &self, + device_verification_request_model: Option, + ) -> Result< + models::DeviceVerificationResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/device-verification-settings", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&device_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceVerificationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceVerificationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_disable_post<'a>( + &self, + two_factor_provider_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor/disable", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&two_factor_provider_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_disable_put<'a>( + &self, + two_factor_provider_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor/disable", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&two_factor_provider_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_duo_post<'a>( + &self, + update_two_factor_duo_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor/duo", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_two_factor_duo_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_duo_put<'a>( + &self, + update_two_factor_duo_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor/duo", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_two_factor_duo_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_email_post<'a>( + &self, + update_two_factor_email_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor/email", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_two_factor_email_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } -/// struct for typed errors of method [`organizations_id_two_factor_disable_post`] + async fn two_factor_email_put<'a>( + &self, + update_two_factor_email_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor/email", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&update_two_factor_email_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_get<'a>( + &self, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_get_authenticator_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result< + models::TwoFactorAuthenticatorResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/get-authenticator", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_get_device_verification_settings_get<'a>( + &self, + ) -> Result< + models::DeviceVerificationResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/get-device-verification-settings", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceVerificationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::DeviceVerificationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_get_duo_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor/get-duo", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_get_email_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = + format!("{}/two-factor/get-email", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_get_recover_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/get-recover", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorRecoverResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorRecoverResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_get_webauthn_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/get-webauthn", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_get_yubikey_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/get-yubikey", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_recover_post<'a>( + &self, + two_factor_recovery_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor/recover", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&two_factor_recovery_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_send_email_login_post<'a>( + &self, + two_factor_email_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/send-email-login", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&two_factor_email_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_send_email_post<'a>( + &self, + two_factor_email_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/send-email", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&two_factor_email_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_webauthn_delete<'a>( + &self, + two_factor_web_authn_delete_request_model: Option< + models::TwoFactorWebAuthnDeleteRequestModel, + >, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = + format!("{}/two-factor/webauthn", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&two_factor_web_authn_delete_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_webauthn_post<'a>( + &self, + two_factor_web_authn_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = + format!("{}/two-factor/webauthn", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&two_factor_web_authn_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_webauthn_put<'a>( + &self, + two_factor_web_authn_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = + format!("{}/two-factor/webauthn", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&two_factor_web_authn_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_yubikey_post<'a>( + &self, + update_two_factor_yubico_otp_request_model: Option< + models::UpdateTwoFactorYubicoOtpRequestModel, + >, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor/yubikey", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&update_two_factor_yubico_otp_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn two_factor_yubikey_put<'a>( + &self, + update_two_factor_yubico_otp_request_model: Option< + models::UpdateTwoFactorYubicoOtpRequestModel, + >, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/two-factor/yubikey", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&update_two_factor_yubico_otp_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`TwoFactorApi::organizations_id_two_factor_disable_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdTwoFactorDisablePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_two_factor_disable_put`] +/// struct for typed errors of method [`TwoFactorApi::organizations_id_two_factor_disable_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdTwoFactorDisablePutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_two_factor_duo_post`] +/// struct for typed errors of method [`TwoFactorApi::organizations_id_two_factor_duo_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdTwoFactorDuoPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_two_factor_duo_put`] +/// struct for typed errors of method [`TwoFactorApi::organizations_id_two_factor_duo_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdTwoFactorDuoPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_two_factor_get`] +/// struct for typed errors of method [`TwoFactorApi::organizations_id_two_factor_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdTwoFactorGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_two_factor_get_duo_post`] +/// struct for typed errors of method [`TwoFactorApi::organizations_id_two_factor_get_duo_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdTwoFactorGetDuoPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_authenticator_delete`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_authenticator_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorAuthenticatorDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_authenticator_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_authenticator_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorAuthenticatorPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_authenticator_put`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_authenticator_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorAuthenticatorPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_device_verification_settings_put`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_device_verification_settings_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorDeviceVerificationSettingsPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_disable_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_disable_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorDisablePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_disable_put`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_disable_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorDisablePutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_duo_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_duo_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorDuoPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_duo_put`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_duo_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorDuoPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_email_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_email_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorEmailPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_email_put`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_email_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorEmailPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_get`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_get_authenticator_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_get_authenticator_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorGetAuthenticatorPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_get_device_verification_settings_get`] +/// struct for typed errors of method +/// [`TwoFactorApi::two_factor_get_device_verification_settings_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorGetDeviceVerificationSettingsGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_get_duo_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_get_duo_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorGetDuoPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_get_email_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_get_email_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorGetEmailPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_get_recover_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_get_recover_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorGetRecoverPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_get_webauthn_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_get_webauthn_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorGetWebauthnPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_get_yubikey_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_get_yubikey_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorGetYubikeyPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_recover_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_recover_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorRecoverPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_send_email_login_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_send_email_login_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorSendEmailLoginPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_send_email_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_send_email_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorSendEmailPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_webauthn_delete`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_webauthn_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorWebauthnDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_webauthn_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_webauthn_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorWebauthnPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_webauthn_put`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_webauthn_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorWebauthnPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_yubikey_post`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_yubikey_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorYubikeyPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`two_factor_yubikey_put`] +/// struct for typed errors of method [`TwoFactorApi::two_factor_yubikey_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum TwoFactorYubikeyPutError { UnknownValue(serde_json::Value), } - -pub async fn organizations_id_two_factor_disable_post( - configuration: &configuration::Configuration, - id: &str, - two_factor_provider_request_model: Option, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_two_factor_provider_request_model = two_factor_provider_request_model; - - let uri_str = format!( - "{}/organizations/{id}/two-factor/disable", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_provider_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_two_factor_disable_put( - configuration: &configuration::Configuration, - id: &str, - two_factor_provider_request_model: Option, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_two_factor_provider_request_model = two_factor_provider_request_model; - - let uri_str = format!( - "{}/organizations/{id}/two-factor/disable", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_provider_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_two_factor_duo_post( - configuration: &configuration::Configuration, - id: &str, - update_two_factor_duo_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_update_two_factor_duo_request_model = update_two_factor_duo_request_model; - - let uri_str = format!( - "{}/organizations/{id}/two-factor/duo", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_two_factor_duo_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_two_factor_duo_put( - configuration: &configuration::Configuration, - id: &str, - update_two_factor_duo_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_update_two_factor_duo_request_model = update_two_factor_duo_request_model; - - let uri_str = format!( - "{}/organizations/{id}/two-factor/duo", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_two_factor_duo_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_two_factor_get( - configuration: &configuration::Configuration, - id: &str, -) -> Result< - models::TwoFactorProviderResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/organizations/{id}/two-factor", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn organizations_id_two_factor_get_duo_post( - configuration: &configuration::Configuration, - id: &str, - secret_verification_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!( - "{}/organizations/{id}/two-factor/get-duo", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_authenticator_delete( - configuration: &configuration::Configuration, - two_factor_authenticator_disable_request_model: Option< - models::TwoFactorAuthenticatorDisableRequestModel, - >, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_two_factor_authenticator_disable_request_model = - two_factor_authenticator_disable_request_model; - - let uri_str = format!("{}/two-factor/authenticator", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_authenticator_disable_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_authenticator_post( - configuration: &configuration::Configuration, - update_two_factor_authenticator_request_model: Option< - models::UpdateTwoFactorAuthenticatorRequestModel, - >, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_two_factor_authenticator_request_model = - update_two_factor_authenticator_request_model; - - let uri_str = format!("{}/two-factor/authenticator", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_two_factor_authenticator_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_authenticator_put( - configuration: &configuration::Configuration, - update_two_factor_authenticator_request_model: Option< - models::UpdateTwoFactorAuthenticatorRequestModel, - >, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_two_factor_authenticator_request_model = - update_two_factor_authenticator_request_model; - - let uri_str = format!("{}/two-factor/authenticator", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_two_factor_authenticator_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_device_verification_settings_put( - configuration: &configuration::Configuration, - device_verification_request_model: Option, -) -> Result< - models::DeviceVerificationResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_device_verification_request_model = device_verification_request_model; - - let uri_str = format!( - "{}/two-factor/device-verification-settings", - configuration.base_path - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_device_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceVerificationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceVerificationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_disable_post( - configuration: &configuration::Configuration, - two_factor_provider_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_two_factor_provider_request_model = two_factor_provider_request_model; - - let uri_str = format!("{}/two-factor/disable", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_provider_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_disable_put( - configuration: &configuration::Configuration, - two_factor_provider_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_two_factor_provider_request_model = two_factor_provider_request_model; - - let uri_str = format!("{}/two-factor/disable", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_provider_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_duo_post( - configuration: &configuration::Configuration, - update_two_factor_duo_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_two_factor_duo_request_model = update_two_factor_duo_request_model; - - let uri_str = format!("{}/two-factor/duo", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_two_factor_duo_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_duo_put( - configuration: &configuration::Configuration, - update_two_factor_duo_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_two_factor_duo_request_model = update_two_factor_duo_request_model; - - let uri_str = format!("{}/two-factor/duo", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_two_factor_duo_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_email_post( - configuration: &configuration::Configuration, - update_two_factor_email_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_two_factor_email_request_model = update_two_factor_email_request_model; - - let uri_str = format!("{}/two-factor/email", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_two_factor_email_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_email_put( - configuration: &configuration::Configuration, - update_two_factor_email_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_two_factor_email_request_model = update_two_factor_email_request_model; - - let uri_str = format!("{}/two-factor/email", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_two_factor_email_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/two-factor", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_get_authenticator_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!("{}/two-factor/get-authenticator", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_get_device_verification_settings_get( - configuration: &configuration::Configuration, -) -> Result< - models::DeviceVerificationResponseModel, - Error, -> { - let uri_str = format!( - "{}/two-factor/get-device-verification-settings", - configuration.base_path - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceVerificationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceVerificationResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_get_duo_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!("{}/two-factor/get-duo", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_get_email_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!("{}/two-factor/get-email", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_get_recover_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!("{}/two-factor/get-recover", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorRecoverResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorRecoverResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_get_webauthn_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!("{}/two-factor/get-webauthn", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_get_yubikey_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!("{}/two-factor/get-yubikey", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_recover_post( - configuration: &configuration::Configuration, - two_factor_recovery_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_two_factor_recovery_request_model = two_factor_recovery_request_model; - - let uri_str = format!("{}/two-factor/recover", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_recovery_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_send_email_login_post( - configuration: &configuration::Configuration, - two_factor_email_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_two_factor_email_request_model = two_factor_email_request_model; - - let uri_str = format!("{}/two-factor/send-email-login", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_email_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_send_email_post( - configuration: &configuration::Configuration, - two_factor_email_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_two_factor_email_request_model = two_factor_email_request_model; - - let uri_str = format!("{}/two-factor/send-email", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_email_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_webauthn_delete( - configuration: &configuration::Configuration, - two_factor_web_authn_delete_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_two_factor_web_authn_delete_request_model = two_factor_web_authn_delete_request_model; - - let uri_str = format!("{}/two-factor/webauthn", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_web_authn_delete_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_webauthn_post( - configuration: &configuration::Configuration, - two_factor_web_authn_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_two_factor_web_authn_request_model = two_factor_web_authn_request_model; - - let uri_str = format!("{}/two-factor/webauthn", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_web_authn_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_webauthn_put( - configuration: &configuration::Configuration, - two_factor_web_authn_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_two_factor_web_authn_request_model = two_factor_web_authn_request_model; - - let uri_str = format!("{}/two-factor/webauthn", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_two_factor_web_authn_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_yubikey_post( - configuration: &configuration::Configuration, - update_two_factor_yubico_otp_request_model: Option< - models::UpdateTwoFactorYubicoOtpRequestModel, - >, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_two_factor_yubico_otp_request_model = update_two_factor_yubico_otp_request_model; - - let uri_str = format!("{}/two-factor/yubikey", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_two_factor_yubico_otp_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn two_factor_yubikey_put( - configuration: &configuration::Configuration, - update_two_factor_yubico_otp_request_model: Option< - models::UpdateTwoFactorYubicoOtpRequestModel, - >, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_update_two_factor_yubico_otp_request_model = update_two_factor_yubico_otp_request_model; - - let uri_str = format!("{}/two-factor/yubikey", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_update_two_factor_yubico_otp_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/apis/users_api.rs b/crates/bitwarden-api-api/src/apis/users_api.rs index 75893cfbd..bd4e31c18 100644 --- a/crates/bitwarden-api-api/src/apis/users_api.rs +++ b/crates/bitwarden-api-api/src/apis/users_api.rs @@ -8,65 +8,100 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`users_id_public_key_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum UsersIdPublicKeyGetError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait UsersApi: Send + Sync { + /// GET /users/{id}/public-key + async fn users_id_public_key_get<'a>( + &self, + id: &'a str, + ) -> Result>; } -pub async fn users_id_public_key_get( - configuration: &configuration::Configuration, - id: &str, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - - let uri_str = format!( - "{}/users/{id}/public-key", - configuration.base_path, - id = crate::apis::urlencode(p_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +pub struct UsersApiClient { + configuration: Arc, +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +impl UsersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; +} - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; +#[async_trait(?Send)] +impl UsersApi for UsersApiClient { + async fn users_id_public_key_get<'a>( + &self, + id: &'a str, + ) -> Result> { + let local_var_configuration = &self.configuration; - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); + let local_var_client = &local_var_configuration.client; - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserKeyResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserKeyResponseModel`")))), + let local_var_uri_str = format!( + "{}/users/{id}/public-key", + local_var_configuration.base_path, + id = crate::apis::urlencode(id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserKeyResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::UserKeyResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } + +/// struct for typed errors of method [`UsersApi::users_id_public_key_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UsersIdPublicKeyGetError { + UnknownValue(serde_json::Value), +} diff --git a/crates/bitwarden-api-api/src/apis/web_authn_api.rs b/crates/bitwarden-api-api/src/apis/web_authn_api.rs index fc1d73054..22a2ade15 100644 --- a/crates/bitwarden-api-api/src/apis/web_authn_api.rs +++ b/crates/bitwarden-api-api/src/apis/web_authn_api.rs @@ -8,321 +8,419 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait WebAuthnApi: Send + Sync { + /// POST /webauthn/assertion-options + async fn webauthn_assertion_options_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result< + models::WebAuthnLoginAssertionOptionsResponseModel, + Error, + >; + + /// POST /webauthn/attestation-options + async fn webauthn_attestation_options_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result< + models::WebAuthnCredentialCreateOptionsResponseModel, + Error, + >; + + /// GET /webauthn + async fn webauthn_get<'a>( + &self, + ) -> Result>; + + /// POST /webauthn/{id}/delete + async fn webauthn_id_delete_post<'a>( + &self, + id: uuid::Uuid, + secret_verification_request_model: Option, + ) -> Result<(), Error>; + + /// POST /webauthn + async fn webauthn_post<'a>( + &self, + web_authn_login_credential_create_request_model: Option< + models::WebAuthnLoginCredentialCreateRequestModel, + >, + ) -> Result<(), Error>; + + /// PUT /webauthn + async fn webauthn_put<'a>( + &self, + web_authn_login_credential_update_request_model: Option< + models::WebAuthnLoginCredentialUpdateRequestModel, + >, + ) -> Result<(), Error>; +} + +pub struct WebAuthnApiClient { + configuration: Arc, +} + +impl WebAuthnApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl WebAuthnApi for WebAuthnApiClient { + async fn webauthn_assertion_options_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result< + models::WebAuthnLoginAssertionOptionsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/webauthn/assertion-options", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebAuthnLoginAssertionOptionsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::WebAuthnLoginAssertionOptionsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn webauthn_attestation_options_post<'a>( + &self, + secret_verification_request_model: Option, + ) -> Result< + models::WebAuthnCredentialCreateOptionsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/webauthn/attestation-options", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebAuthnCredentialCreateOptionsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::WebAuthnCredentialCreateOptionsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn webauthn_get<'a>( + &self, + ) -> Result> + { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/webauthn", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebAuthnCredentialResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::WebAuthnCredentialResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn webauthn_id_delete_post<'a>( + &self, + id: uuid::Uuid, + secret_verification_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/webauthn/{id}/delete", + local_var_configuration.base_path, + id = id + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn webauthn_post<'a>( + &self, + web_authn_login_credential_create_request_model: Option< + models::WebAuthnLoginCredentialCreateRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/webauthn", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&web_authn_login_credential_create_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn webauthn_put<'a>( + &self, + web_authn_login_credential_update_request_model: Option< + models::WebAuthnLoginCredentialUpdateRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; -/// struct for typed errors of method [`webauthn_assertion_options_post`] + let local_var_uri_str = format!("{}/webauthn", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&web_authn_login_credential_update_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`WebAuthnApi::webauthn_assertion_options_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum WebauthnAssertionOptionsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`webauthn_attestation_options_post`] +/// struct for typed errors of method [`WebAuthnApi::webauthn_attestation_options_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum WebauthnAttestationOptionsPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`webauthn_get`] +/// struct for typed errors of method [`WebAuthnApi::webauthn_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum WebauthnGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`webauthn_id_delete_post`] +/// struct for typed errors of method [`WebAuthnApi::webauthn_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum WebauthnIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`webauthn_post`] +/// struct for typed errors of method [`WebAuthnApi::webauthn_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum WebauthnPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`webauthn_put`] +/// struct for typed errors of method [`WebAuthnApi::webauthn_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum WebauthnPutError { UnknownValue(serde_json::Value), } - -pub async fn webauthn_assertion_options_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result< - models::WebAuthnLoginAssertionOptionsResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!("{}/webauthn/assertion-options", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebAuthnLoginAssertionOptionsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WebAuthnLoginAssertionOptionsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn webauthn_attestation_options_post( - configuration: &configuration::Configuration, - secret_verification_request_model: Option, -) -> Result< - models::WebAuthnCredentialCreateOptionsResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!("{}/webauthn/attestation-options", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebAuthnCredentialCreateOptionsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WebAuthnCredentialCreateOptionsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn webauthn_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/webauthn", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebAuthnCredentialResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WebAuthnCredentialResponseModelListResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn webauthn_id_delete_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, - secret_verification_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_id = id; - let p_secret_verification_request_model = secret_verification_request_model; - - let uri_str = format!( - "{}/webauthn/{id}/delete", - configuration.base_path, - id = crate::apis::urlencode(p_id.to_string()) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_secret_verification_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn webauthn_post( - configuration: &configuration::Configuration, - web_authn_login_credential_create_request_model: Option< - models::WebAuthnLoginCredentialCreateRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_web_authn_login_credential_create_request_model = - web_authn_login_credential_create_request_model; - - let uri_str = format!("{}/webauthn", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_web_authn_login_credential_create_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn webauthn_put( - configuration: &configuration::Configuration, - web_authn_login_credential_update_request_model: Option< - models::WebAuthnLoginCredentialUpdateRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_web_authn_login_credential_update_request_model = - web_authn_login_credential_update_request_model; - - let uri_str = format!("{}/webauthn", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_web_authn_login_credential_update_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-api/src/lib.rs b/crates/bitwarden-api-api/src/lib.rs index 215cde4c7..a061635ce 100644 --- a/crates/bitwarden-api-api/src/lib.rs +++ b/crates/bitwarden-api-api/src/lib.rs @@ -4,10 +4,10 @@ clippy::empty_docs, clippy::to_string_in_format_args, clippy::needless_return, - clippy::uninlined_format_args + clippy::uninlined_format_args, + clippy::new_without_default )] -extern crate reqwest; extern crate serde; extern crate serde_json; extern crate serde_repr; diff --git a/crates/bitwarden-api-identity/Cargo.toml b/crates/bitwarden-api-identity/Cargo.toml index 022225451..92bca252b 100644 --- a/crates/bitwarden-api-identity/Cargo.toml +++ b/crates/bitwarden-api-identity/Cargo.toml @@ -12,7 +12,12 @@ repository.workspace = true license-file.workspace = true keywords.workspace = true +[features] +mockall = ["dep:mockall"] + [dependencies] +async-trait = { workspace = true } +mockall = { version = ">=0.13, <0.14", optional = true } reqwest = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/crates/bitwarden-api-identity/README.md b/crates/bitwarden-api-identity/README.md index 678c1b2fa..6babec404 100644 --- a/crates/bitwarden-api-identity/README.md +++ b/crates/bitwarden-api-identity/README.md @@ -25,7 +25,7 @@ bitwarden-api-identity = { path = "./bitwarden-api-identity" } ## Documentation for API Endpoints -All URIs are relative to _http://localhost_ +All URIs are relative to *https://identity.bitwarden.com* | Class | Method | HTTP request | Description | | ------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------ | ----------- | diff --git a/crates/bitwarden-api-identity/src/apis/accounts_api.rs b/crates/bitwarden-api-identity/src/apis/accounts_api.rs index 8be0fd174..bc2c24745 100644 --- a/crates/bitwarden-api-identity/src/apis/accounts_api.rs +++ b/crates/bitwarden-api-identity/src/apis/accounts_api.rs @@ -8,366 +8,465 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; + +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait AccountsApi: Send + Sync { + /// POST /accounts/prelogin + async fn accounts_prelogin_post<'a>( + &self, + prelogin_request_model: Option, + ) -> Result>; + + /// POST /accounts/register/finish + async fn accounts_register_finish_post<'a>( + &self, + register_finish_request_model: Option, + ) -> Result>; + + /// POST /accounts/register + async fn accounts_register_post<'a>( + &self, + register_request_model: Option, + ) -> Result>; + + /// POST /accounts/register/send-verification-email + async fn accounts_register_send_verification_email_post<'a>( + &self, + register_send_verification_email_request_model: Option< + models::RegisterSendVerificationEmailRequestModel, + >, + ) -> Result<(), Error>; + + /// POST /accounts/register/verification-email-clicked + async fn accounts_register_verification_email_clicked_post<'a>( + &self, + register_verification_email_clicked_request_model: Option< + models::RegisterVerificationEmailClickedRequestModel, + >, + ) -> Result<(), Error>; + + /// POST /accounts/trial/send-verification-email + async fn accounts_trial_send_verification_email_post<'a>( + &self, + trial_send_verification_email_request_model: Option< + models::TrialSendVerificationEmailRequestModel, + >, + ) -> Result<(), Error>; + + /// GET /accounts/webauthn/assertion-options + async fn accounts_webauthn_assertion_options_get<'a>( + &self, + ) -> Result< + models::WebAuthnLoginAssertionOptionsResponseModel, + Error, + >; +} + +pub struct AccountsApiClient { + configuration: Arc, +} + +impl AccountsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +#[async_trait(?Send)] +impl AccountsApi for AccountsApiClient { + async fn accounts_prelogin_post<'a>( + &self, + prelogin_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/accounts/prelogin", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = local_var_req_builder.json(&prelogin_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PreloginResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PreloginResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn accounts_register_finish_post<'a>( + &self, + register_finish_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/register/finish", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = local_var_req_builder.json(®ister_finish_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegisterResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::RegisterResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn accounts_register_post<'a>( + &self, + register_request_model: Option, + ) -> Result> { + let local_var_configuration = &self.configuration; -/// struct for typed errors of method [`accounts_prelogin_post`] + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/accounts/register", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = local_var_req_builder.json(®ister_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegisterResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::RegisterResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn accounts_register_send_verification_email_post<'a>( + &self, + register_send_verification_email_request_model: Option< + models::RegisterSendVerificationEmailRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/register/send-verification-email", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = + local_var_req_builder.json(®ister_send_verification_email_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn accounts_register_verification_email_clicked_post<'a>( + &self, + register_verification_email_clicked_request_model: Option< + models::RegisterVerificationEmailClickedRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/register/verification-email-clicked", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = + local_var_req_builder.json(®ister_verification_email_clicked_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn accounts_trial_send_verification_email_post<'a>( + &self, + trial_send_verification_email_request_model: Option< + models::TrialSendVerificationEmailRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/trial/send-verification-email", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = + local_var_req_builder.json(&trial_send_verification_email_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } + + async fn accounts_webauthn_assertion_options_get<'a>( + &self, + ) -> Result< + models::WebAuthnLoginAssertionOptionsResponseModel, + Error, + > { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/webauthn/assertion-options", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebAuthnLoginAssertionOptionsResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::WebAuthnLoginAssertionOptionsResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } + } +} + +/// struct for typed errors of method [`AccountsApi::accounts_prelogin_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsPreloginPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_register_finish_post`] +/// struct for typed errors of method [`AccountsApi::accounts_register_finish_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsRegisterFinishPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_register_post`] +/// struct for typed errors of method [`AccountsApi::accounts_register_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsRegisterPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_register_send_verification_email_post`] +/// struct for typed errors of method +/// [`AccountsApi::accounts_register_send_verification_email_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsRegisterSendVerificationEmailPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_register_verification_email_clicked_post`] +/// struct for typed errors of method +/// [`AccountsApi::accounts_register_verification_email_clicked_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsRegisterVerificationEmailClickedPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_trial_send_verification_email_post`] +/// struct for typed errors of method [`AccountsApi::accounts_trial_send_verification_email_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsTrialSendVerificationEmailPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_webauthn_assertion_options_get`] +/// struct for typed errors of method [`AccountsApi::accounts_webauthn_assertion_options_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AccountsWebauthnAssertionOptionsGetError { UnknownValue(serde_json::Value), } - -pub async fn accounts_prelogin_post( - configuration: &configuration::Configuration, - prelogin_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_prelogin_request_model = prelogin_request_model; - - let uri_str = format!("{}/accounts/prelogin", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - req_builder = req_builder.json(&p_prelogin_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PreloginResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PreloginResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn accounts_register_finish_post( - configuration: &configuration::Configuration, - register_finish_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_register_finish_request_model = register_finish_request_model; - - let uri_str = format!("{}/accounts/register/finish", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - req_builder = req_builder.json(&p_register_finish_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegisterResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegisterResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn accounts_register_post( - configuration: &configuration::Configuration, - register_request_model: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_register_request_model = register_request_model; - - let uri_str = format!("{}/accounts/register", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - req_builder = req_builder.json(&p_register_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegisterResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegisterResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn accounts_register_send_verification_email_post( - configuration: &configuration::Configuration, - register_send_verification_email_request_model: Option< - models::RegisterSendVerificationEmailRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_register_send_verification_email_request_model = - register_send_verification_email_request_model; - - let uri_str = format!( - "{}/accounts/register/send-verification-email", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - req_builder = req_builder.json(&p_register_send_verification_email_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn accounts_register_verification_email_clicked_post( - configuration: &configuration::Configuration, - register_verification_email_clicked_request_model: Option< - models::RegisterVerificationEmailClickedRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_register_verification_email_clicked_request_model = - register_verification_email_clicked_request_model; - - let uri_str = format!( - "{}/accounts/register/verification-email-clicked", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - req_builder = req_builder.json(&p_register_verification_email_clicked_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn accounts_trial_send_verification_email_post( - configuration: &configuration::Configuration, - trial_send_verification_email_request_model: Option< - models::TrialSendVerificationEmailRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_trial_send_verification_email_request_model = trial_send_verification_email_request_model; - - let uri_str = format!( - "{}/accounts/trial/send-verification-email", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - req_builder = req_builder.json(&p_trial_send_verification_email_request_model); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn accounts_webauthn_assertion_options_get( - configuration: &configuration::Configuration, -) -> Result< - models::WebAuthnLoginAssertionOptionsResponseModel, - Error, -> { - let uri_str = format!( - "{}/accounts/webauthn/assertion-options", - configuration.base_path - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebAuthnLoginAssertionOptionsResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WebAuthnLoginAssertionOptionsResponseModel`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/crates/bitwarden-api-identity/src/apis/configuration.rs b/crates/bitwarden-api-identity/src/apis/configuration.rs index 96c5cca2a..e8270e9fc 100644 --- a/crates/bitwarden-api-identity/src/apis/configuration.rs +++ b/crates/bitwarden-api-identity/src/apis/configuration.rs @@ -36,7 +36,7 @@ impl Configuration { impl Default for Configuration { fn default() -> Self { Configuration { - base_path: "http://localhost".to_owned(), + base_path: "https://identity.bitwarden.com".to_owned(), user_agent: Some("OpenAPI-Generator/v1/rust".to_owned()), client: reqwest::Client::new(), basic_auth: None, diff --git a/crates/bitwarden-api-identity/src/apis/info_api.rs b/crates/bitwarden-api-identity/src/apis/info_api.rs index 503c7145a..8b47ed003 100644 --- a/crates/bitwarden-api-identity/src/apis/info_api.rs +++ b/crates/bitwarden-api-identity/src/apis/info_api.rs @@ -8,135 +8,185 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`alive_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AliveGetError { - UnknownValue(serde_json::Value), +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait InfoApi: Send + Sync { + /// GET /alive + async fn alive_get<'a>(&self) -> Result>; + + /// GET /now + async fn now_get<'a>(&self) -> Result>; + + /// GET /version + async fn version_get<'a>(&self) -> Result<(), Error>; } -/// struct for typed errors of method [`now_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum NowGetError { - UnknownValue(serde_json::Value), +pub struct InfoApiClient { + configuration: Arc, } -/// struct for typed errors of method [`version_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum VersionGetError { - UnknownValue(serde_json::Value), +impl InfoApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn alive_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/alive", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +#[async_trait(?Send)] +impl InfoApi for InfoApiClient { + async fn alive_get<'a>(&self) -> Result> { + let local_var_configuration = &self.configuration; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/alive", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Ok(content), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))), + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Ok(local_var_content), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `String`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } -} -pub async fn now_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/now", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + async fn now_get<'a>(&self) -> Result> { + let local_var_configuration = &self.configuration; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/now", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Ok(local_var_content), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `String`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Ok(content), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))), + async fn version_get<'a>(&self) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/version", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } -pub async fn version_get( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/version", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +/// struct for typed errors of method [`InfoApi::alive_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AliveGetError { + UnknownValue(serde_json::Value), +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } +/// struct for typed errors of method [`InfoApi::now_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum NowGetError { + UnknownValue(serde_json::Value), +} - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`InfoApi::version_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum VersionGetError { + UnknownValue(serde_json::Value), } diff --git a/crates/bitwarden-api-identity/src/apis/mod.rs b/crates/bitwarden-api-identity/src/apis/mod.rs index 9fbb0e914..8fd842a14 100644 --- a/crates/bitwarden-api-identity/src/apis/mod.rs +++ b/crates/bitwarden-api-identity/src/apis/mod.rs @@ -117,3 +117,70 @@ pub mod info_api; pub mod sso_api; pub mod configuration; + +use std::sync::Arc; + +pub trait Api { + fn accounts_api(&self) -> &dyn accounts_api::AccountsApi; + fn info_api(&self) -> &dyn info_api::InfoApi; + fn sso_api(&self) -> &dyn sso_api::SsoApi; +} + +pub struct ApiClient { + accounts_api: Box, + info_api: Box, + sso_api: Box, +} + +impl ApiClient { + pub fn new(configuration: Arc) -> Self { + Self { + accounts_api: Box::new(accounts_api::AccountsApiClient::new(configuration.clone())), + info_api: Box::new(info_api::InfoApiClient::new(configuration.clone())), + sso_api: Box::new(sso_api::SsoApiClient::new(configuration.clone())), + } + } +} + +impl Api for ApiClient { + fn accounts_api(&self) -> &dyn accounts_api::AccountsApi { + self.accounts_api.as_ref() + } + fn info_api(&self) -> &dyn info_api::InfoApi { + self.info_api.as_ref() + } + fn sso_api(&self) -> &dyn sso_api::SsoApi { + self.sso_api.as_ref() + } +} + +#[cfg(feature = "mockall")] +pub struct MockApiClient { + pub accounts_api_mock: accounts_api::MockAccountsApi, + pub info_api_mock: info_api::MockInfoApi, + pub sso_api_mock: sso_api::MockSsoApi, +} + +#[cfg(feature = "mockall")] +impl MockApiClient { + pub fn new() -> Self { + Self { + accounts_api_mock: accounts_api::MockAccountsApi::new(), + info_api_mock: info_api::MockInfoApi::new(), + sso_api_mock: sso_api::MockSsoApi::new(), + } + } +} + +#[cfg(feature = "mockall")] +impl Api for MockApiClient { + fn accounts_api(&self) -> &dyn accounts_api::AccountsApi { + &self.accounts_api_mock + } + fn info_api(&self) -> &dyn info_api::InfoApi { + &self.info_api_mock + } + fn sso_api(&self) -> &dyn sso_api::SsoApi { + &self.sso_api_mock + } +} diff --git a/crates/bitwarden-api-identity/src/apis/sso_api.rs b/crates/bitwarden-api-identity/src/apis/sso_api.rs index 31030869b..3edcd3859 100644 --- a/crates/bitwarden-api-identity/src/apis/sso_api.rs +++ b/crates/bitwarden-api-identity/src/apis/sso_api.rs @@ -8,184 +8,264 @@ * Generated by: https://openapi-generator.tech */ +use std::sync::Arc; + +use async_trait::async_trait; +#[cfg(feature = "mockall")] +use mockall::automock; use reqwest; use serde::{de::Error as _, Deserialize, Serialize}; -use super::{configuration, ContentType, Error}; -use crate::{apis::ResponseContent, models}; +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`sso_external_callback_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SsoExternalCallbackGetError { - UnknownValue(serde_json::Value), -} +#[cfg_attr(feature = "mockall", automock)] +#[async_trait(?Send)] +pub trait SsoApi: Send + Sync { + /// GET /sso/ExternalCallback + async fn sso_external_callback_get<'a>(&self) + -> Result<(), Error>; -/// struct for typed errors of method [`sso_external_challenge_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SsoExternalChallengeGetError { - UnknownValue(serde_json::Value), + /// GET /sso/ExternalChallenge + async fn sso_external_challenge_get<'a>( + &self, + domain_hint: Option<&'a str>, + return_url: Option<&'a str>, + user_identifier: Option<&'a str>, + sso_token: Option<&'a str>, + ) -> Result<(), Error>; + + /// GET /sso/Login + async fn sso_login_get<'a>( + &self, + return_url: Option<&'a str>, + ) -> Result<(), Error>; + + /// GET /sso/PreValidate + async fn sso_pre_validate_get<'a>( + &self, + domain_hint: Option<&'a str>, + ) -> Result<(), Error>; } -/// struct for typed errors of method [`sso_login_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SsoLoginGetError { - UnknownValue(serde_json::Value), +pub struct SsoApiClient { + configuration: Arc, } -/// struct for typed errors of method [`sso_pre_validate_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SsoPreValidateGetError { - UnknownValue(serde_json::Value), +impl SsoApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn sso_external_callback_get( - configuration: &configuration::Configuration, -) -> Result<(), Error> { - let uri_str = format!("{}/sso/ExternalCallback", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +#[async_trait(?Send)] +impl SsoApi for SsoApiClient { + async fn sso_external_callback_get<'a>( + &self, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } + let local_var_client = &local_var_configuration.client; - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} + let local_var_uri_str = + format!("{}/sso/ExternalCallback", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); -pub async fn sso_external_challenge_get( - configuration: &configuration::Configuration, - domain_hint: Option<&str>, - return_url: Option<&str>, - user_identifier: Option<&str>, - sso_token: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_domain_hint = domain_hint; - let p_return_url = return_url; - let p_user_identifier = user_identifier; - let p_sso_token = sso_token; - - let uri_str = format!("{}/sso/ExternalChallenge", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_domain_hint { - req_builder = req_builder.query(&[("domainHint", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_return_url { - req_builder = req_builder.query(&[("returnUrl", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_user_identifier { - req_builder = req_builder.query(&[("userIdentifier", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sso_token { - req_builder = req_builder.query(&[("ssoToken", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } -} -pub async fn sso_login_get( - configuration: &configuration::Configuration, - return_url: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_return_url = return_url; + async fn sso_external_challenge_get<'a>( + &self, + domain_hint: Option<&'a str>, + return_url: Option<&'a str>, + user_identifier: Option<&'a str>, + sso_token: Option<&'a str>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/sso/ExternalChallenge", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = domain_hint { + local_var_req_builder = + local_var_req_builder.query(&[("domainHint", ¶m_value.to_string())]); + } + if let Some(ref param_value) = return_url { + local_var_req_builder = + local_var_req_builder.query(&[("returnUrl", ¶m_value.to_string())]); + } + if let Some(ref param_value) = user_identifier { + local_var_req_builder = + local_var_req_builder.query(&[("userIdentifier", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sso_token { + local_var_req_builder = + local_var_req_builder.query(&[("ssoToken", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let uri_str = format!("{}/sso/Login", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if let Some(ref param_value) = p_return_url { - req_builder = req_builder.query(&[("returnUrl", ¶m_value.to_string())]); + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + + async fn sso_login_get<'a>( + &self, + return_url: Option<&'a str>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/sso/Login", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = return_url { + local_var_req_builder = + local_var_req_builder.query(&[("returnUrl", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + async fn sso_pre_validate_get<'a>( + &self, + domain_hint: Option<&'a str>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/sso/PreValidate", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = domain_hint { + local_var_req_builder = + local_var_req_builder.query(&[("domainHint", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder + .header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } } -pub async fn sso_pre_validate_get( - configuration: &configuration::Configuration, - domain_hint: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_domain_hint = domain_hint; +/// struct for typed errors of method [`SsoApi::sso_external_callback_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SsoExternalCallbackGetError { + UnknownValue(serde_json::Value), +} - let uri_str = format!("{}/sso/PreValidate", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +/// struct for typed errors of method [`SsoApi::sso_external_challenge_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SsoExternalChallengeGetError { + UnknownValue(serde_json::Value), +} - if let Some(ref param_value) = p_domain_hint { - req_builder = req_builder.query(&[("domainHint", ¶m_value.to_string())]); - } - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } +/// struct for typed errors of method [`SsoApi::sso_login_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SsoLoginGetError { + UnknownValue(serde_json::Value), +} - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } +/// struct for typed errors of method [`SsoApi::sso_pre_validate_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SsoPreValidateGetError { + UnknownValue(serde_json::Value), } diff --git a/crates/bitwarden-api-identity/src/lib.rs b/crates/bitwarden-api-identity/src/lib.rs index 215cde4c7..a061635ce 100644 --- a/crates/bitwarden-api-identity/src/lib.rs +++ b/crates/bitwarden-api-identity/src/lib.rs @@ -4,10 +4,10 @@ clippy::empty_docs, clippy::to_string_in_format_args, clippy::needless_return, - clippy::uninlined_format_args + clippy::uninlined_format_args, + clippy::new_without_default )] -extern crate reqwest; extern crate serde; extern crate serde_json; extern crate serde_repr; diff --git a/crates/bitwarden-core/src/auth/api/request/mod.rs b/crates/bitwarden-core/src/auth/api/request/mod.rs index 19f91e524..8fc2d6abb 100644 --- a/crates/bitwarden-core/src/auth/api/request/mod.rs +++ b/crates/bitwarden-core/src/auth/api/request/mod.rs @@ -33,13 +33,11 @@ async fn send_identity_connect_request( email: Option<&str>, body: impl serde::Serialize, ) -> Result { - let mut request = configurations - .identity + let config = &configurations.identity_config; + + let mut request = config .client - .post(format!( - "{}/connect/token", - &configurations.identity.base_path - )) + .post(format!("{}/connect/token", &config.base_path)) .header( reqwest::header::CONTENT_TYPE, "application/x-www-form-urlencoded; charset=utf-8", @@ -47,7 +45,7 @@ async fn send_identity_connect_request( .header(reqwest::header::ACCEPT, "application/json") .header("Device-Type", configurations.device_type as usize); - if let Some(ref user_agent) = configurations.identity.user_agent { + if let Some(ref user_agent) = config.user_agent { request = request.header(reqwest::header::USER_AGENT, user_agent.clone()); } diff --git a/crates/bitwarden-core/src/auth/login/auth_request.rs b/crates/bitwarden-core/src/auth/login/auth_request.rs index 363086fb1..05779e1b9 100644 --- a/crates/bitwarden-core/src/auth/login/auth_request.rs +++ b/crates/bitwarden-core/src/auth/login/auth_request.rs @@ -1,7 +1,4 @@ -use bitwarden_api_api::{ - apis::auth_requests_api::{auth_requests_id_response_get, auth_requests_post}, - models::{AuthRequestCreateRequestModel, AuthRequestType}, -}; +use bitwarden_api_api::models::{AuthRequestCreateRequestModel, AuthRequestType}; use bitwarden_crypto::Kdf; use uuid::Uuid; @@ -43,7 +40,10 @@ pub(crate) async fn send_new_auth_request( r#type: AuthRequestType::AuthenticateAndUnlock, }; - let res = auth_requests_post(&config.api, Some(req)) + let res = config + .api_client + .auth_requests_api() + .auth_requests_post(Some(req)) .await .map_err(ApiError::from)?; @@ -62,14 +62,12 @@ pub(crate) async fn complete_auth_request( auth_req: NewAuthRequestResponse, ) -> Result<(), LoginError> { let config = client.internal.get_api_configurations().await; - - let res = auth_requests_id_response_get( - &config.api, - auth_req.auth_request_id, - Some(&auth_req.access_code), - ) - .await - .map_err(ApiError::from)?; + let res = config + .api_client + .auth_requests_api() + .auth_requests_id_response_get(auth_req.auth_request_id, Some(&auth_req.access_code)) + .await + .map_err(ApiError::from)?; let approved = res.request_approved.unwrap_or(false); diff --git a/crates/bitwarden-core/src/auth/login/prelogin.rs b/crates/bitwarden-core/src/auth/login/prelogin.rs index 5d5d58e6b..40250fe89 100644 --- a/crates/bitwarden-core/src/auth/login/prelogin.rs +++ b/crates/bitwarden-core/src/auth/login/prelogin.rs @@ -1,7 +1,4 @@ -use bitwarden_api_identity::{ - apis::accounts_api::accounts_prelogin_post, - models::{PreloginRequestModel, PreloginResponseModel}, -}; +use bitwarden_api_identity::models::{PreloginRequestModel, PreloginResponseModel}; use bitwarden_crypto::Kdf; use thiserror::Error; @@ -19,7 +16,10 @@ pub enum PreloginError { pub(crate) async fn prelogin(client: &Client, email: String) -> Result { let request_model = PreloginRequestModel::new(email); let config = client.internal.get_api_configurations().await; - let result = accounts_prelogin_post(&config.identity, Some(request_model)) + let result = config + .identity_client + .accounts_api() + .accounts_prelogin_post(Some(request_model)) .await .map_err(ApiError::from)?; diff --git a/crates/bitwarden-core/src/auth/login/two_factor.rs b/crates/bitwarden-core/src/auth/login/two_factor.rs index ca163b4c2..bc4cb7f95 100644 --- a/crates/bitwarden-core/src/auth/login/two_factor.rs +++ b/crates/bitwarden-core/src/auth/login/two_factor.rs @@ -46,9 +46,10 @@ pub(crate) async fn send_two_factor_email( )?; let config = client.internal.get_api_configurations().await; - bitwarden_api_api::apis::two_factor_api::two_factor_send_email_login_post( - &config.api, - Some(TwoFactorEmailRequestModel { + config + .api_client + .two_factor_api() + .two_factor_send_email_login_post(Some(TwoFactorEmailRequestModel { master_password_hash: Some(password_hash), otp: None, auth_request_access_code: None, @@ -56,10 +57,9 @@ pub(crate) async fn send_two_factor_email( email: input.email.to_owned(), auth_request_id: None, sso_email2_fa_session_token: None, - }), - ) - .await - .map_err(ApiError::from)?; + })) + .await + .map_err(ApiError::from)?; Ok(()) } diff --git a/crates/bitwarden-core/src/auth/register.rs b/crates/bitwarden-core/src/auth/register.rs index 88833632d..bba8f8609 100644 --- a/crates/bitwarden-core/src/auth/register.rs +++ b/crates/bitwarden-core/src/auth/register.rs @@ -1,7 +1,4 @@ -use bitwarden_api_identity::{ - apis::accounts_api::accounts_register_post, - models::{KeysRequestModel, RegisterRequestModel}, -}; +use bitwarden_api_identity::models::{KeysRequestModel, RegisterRequestModel}; use bitwarden_crypto::{ default_pbkdf2_iterations, CryptoError, EncString, HashPurpose, Kdf, MasterKey, RsaKeyPair, }; @@ -37,9 +34,10 @@ pub(super) async fn register(client: &Client, req: &RegisterRequest) -> Result<( let keys = make_register_keys(req.email.to_owned(), req.password.to_owned(), kdf)?; - accounts_register_post( - &config.identity, - Some(RegisterRequestModel { + config + .identity_client + .accounts_api() + .accounts_register_post(Some(RegisterRequestModel { name: req.name.to_owned(), email: req.email.to_owned(), master_password_hash: keys.master_password_hash, @@ -57,10 +55,9 @@ pub(super) async fn register(client: &Client, req: &RegisterRequest) -> Result<( kdf_memory: None, kdf_parallelism: None, reference_data: None, // TODO: Add - }), - ) - .await - .map_err(ApiError::from)?; + })) + .await + .map_err(ApiError::from)?; Ok(()) } diff --git a/crates/bitwarden-core/src/client/client.rs b/crates/bitwarden-core/src/client/client.rs index 6cd632eb4..321eeb524 100644 --- a/crates/bitwarden-core/src/client/client.rs +++ b/crates/bitwarden-core/src/client/client.rs @@ -97,11 +97,11 @@ impl Client { login_method: RwLock::new(None), #[cfg(feature = "internal")] flags: RwLock::new(Flags::default()), - __api_configurations: RwLock::new(Arc::new(ApiConfigurations { + __api_configurations: RwLock::new(ApiConfigurations::new( identity, api, - device_type: settings.device_type, - })), + settings.device_type, + )), external_client, key_store: KeyStore::default(), #[cfg(feature = "internal")] diff --git a/crates/bitwarden-core/src/client/internal.rs b/crates/bitwarden-core/src/client/internal.rs index 5c0e085b5..995a5708a 100644 --- a/crates/bitwarden-core/src/client/internal.rs +++ b/crates/bitwarden-core/src/client/internal.rs @@ -26,13 +26,54 @@ use crate::{ }; #[allow(missing_docs)] -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiConfigurations { - pub identity: bitwarden_api_identity::apis::configuration::Configuration, - pub api: bitwarden_api_api::apis::configuration::Configuration, + pub identity_client: Arc, + pub api_client: Arc, + pub(crate) identity_config: Arc, + pub(crate) api_config: Arc, pub device_type: DeviceType, } +impl std::fmt::Debug for ApiConfigurations { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiConfigurations") + .field("device_type", &self.device_type) + .finish_non_exhaustive() + } +} + +impl ApiConfigurations { + pub fn new( + identity: bitwarden_api_identity::apis::configuration::Configuration, + api: bitwarden_api_api::apis::configuration::Configuration, + device_type: DeviceType, + ) -> Self { + let identity_config = Arc::new(identity); + let api_config = Arc::new(api); + + Self { + identity_client: Arc::new(bitwarden_api_identity::apis::ApiClient::new( + identity_config.clone(), + )), + api_client: Arc::new(bitwarden_api_api::apis::ApiClient::new(api_config.clone())), + identity_config, + api_config, + device_type, + } + } + + pub fn set_tokens(&mut self, token: String) { + let mut identity = (*self.identity_config).clone(); + let mut api = (*self.api_config).clone(); + + identity.oauth_access_token = Some(token.clone()); + api.oauth_access_token = Some(token); + + *self = ApiConfigurations::new(identity, api, self.device_type); + } +} + /// Access and refresh tokens used for authentication and authorization. #[derive(Debug, Clone)] pub(crate) enum Tokens { @@ -73,7 +114,7 @@ pub struct InternalClient { /// Use Client::get_api_configurations().await to access this. /// It should only be used directly in renew_token #[doc(hidden)] - pub(crate) __api_configurations: RwLock>, + pub(crate) __api_configurations: RwLock, /// Reqwest client useable for external integrations like email forwarders, HIBP. #[allow(unused)] @@ -143,14 +184,10 @@ impl InternalClient { /// Sets api tokens for only internal API clients, use `set_tokens` for SdkManagedTokens. pub(crate) fn set_api_tokens_internal(&self, token: String) { - let mut guard = self - .__api_configurations + self.__api_configurations .write() - .expect("RwLock is not poisoned"); - - let inner = Arc::make_mut(&mut guard); - inner.identity.oauth_access_token = Some(token.clone()); - inner.api.oauth_access_token = Some(token); + .expect("RwLock is not poisoned") + .set_tokens(token); } #[allow(missing_docs)] @@ -170,7 +207,7 @@ impl InternalClient { } #[allow(missing_docs)] - pub async fn get_api_configurations(&self) -> Arc { + pub async fn get_api_configurations(&self) -> ApiConfigurations { // At the moment we ignore the error result from the token renewal, if it fails, // the token will end up expiring and the next operation is going to fail anyway. renew_token(self).await.ok(); diff --git a/crates/bitwarden-core/src/platform/get_user_api_key.rs b/crates/bitwarden-core/src/platform/get_user_api_key.rs index fad5ae5ed..ce579e7b2 100644 --- a/crates/bitwarden-core/src/platform/get_user_api_key.rs +++ b/crates/bitwarden-core/src/platform/get_user_api_key.rs @@ -14,10 +14,7 @@ use std::sync::Arc; -use bitwarden_api_api::{ - apis::accounts_api::accounts_api_key_post, - models::{ApiKeyResponseModel, SecretVerificationRequestModel}, -}; +use bitwarden_api_api::models::{ApiKeyResponseModel, SecretVerificationRequestModel}; use bitwarden_crypto::{HashPurpose, MasterKey}; use log::{debug, info}; use serde::{Deserialize, Serialize}; @@ -56,7 +53,11 @@ pub(crate) async fn get_user_api_key( let config = client.internal.get_api_configurations().await; let request = build_secret_verification_request(&auth_settings, input)?; - let response = accounts_api_key_post(&config.api, Some(request)) + + let response = config + .api_client + .accounts_api() + .accounts_api_key_post(Some(request)) .await .map_err(ApiError::from)?; UserApiKeyResponse::process_response(response) diff --git a/crates/bitwarden-vault/src/sync.rs b/crates/bitwarden-vault/src/sync.rs index df959a7d1..64ed0a21f 100644 --- a/crates/bitwarden-vault/src/sync.rs +++ b/crates/bitwarden-vault/src/sync.rs @@ -32,7 +32,10 @@ pub struct SyncRequest { pub(crate) async fn sync(client: &Client, input: &SyncRequest) -> Result { let config = client.internal.get_api_configurations().await; - let sync = bitwarden_api_api::apis::sync_api::sync_get(&config.api, input.exclude_subdomains) + let sync = config + .api_client + .sync_api() + .sync_get(input.exclude_subdomains) .await .map_err(|e| SyncError::Api(e.into()))?; diff --git a/support/build-api.sh b/support/build-api.sh index e45c4c298..2495b31d0 100755 --- a/support/build-api.sh +++ b/support/build-api.sh @@ -18,7 +18,7 @@ npx openapi-generator-cli generate \ -o crates/bitwarden-api-api \ --package-name bitwarden-api-api \ -t ./support/openapi-template \ - --additional-properties=packageVersion=$VERSION,packageDescription=\"Api bindings for the Bitwarden API.\" + --additional-properties=library=reqwest-trait,mockall,topLevelApiClient,packageVersion=$VERSION,packageDescription=\"Api bindings for the Bitwarden API.\" # Delete old directory to ensure all files are updated rm -rf crates/bitwarden-api-identity/src @@ -30,8 +30,23 @@ npx openapi-generator-cli generate \ -o crates/bitwarden-api-identity \ --package-name bitwarden-api-identity \ -t ./support/openapi-template \ - --additional-properties=packageVersion=$VERSION,packageDescription=\"Api bindings for the Bitwarden Identity API.\" + --additional-properties=library=reqwest-trait,mockall,topLevelApiClient,packageVersion=$VERSION,packageDescription=\"Api bindings for the Bitwarden Identity API.\" rustup toolchain install nightly + +# Rustfmt has what looks like a bug, where it requires multiple passes to format the code. +# For example with code like this: +# ```rust +# /// Test Doc +# /// +# /// +# fn test() {} +# ``` +# The first pass will remove one of the empty lines but not the second one, so we need a +# second pass to remove the second empty line. The swagger generated code adds three comment +# lines, for path, description and notes and for us the last two are usually empty, which explains +# the need for these two passes. +cargo +nightly fmt cargo +nightly fmt + npm run prettier diff --git a/support/openapi-template/lib.mustache b/support/openapi-template/lib.mustache index d41f37349..dee5e6a0c 100644 --- a/support/openapi-template/lib.mustache +++ b/support/openapi-template/lib.mustache @@ -4,7 +4,8 @@ clippy::empty_docs, clippy::to_string_in_format_args, clippy::needless_return, - clippy::uninlined_format_args + clippy::uninlined_format_args, + clippy::new_without_default )] extern crate serde_repr; diff --git a/support/openapi-template/reqwest-trait/api.mustache b/support/openapi-template/reqwest-trait/api.mustache index ae7ea7d4e..3adadeea0 100644 --- a/support/openapi-template/reqwest-trait/api.mustache +++ b/support/openapi-template/reqwest-trait/api.mustache @@ -15,7 +15,7 @@ use crate::apis::ContentType; {{#mockall}} #[cfg_attr(feature = "mockall", automock)] {{/mockall}} -#[async_trait] +#[async_trait(?Send)] pub trait {{{classname}}}: Send + Sync { {{#operations}} {{#operation}} @@ -26,11 +26,11 @@ pub trait {{{classname}}}: Send + Sync { /// {{{notes}}} {{/notes.empty}} {{#vendorExtensions.x-group-parameters}} - async fn {{{operationId}}}(&self, {{#allParams}}{{#-first}} params: {{{operationIdCamelCase}}}Params {{/-first}}{{/allParams}}{{! + async fn {{{operationId}}}(&self, {{#allParams}}{{#-first}} params: {{{operationIdCamelCase}}}Params {{/-first}}{{/allParams}}{{! ### Function return type }}) -> Result<{{! ### Multi response support - }}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{! + }}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{! ### Regular return type }}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}{{! ### Error Type @@ -39,27 +39,27 @@ pub trait {{{classname}}}: Send + Sync { {{^vendorExtensions.x-group-parameters}} async fn {{{operationId}}}{{! ### Lifetimes - }}<{{#allParams}}'{{#lambda.lifetimeName}}{{{paramName}}}{{/lambda.lifetimeName}}{{^-last}}, {{/-last}}{{/allParams}}>{{! + }}<'a>{{! ### Function parameter names - }}(&self, {{#allParams}}{{{paramName}}}: {{! + }}(&self, {{#allParams}}{{{paramName}}}: {{! ### Option Start - }}{{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{! + }}{{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{! ### &str and Vec<&str> - }}{{#isString}}{{#isArray}}Vec<{{/isArray}}{{^isUuid}}&'{{#lambda.lifetimeName}}{{{paramName}}}{{/lambda.lifetimeName}} str{{/isUuid}}{{#isArray}}>{{/isArray}}{{/isString}}{{! + }}{{#isString}}{{#isArray}}Vec<{{/isArray}}{{^isUuid}}&'a str{{/isUuid}}{{#isArray}}>{{/isArray}}{{/isString}}{{! ### UUIDs - }}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isUuid}}{{! + }}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}uuid::Uuid{{#isArray}}>{{/isArray}}{{/isUuid}}{{! ### Models and primative types - }}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{! + }}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{! ### Option End - }}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{! + }}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{! ### Comma for next arguement }}{{^-last}}, {{/-last}}{{/allParams}}{{! ### Function return type - }}) -> Result<{{! + }}) -> Result<{{! ### Multi response support - }}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{! + }}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{! ### Regular return type - }}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}{{! + }}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}{{! ### Error Type }}, Error<{{{operationIdCamelCase}}}Error>>; {{/vendorExtensions.x-group-parameters}} @@ -83,7 +83,7 @@ impl {{classname}}Client { {{#vendorExtensions.x-group-parameters}} {{#allParams}} {{#-first}} -/// struct for passing parameters to the method [`{{operationId}}`] +/// struct for passing parameters to the method [`{{{classname}}}::{{operationId}}`] #[derive(Clone, Debug)] {{#useBonBuilder}} #[cfg_attr(feature = "bon", derive(::bon::Builder))] @@ -115,7 +115,7 @@ pub struct {{{operationIdCamelCase}}}Params { {{/operation}} {{/operations}} -#[async_trait] +#[async_trait(?Send)] impl {{classname}} for {{classname}}Client { {{#operations}} {{#operation}} @@ -147,23 +147,23 @@ impl {{classname}} for {{classname}}Client { {{^vendorExtensions.x-group-parameters}} async fn {{{operationId}}}{{! ### Lifetimes - }}<{{#allParams}}'{{#lambda.lifetimeName}}{{{paramName}}}{{/lambda.lifetimeName}}{{^-last}}, {{/-last}}{{/allParams}}>{{! + }}<'a>{{! ### Function parameter names - }}(&self, {{#allParams}}{{{paramName}}}: {{! + }}(&self, {{#allParams}}{{{paramName}}}: {{! ### Option Start }}{{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{! ### &str and Vec<&str> - }}{{#isString}}{{#isArray}}Vec<{{/isArray}}{{^isUuid}}&'{{#lambda.lifetimeName}}{{{paramName}}}{{/lambda.lifetimeName}} str{{/isUuid}}{{#isArray}}>{{/isArray}}{{/isString}}{{! + }}{{#isString}}{{#isArray}}Vec<{{/isArray}}{{^isUuid}}&'a str{{/isUuid}}{{#isArray}}>{{/isArray}}{{/isString}}{{! ### UUIDs - }}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isUuid}}{{! + }}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}uuid::Uuid{{#isArray}}>{{/isArray}}{{/isUuid}}{{! ### Models and primative types }}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{! ### Option End }}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{! ### Comma for next arguement - }}{{^-last}}, {{/-last}}{{/allParams}}{{! + }}{{^-last}}, {{/-last}}{{/allParams}}{{! ### Function return type - }}) -> Result<{{! + }}) -> Result<{{! ### Multi response support }}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{! ### Regular return type @@ -175,7 +175,7 @@ impl {{classname}} for {{classname}}Client { let local_var_client = &local_var_configuration.client; - let local_var_uri_str = format!("{}{{{path}}}", local_var_configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}.to_string(){{/isContainer}}{{/isPrimitiveType}}{{/isUuid}}{{/isString}}{{#isString}}){{/isString}}{{/pathParams}}); + let local_var_uri_str = format!("{}{{{path}}}", local_var_configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}{{^isUuid}}crate::apis::urlencode({{/isUuid}}{{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}.to_string(){{/isContainer}}{{/isPrimitiveType}}{{/isUuid}}{{/isString}}{{#isString}}{{^isUuid}}){{/isUuid}}{{/isString}}{{/pathParams}}); let mut local_var_req_builder = local_var_client.request(reqwest::Method::{{{httpMethod}}}, local_var_uri_str.as_str()); {{#queryParams}} @@ -516,7 +516,7 @@ impl {{classname}} for {{classname}}Client { {{#supportMultipleResponses}} {{#operations}} {{#operation}} -/// struct for typed successes of method [`{{operationId}}`] +/// struct for typed successes of method [`{{{classname}}}::{{operationId}}`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum {{{operationIdCamelCase}}}Success { @@ -536,7 +536,7 @@ pub enum {{{operationIdCamelCase}}}Success { {{/supportMultipleResponses}} {{#operations}} {{#operation}} -/// struct for typed errors of method [`{{operationId}}`] +/// struct for typed errors of method [`{{{classname}}}::{{operationId}}`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum {{{operationIdCamelCase}}}Error {