diff --git a/bitwarden_license/bitwarden-sm/src/error.rs b/bitwarden_license/bitwarden-sm/src/error.rs index 76203759b..4ca4d4915 100644 --- a/bitwarden_license/bitwarden-sm/src/error.rs +++ b/bitwarden_license/bitwarden-sm/src/error.rs @@ -84,8 +84,8 @@ impl From for SecretsManagerError { } } -impl From> for SecretsManagerError { - fn from(e: bitwarden_api_api::apis::Error) -> Self { +impl From for SecretsManagerError { + fn from(e: bitwarden_api_api::apis::Error) -> Self { SecretsManagerError::ApiError(e.into()) } } diff --git a/bitwarden_license/bitwarden-sm/src/projects/create.rs b/bitwarden_license/bitwarden-sm/src/projects/create.rs index c4a73d363..54a83e3b8 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..6016fcdf2 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..7013bfde3 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..25588f37c 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..a784bddbe 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..bb5b2aab0 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..b412f39f7 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..73441a195 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..9d1d47d99 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..38824b0a4 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..36b50b739 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..c522ce0a8 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/.openapi-generator-ignore b/crates/bitwarden-api-api/.openapi-generator-ignore index 0a3fec13f..bbda31728 100644 --- a/crates/bitwarden-api-api/.openapi-generator-ignore +++ b/crates/bitwarden-api-api/.openapi-generator-ignore @@ -25,3 +25,7 @@ docs/*.md .travis.yml git_push.sh +.gitignore + +# We handle dependency updates with renovate, so we don't want to overwrite Cargo.toml +Cargo.toml diff --git a/crates/bitwarden-api-api/.openapi-generator/FILES b/crates/bitwarden-api-api/.openapi-generator/FILES index d477e416e..207154eec 100644 --- a/crates/bitwarden-api-api/.openapi-generator/FILES +++ b/crates/bitwarden-api-api/.openapi-generator/FILES @@ -1,5 +1,3 @@ -.gitignore -Cargo.toml README.md src/apis/access_policies_api.rs src/apis/account_billing_v_next_api.rs diff --git a/crates/bitwarden-api-api/.openapi-generator/VERSION b/crates/bitwarden-api-api/.openapi-generator/VERSION index eb1dc6a51..e465da431 100644 --- a/crates/bitwarden-api-api/.openapi-generator/VERSION +++ b/crates/bitwarden-api-api/.openapi-generator/VERSION @@ -1 +1 @@ -7.13.0 +7.14.0 diff --git a/crates/bitwarden-api-api/README.md b/crates/bitwarden-api-api/README.md index f79a76f09..2ee0fe6c5 100644 --- a/crates/bitwarden-api-api/README.md +++ b/crates/bitwarden-api-api/README.md @@ -11,7 +11,7 @@ client. - API version: latest - Package version: 1.0.0 -- Generator version: 7.13.0 +- Generator version: 7.14.0 - Build package: `org.openapitools.codegen.languages.RustClientCodegen` ## Installation @@ -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..6e06aa246 100644 --- a/crates/bitwarden-api-api/src/apis/access_policies_api.rs +++ b/crates/bitwarden-api-api/src/apis/access_policies_api.rs @@ -8,759 +8,695 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 -/// [`organizations_id_access_policies_people_potential_grantees_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdAccessPoliciesPeoplePotentialGranteesGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organizations_id_access_policies_projects_potential_grantees_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdAccessPoliciesProjectsPotentialGranteesGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SecretsSecretIdAccessPoliciesGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ServiceAccountsIdAccessPoliciesPeoplePutError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait AccessPoliciesApi: Send + Sync { + + /// GET /organizations/{id}/access-policies/people/potential-grantees + /// + /// + async fn organizations_id_access_policies_people_potential_grantees_get(&self, id: uuid::Uuid) -> Result; + + /// GET /organizations/{id}/access-policies/projects/potential-grantees + /// + /// + async fn organizations_id_access_policies_projects_potential_grantees_get(&self, id: uuid::Uuid) -> Result; + + /// GET /organizations/{id}/access-policies/service-accounts/potential-grantees + /// + /// + async fn organizations_id_access_policies_service_accounts_potential_grantees_get(&self, id: uuid::Uuid) -> Result; + + /// GET /projects/{id}/access-policies/people + /// + /// + async fn projects_id_access_policies_people_get(&self, id: uuid::Uuid) -> Result; + + /// PUT /projects/{id}/access-policies/people + /// + /// + async fn projects_id_access_policies_people_put(&self, id: uuid::Uuid, people_access_policies_request_model: Option) -> Result; + + /// GET /projects/{id}/access-policies/service-accounts + /// + /// + async fn projects_id_access_policies_service_accounts_get(&self, id: uuid::Uuid) -> Result; + + /// PUT /projects/{id}/access-policies/service-accounts + /// + /// + async fn projects_id_access_policies_service_accounts_put(&self, id: uuid::Uuid, project_service_accounts_access_policies_request_model: Option) -> Result; + + /// GET /secrets/{secretId}/access-policies + /// + /// + async fn secrets_secret_id_access_policies_get(&self, secret_id: uuid::Uuid) -> Result; + + /// GET /service-accounts/{id}/access-policies/people + /// + /// + async fn service_accounts_id_access_policies_people_get(&self, id: uuid::Uuid) -> Result; + + /// PUT /service-accounts/{id}/access-policies/people + /// + /// + async fn service_accounts_id_access_policies_people_put(&self, id: uuid::Uuid, people_access_policies_request_model: Option) -> Result; + + /// GET /service-accounts/{id}/granted-policies + /// + /// + async fn service_accounts_id_granted_policies_get(&self, id: uuid::Uuid) -> Result; + + /// PUT /service-accounts/{id}/granted-policies + /// + /// + async fn service_accounts_id_granted_policies_put(&self, id: uuid::Uuid, service_account_granted_policies_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`service_accounts_id_granted_policies_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ServiceAccountsIdGrantedPoliciesGetError { - UnknownValue(serde_json::Value), +pub struct AccessPoliciesApiClient { + configuration: Arc, } -/// struct for typed errors of method [`service_accounts_id_granted_policies_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ServiceAccountsIdGrantedPoliciesPutError { - UnknownValue(serde_json::Value), +impl AccessPoliciesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl AccessPoliciesApiClient { + pub async fn organizations_id_access_policies_people_potential_grantees_get( + &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}/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_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 = + serde_json::from_str(&local_var_content).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 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`")))), + pub async fn organizations_id_access_policies_projects_potential_grantees_get( + &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}/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_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 = + serde_json::from_str(&local_var_content).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 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`")))), + pub async fn organizations_id_access_policies_service_accounts_potential_grantees_get( + &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}/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_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 = + serde_json::from_str(&local_var_content).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 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`")))), + pub async fn projects_id_access_policies_people_get( + &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}/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_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)) } - } else { - 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`")))), + pub async fn projects_id_access_policies_people_put( + &self, + id: uuid::Uuid, + people_access_policies_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn projects_id_access_policies_service_accounts_get( + &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}/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_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)) } - } else { - 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`")))), + pub async fn projects_id_access_policies_service_accounts_put( + &self, + id: uuid::Uuid, + project_service_accounts_access_policies_request_model: Option< + models::ProjectServiceAccountsAccessPoliciesRequestModel, + >, + ) -> Result { + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn secrets_secret_id_access_policies_get( + &self, + secret_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/{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_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)) } - } else { - 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`")))), + pub async fn service_accounts_id_access_policies_people_get( + &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}/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_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)) } - } else { - 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`")))), + pub async fn service_accounts_id_access_policies_people_put( + &self, + id: uuid::Uuid, + people_access_policies_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn service_accounts_id_granted_policies_get( + &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}/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_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)) } - } else { - 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`")))), + pub async fn service_accounts_id_granted_policies_put( + &self, + id: uuid::Uuid, + service_account_granted_policies_request_model: Option< + models::ServiceAccountGrantedPoliciesRequestModel, + >, + ) -> Result { + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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/account_billing_v_next_api.rs b/crates/bitwarden-api-api/src/apis/account_billing_v_next_api.rs index 6e6cdee82..4d95676c7 100644 --- a/crates/bitwarden-api-api/src/apis/account_billing_v_next_api.rs +++ b/crates/bitwarden-api-api/src/apis/account_billing_v_next_api.rs @@ -8,1028 +8,1033 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`account_billing_vnext_credit_bitpay_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountBillingVnextCreditBitpayPostError { - UnknownValue(serde_json::Value), -} +/* +#[async_trait] +pub trait AccountBillingVNextApi: Send + Sync { + + /// POST /account/billing/vnext/credit/bitpay + /// + /// + async fn account_billing_vnext_credit_bitpay_post(&self, email: &str, security_stamp: &str, api_key: &str, id: Option, name: Option<&str>, email_verified: Option, master_password: Option<&str>, master_password_hint: Option<&str>, culture: Option<&str>, two_factor_providers: Option<&str>, two_factor_recovery_code: Option<&str>, equivalent_domains: Option<&str>, excluded_global_equivalent_domains: Option<&str>, account_revision_date: Option, key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, premium: Option, premium_expiration_date: Option, renewal_reminder_date: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, license_key: Option<&str>, kdf: Option, kdf_iterations: Option, kdf_memory: Option, kdf_parallelism: Option, creation_date: Option, revision_date: Option, force_password_reset: Option, uses_key_connector: Option, failed_login_count: Option, last_failed_login_date: Option, avatar_color: Option<&str>, last_password_change_date: Option, last_kdf_change_date: Option, last_key_rotation_date: Option, last_email_change_date: Option, verify_devices: Option, bit_pay_credit_request: Option) -> Result<(), Error>; + + /// GET /account/billing/vnext/credit + /// + /// + async fn account_billing_vnext_credit_get(&self, email: &str, security_stamp: &str, api_key: &str, id: Option, name: Option<&str>, email_verified: Option, master_password: Option<&str>, master_password_hint: Option<&str>, culture: Option<&str>, two_factor_providers: Option<&str>, two_factor_recovery_code: Option<&str>, equivalent_domains: Option<&str>, excluded_global_equivalent_domains: Option<&str>, account_revision_date: Option, key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, premium: Option, premium_expiration_date: Option, renewal_reminder_date: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, license_key: Option<&str>, kdf: Option, kdf_iterations: Option, kdf_memory: Option, kdf_parallelism: Option, creation_date: Option, revision_date: Option, force_password_reset: Option, uses_key_connector: Option, failed_login_count: Option, last_failed_login_date: Option, avatar_color: Option<&str>, last_password_change_date: Option, last_kdf_change_date: Option, last_key_rotation_date: Option, last_email_change_date: Option, verify_devices: Option) -> Result<(), Error>; + + /// GET /account/billing/vnext/payment-method + /// + /// + async fn account_billing_vnext_payment_method_get(&self, email: &str, security_stamp: &str, api_key: &str, id: Option, name: Option<&str>, email_verified: Option, master_password: Option<&str>, master_password_hint: Option<&str>, culture: Option<&str>, two_factor_providers: Option<&str>, two_factor_recovery_code: Option<&str>, equivalent_domains: Option<&str>, excluded_global_equivalent_domains: Option<&str>, account_revision_date: Option, key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, premium: Option, premium_expiration_date: Option, renewal_reminder_date: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, license_key: Option<&str>, kdf: Option, kdf_iterations: Option, kdf_memory: Option, kdf_parallelism: Option, creation_date: Option, revision_date: Option, force_password_reset: Option, uses_key_connector: Option, failed_login_count: Option, last_failed_login_date: Option, avatar_color: Option<&str>, last_password_change_date: Option, last_kdf_change_date: Option, last_key_rotation_date: Option, last_email_change_date: Option, verify_devices: Option) -> Result<(), Error>; -/// struct for typed errors of method [`account_billing_vnext_credit_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountBillingVnextCreditGetError { - UnknownValue(serde_json::Value), + /// PUT /account/billing/vnext/payment-method + /// + /// + async fn account_billing_vnext_payment_method_put(&self, email: &str, security_stamp: &str, api_key: &str, id: Option, name: Option<&str>, email_verified: Option, master_password: Option<&str>, master_password_hint: Option<&str>, culture: Option<&str>, two_factor_providers: Option<&str>, two_factor_recovery_code: Option<&str>, equivalent_domains: Option<&str>, excluded_global_equivalent_domains: Option<&str>, account_revision_date: Option, key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, premium: Option, premium_expiration_date: Option, renewal_reminder_date: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, license_key: Option<&str>, kdf: Option, kdf_iterations: Option, kdf_memory: Option, kdf_parallelism: Option, creation_date: Option, revision_date: Option, force_password_reset: Option, uses_key_connector: Option, failed_login_count: Option, last_failed_login_date: Option, avatar_color: Option<&str>, last_password_change_date: Option, last_kdf_change_date: Option, last_key_rotation_date: Option, last_email_change_date: Option, verify_devices: Option, tokenized_payment_method_request: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`account_billing_vnext_payment_method_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountBillingVnextPaymentMethodGetError { - UnknownValue(serde_json::Value), +pub struct AccountBillingVNextApiClient { + configuration: Arc, } -/// struct for typed errors of method [`account_billing_vnext_payment_method_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountBillingVnextPaymentMethodPutError { - UnknownValue(serde_json::Value), +impl AccountBillingVNextApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn account_billing_vnext_credit_bitpay_post( - configuration: &configuration::Configuration, - email: &str, - security_stamp: &str, - api_key: &str, - id: Option, - name: Option<&str>, - email_verified: Option, - master_password: Option<&str>, - master_password_hint: Option<&str>, - culture: Option<&str>, - two_factor_providers: Option<&str>, - two_factor_recovery_code: Option<&str>, - equivalent_domains: Option<&str>, - excluded_global_equivalent_domains: Option<&str>, - account_revision_date: Option, - key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - premium: Option, - premium_expiration_date: Option, - renewal_reminder_date: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - license_key: Option<&str>, - kdf: Option, - kdf_iterations: Option, - kdf_memory: Option, - kdf_parallelism: Option, - creation_date: Option, - revision_date: Option, - force_password_reset: Option, - uses_key_connector: Option, - failed_login_count: Option, - last_failed_login_date: Option, - avatar_color: Option<&str>, - last_password_change_date: Option, - last_kdf_change_date: Option, - last_key_rotation_date: Option, - last_email_change_date: Option, - verify_devices: Option, - bit_pay_credit_request: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_email = email; - let p_security_stamp = security_stamp; - let p_api_key = api_key; - let p_id = id; - let p_name = name; - let p_email_verified = email_verified; - let p_master_password = master_password; - let p_master_password_hint = master_password_hint; - let p_culture = culture; - let p_two_factor_providers = two_factor_providers; - let p_two_factor_recovery_code = two_factor_recovery_code; - let p_equivalent_domains = equivalent_domains; - let p_excluded_global_equivalent_domains = excluded_global_equivalent_domains; - let p_account_revision_date = account_revision_date; - let p_key = key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_premium = premium; - let p_premium_expiration_date = premium_expiration_date; - let p_renewal_reminder_date = renewal_reminder_date; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_license_key = license_key; - let p_kdf = kdf; - let p_kdf_iterations = kdf_iterations; - let p_kdf_memory = kdf_memory; - let p_kdf_parallelism = kdf_parallelism; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_force_password_reset = force_password_reset; - let p_uses_key_connector = uses_key_connector; - let p_failed_login_count = failed_login_count; - let p_last_failed_login_date = last_failed_login_date; - let p_avatar_color = avatar_color; - let p_last_password_change_date = last_password_change_date; - let p_last_kdf_change_date = last_kdf_change_date; - let p_last_key_rotation_date = last_key_rotation_date; - let p_last_email_change_date = last_email_change_date; - let p_verify_devices = verify_devices; - let p_bit_pay_credit_request = bit_pay_credit_request; +// #[async_trait] +impl AccountBillingVNextApiClient { + pub async fn account_billing_vnext_credit_bitpay_post( + &self, + email: &str, + security_stamp: &str, + api_key: &str, + id: Option, + name: Option<&str>, + email_verified: Option, + master_password: Option<&str>, + master_password_hint: Option<&str>, + culture: Option<&str>, + two_factor_providers: Option<&str>, + two_factor_recovery_code: Option<&str>, + equivalent_domains: Option<&str>, + excluded_global_equivalent_domains: Option<&str>, + account_revision_date: Option, + key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + premium: Option, + premium_expiration_date: Option, + renewal_reminder_date: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + license_key: Option<&str>, + kdf: Option, + kdf_iterations: Option, + kdf_memory: Option, + kdf_parallelism: Option, + creation_date: Option, + revision_date: Option, + force_password_reset: Option, + uses_key_connector: Option, + failed_login_count: Option, + last_failed_login_date: Option, + avatar_color: Option<&str>, + last_password_change_date: Option, + last_kdf_change_date: Option, + last_key_rotation_date: Option, + last_email_change_date: Option, + verify_devices: Option, + bit_pay_credit_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/account/billing/vnext/credit/bitpay", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/account/billing/vnext/credit/bitpay", + 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) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("email", &p_email.to_string())]); - if let Some(ref param_value) = p_email_verified { - req_builder = req_builder.query(&[("emailVerified", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_master_password { - req_builder = req_builder.query(&[("masterPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_master_password_hint { - req_builder = req_builder.query(&[("masterPasswordHint", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_culture { - req_builder = req_builder.query(&[("culture", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("securityStamp", &p_security_stamp.to_string())]); - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_recovery_code { - req_builder = req_builder.query(&[("twoFactorRecoveryCode", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_equivalent_domains { - req_builder = req_builder.query(&[("equivalentDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_excluded_global_equivalent_domains { - req_builder = - req_builder.query(&[("excludedGlobalEquivalentDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_account_revision_date { - req_builder = req_builder.query(&[("accountRevisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_key { - req_builder = req_builder.query(&[("key", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_premium { - req_builder = req_builder.query(&[("premium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_premium_expiration_date { - req_builder = req_builder.query(&[("premiumExpirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_renewal_reminder_date { - req_builder = req_builder.query(&[("renewalReminderDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("apiKey", &p_api_key.to_string())]); - if let Some(ref param_value) = p_kdf { - req_builder = req_builder.query(&[("kdf", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_iterations { - req_builder = req_builder.query(&[("kdfIterations", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_memory { - req_builder = req_builder.query(&[("kdfMemory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_parallelism { - req_builder = req_builder.query(&[("kdfParallelism", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_force_password_reset { - req_builder = req_builder.query(&[("forcePasswordReset", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_uses_key_connector { - req_builder = req_builder.query(&[("usesKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_failed_login_count { - req_builder = req_builder.query(&[("failedLoginCount", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_failed_login_date { - req_builder = req_builder.query(&[("lastFailedLoginDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_avatar_color { - req_builder = req_builder.query(&[("avatarColor", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_password_change_date { - req_builder = req_builder.query(&[("lastPasswordChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_kdf_change_date { - req_builder = req_builder.query(&[("lastKdfChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_key_rotation_date { - req_builder = req_builder.query(&[("lastKeyRotationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_email_change_date { - req_builder = req_builder.query(&[("lastEmailChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_verify_devices { - req_builder = req_builder.query(&[("verifyDevices", ¶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_bit_pay_credit_request); + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("email", &email.to_string())]); + if let Some(ref param_value) = email_verified { + local_var_req_builder = + local_var_req_builder.query(&[("emailVerified", ¶m_value.to_string())]); + } + if let Some(ref param_value) = master_password { + local_var_req_builder = + local_var_req_builder.query(&[("masterPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = master_password_hint { + local_var_req_builder = + local_var_req_builder.query(&[("masterPasswordHint", ¶m_value.to_string())]); + } + if let Some(ref param_value) = culture { + local_var_req_builder = + local_var_req_builder.query(&[("culture", ¶m_value.to_string())]); + } + local_var_req_builder = + local_var_req_builder.query(&[("securityStamp", &security_stamp.to_string())]); + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_recovery_code { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorRecoveryCode", ¶m_value.to_string())]); + } + if let Some(ref param_value) = equivalent_domains { + local_var_req_builder = + local_var_req_builder.query(&[("equivalentDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = excluded_global_equivalent_domains { + local_var_req_builder = local_var_req_builder + .query(&[("excludedGlobalEquivalentDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = account_revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("accountRevisionDate", ¶m_value.to_string())]); + } + 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 param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = premium { + local_var_req_builder = + local_var_req_builder.query(&[("premium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = premium_expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("premiumExpirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = renewal_reminder_date { + local_var_req_builder = + local_var_req_builder.query(&[("renewalReminderDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("apiKey", &api_key.to_string())]); + if let Some(ref param_value) = kdf { + local_var_req_builder = + local_var_req_builder.query(&[("kdf", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_iterations { + local_var_req_builder = + local_var_req_builder.query(&[("kdfIterations", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_memory { + local_var_req_builder = + local_var_req_builder.query(&[("kdfMemory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_parallelism { + local_var_req_builder = + local_var_req_builder.query(&[("kdfParallelism", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = force_password_reset { + local_var_req_builder = + local_var_req_builder.query(&[("forcePasswordReset", ¶m_value.to_string())]); + } + if let Some(ref param_value) = uses_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("usesKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = failed_login_count { + local_var_req_builder = + local_var_req_builder.query(&[("failedLoginCount", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_failed_login_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastFailedLoginDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = avatar_color { + local_var_req_builder = + local_var_req_builder.query(&[("avatarColor", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_password_change_date { + local_var_req_builder = local_var_req_builder + .query(&[("lastPasswordChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_kdf_change_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastKdfChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_key_rotation_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastKeyRotationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_email_change_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastEmailChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = verify_devices { + local_var_req_builder = + local_var_req_builder.query(&[("verifyDevices", ¶m_value.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()); + }; + local_var_req_builder = local_var_req_builder.json(&bit_pay_credit_request); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 account_billing_vnext_credit_get( - configuration: &configuration::Configuration, - email: &str, - security_stamp: &str, - api_key: &str, - id: Option, - name: Option<&str>, - email_verified: Option, - master_password: Option<&str>, - master_password_hint: Option<&str>, - culture: Option<&str>, - two_factor_providers: Option<&str>, - two_factor_recovery_code: Option<&str>, - equivalent_domains: Option<&str>, - excluded_global_equivalent_domains: Option<&str>, - account_revision_date: Option, - key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - premium: Option, - premium_expiration_date: Option, - renewal_reminder_date: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - license_key: Option<&str>, - kdf: Option, - kdf_iterations: Option, - kdf_memory: Option, - kdf_parallelism: Option, - creation_date: Option, - revision_date: Option, - force_password_reset: Option, - uses_key_connector: Option, - failed_login_count: Option, - last_failed_login_date: Option, - avatar_color: Option<&str>, - last_password_change_date: Option, - last_kdf_change_date: Option, - last_key_rotation_date: Option, - last_email_change_date: Option, - verify_devices: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_email = email; - let p_security_stamp = security_stamp; - let p_api_key = api_key; - let p_id = id; - let p_name = name; - let p_email_verified = email_verified; - let p_master_password = master_password; - let p_master_password_hint = master_password_hint; - let p_culture = culture; - let p_two_factor_providers = two_factor_providers; - let p_two_factor_recovery_code = two_factor_recovery_code; - let p_equivalent_domains = equivalent_domains; - let p_excluded_global_equivalent_domains = excluded_global_equivalent_domains; - let p_account_revision_date = account_revision_date; - let p_key = key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_premium = premium; - let p_premium_expiration_date = premium_expiration_date; - let p_renewal_reminder_date = renewal_reminder_date; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_license_key = license_key; - let p_kdf = kdf; - let p_kdf_iterations = kdf_iterations; - let p_kdf_memory = kdf_memory; - let p_kdf_parallelism = kdf_parallelism; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_force_password_reset = force_password_reset; - let p_uses_key_connector = uses_key_connector; - let p_failed_login_count = failed_login_count; - let p_last_failed_login_date = last_failed_login_date; - let p_avatar_color = avatar_color; - let p_last_password_change_date = last_password_change_date; - let p_last_kdf_change_date = last_kdf_change_date; - let p_last_key_rotation_date = last_key_rotation_date; - let p_last_email_change_date = last_email_change_date; - let p_verify_devices = verify_devices; + pub async fn account_billing_vnext_credit_get( + &self, + email: &str, + security_stamp: &str, + api_key: &str, + id: Option, + name: Option<&str>, + email_verified: Option, + master_password: Option<&str>, + master_password_hint: Option<&str>, + culture: Option<&str>, + two_factor_providers: Option<&str>, + two_factor_recovery_code: Option<&str>, + equivalent_domains: Option<&str>, + excluded_global_equivalent_domains: Option<&str>, + account_revision_date: Option, + key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + premium: Option, + premium_expiration_date: Option, + renewal_reminder_date: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + license_key: Option<&str>, + kdf: Option, + kdf_iterations: Option, + kdf_memory: Option, + kdf_parallelism: Option, + creation_date: Option, + revision_date: Option, + force_password_reset: Option, + uses_key_connector: Option, + failed_login_count: Option, + last_failed_login_date: Option, + avatar_color: Option<&str>, + last_password_change_date: Option, + last_kdf_change_date: Option, + last_key_rotation_date: Option, + last_email_change_date: Option, + verify_devices: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/account/billing/vnext/credit", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/account/billing/vnext/credit", + 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) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("email", &p_email.to_string())]); - if let Some(ref param_value) = p_email_verified { - req_builder = req_builder.query(&[("emailVerified", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_master_password { - req_builder = req_builder.query(&[("masterPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_master_password_hint { - req_builder = req_builder.query(&[("masterPasswordHint", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_culture { - req_builder = req_builder.query(&[("culture", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("securityStamp", &p_security_stamp.to_string())]); - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_recovery_code { - req_builder = req_builder.query(&[("twoFactorRecoveryCode", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_equivalent_domains { - req_builder = req_builder.query(&[("equivalentDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_excluded_global_equivalent_domains { - req_builder = - req_builder.query(&[("excludedGlobalEquivalentDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_account_revision_date { - req_builder = req_builder.query(&[("accountRevisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_key { - req_builder = req_builder.query(&[("key", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_premium { - req_builder = req_builder.query(&[("premium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_premium_expiration_date { - req_builder = req_builder.query(&[("premiumExpirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_renewal_reminder_date { - req_builder = req_builder.query(&[("renewalReminderDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("apiKey", &p_api_key.to_string())]); - if let Some(ref param_value) = p_kdf { - req_builder = req_builder.query(&[("kdf", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_iterations { - req_builder = req_builder.query(&[("kdfIterations", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_memory { - req_builder = req_builder.query(&[("kdfMemory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_parallelism { - req_builder = req_builder.query(&[("kdfParallelism", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_force_password_reset { - req_builder = req_builder.query(&[("forcePasswordReset", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_uses_key_connector { - req_builder = req_builder.query(&[("usesKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_failed_login_count { - req_builder = req_builder.query(&[("failedLoginCount", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_failed_login_date { - req_builder = req_builder.query(&[("lastFailedLoginDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_avatar_color { - req_builder = req_builder.query(&[("avatarColor", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_password_change_date { - req_builder = req_builder.query(&[("lastPasswordChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_kdf_change_date { - req_builder = req_builder.query(&[("lastKdfChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_key_rotation_date { - req_builder = req_builder.query(&[("lastKeyRotationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_email_change_date { - req_builder = req_builder.query(&[("lastEmailChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_verify_devices { - req_builder = req_builder.query(&[("verifyDevices", ¶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()); - }; + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("email", &email.to_string())]); + if let Some(ref param_value) = email_verified { + local_var_req_builder = + local_var_req_builder.query(&[("emailVerified", ¶m_value.to_string())]); + } + if let Some(ref param_value) = master_password { + local_var_req_builder = + local_var_req_builder.query(&[("masterPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = master_password_hint { + local_var_req_builder = + local_var_req_builder.query(&[("masterPasswordHint", ¶m_value.to_string())]); + } + if let Some(ref param_value) = culture { + local_var_req_builder = + local_var_req_builder.query(&[("culture", ¶m_value.to_string())]); + } + local_var_req_builder = + local_var_req_builder.query(&[("securityStamp", &security_stamp.to_string())]); + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_recovery_code { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorRecoveryCode", ¶m_value.to_string())]); + } + if let Some(ref param_value) = equivalent_domains { + local_var_req_builder = + local_var_req_builder.query(&[("equivalentDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = excluded_global_equivalent_domains { + local_var_req_builder = local_var_req_builder + .query(&[("excludedGlobalEquivalentDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = account_revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("accountRevisionDate", ¶m_value.to_string())]); + } + 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 param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = premium { + local_var_req_builder = + local_var_req_builder.query(&[("premium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = premium_expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("premiumExpirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = renewal_reminder_date { + local_var_req_builder = + local_var_req_builder.query(&[("renewalReminderDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("apiKey", &api_key.to_string())]); + if let Some(ref param_value) = kdf { + local_var_req_builder = + local_var_req_builder.query(&[("kdf", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_iterations { + local_var_req_builder = + local_var_req_builder.query(&[("kdfIterations", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_memory { + local_var_req_builder = + local_var_req_builder.query(&[("kdfMemory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_parallelism { + local_var_req_builder = + local_var_req_builder.query(&[("kdfParallelism", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = force_password_reset { + local_var_req_builder = + local_var_req_builder.query(&[("forcePasswordReset", ¶m_value.to_string())]); + } + if let Some(ref param_value) = uses_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("usesKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = failed_login_count { + local_var_req_builder = + local_var_req_builder.query(&[("failedLoginCount", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_failed_login_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastFailedLoginDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = avatar_color { + local_var_req_builder = + local_var_req_builder.query(&[("avatarColor", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_password_change_date { + local_var_req_builder = local_var_req_builder + .query(&[("lastPasswordChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_kdf_change_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastKdfChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_key_rotation_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastKeyRotationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_email_change_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastEmailChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = verify_devices { + local_var_req_builder = + local_var_req_builder.query(&[("verifyDevices", ¶m_value.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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 account_billing_vnext_payment_method_get( - configuration: &configuration::Configuration, - email: &str, - security_stamp: &str, - api_key: &str, - id: Option, - name: Option<&str>, - email_verified: Option, - master_password: Option<&str>, - master_password_hint: Option<&str>, - culture: Option<&str>, - two_factor_providers: Option<&str>, - two_factor_recovery_code: Option<&str>, - equivalent_domains: Option<&str>, - excluded_global_equivalent_domains: Option<&str>, - account_revision_date: Option, - key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - premium: Option, - premium_expiration_date: Option, - renewal_reminder_date: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - license_key: Option<&str>, - kdf: Option, - kdf_iterations: Option, - kdf_memory: Option, - kdf_parallelism: Option, - creation_date: Option, - revision_date: Option, - force_password_reset: Option, - uses_key_connector: Option, - failed_login_count: Option, - last_failed_login_date: Option, - avatar_color: Option<&str>, - last_password_change_date: Option, - last_kdf_change_date: Option, - last_key_rotation_date: Option, - last_email_change_date: Option, - verify_devices: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_email = email; - let p_security_stamp = security_stamp; - let p_api_key = api_key; - let p_id = id; - let p_name = name; - let p_email_verified = email_verified; - let p_master_password = master_password; - let p_master_password_hint = master_password_hint; - let p_culture = culture; - let p_two_factor_providers = two_factor_providers; - let p_two_factor_recovery_code = two_factor_recovery_code; - let p_equivalent_domains = equivalent_domains; - let p_excluded_global_equivalent_domains = excluded_global_equivalent_domains; - let p_account_revision_date = account_revision_date; - let p_key = key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_premium = premium; - let p_premium_expiration_date = premium_expiration_date; - let p_renewal_reminder_date = renewal_reminder_date; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_license_key = license_key; - let p_kdf = kdf; - let p_kdf_iterations = kdf_iterations; - let p_kdf_memory = kdf_memory; - let p_kdf_parallelism = kdf_parallelism; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_force_password_reset = force_password_reset; - let p_uses_key_connector = uses_key_connector; - let p_failed_login_count = failed_login_count; - let p_last_failed_login_date = last_failed_login_date; - let p_avatar_color = avatar_color; - let p_last_password_change_date = last_password_change_date; - let p_last_kdf_change_date = last_kdf_change_date; - let p_last_key_rotation_date = last_key_rotation_date; - let p_last_email_change_date = last_email_change_date; - let p_verify_devices = verify_devices; + pub async fn account_billing_vnext_payment_method_get( + &self, + email: &str, + security_stamp: &str, + api_key: &str, + id: Option, + name: Option<&str>, + email_verified: Option, + master_password: Option<&str>, + master_password_hint: Option<&str>, + culture: Option<&str>, + two_factor_providers: Option<&str>, + two_factor_recovery_code: Option<&str>, + equivalent_domains: Option<&str>, + excluded_global_equivalent_domains: Option<&str>, + account_revision_date: Option, + key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + premium: Option, + premium_expiration_date: Option, + renewal_reminder_date: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + license_key: Option<&str>, + kdf: Option, + kdf_iterations: Option, + kdf_memory: Option, + kdf_parallelism: Option, + creation_date: Option, + revision_date: Option, + force_password_reset: Option, + uses_key_connector: Option, + failed_login_count: Option, + last_failed_login_date: Option, + avatar_color: Option<&str>, + last_password_change_date: Option, + last_kdf_change_date: Option, + last_key_rotation_date: Option, + last_email_change_date: Option, + verify_devices: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/account/billing/vnext/payment-method", - configuration.base_path - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/account/billing/vnext/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()); - if let Some(ref param_value) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("email", &p_email.to_string())]); - if let Some(ref param_value) = p_email_verified { - req_builder = req_builder.query(&[("emailVerified", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_master_password { - req_builder = req_builder.query(&[("masterPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_master_password_hint { - req_builder = req_builder.query(&[("masterPasswordHint", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_culture { - req_builder = req_builder.query(&[("culture", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("securityStamp", &p_security_stamp.to_string())]); - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_recovery_code { - req_builder = req_builder.query(&[("twoFactorRecoveryCode", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_equivalent_domains { - req_builder = req_builder.query(&[("equivalentDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_excluded_global_equivalent_domains { - req_builder = - req_builder.query(&[("excludedGlobalEquivalentDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_account_revision_date { - req_builder = req_builder.query(&[("accountRevisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_key { - req_builder = req_builder.query(&[("key", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_premium { - req_builder = req_builder.query(&[("premium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_premium_expiration_date { - req_builder = req_builder.query(&[("premiumExpirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_renewal_reminder_date { - req_builder = req_builder.query(&[("renewalReminderDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("apiKey", &p_api_key.to_string())]); - if let Some(ref param_value) = p_kdf { - req_builder = req_builder.query(&[("kdf", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_iterations { - req_builder = req_builder.query(&[("kdfIterations", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_memory { - req_builder = req_builder.query(&[("kdfMemory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_parallelism { - req_builder = req_builder.query(&[("kdfParallelism", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_force_password_reset { - req_builder = req_builder.query(&[("forcePasswordReset", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_uses_key_connector { - req_builder = req_builder.query(&[("usesKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_failed_login_count { - req_builder = req_builder.query(&[("failedLoginCount", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_failed_login_date { - req_builder = req_builder.query(&[("lastFailedLoginDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_avatar_color { - req_builder = req_builder.query(&[("avatarColor", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_password_change_date { - req_builder = req_builder.query(&[("lastPasswordChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_kdf_change_date { - req_builder = req_builder.query(&[("lastKdfChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_key_rotation_date { - req_builder = req_builder.query(&[("lastKeyRotationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_email_change_date { - req_builder = req_builder.query(&[("lastEmailChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_verify_devices { - req_builder = req_builder.query(&[("verifyDevices", ¶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()); - }; + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("email", &email.to_string())]); + if let Some(ref param_value) = email_verified { + local_var_req_builder = + local_var_req_builder.query(&[("emailVerified", ¶m_value.to_string())]); + } + if let Some(ref param_value) = master_password { + local_var_req_builder = + local_var_req_builder.query(&[("masterPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = master_password_hint { + local_var_req_builder = + local_var_req_builder.query(&[("masterPasswordHint", ¶m_value.to_string())]); + } + if let Some(ref param_value) = culture { + local_var_req_builder = + local_var_req_builder.query(&[("culture", ¶m_value.to_string())]); + } + local_var_req_builder = + local_var_req_builder.query(&[("securityStamp", &security_stamp.to_string())]); + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_recovery_code { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorRecoveryCode", ¶m_value.to_string())]); + } + if let Some(ref param_value) = equivalent_domains { + local_var_req_builder = + local_var_req_builder.query(&[("equivalentDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = excluded_global_equivalent_domains { + local_var_req_builder = local_var_req_builder + .query(&[("excludedGlobalEquivalentDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = account_revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("accountRevisionDate", ¶m_value.to_string())]); + } + 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 param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = premium { + local_var_req_builder = + local_var_req_builder.query(&[("premium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = premium_expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("premiumExpirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = renewal_reminder_date { + local_var_req_builder = + local_var_req_builder.query(&[("renewalReminderDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("apiKey", &api_key.to_string())]); + if let Some(ref param_value) = kdf { + local_var_req_builder = + local_var_req_builder.query(&[("kdf", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_iterations { + local_var_req_builder = + local_var_req_builder.query(&[("kdfIterations", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_memory { + local_var_req_builder = + local_var_req_builder.query(&[("kdfMemory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_parallelism { + local_var_req_builder = + local_var_req_builder.query(&[("kdfParallelism", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = force_password_reset { + local_var_req_builder = + local_var_req_builder.query(&[("forcePasswordReset", ¶m_value.to_string())]); + } + if let Some(ref param_value) = uses_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("usesKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = failed_login_count { + local_var_req_builder = + local_var_req_builder.query(&[("failedLoginCount", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_failed_login_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastFailedLoginDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = avatar_color { + local_var_req_builder = + local_var_req_builder.query(&[("avatarColor", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_password_change_date { + local_var_req_builder = local_var_req_builder + .query(&[("lastPasswordChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_kdf_change_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastKdfChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_key_rotation_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastKeyRotationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_email_change_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastEmailChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = verify_devices { + local_var_req_builder = + local_var_req_builder.query(&[("verifyDevices", ¶m_value.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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 account_billing_vnext_payment_method_put( - configuration: &configuration::Configuration, - email: &str, - security_stamp: &str, - api_key: &str, - id: Option, - name: Option<&str>, - email_verified: Option, - master_password: Option<&str>, - master_password_hint: Option<&str>, - culture: Option<&str>, - two_factor_providers: Option<&str>, - two_factor_recovery_code: Option<&str>, - equivalent_domains: Option<&str>, - excluded_global_equivalent_domains: Option<&str>, - account_revision_date: Option, - key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - premium: Option, - premium_expiration_date: Option, - renewal_reminder_date: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - license_key: Option<&str>, - kdf: Option, - kdf_iterations: Option, - kdf_memory: Option, - kdf_parallelism: Option, - creation_date: Option, - revision_date: Option, - force_password_reset: Option, - uses_key_connector: Option, - failed_login_count: Option, - last_failed_login_date: Option, - avatar_color: Option<&str>, - last_password_change_date: Option, - last_kdf_change_date: Option, - last_key_rotation_date: Option, - last_email_change_date: Option, - verify_devices: Option, - tokenized_payment_method_request: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_email = email; - let p_security_stamp = security_stamp; - let p_api_key = api_key; - let p_id = id; - let p_name = name; - let p_email_verified = email_verified; - let p_master_password = master_password; - let p_master_password_hint = master_password_hint; - let p_culture = culture; - let p_two_factor_providers = two_factor_providers; - let p_two_factor_recovery_code = two_factor_recovery_code; - let p_equivalent_domains = equivalent_domains; - let p_excluded_global_equivalent_domains = excluded_global_equivalent_domains; - let p_account_revision_date = account_revision_date; - let p_key = key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_premium = premium; - let p_premium_expiration_date = premium_expiration_date; - let p_renewal_reminder_date = renewal_reminder_date; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_license_key = license_key; - let p_kdf = kdf; - let p_kdf_iterations = kdf_iterations; - let p_kdf_memory = kdf_memory; - let p_kdf_parallelism = kdf_parallelism; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_force_password_reset = force_password_reset; - let p_uses_key_connector = uses_key_connector; - let p_failed_login_count = failed_login_count; - let p_last_failed_login_date = last_failed_login_date; - let p_avatar_color = avatar_color; - let p_last_password_change_date = last_password_change_date; - let p_last_kdf_change_date = last_kdf_change_date; - let p_last_key_rotation_date = last_key_rotation_date; - let p_last_email_change_date = last_email_change_date; - let p_verify_devices = verify_devices; - let p_tokenized_payment_method_request = tokenized_payment_method_request; + pub async fn account_billing_vnext_payment_method_put( + &self, + email: &str, + security_stamp: &str, + api_key: &str, + id: Option, + name: Option<&str>, + email_verified: Option, + master_password: Option<&str>, + master_password_hint: Option<&str>, + culture: Option<&str>, + two_factor_providers: Option<&str>, + two_factor_recovery_code: Option<&str>, + equivalent_domains: Option<&str>, + excluded_global_equivalent_domains: Option<&str>, + account_revision_date: Option, + key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + premium: Option, + premium_expiration_date: Option, + renewal_reminder_date: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + license_key: Option<&str>, + kdf: Option, + kdf_iterations: Option, + kdf_memory: Option, + kdf_parallelism: Option, + creation_date: Option, + revision_date: Option, + force_password_reset: Option, + uses_key_connector: Option, + failed_login_count: Option, + last_failed_login_date: Option, + avatar_color: Option<&str>, + last_password_change_date: Option, + last_kdf_change_date: Option, + last_key_rotation_date: Option, + last_email_change_date: Option, + verify_devices: Option, + tokenized_payment_method_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/account/billing/vnext/payment-method", - configuration.base_path - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/account/billing/vnext/payment-method", + 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 param_value) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("email", &p_email.to_string())]); - if let Some(ref param_value) = p_email_verified { - req_builder = req_builder.query(&[("emailVerified", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_master_password { - req_builder = req_builder.query(&[("masterPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_master_password_hint { - req_builder = req_builder.query(&[("masterPasswordHint", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_culture { - req_builder = req_builder.query(&[("culture", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("securityStamp", &p_security_stamp.to_string())]); - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_recovery_code { - req_builder = req_builder.query(&[("twoFactorRecoveryCode", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_equivalent_domains { - req_builder = req_builder.query(&[("equivalentDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_excluded_global_equivalent_domains { - req_builder = - req_builder.query(&[("excludedGlobalEquivalentDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_account_revision_date { - req_builder = req_builder.query(&[("accountRevisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_key { - req_builder = req_builder.query(&[("key", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_premium { - req_builder = req_builder.query(&[("premium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_premium_expiration_date { - req_builder = req_builder.query(&[("premiumExpirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_renewal_reminder_date { - req_builder = req_builder.query(&[("renewalReminderDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - req_builder = req_builder.query(&[("apiKey", &p_api_key.to_string())]); - if let Some(ref param_value) = p_kdf { - req_builder = req_builder.query(&[("kdf", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_iterations { - req_builder = req_builder.query(&[("kdfIterations", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_memory { - req_builder = req_builder.query(&[("kdfMemory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_kdf_parallelism { - req_builder = req_builder.query(&[("kdfParallelism", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_force_password_reset { - req_builder = req_builder.query(&[("forcePasswordReset", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_uses_key_connector { - req_builder = req_builder.query(&[("usesKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_failed_login_count { - req_builder = req_builder.query(&[("failedLoginCount", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_failed_login_date { - req_builder = req_builder.query(&[("lastFailedLoginDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_avatar_color { - req_builder = req_builder.query(&[("avatarColor", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_password_change_date { - req_builder = req_builder.query(&[("lastPasswordChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_kdf_change_date { - req_builder = req_builder.query(&[("lastKdfChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_key_rotation_date { - req_builder = req_builder.query(&[("lastKeyRotationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_last_email_change_date { - req_builder = req_builder.query(&[("lastEmailChangeDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_verify_devices { - req_builder = req_builder.query(&[("verifyDevices", ¶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_tokenized_payment_method_request); + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("email", &email.to_string())]); + if let Some(ref param_value) = email_verified { + local_var_req_builder = + local_var_req_builder.query(&[("emailVerified", ¶m_value.to_string())]); + } + if let Some(ref param_value) = master_password { + local_var_req_builder = + local_var_req_builder.query(&[("masterPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = master_password_hint { + local_var_req_builder = + local_var_req_builder.query(&[("masterPasswordHint", ¶m_value.to_string())]); + } + if let Some(ref param_value) = culture { + local_var_req_builder = + local_var_req_builder.query(&[("culture", ¶m_value.to_string())]); + } + local_var_req_builder = + local_var_req_builder.query(&[("securityStamp", &security_stamp.to_string())]); + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_recovery_code { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorRecoveryCode", ¶m_value.to_string())]); + } + if let Some(ref param_value) = equivalent_domains { + local_var_req_builder = + local_var_req_builder.query(&[("equivalentDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = excluded_global_equivalent_domains { + local_var_req_builder = local_var_req_builder + .query(&[("excludedGlobalEquivalentDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = account_revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("accountRevisionDate", ¶m_value.to_string())]); + } + 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 param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = premium { + local_var_req_builder = + local_var_req_builder.query(&[("premium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = premium_expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("premiumExpirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = renewal_reminder_date { + local_var_req_builder = + local_var_req_builder.query(&[("renewalReminderDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("apiKey", &api_key.to_string())]); + if let Some(ref param_value) = kdf { + local_var_req_builder = + local_var_req_builder.query(&[("kdf", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_iterations { + local_var_req_builder = + local_var_req_builder.query(&[("kdfIterations", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_memory { + local_var_req_builder = + local_var_req_builder.query(&[("kdfMemory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = kdf_parallelism { + local_var_req_builder = + local_var_req_builder.query(&[("kdfParallelism", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = force_password_reset { + local_var_req_builder = + local_var_req_builder.query(&[("forcePasswordReset", ¶m_value.to_string())]); + } + if let Some(ref param_value) = uses_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("usesKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = failed_login_count { + local_var_req_builder = + local_var_req_builder.query(&[("failedLoginCount", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_failed_login_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastFailedLoginDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = avatar_color { + local_var_req_builder = + local_var_req_builder.query(&[("avatarColor", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_password_change_date { + local_var_req_builder = local_var_req_builder + .query(&[("lastPasswordChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_kdf_change_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastKdfChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_key_rotation_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastKeyRotationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = last_email_change_date { + local_var_req_builder = + local_var_req_builder.query(&[("lastEmailChangeDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = verify_devices { + local_var_req_builder = + local_var_req_builder.query(&[("verifyDevices", ¶m_value.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()); + }; + local_var_req_builder = local_var_req_builder.json(&tokenized_payment_method_request); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/accounts_api.rs b/crates/bitwarden-api-api/src/apis/accounts_api.rs index a27033a2a..fb0aff5ec 100644 --- a/crates/bitwarden-api-api/src/apis/accounts_api.rs +++ b/crates/bitwarden-api-api/src/apis/accounts_api.rs @@ -8,2101 +8,2026 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`accounts_api_key_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsApiKeyPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_avatar_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsAvatarPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_avatar_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsAvatarPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_cancel_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsCancelPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsDeleteError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsDeletePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_delete_recover_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsDeleteRecoverPostError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// struct for typed errors of method [`accounts_email_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsEmailPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_email_token_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsEmailTokenPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_kdf_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsKdfPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_keys_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsKeysGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_keys_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsKeysPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_license_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsLicensePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_organizations_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsOrganizationsGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_password_hint_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsPasswordHintPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_password_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsPasswordPostError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// struct for typed errors of method [`accounts_profile_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsProfileGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_profile_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsProfilePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_profile_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsProfilePutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_reinstate_premium_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsReinstatePremiumPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_request_otp_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsRequestOtpPostError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// struct for typed errors of method [`accounts_revision_date_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsRevisionDateGetError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// struct for typed errors of method [`accounts_security_stamp_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsSecurityStampPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_set_password_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsSetPasswordPostError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// 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), -} - -/// struct for typed errors of method [`accounts_storage_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsStoragePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_subscription_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsSubscriptionGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_tax_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsTaxGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`accounts_tax_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsTaxPutError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// 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), -} - -/// struct for typed errors of method [`accounts_verify_devices_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyDevicesPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_verify_devices_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyDevicesPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_verify_email_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyEmailPostError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// struct for typed errors of method [`accounts_verify_otp_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyOtpPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`accounts_verify_password_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsVerifyPasswordPostError { - UnknownValue(serde_json::Value), -} - -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 uri_str = format!("{}/accounts/api-key", 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::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`")))), +/* +#[async_trait] +pub trait AccountsApi: Send + Sync { + + /// POST /accounts/api-key + /// + /// + async fn accounts_api_key_post(&self, secret_verification_request_model: Option) -> Result; + + /// POST /accounts/avatar + /// + /// + async fn accounts_avatar_post(&self, update_avatar_request_model: Option) -> Result; + + /// PUT /accounts/avatar + /// + /// + async fn accounts_avatar_put(&self, update_avatar_request_model: Option) -> Result; + + /// POST /accounts/cancel + /// + /// + async fn accounts_cancel_post(&self, subscription_cancellation_request_model: Option) -> Result<(), Error>; + + /// DELETE /accounts + /// + /// + async fn accounts_delete(&self, secret_verification_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/delete + /// + /// + async fn accounts_delete_post(&self, secret_verification_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/delete-recover + /// + /// + async fn accounts_delete_recover_post(&self, delete_recover_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/delete-recover-token + /// + /// + async fn accounts_delete_recover_token_post(&self, verify_delete_recover_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/email + /// + /// + async fn accounts_email_post(&self, email_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/email-token + /// + /// + async fn accounts_email_token_post(&self, email_token_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/kdf + /// + /// + async fn accounts_kdf_post(&self, kdf_request_model: Option) -> Result<(), Error>; + + /// GET /accounts/keys + /// + /// + async fn accounts_keys_get(&self, ) -> Result; + + /// POST /accounts/keys + /// + /// + async fn accounts_keys_post(&self, keys_request_model: Option) -> Result; + + /// POST /accounts/license + /// + /// + async fn accounts_license_post(&self, license: std::path::PathBuf) -> Result<(), Error>; + + /// GET /accounts/organizations + /// + /// + async fn accounts_organizations_get(&self, ) -> Result; + + /// POST /accounts/password-hint + /// + /// + async fn accounts_password_hint_post(&self, password_hint_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/password + /// + /// + async fn accounts_password_post(&self, password_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/payment + /// + /// + async fn accounts_payment_post(&self, payment_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/premium + /// + /// + async fn accounts_premium_post(&self, payment_method_type: models::PaymentMethodType, payment_token: Option<&str>, additional_storage_gb: Option, country: Option<&str>, postal_code: Option<&str>, license: Option) -> Result; + + /// GET /accounts/profile + /// + /// + async fn accounts_profile_get(&self, ) -> Result; + + /// POST /accounts/profile + /// + /// + async fn accounts_profile_post(&self, update_profile_request_model: Option) -> Result; + + /// PUT /accounts/profile + /// + /// + async fn accounts_profile_put(&self, update_profile_request_model: Option) -> Result; + + /// POST /accounts/reinstate-premium + /// + /// + async fn accounts_reinstate_premium_post(&self, ) -> Result<(), Error>; + + /// POST /accounts/request-otp + /// + /// + async fn accounts_request_otp_post(&self, ) -> Result<(), Error>; + + /// POST /accounts/resend-new-device-otp + /// + /// + async fn accounts_resend_new_device_otp_post(&self, unauthenticated_secret_verification_request_model: Option) -> Result<(), Error>; + + /// GET /accounts/revision-date + /// + /// + async fn accounts_revision_date_get(&self, ) -> Result; + + /// POST /accounts/rotate-api-key + /// + /// + async fn accounts_rotate_api_key_post(&self, secret_verification_request_model: Option) -> Result; + + /// POST /accounts/security-stamp + /// + /// + async fn accounts_security_stamp_post(&self, secret_verification_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/set-password + /// + /// + async fn accounts_set_password_post(&self, set_password_request_model: Option) -> Result<(), Error>; + + /// DELETE /accounts/sso/{organizationId} + /// + /// + async fn accounts_sso_organization_id_delete(&self, organization_id: &str) -> Result<(), Error>; + + /// GET /accounts/sso/user-identifier + /// + /// + async fn accounts_sso_user_identifier_get(&self, ) -> Result; + + /// POST /accounts/storage + /// + /// + async fn accounts_storage_post(&self, storage_request_model: Option) -> Result; + + /// GET /accounts/subscription + /// + /// + async fn accounts_subscription_get(&self, ) -> Result; + + /// GET /accounts/tax + /// + /// + async fn accounts_tax_get(&self, ) -> Result; + + /// PUT /accounts/tax + /// + /// + async fn accounts_tax_put(&self, tax_info_update_request_model: Option) -> Result<(), Error>; + + /// PUT /accounts/update-tde-offboarding-password + /// + /// + async fn accounts_update_tde_offboarding_password_put(&self, update_tde_offboarding_password_request_model: Option) -> Result<(), Error>; + + /// PUT /accounts/update-temp-password + /// + /// + async fn accounts_update_temp_password_put(&self, update_temp_password_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/verify-devices + /// + /// + async fn accounts_verify_devices_post(&self, set_verify_devices_request_model: Option) -> Result<(), Error>; + + /// PUT /accounts/verify-devices + /// + /// + async fn accounts_verify_devices_put(&self, set_verify_devices_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/verify-email + /// + /// + async fn accounts_verify_email_post(&self, ) -> Result<(), Error>; + + /// POST /accounts/verify-email-token + /// + /// + async fn accounts_verify_email_token_post(&self, verify_email_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/verify-otp + /// + /// + async fn accounts_verify_otp_post(&self, verify_otp_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/verify-password + /// + /// + async fn accounts_verify_password_post(&self, secret_verification_request_model: Option) -> Result; +} +*/ + +pub struct AccountsApiClient { + configuration: Arc, +} + +impl AccountsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +// #[async_trait] +impl AccountsApiClient { + pub async fn accounts_api_key_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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; - let uri_str = format!("{}/accounts/avatar", 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_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`")))), + pub async fn accounts_avatar_post( + &self, + update_avatar_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/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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; - let uri_str = format!("{}/accounts/avatar", 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_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`")))), + pub async fn accounts_avatar_put( + &self, + update_avatar_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/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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; - let uri_str = format!("{}/accounts/cancel", 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_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 accounts_cancel_post( + &self, + 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!("{}/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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; - let uri_str = format!("{}/accounts", 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_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 accounts_delete( + &self, + 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!("{}/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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_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; - - let uri_str = format!("{}/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_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 accounts_delete_post( + &self, + 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!("{}/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_token) = local_var_configuration.oauth_access_token { + 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_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; - let uri_str = format!("{}/accounts/delete-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_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 accounts_delete_recover_post( + &self, + delete_recover_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/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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; - - let uri_str = format!("{}/accounts/delete-recover-token", 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_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 accounts_delete_recover_token_post( + &self, + verify_delete_recover_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/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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; - - let uri_str = format!("{}/accounts/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_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_email_post( + &self, + 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!("{}/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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; - let uri_str = format!("{}/accounts/email-token", 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_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, - })) + pub async fn accounts_email_token_post( + &self, + email_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!("{}/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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; - - let uri_str = format!("{}/accounts/kdf", 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_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, - })) + pub async fn accounts_kdf_post( + &self, + kdf_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/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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`")))), + pub async fn accounts_keys_get(&self) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_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)) } - } else { - 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_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; - let uri_str = format!("{}/accounts/keys", 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_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`")))), + pub async fn accounts_keys_post( + &self, + 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!("{}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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; - - let uri_str = format!("{}/accounts/license", 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 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 accounts_license_post(&self, 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!("{}/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()); + + if let Some(ref 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_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`")))), + pub async fn accounts_organizations_get( + &self, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_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)) } - } else { - 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_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; - let uri_str = format!("{}/accounts/password-hint", 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_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, - })) + pub async fn accounts_password_hint_post( + &self, + password_hint_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/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_token) = local_var_configuration.oauth_access_token { + 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_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; - let uri_str = format!("{}/accounts/password", 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_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_password_post( + &self, + 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/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_token) = local_var_configuration.oauth_access_token { + 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_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; - - let uri_str = format!("{}/accounts/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_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 accounts_payment_post( + &self, + 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!("{}/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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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 param_value) = p_country { - req_builder = req_builder.query(&[("country", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_postal_code { - req_builder = req_builder.query(&[("postalCode", ¶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 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`")))), + pub async fn accounts_premium_post( + &self, + payment_method_type: models::PaymentMethodType, + payment_token: Option<&str>, + additional_storage_gb: Option, + country: Option<&str>, + postal_code: Option<&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_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)) } - } else { - 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_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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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::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`")))), + pub async fn accounts_profile_get(&self) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_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)) } - } else { - 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_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; - let uri_str = format!("{}/accounts/profile", 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_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`")))), + pub async fn accounts_profile_post( + &self, + update_profile_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/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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; - let uri_str = format!("{}/accounts/profile", 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_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`")))), + pub async fn accounts_profile_put( + &self, + update_profile_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/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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); - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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_reinstate_premium_post(&self) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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_request_otp_post(&self) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + 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_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_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, - })) + pub async fn accounts_resend_new_device_otp_post( + &self, + unauthenticated_secret_verification_request_model: Option< + models::UnauthenticatedSecretVerificationRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_token) = local_var_configuration.oauth_access_token { + 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_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); - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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`")))), + pub async fn accounts_revision_date_get(&self) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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()); + + if let Some(ref 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)) } - } else { - 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_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; - - let uri_str = format!("{}/accounts/rotate-api-key", 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::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`")))), + pub async fn accounts_rotate_api_key_post( + &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/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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; - let uri_str = format!("{}/accounts/security-stamp", 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(); - - 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_security_stamp_post( + &self, + 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!( + "{}/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_token) = local_var_configuration.oauth_access_token { + 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_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; - - let uri_str = format!("{}/accounts/set-password", 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_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, - })) + pub async fn accounts_set_password_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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, - })) + pub async fn accounts_sso_organization_id_delete( + &self, + organization_id: &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_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_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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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`")))), + pub async fn accounts_sso_user_identifier_get(&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_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 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; - - let uri_str = format!("{}/accounts/storage", 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_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`")))), + pub async fn accounts_storage_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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`")))), + pub async fn accounts_subscription_get( + &self, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_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)) } - } else { - 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_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); - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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`")))), + pub async fn accounts_tax_get(&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_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)) } - } else { - 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_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; - - let uri_str = format!("{}/accounts/tax", 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_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 accounts_tax_put( + &self, + 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!("{}/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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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, - })) + pub async fn accounts_update_tde_offboarding_password_put( + &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_token) = local_var_configuration.oauth_access_token { + 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_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; - let uri_str = format!("{}/accounts/update-temp-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_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, - })) + pub async fn accounts_update_temp_password_put( + &self, + update_temp_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/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 local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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; - - let uri_str = format!("{}/accounts/verify-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_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, - })) + pub async fn accounts_verify_devices_post( + &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_token) = local_var_configuration.oauth_access_token { + 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_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; - let uri_str = format!("{}/accounts/verify-devices", 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_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, - })) + pub async fn accounts_verify_devices_put( + &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::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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_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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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_verify_email_post(&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_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_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; - let uri_str = format!("{}/accounts/verify-email-token", 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_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, - })) + pub async fn accounts_verify_email_token_post( + &self, + verify_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!( + "{}/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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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; - - let uri_str = format!("{}/accounts/verify-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_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, - })) + pub async fn accounts_verify_otp_post( + &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_token) = local_var_configuration.oauth_access_token { + 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_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; - let uri_str = format!("{}/accounts/verify-password", 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::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`")))), + pub async fn accounts_verify_password_post( + &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/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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_billing_api.rs b/crates/bitwarden-api-api/src/apis/accounts_billing_api.rs index 8e6eb0a73..9f7470898 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,283 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsBillingInvoicesGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`accounts_billing_payment_method_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsBillingPaymentMethodGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait AccountsBillingApi: Send + Sync { + + /// GET /accounts/billing/history + /// + /// + async fn accounts_billing_history_get(&self, ) -> Result; + + /// GET /accounts/billing/invoices + /// + /// + async fn accounts_billing_invoices_get(&self, status: Option<&str>, start_after: Option<&str>) -> Result<(), Error>; + + /// GET /accounts/billing/payment-method + /// + /// + async fn accounts_billing_payment_method_get(&self, ) -> Result; + + /// POST /accounts/billing/preview-invoice + /// + /// + async fn accounts_billing_preview_invoice_post(&self, preview_individual_invoice_request_body: Option) -> Result<(), Error>; + + /// GET /accounts/billing/transactions + /// + /// + async fn accounts_billing_transactions_get(&self, start_after: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`accounts_billing_preview_invoice_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsBillingPreviewInvoicePostError { - UnknownValue(serde_json::Value), +pub struct AccountsBillingApiClient { + configuration: Arc, } -/// struct for typed errors of method [`accounts_billing_transactions_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsBillingTransactionsGetError { - UnknownValue(serde_json::Value), +impl AccountsBillingApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl AccountsBillingApiClient { + pub async fn accounts_billing_history_get( + &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_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)) } - } else { - 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_invoices_get( + &self, + status: Option<&str>, + start_after: Option<&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_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_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`")))), + pub async fn accounts_billing_payment_method_get( + &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()); + + if let Some(ref 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)) } - } else { - 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_preview_invoice_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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, - })) + pub async fn accounts_billing_transactions_get( + &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_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)) + } } } 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 6dc9f9ed8..2f7e4eda5 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,199 +8,208 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`accounts_convert_to_key_connector_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsConvertToKeyConnectorPostError { - UnknownValue(serde_json::Value), -} +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), -} - -/// struct for typed errors of method [`accounts_key_management_rotate_user_account_keys_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsKeyManagementRotateUserAccountKeysPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait AccountsKeyManagementApi: Send + Sync { + + /// POST /accounts/convert-to-key-connector + /// + /// + async fn accounts_convert_to_key_connector_post(&self, ) -> Result<(), Error>; + + /// POST /accounts/key-management/regenerate-keys + /// + /// + async fn accounts_key_management_regenerate_keys_post(&self, key_regeneration_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/key-management/rotate-user-account-keys + /// + /// + async fn accounts_key_management_rotate_user_account_keys_post(&self, rotate_user_account_keys_and_data_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/set-key-connector-key + /// + /// + async fn accounts_set_key_connector_key_post(&self, set_key_connector_key_request_model: Option) -> Result<(), Error>; } +*/ -/// 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), +pub struct AccountsKeyManagementApiClient { + configuration: Arc, } -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, - })) +impl AccountsKeyManagementApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +// #[async_trait] +impl AccountsKeyManagementApiClient { + pub async fn accounts_convert_to_key_connector_post(&self) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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()); + + if let Some(ref 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_key_regeneration_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_key_management_rotate_user_account_keys_post( - configuration: &configuration::Configuration, - rotate_user_account_keys_and_data_request_model: Option< - models::RotateUserAccountKeysAndDataRequestModel, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_rotate_user_account_keys_and_data_request_model = - rotate_user_account_keys_and_data_request_model; - - let uri_str = format!( - "{}/accounts/key-management/rotate-user-account-keys", - 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 async fn accounts_key_management_regenerate_keys_post( + &self, + key_regeneration_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/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 let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_rotate_user_account_keys_and_data_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_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; - - let uri_str = format!("{}/accounts/set-key-connector-key", 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 async fn accounts_key_management_rotate_user_account_keys_post( + &self, + rotate_user_account_keys_and_data_request_model: Option< + models::RotateUserAccountKeysAndDataRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/accounts/key-management/rotate-user-account-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_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&rotate_user_account_keys_and_data_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_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, - })) + + pub async fn accounts_set_key_connector_key_post( + &self, + set_key_connector_key_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-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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } } 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 7e74ea84c..d5091c294 100644 --- a/crates/bitwarden-api-api/src/apis/auth_requests_api.rs +++ b/crates/bitwarden-api-api/src/apis/auth_requests_api.rs @@ -8,400 +8,408 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AuthRequestsGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AuthRequestsIdPutError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`auth_requests_id_response_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AuthRequestsIdResponseGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait AuthRequestsApi: Send + Sync { + + /// POST /auth-requests/admin-request + /// + /// + async fn auth_requests_admin_request_post(&self, auth_request_create_request_model: Option) -> Result; + + /// GET /auth-requests + /// + /// + async fn auth_requests_get(&self, ) -> Result; + + /// GET /auth-requests/{id} + /// + /// + async fn auth_requests_id_get(&self, id: uuid::Uuid) -> Result; + + /// PUT /auth-requests/{id} + /// + /// + async fn auth_requests_id_put(&self, id: uuid::Uuid, auth_request_update_request_model: Option) -> Result; + + /// GET /auth-requests/{id}/response + /// + /// + async fn auth_requests_id_response_get(&self, id: uuid::Uuid, code: Option<&str>) -> Result; + + /// GET /auth-requests/pending + /// + /// + async fn auth_requests_pending_get(&self, ) -> Result; + + /// POST /auth-requests + /// + /// + async fn auth_requests_post(&self, auth_request_create_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`auth_requests_pending_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AuthRequestsPendingGetError { - UnknownValue(serde_json::Value), +pub struct AuthRequestsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`auth_requests_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AuthRequestsPostError { - UnknownValue(serde_json::Value), +impl AuthRequestsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl AuthRequestsApiClient { + pub async fn auth_requests_admin_request_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn auth_requests_get( + &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_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)) } - } else { - 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`")))), + pub async fn auth_requests_id_get( + &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_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)) } - } else { - 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`")))), + pub async fn auth_requests_id_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn auth_requests_id_response_get( + &self, + id: uuid::Uuid, + code: Option<&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_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)) } - } else { - 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_pending_get( - configuration: &configuration::Configuration, -) -> Result< - models::PendingAuthRequestResponseModelListResponseModel, - Error, -> { - let uri_str = format!("{}/auth-requests/pending", 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::PendingAuthRequestResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PendingAuthRequestResponseModelListResponseModel`")))), + pub async fn auth_requests_pending_get( + &self, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/auth-requests/pending", + 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_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::PendingAuthRequestResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PendingAuthRequestResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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 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`")))), + pub async fn auth_requests_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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 c5f0c2ce2..3b318ba9b 100644 --- a/crates/bitwarden-api-api/src/apis/ciphers_api.rs +++ b/crates/bitwarden-api-api/src/apis/ciphers_api.rs @@ -8,3280 +8,3026 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`ciphers_admin_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersAdminDeleteError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_admin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersAdminPostError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// struct for typed errors of method [`ciphers_bulk_collections_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersBulkCollectionsPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_create_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersCreatePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersDeleteError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_delete_admin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersDeleteAdminPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_delete_admin_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersDeleteAdminPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersDeletePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_delete_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersDeletePutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_admin_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAdminDeleteError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_admin_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAdminGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_admin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAdminPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_admin_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAdminPutError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// 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), -} - -/// struct for typed errors of method [`ciphers_id_attachment_attachment_id_admin_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentAttachmentIdAdminGetError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// 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), -} - -/// 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), -} - -/// 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), -} - -/// 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), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// 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), -} - -/// 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), -} - -/// struct for typed errors of method [`ciphers_id_attachment_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdAttachmentPostError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// 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), -} - -/// 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), -} - -/// struct for typed errors of method [`ciphers_id_collections_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdCollectionsPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_collections_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdCollectionsPutError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// 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), -} - -/// struct for typed errors of method [`ciphers_id_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdDeleteError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// 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), -} - -/// struct for typed errors of method [`ciphers_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdDeletePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_delete_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdDeletePutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_details_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdDetailsGetError { - UnknownValue(serde_json::Value), -} - -/// 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), -} - -/// struct for typed errors of method [`ciphers_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_partial_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdPartialPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_partial_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdPartialPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_restore_admin_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdRestoreAdminPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_restore_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdRestorePutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_share_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdSharePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_id_share_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersIdSharePutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_move_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersMovePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_move_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersMovePutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_organization_details_assigned_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersOrganizationDetailsAssignedGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_organization_details_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersOrganizationDetailsGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_purge_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersPurgePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_restore_admin_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersRestoreAdminPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_restore_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersRestorePutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_share_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersSharePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`ciphers_share_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersSharePutError { - 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, - })) +/* +#[async_trait] +pub trait CiphersApi: Send + Sync { + + /// DELETE /ciphers/admin + /// + /// + async fn ciphers_admin_delete(&self, cipher_bulk_delete_request_model: Option) -> Result<(), Error>; + + /// POST /ciphers/admin + /// + /// + async fn ciphers_admin_post(&self, cipher_create_request_model: Option) -> Result; + + /// POST /ciphers/attachment/validate/azure + /// + /// + async fn ciphers_attachment_validate_azure_post(&self, ) -> Result<(), Error>; + + /// POST /ciphers/bulk-collections + /// + /// + async fn ciphers_bulk_collections_post(&self, cipher_bulk_update_collections_request_model: Option) -> Result<(), Error>; + + /// POST /ciphers/create + /// + /// + async fn ciphers_create_post(&self, cipher_create_request_model: Option) -> Result; + + /// DELETE /ciphers + /// + /// + async fn ciphers_delete(&self, cipher_bulk_delete_request_model: Option) -> Result<(), Error>; + + /// POST /ciphers/delete-admin + /// + /// + async fn ciphers_delete_admin_post(&self, cipher_bulk_delete_request_model: Option) -> Result<(), Error>; + + /// PUT /ciphers/delete-admin + /// + /// + async fn ciphers_delete_admin_put(&self, cipher_bulk_delete_request_model: Option) -> Result<(), Error>; + + /// POST /ciphers/delete + /// + /// + async fn ciphers_delete_post(&self, cipher_bulk_delete_request_model: Option) -> Result<(), Error>; + + /// PUT /ciphers/delete + /// + /// + async fn ciphers_delete_put(&self, cipher_bulk_delete_request_model: Option) -> Result<(), Error>; + + /// GET /ciphers + /// + /// + async fn ciphers_get(&self, ) -> Result; + + /// DELETE /ciphers/{id}/admin + /// + /// + async fn ciphers_id_admin_delete(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// GET /ciphers/{id}/admin + /// + /// + async fn ciphers_id_admin_get(&self, id: &str) -> Result; + + /// POST /ciphers/{id}/admin + /// + /// + async fn ciphers_id_admin_post(&self, id: uuid::Uuid, cipher_request_model: Option) -> Result; + + /// PUT /ciphers/{id}/admin + /// + /// + async fn ciphers_id_admin_put(&self, id: uuid::Uuid, cipher_request_model: Option) -> Result; + + /// POST /ciphers/{id}/attachment-admin + /// + /// + async fn ciphers_id_attachment_admin_post(&self, id: &str) -> Result; + + /// DELETE /ciphers/{id}/attachment/{attachmentId}/admin + /// + /// + async fn ciphers_id_attachment_attachment_id_admin_delete(&self, id: uuid::Uuid, attachment_id: &str) -> Result; + + /// GET /ciphers/{id}/attachment/{attachmentId}/admin + /// + /// + async fn ciphers_id_attachment_attachment_id_admin_get(&self, id: uuid::Uuid, attachment_id: &str) -> Result; + + /// DELETE /ciphers/{id}/attachment/{attachmentId} + /// + /// + async fn ciphers_id_attachment_attachment_id_delete(&self, id: uuid::Uuid, attachment_id: &str) -> Result; + + /// POST /ciphers/{id}/attachment/{attachmentId}/delete-admin + /// + /// + async fn ciphers_id_attachment_attachment_id_delete_admin_post(&self, id: uuid::Uuid, attachment_id: &str) -> Result; + + /// POST /ciphers/{id}/attachment/{attachmentId}/delete + /// + /// + async fn ciphers_id_attachment_attachment_id_delete_post(&self, id: uuid::Uuid, attachment_id: &str) -> Result; + + /// GET /ciphers/{id}/attachment/{attachmentId} + /// + /// + async fn ciphers_id_attachment_attachment_id_get(&self, id: uuid::Uuid, attachment_id: &str) -> Result; + + /// POST /ciphers/{id}/attachment/{attachmentId} + /// + /// + async fn ciphers_id_attachment_attachment_id_post(&self, id: uuid::Uuid, attachment_id: &str) -> Result<(), Error>; + + /// GET /ciphers/{id}/attachment/{attachmentId}/renew + /// + /// + async fn ciphers_id_attachment_attachment_id_renew_get(&self, id: uuid::Uuid, attachment_id: &str) -> Result; + + /// POST /ciphers/{id}/attachment/{attachmentId}/share + /// + /// + async fn ciphers_id_attachment_attachment_id_share_post(&self, id: &str, attachment_id: &str, organization_id: Option) -> Result<(), Error>; + + /// POST /ciphers/{id}/attachment + /// + /// + async fn ciphers_id_attachment_post(&self, id: uuid::Uuid) -> Result; + + /// POST /ciphers/{id}/attachment/v2 + /// + /// + async fn ciphers_id_attachment_v2_post(&self, id: uuid::Uuid, attachment_request_model: Option) -> Result; + + /// POST /ciphers/{id}/collections-admin + /// + /// + async fn ciphers_id_collections_admin_post(&self, id: &str, cipher_collections_request_model: Option) -> Result; + + /// PUT /ciphers/{id}/collections-admin + /// + /// + async fn ciphers_id_collections_admin_put(&self, id: &str, cipher_collections_request_model: Option) -> Result; + + /// POST /ciphers/{id}/collections + /// + /// + async fn ciphers_id_collections_post(&self, id: uuid::Uuid, cipher_collections_request_model: Option) -> Result; + + /// PUT /ciphers/{id}/collections + /// + /// + async fn ciphers_id_collections_put(&self, id: uuid::Uuid, cipher_collections_request_model: Option) -> Result; + + /// POST /ciphers/{id}/collections_v2 + /// + /// + async fn ciphers_id_collections_v2_post(&self, id: uuid::Uuid, cipher_collections_request_model: Option) -> Result; + + /// PUT /ciphers/{id}/collections_v2 + /// + /// + async fn ciphers_id_collections_v2_put(&self, id: uuid::Uuid, cipher_collections_request_model: Option) -> Result; + + /// DELETE /ciphers/{id} + /// + /// + async fn ciphers_id_delete(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /ciphers/{id}/delete-admin + /// + /// + async fn ciphers_id_delete_admin_post(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// PUT /ciphers/{id}/delete-admin + /// + /// + async fn ciphers_id_delete_admin_put(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /ciphers/{id}/delete + /// + /// + async fn ciphers_id_delete_post(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// PUT /ciphers/{id}/delete + /// + /// + async fn ciphers_id_delete_put(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// GET /ciphers/{id}/details + /// + /// + async fn ciphers_id_details_get(&self, id: uuid::Uuid) -> Result; + + /// GET /ciphers/{id}/full-details + /// + /// + async fn ciphers_id_full_details_get(&self, id: uuid::Uuid) -> Result; + + /// GET /ciphers/{id} + /// + /// + async fn ciphers_id_get(&self, id: uuid::Uuid) -> Result; + + /// POST /ciphers/{id}/partial + /// + /// + async fn ciphers_id_partial_post(&self, id: uuid::Uuid, cipher_partial_request_model: Option) -> Result; + + /// PUT /ciphers/{id}/partial + /// + /// + async fn ciphers_id_partial_put(&self, id: uuid::Uuid, cipher_partial_request_model: Option) -> Result; + + /// POST /ciphers/{id} + /// + /// + async fn ciphers_id_post(&self, id: uuid::Uuid, cipher_request_model: Option) -> Result; + + /// PUT /ciphers/{id} + /// + /// + async fn ciphers_id_put(&self, id: uuid::Uuid, cipher_request_model: Option) -> Result; + + /// PUT /ciphers/{id}/restore-admin + /// + /// + async fn ciphers_id_restore_admin_put(&self, id: uuid::Uuid) -> Result; + + /// PUT /ciphers/{id}/restore + /// + /// + async fn ciphers_id_restore_put(&self, id: uuid::Uuid) -> Result; + + /// POST /ciphers/{id}/share + /// + /// + async fn ciphers_id_share_post(&self, id: uuid::Uuid, cipher_share_request_model: Option) -> Result; + + /// PUT /ciphers/{id}/share + /// + /// + async fn ciphers_id_share_put(&self, id: uuid::Uuid, cipher_share_request_model: Option) -> Result; + + /// POST /ciphers/move + /// + /// + async fn ciphers_move_post(&self, cipher_bulk_move_request_model: Option) -> Result<(), Error>; + + /// PUT /ciphers/move + /// + /// + async fn ciphers_move_put(&self, cipher_bulk_move_request_model: Option) -> Result<(), Error>; + + /// GET /ciphers/organization-details/assigned + /// + /// + async fn ciphers_organization_details_assigned_get(&self, organization_id: Option) -> Result; + + /// GET /ciphers/organization-details + /// + /// + async fn ciphers_organization_details_get(&self, organization_id: Option) -> Result; + + /// POST /ciphers + /// + /// + async fn ciphers_post(&self, cipher_request_model: Option) -> Result; + + /// POST /ciphers/purge + /// + /// + async fn ciphers_purge_post(&self, organization_id: Option, secret_verification_request_model: Option) -> Result<(), Error>; + + /// PUT /ciphers/restore-admin + /// + /// + async fn ciphers_restore_admin_put(&self, cipher_bulk_restore_request_model: Option) -> Result; + + /// PUT /ciphers/restore + /// + /// + async fn ciphers_restore_put(&self, cipher_bulk_restore_request_model: Option) -> Result; + + /// POST /ciphers/share + /// + /// + async fn ciphers_share_post(&self, cipher_bulk_share_request_model: Option) -> Result; + + /// PUT /ciphers/share + /// + /// + async fn ciphers_share_put(&self, cipher_bulk_share_request_model: Option) -> Result; +} +*/ + +pub struct CiphersApiClient { + configuration: Arc, +} + +impl CiphersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +// #[async_trait] +impl CiphersApiClient { + pub async fn ciphers_admin_delete( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn ciphers_admin_post( + &self, + cipher_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!("{}/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_attachment_validate_azure_post(&self) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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()); + + if let Some(ref 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 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_bulk_collections_post( + &self, + cipher_bulk_update_collections_request_model: Option< + models::CipherBulkUpdateCollectionsRequestModel, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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`")))), + pub async fn ciphers_create_post( + &self, + cipher_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!("{}/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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( + &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", 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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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_admin_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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_delete_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn ciphers_get( + &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_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)) } - } else { - 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: uuid::Uuid, -) -> 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.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 ciphers_id_admin_delete(&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}/admin", + 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_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 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`")))), + pub async fn ciphers_id_admin_get( + &self, + id: &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_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)) } - } else { - 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`")))), + pub async fn ciphers_id_admin_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn ciphers_id_admin_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn ciphers_id_attachment_admin_post( + &self, + id: &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_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)) } - } else { - 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: 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}/admin", - 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`")))), + pub async fn ciphers_id_attachment_attachment_id_admin_delete( + &self, + id: uuid::Uuid, + attachment_id: &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}/admin", + 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_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)) } - } else { - 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_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}/admin", - 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`")))), + pub async fn ciphers_id_attachment_attachment_id_admin_get( + &self, + id: uuid::Uuid, + attachment_id: &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}/admin", + 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_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)) } - } else { - 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`")))), + pub async fn ciphers_id_attachment_attachment_id_delete( + &self, + id: uuid::Uuid, + attachment_id: &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::DELETE, local_var_uri_str.as_str()); + + if let Some(ref 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)) } - } else { - 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: 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-admin", - 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`")))), + pub async fn ciphers_id_attachment_attachment_id_delete_admin_post( + &self, + id: uuid::Uuid, + attachment_id: &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}/delete-admin", + 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_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)) } - } else { - 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`")))), + pub async fn ciphers_id_attachment_attachment_id_delete_post( + &self, + id: uuid::Uuid, + attachment_id: &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}/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_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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_attachment_attachment_id_get( + &self, + id: uuid::Uuid, + attachment_id: &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_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)) } - } else { - 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_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, - })) + pub async fn ciphers_id_attachment_attachment_id_post( + &self, + id: uuid::Uuid, + attachment_id: &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_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 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`")))), + pub async fn ciphers_id_attachment_attachment_id_renew_get( + &self, + id: uuid::Uuid, + attachment_id: &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}/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_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)) } - } else { - 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_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, - })) + pub async fn ciphers_id_attachment_attachment_id_share_post( + &self, + id: &str, + attachment_id: &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_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 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`")))), + pub async fn ciphers_id_attachment_post( + &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_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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_attachment_v2_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_collections_admin_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_collections_admin_put( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_collections_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_collections_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_collections_v2_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_collections_v2_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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, - })) + pub async fn ciphers_id_delete(&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_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 ciphers_id_delete_admin_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-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()); - }; - - 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_delete_admin_post(&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-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_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 ciphers_id_delete_admin_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-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()); - }; - - 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_delete_admin_put(&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-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_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 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, - })) + pub async fn ciphers_id_delete_post(&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_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 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, - })) + pub async fn ciphers_id_delete_put(&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_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 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`")))), + pub async fn ciphers_id_details_get( + &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_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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_full_details_get( + &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_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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_get( + &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_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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_partial_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_partial_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_restore_admin_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-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()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(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`")))), + pub async fn ciphers_id_restore_admin_put( + &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-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_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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_restore_put( + &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_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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_share_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_id_share_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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, - })) + pub async fn ciphers_move_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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; + pub async fn ciphers_move_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } + } - let uri_str = format!("{}/ciphers/move", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + pub async fn ciphers_organization_details_assigned_get( + &self, + organization_id: 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_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, - })) - } -} + 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()); -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`")))), + if let Some(ref param_value) = organization_id { + local_var_req_builder = + local_var_req_builder.query(&[("organizationId", ¶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, - })) - } -} - -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`")))), + if let Some(ref 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)) } - } else { - 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_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; + pub async fn ciphers_organization_details_get( + &self, + organization_id: Option, + ) -> Result { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/ciphers", configuration.base_path); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + 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 user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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`")))), + 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_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)) } - } else { - 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_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, - })) + pub async fn ciphers_post( + &self, + 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", 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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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; + pub async fn ciphers_purge_post( + &self, + organization_id: Option, + secret_verification_request_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!("{}/ciphers/restore-admin", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + let local_var_client = &local_var_configuration.client; + 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()); - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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`")))), + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_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`")))), + pub async fn ciphers_restore_admin_put( + &self, + cipher_bulk_restore_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/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_share_post( - configuration: &configuration::Configuration, - cipher_bulk_share_request_model: Option, -) -> Result> { - // 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(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(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`")))), + pub async fn ciphers_restore_put( + &self, + cipher_bulk_restore_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/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_share_put( - configuration: &configuration::Configuration, - cipher_bulk_share_request_model: Option, -) -> Result> { - // 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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + pub async fn ciphers_share_post( + &self, + cipher_bulk_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/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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(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)) + } } - 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(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(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`")))), + + pub async fn ciphers_share_put( + &self, + cipher_bulk_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/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_token) = local_var_configuration.oauth_access_token { + 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_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(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)) } - } 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/collections_api.rs b/crates/bitwarden-api-api/src/apis/collections_api.rs index ac7b1cad3..bbd8c247d 100644 --- a/crates/bitwarden-api-api/src/apis/collections_api.rs +++ b/crates/bitwarden-api-api/src/apis/collections_api.rs @@ -8,821 +8,760 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdCollectionsIdDeleteError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`organizations_org_id_collections_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdCollectionsIdDeletePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdCollectionsIdPutError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait CollectionsApi: Send + Sync { + + /// GET /collections + /// + /// + async fn collections_get(&self, ) -> Result; + + /// POST /organizations/{orgId}/collections/bulk-access + /// + /// + async fn organizations_org_id_collections_bulk_access_post(&self, org_id: uuid::Uuid, bulk_collection_access_request_model: Option) -> Result<(), Error>; + + /// DELETE /organizations/{orgId}/collections + /// + /// + async fn organizations_org_id_collections_delete(&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(&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(&self, org_id: uuid::Uuid) -> Result; + + /// GET /organizations/{orgId}/collections + /// + /// + async fn organizations_org_id_collections_get(&self, org_id: uuid::Uuid) -> Result; + + /// DELETE /organizations/{orgId}/collections/{id} + /// + /// + async fn organizations_org_id_collections_id_delete(&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(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>; + + /// GET /organizations/{orgId}/collections/{id}/details + /// + /// + async fn organizations_org_id_collections_id_details_get(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result; + + /// GET /organizations/{orgId}/collections/{id} + /// + /// + async fn organizations_org_id_collections_id_get(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result; + + /// POST /organizations/{orgId}/collections/{id} + /// + /// + async fn organizations_org_id_collections_id_post(&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(&self, org_id: uuid::Uuid, id: uuid::Uuid, collection_request_model: Option) -> Result; + + /// GET /organizations/{orgId}/collections/{id}/users + /// + /// + async fn organizations_org_id_collections_id_users_get(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result, Error>; + + /// POST /organizations/{orgId}/collections + /// + /// + async fn organizations_org_id_collections_post(&self, org_id: uuid::Uuid, collection_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`organizations_org_id_collections_id_users_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdCollectionsIdUsersGetError { - UnknownValue(serde_json::Value), +pub struct CollectionsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`organizations_org_id_collections_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdCollectionsPostError { - UnknownValue(serde_json::Value), +impl CollectionsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl CollectionsApiClient { + pub async fn collections_get( + &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_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)) } - } else { - 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_bulk_access_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_delete_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn organizations_org_id_collections_details_get( + &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}/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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_collections_get( + &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}/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_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)) } - } else { - 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( + &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_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 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_post( + &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_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 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`")))), + pub async fn organizations_org_id_collections_id_details_get( + &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}/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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_collections_id_get( + &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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_collections_id_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_collections_id_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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>`")))), + pub async fn organizations_org_id_collections_id_users_get( + &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}/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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_collections_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..8216fe5ae 100644 --- a/crates/bitwarden-api-api/src/apis/config_api.rs +++ b/crates/bitwarden-api-api/src/apis/config_api.rs @@ -8,57 +8,80 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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, +}; + +/* +#[async_trait] +pub trait ConfigApi: Send + Sync { -/// struct for typed errors of method [`config_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ConfigGetError { - UnknownValue(serde_json::Value), + /// GET /config + /// + /// + async fn config_get(&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] +impl ConfigApiClient { + pub async fn config_get(&self) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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()); + + if let Some(ref 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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content_type = resp - .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_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/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, - })) } } 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..248853edd 100644 --- a/crates/bitwarden-api-api/src/apis/counts_api.rs +++ b/crates/bitwarden-api-api/src/apis/counts_api.rs @@ -8,187 +8,195 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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_sm_counts_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdSmCountsGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait CountsApi: Send + Sync { + + /// GET /organizations/{organizationId}/sm-counts + /// + /// + async fn organizations_organization_id_sm_counts_get(&self, organization_id: uuid::Uuid) -> Result; + + /// GET /projects/{projectId}/sm-counts + /// + /// + async fn projects_project_id_sm_counts_get(&self, project_id: uuid::Uuid) -> Result; + + /// GET /service-accounts/{serviceAccountId}/sm-counts + /// + /// + async fn service_accounts_service_account_id_sm_counts_get(&self, service_account_id: uuid::Uuid) -> Result; } +*/ -/// struct for typed errors of method [`projects_project_id_sm_counts_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProjectsProjectIdSmCountsGetError { - UnknownValue(serde_json::Value), +pub struct CountsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`service_accounts_service_account_id_sm_counts_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ServiceAccountsServiceAccountIdSmCountsGetError { - UnknownValue(serde_json::Value), +impl CountsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl CountsApiClient { + pub async fn organizations_organization_id_sm_counts_get( + &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!( + "{}/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_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)) } - } else { - 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`")))), + pub async fn projects_project_id_sm_counts_get( + &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_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)) } - } else { - 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`")))), + pub async fn service_accounts_service_account_id_sm_counts_get( + &self, + service_account_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/{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_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)) } - } 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 7a4025256..f734cfdd9 100644 --- a/crates/bitwarden-api-api/src/apis/devices_api.rs +++ b/crates/bitwarden-api-api/src/apis/devices_api.rs @@ -8,1176 +8,1102 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DevicesIdDeactivatePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DevicesIdGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DevicesIdentifierIdentifierClearTokenPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DevicesIdentifierIdentifierWebPushAuthPutError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DevicesKnowndeviceEmailIdentifierGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DevicesLostTrustPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`devices_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DevicesPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait DevicesApi: Send + Sync { + + /// GET /devices + /// + /// + async fn devices_get(&self, ) -> Result; + + /// POST /devices/{id}/deactivate + /// + /// + async fn devices_id_deactivate_post(&self, id: &str) -> Result<(), Error>; + + /// DELETE /devices/{id} + /// + /// + async fn devices_id_delete(&self, id: &str) -> Result<(), Error>; + + /// GET /devices/{id} + /// + /// + async fn devices_id_get(&self, id: &str) -> Result; + + /// POST /devices/{id} + /// + /// + async fn devices_id_post(&self, id: &str, device_request_model: Option) -> Result; + + /// PUT /devices/{id} + /// + /// + async fn devices_id_put(&self, id: &str, device_request_model: Option) -> Result; + + /// POST /devices/identifier/{identifier}/clear-token + /// + /// + async fn devices_identifier_identifier_clear_token_post(&self, identifier: &str) -> Result<(), Error>; + + /// PUT /devices/identifier/{identifier}/clear-token + /// + /// + async fn devices_identifier_identifier_clear_token_put(&self, identifier: &str) -> Result<(), Error>; + + /// GET /devices/identifier/{identifier} + /// + /// + async fn devices_identifier_identifier_get(&self, identifier: &str) -> Result; + + /// POST /devices/identifier/{identifier}/token + /// + /// + async fn devices_identifier_identifier_token_post(&self, identifier: &str, device_token_request_model: Option) -> Result<(), Error>; + + /// PUT /devices/identifier/{identifier}/token + /// + /// + async fn devices_identifier_identifier_token_put(&self, identifier: &str, device_token_request_model: Option) -> Result<(), Error>; + + /// POST /devices/identifier/{identifier}/web-push-auth + /// + /// + async fn devices_identifier_identifier_web_push_auth_post(&self, identifier: &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(&self, identifier: &str, web_push_auth_request_model: Option) -> Result<(), Error>; + + /// POST /devices/{identifier}/keys + /// + /// + async fn devices_identifier_keys_post(&self, identifier: &str, device_keys_request_model: Option) -> Result; + + /// PUT /devices/{identifier}/keys + /// + /// + async fn devices_identifier_keys_put(&self, identifier: &str, device_keys_request_model: Option) -> Result; + + /// POST /devices/{identifier}/retrieve-keys + /// + /// + async fn devices_identifier_retrieve_keys_post(&self, identifier: &str) -> Result; + + /// GET /devices/knowndevice/{email}/{identifier} + /// + /// + async fn devices_knowndevice_email_identifier_get(&self, email: &str, identifier: &str) -> Result; + + /// GET /devices/knowndevice + /// + /// + async fn devices_knowndevice_get(&self, x_request_email: &str, x_device_identifier: &str) -> Result; + + /// POST /devices/lost-trust + /// + /// + async fn devices_lost_trust_post(&self, ) -> Result<(), Error>; + + /// POST /devices + /// + /// + async fn devices_post(&self, device_request_model: Option) -> Result; + + /// POST /devices/untrust + /// + /// + async fn devices_untrust_post(&self, untrust_devices_request_model: Option) -> Result<(), Error>; + + /// POST /devices/update-trust + /// + /// + async fn devices_update_trust_post(&self, update_devices_trust_request_model: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`devices_untrust_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DevicesUntrustPostError { - UnknownValue(serde_json::Value), +pub struct DevicesApiClient { + configuration: Arc, } -/// struct for typed errors of method [`devices_update_trust_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DevicesUpdateTrustPostError { - UnknownValue(serde_json::Value), +impl DevicesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl DevicesApiClient { + pub async fn devices_get( + &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_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)) } - } else { - 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_deactivate_post(&self, id: &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_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 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_delete(&self, id: &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_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 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`")))), + pub async fn devices_id_get(&self, id: &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_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)) } - } else { - 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`")))), + pub async fn devices_id_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn devices_id_put( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_post( + &self, + identifier: &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_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 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_clear_token_put( + &self, + identifier: &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_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 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`")))), + pub async fn devices_identifier_identifier_get( + &self, + identifier: &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_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)) } - } else { - 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_post( + &self, + identifier: &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_token_put( + &self, + identifier: &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_post( + &self, + identifier: &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_identifier_web_push_auth_put( + &self, + identifier: &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn devices_identifier_keys_post( + &self, + identifier: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn devices_identifier_keys_put( + &self, + identifier: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_identifier = identifier; - - 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()); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(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`")))), + pub async fn devices_identifier_retrieve_keys_post( + &self, + identifier: &str, + ) -> 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_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::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)) } - } else { - 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`")))), + pub async fn devices_knowndevice_email_identifier_get( + &self, + email: &str, + identifier: &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_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)) } - } else { - 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`")))), + pub async fn devices_knowndevice_get( + &self, + x_request_email: &str, + x_device_identifier: &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()); + + 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)) } - } else { - 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_lost_trust_post(&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_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 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`")))), + pub async fn devices_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_untrust_post( - configuration: &configuration::Configuration, - untrust_devices_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_untrust_devices_request_model = untrust_devices_request_model; - - let uri_str = format!("{}/devices/untrust", 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_untrust_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, - })) + pub async fn devices_untrust_post( + &self, + untrust_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!("{}/devices/untrust", 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_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&untrust_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 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, - })) + pub async fn devices_update_trust_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } } 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..fb2c85208 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,937 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum EmergencyAccessIdConfirmPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum EmergencyAccessIdDeletePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum EmergencyAccessIdPoliciesGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum EmergencyAccessIdViewPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[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`")))), +/* +#[async_trait] +pub trait EmergencyAccessApi: Send + Sync { + + /// GET /emergency-access/granted + /// + /// + async fn emergency_access_granted_get(&self, ) -> Result; + + /// POST /emergency-access/{id}/accept + /// + /// + async fn emergency_access_id_accept_post(&self, id: uuid::Uuid, organization_user_accept_request_model: Option) -> Result<(), Error>; + + /// POST /emergency-access/{id}/approve + /// + /// + async fn emergency_access_id_approve_post(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// GET /emergency-access/{id}/{cipherId}/attachment/{attachmentId} + /// + /// + async fn emergency_access_id_cipher_id_attachment_attachment_id_get(&self, id: uuid::Uuid, cipher_id: uuid::Uuid, attachment_id: &str) -> Result; + + /// POST /emergency-access/{id}/confirm + /// + /// + async fn emergency_access_id_confirm_post(&self, id: uuid::Uuid, organization_user_confirm_request_model: Option) -> Result<(), Error>; + + /// DELETE /emergency-access/{id} + /// + /// + async fn emergency_access_id_delete(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /emergency-access/{id}/delete + /// + /// + async fn emergency_access_id_delete_post(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// GET /emergency-access/{id} + /// + /// + async fn emergency_access_id_get(&self, id: uuid::Uuid) -> Result; + + /// POST /emergency-access/{id}/initiate + /// + /// + async fn emergency_access_id_initiate_post(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /emergency-access/{id}/password + /// + /// + async fn emergency_access_id_password_post(&self, id: uuid::Uuid, emergency_access_password_request_model: Option) -> Result<(), Error>; + + /// GET /emergency-access/{id}/policies + /// + /// + async fn emergency_access_id_policies_get(&self, id: uuid::Uuid) -> Result; + + /// POST /emergency-access/{id} + /// + /// + async fn emergency_access_id_post(&self, id: uuid::Uuid, emergency_access_update_request_model: Option) -> Result<(), Error>; + + /// PUT /emergency-access/{id} + /// + /// + async fn emergency_access_id_put(&self, id: uuid::Uuid, emergency_access_update_request_model: Option) -> Result<(), Error>; + + /// POST /emergency-access/{id}/reinvite + /// + /// + async fn emergency_access_id_reinvite_post(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /emergency-access/{id}/reject + /// + /// + async fn emergency_access_id_reject_post(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /emergency-access/{id}/takeover + /// + /// + async fn emergency_access_id_takeover_post(&self, id: uuid::Uuid) -> Result; + + /// POST /emergency-access/{id}/view + /// + /// + async fn emergency_access_id_view_post(&self, id: uuid::Uuid) -> Result; + + /// POST /emergency-access/invite + /// + /// + async fn emergency_access_invite_post(&self, emergency_access_invite_request_model: Option) -> Result<(), Error>; + + /// GET /emergency-access/trusted + /// + /// + async fn emergency_access_trusted_get(&self, ) -> Result; +} +*/ + +pub struct EmergencyAccessApiClient { + configuration: Arc, +} + +impl EmergencyAccessApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +// #[async_trait] +impl EmergencyAccessApiClient { + pub async fn emergency_access_granted_get( + &self, + ) -> Result { + 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_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)) } - } else { - 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_accept_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_approve_post(&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_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 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`")))), + pub async fn emergency_access_id_cipher_id_attachment_attachment_id_get( + &self, + id: uuid::Uuid, + cipher_id: uuid::Uuid, + attachment_id: &str, + ) -> Result { + 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_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)) } - } else { - 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_confirm_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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(&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_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 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_delete_post(&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_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 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`")))), + pub async fn emergency_access_id_get( + &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_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)) } - } else { - 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_initiate_post(&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_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 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_password_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn emergency_access_id_policies_get( + &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}/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_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)) } - } else { - 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_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_reinvite_post(&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_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 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_reject_post(&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_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 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`")))), + pub async fn emergency_access_id_takeover_post( + &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}/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_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)) } - } else { - 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`")))), + pub async fn emergency_access_id_view_post( + &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_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)) } - } else { - 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_invite_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn emergency_access_trusted_get( + &self, + ) -> Result { + 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_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)) } - } 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..26f5e1534 100644 --- a/crates/bitwarden-api-api/src/apis/events_api.rs +++ b/crates/bitwarden-api-api/src/apis/events_api.rs @@ -8,448 +8,446 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum EventsGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`organizations_id_events_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdEventsGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`organizations_org_id_users_id_events_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersIdEventsGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait EventsApi: Send + Sync { + + /// GET /ciphers/{id}/events + /// + /// + async fn ciphers_id_events_get(&self, id: &str, start: Option, end: Option, continuation_token: Option<&str>) -> Result; + + /// GET /events + /// + /// + async fn events_get(&self, start: Option, end: Option, continuation_token: Option<&str>) -> Result; + + /// GET /organizations/{id}/events + /// + /// + async fn organizations_id_events_get(&self, id: &str, start: Option, end: Option, continuation_token: Option<&str>) -> Result; + + /// GET /organizations/{orgId}/users/{id}/events + /// + /// + async fn organizations_org_id_users_id_events_get(&self, org_id: &str, id: &str, start: Option, end: Option, continuation_token: Option<&str>) -> Result; + + /// GET /providers/{providerId}/events + /// + /// + async fn providers_provider_id_events_get(&self, provider_id: uuid::Uuid, start: Option, end: Option, continuation_token: Option<&str>) -> Result; + + /// GET /providers/{providerId}/users/{id}/events + /// + /// + async fn providers_provider_id_users_id_events_get(&self, provider_id: uuid::Uuid, id: uuid::Uuid, start: Option, end: Option, continuation_token: Option<&str>) -> Result; } +*/ -/// struct for typed errors of method [`providers_provider_id_events_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdEventsGetError { - UnknownValue(serde_json::Value), +pub struct EventsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`providers_provider_id_users_id_events_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdUsersIdEventsGetError { - UnknownValue(serde_json::Value), +impl EventsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl EventsApiClient { + pub async fn ciphers_id_events_get( + &self, + id: &str, + start: Option, + end: Option, + continuation_token: Option<&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_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, - })) } -} -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`")))), + pub async fn events_get( + &self, + start: Option, + end: Option, + continuation_token: Option<&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()); + + 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_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, - })) } -} -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`")))), + pub async fn organizations_id_events_get( + &self, + id: &str, + start: Option, + end: Option, + continuation_token: Option<&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_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, - })) } -} -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`")))), + pub async fn organizations_org_id_users_id_events_get( + &self, + org_id: &str, + id: &str, + start: Option, + end: Option, + continuation_token: Option<&str>, + ) -> Result { + 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_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, - })) } -} -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`")))), + pub async fn providers_provider_id_events_get( + &self, + provider_id: uuid::Uuid, + start: Option, + end: Option, + continuation_token: Option<&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_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, - })) } -} -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`")))), + pub async fn providers_provider_id_users_id_events_get( + &self, + provider_id: uuid::Uuid, + id: uuid::Uuid, + start: Option, + end: Option, + continuation_token: Option<&str>, + ) -> 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}/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_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, - })) } } diff --git a/crates/bitwarden-api-api/src/apis/folders_api.rs b/crates/bitwarden-api-api/src/apis/folders_api.rs index e48e0f34c..ede3b8f73 100644 --- a/crates/bitwarden-api-api/src/apis/folders_api.rs +++ b/crates/bitwarden-api-api/src/apis/folders_api.rs @@ -8,428 +8,413 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum FoldersGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum FoldersIdDeletePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`folders_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum FoldersIdGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum FoldersIdPutError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait FoldersApi: Send + Sync { + + /// DELETE /folders/all + /// + /// + async fn folders_all_delete(&self, ) -> Result<(), Error>; + + /// GET /folders + /// + /// + async fn folders_get(&self, ) -> Result; + + /// DELETE /folders/{id} + /// + /// + async fn folders_id_delete(&self, id: &str) -> Result<(), Error>; + + /// POST /folders/{id}/delete + /// + /// + async fn folders_id_delete_post(&self, id: &str) -> Result<(), Error>; + + /// GET /folders/{id} + /// + /// + async fn folders_id_get(&self, id: &str) -> Result; + + /// POST /folders/{id} + /// + /// + async fn folders_id_post(&self, id: &str, folder_request_model: Option) -> Result; + + /// PUT /folders/{id} + /// + /// + async fn folders_id_put(&self, id: &str, folder_request_model: Option) -> Result; + + /// POST /folders + /// + /// + async fn folders_post(&self, folder_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`folders_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum FoldersPostError { - UnknownValue(serde_json::Value), +pub struct FoldersApiClient { + configuration: Arc, } -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, - })) +impl FoldersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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`")))), +// #[async_trait] +impl FoldersApiClient { + pub async fn folders_all_delete(&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_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 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_get(&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_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)) + } } -} -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_delete(&self, id: &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_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 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`")))), + pub async fn folders_id_delete_post(&self, id: &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_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 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`")))), + pub async fn folders_id_get(&self, id: &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_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)) } - } else { - 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`")))), + pub async fn folders_id_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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()); + pub async fn folders_id_put( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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`")))), + + pub async fn folders_post( + &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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..ce30f4a35 100644 --- a/crates/bitwarden-api-api/src/apis/groups_api.rs +++ b/crates/bitwarden-api-api/src/apis/groups_api.rs @@ -8,820 +8,761 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdGroupsIdDeletePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`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), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdGroupsIdUsersGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait GroupsApi: Send + Sync { + + /// DELETE /organizations/{orgId}/groups + /// + /// + async fn organizations_org_id_groups_delete(&self, org_id: &str, group_bulk_request_model: Option) -> Result<(), Error>; + + /// POST /organizations/{orgId}/groups/delete + /// + /// + async fn organizations_org_id_groups_delete_post(&self, org_id: &str, group_bulk_request_model: Option) -> Result<(), Error>; + + /// GET /organizations/{orgId}/groups/details + /// + /// + async fn organizations_org_id_groups_details_get(&self, org_id: uuid::Uuid) -> Result; + + /// GET /organizations/{orgId}/groups + /// + /// + async fn organizations_org_id_groups_get(&self, org_id: uuid::Uuid) -> Result; + + /// DELETE /organizations/{orgId}/groups/{id} + /// + /// + async fn organizations_org_id_groups_id_delete(&self, org_id: &str, id: &str) -> Result<(), Error>; + + /// POST /organizations/{orgId}/groups/{id}/delete + /// + /// + async fn organizations_org_id_groups_id_delete_post(&self, org_id: &str, id: &str) -> Result<(), Error>; + + /// POST /organizations/{orgId}/groups/{id}/delete-user/{orgUserId} + /// + /// + async fn organizations_org_id_groups_id_delete_user_org_user_id_post(&self, org_id: &str, id: &str, org_user_id: &str) -> Result<(), Error>; + + /// GET /organizations/{orgId}/groups/{id}/details + /// + /// + async fn organizations_org_id_groups_id_details_get(&self, org_id: &str, id: &str) -> Result; + + /// GET /organizations/{orgId}/groups/{id} + /// + /// + async fn organizations_org_id_groups_id_get(&self, org_id: &str, id: &str) -> Result; + + /// POST /organizations/{orgId}/groups/{id} + /// + /// + async fn organizations_org_id_groups_id_post(&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(&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(&self, org_id: &str, id: &str, org_user_id: &str) -> Result<(), Error>; + + /// GET /organizations/{orgId}/groups/{id}/users + /// + /// + async fn organizations_org_id_groups_id_users_get(&self, org_id: &str, id: &str) -> Result, Error>; + + /// POST /organizations/{orgId}/groups + /// + /// + async fn organizations_org_id_groups_post(&self, org_id: uuid::Uuid, group_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`organizations_org_id_groups_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdGroupsPostError { - UnknownValue(serde_json::Value), +pub struct GroupsApiClient { + configuration: Arc, } -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, - })) +impl GroupsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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, - })) +// #[async_trait] +impl GroupsApiClient { + pub async fn organizations_org_id_groups_delete( + &self, + org_id: &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn organizations_org_id_groups_delete_post( + &self, + org_id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_groups_details_get( + &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/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_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)) } - } else { - 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_get( + &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_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)) + } } -} -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( + &self, + org_id: &str, + id: &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_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 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_delete_post( + &self, + org_id: &str, + id: &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_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 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`")))), + pub async fn organizations_org_id_groups_id_delete_user_org_user_id_post( + &self, + org_id: &str, + id: &str, + org_user_id: &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_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 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`")))), + pub async fn organizations_org_id_groups_id_details_get( + &self, + org_id: &str, + id: &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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_groups_id_get( + &self, + org_id: &str, + id: &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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_groups_id_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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>`")))), + pub async fn organizations_org_id_groups_id_user_org_user_id_delete( + &self, + org_id: &str, + id: &str, + org_user_id: &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_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 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()); + pub async fn organizations_org_id_groups_id_users_get( + &self, + org_id: &str, + id: &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_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)) + } } - 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`")))), + + pub async fn organizations_org_id_groups_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..032979740 100644 --- a/crates/bitwarden-api-api/src/apis/hibp_api.rs +++ b/crates/bitwarden-api-api/src/apis/hibp_api.rs @@ -8,53 +8,74 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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), -} +/* +#[async_trait] +pub trait HibpApi: Send + Sync { -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; + /// GET /hibp/breach + /// + /// + async fn hibp_breach_get(&self, username: Option<&str>) -> Result<(), Error>; +} +*/ - 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] +impl HibpApiClient { + pub async fn hibp_breach_get(&self, username: Option<&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_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)) + } } } 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..a7841ab58 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,126 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`ciphers_import_organization_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersImportOrganizationPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait ImportCiphersApi: Send + Sync { + + /// POST /ciphers/import-organization + /// + /// + async fn ciphers_import_organization_post(&self, organization_id: Option<&str>, import_organization_ciphers_request_model: Option) -> Result<(), Error>; + + /// POST /ciphers/import + /// + /// + async fn ciphers_import_post(&self, import_ciphers_request_model: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`ciphers_import_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersImportPostError { - UnknownValue(serde_json::Value), +pub struct ImportCiphersApiClient { + configuration: Arc, } -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, - })) +impl ImportCiphersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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()); +// #[async_trait] +impl ImportCiphersApiClient { + pub async fn ciphers_import_organization_post( + &self, + organization_id: Option<&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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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, - })) + + pub async fn ciphers_import_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/info_api.rs b/crates/bitwarden-api-api/src/apis/info_api.rs index c3511a58e..420fee7f9 100644 --- a/crates/bitwarden-api-api/src/apis/info_api.rs +++ b/crates/bitwarden-api-api/src/apis/info_api.rs @@ -8,144 +8,164 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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), +/* +#[async_trait] +pub trait InfoApi: Send + Sync { + + /// GET /alive + /// + /// + async fn alive_get(&self, ) -> Result; + + /// GET /now + /// + /// + async fn now_get(&self, ) -> Result; + + /// GET /version + /// + /// + async fn version_get(&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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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`")))), +// #[async_trait] +impl InfoApiClient { + pub async fn alive_get(&self) -> Result { + let local_var_configuration = &self.configuration; + + 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_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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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`")))), + pub async fn now_get(&self) -> Result { + let local_var_configuration = &self.configuration; + + 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_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 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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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 version_get(&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_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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/installations_api.rs b/crates/bitwarden-api-api/src/apis/installations_api.rs index 38d362f42..c0cb58911 100644 --- a/crates/bitwarden-api-api/src/apis/installations_api.rs +++ b/crates/bitwarden-api-api/src/apis/installations_api.rs @@ -8,121 +8,138 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`installations_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum InstallationsIdGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait InstallationsApi: Send + Sync { + + /// GET /installations/{id} + /// + /// + async fn installations_id_get(&self, id: uuid::Uuid) -> Result; + + /// POST /installations + /// + /// + async fn installations_post(&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()); - } - 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`")))), - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) +impl InstallationsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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; - - let uri_str = format!("{}/installations", 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()); +// #[async_trait] +impl InstallationsApiClient { + pub async fn installations_id_get( + &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_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)) + } } - 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`")))), + + pub async fn installations_post( + &self, + installation_request_model: Option, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_token) = local_var_configuration.oauth_access_token { + 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, - })) } } diff --git a/crates/bitwarden-api-api/src/apis/invoices_api.rs b/crates/bitwarden-api-api/src/apis/invoices_api.rs index 30742faf8..3d048dc43 100644 --- a/crates/bitwarden-api-api/src/apis/invoices_api.rs +++ b/crates/bitwarden-api-api/src/apis/invoices_api.rs @@ -8,56 +8,80 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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, +}; + +/* +#[async_trait] +pub trait InvoicesApi: Send + Sync { + + /// POST /invoices/preview-organization + /// + /// + async fn invoices_preview_organization_post(&self, preview_organization_invoice_request_body: Option) -> Result<(), Error>; +} +*/ -/// struct for typed errors of method [`invoices_preview_organization_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum InvoicesPreviewOrganizationPostError { - UnknownValue(serde_json::Value), +pub struct InvoicesApiClient { + configuration: Arc, } -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()); +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] +impl InvoicesApiClient { + pub async fn invoices_preview_organization_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/licenses_api.rs b/crates/bitwarden-api-api/src/apis/licenses_api.rs index c6018738d..cf2963d08 100644 --- a/crates/bitwarden-api-api/src/apis/licenses_api.rs +++ b/crates/bitwarden-api-api/src/apis/licenses_api.rs @@ -8,133 +8,151 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`licenses_organization_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum LicensesOrganizationIdGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait LicensesApi: Send + Sync { + + /// GET /licenses/organization/{id} + /// + /// + async fn licenses_organization_id_get(&self, id: &str, self_hosted_organization_license_request_model: Option) -> Result; + + /// GET /licenses/user/{id} + /// + /// + async fn licenses_user_id_get(&self, id: &str, key: Option<&str>) -> Result; } +*/ -/// struct for typed errors of method [`licenses_user_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum LicensesUserIdGetError { - UnknownValue(serde_json::Value), +pub struct LicensesApiClient { + configuration: Arc, } -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, - })) +impl LicensesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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()); +// #[async_trait] +impl LicensesApiClient { + pub async fn licenses_organization_id_get( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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`")))), + + pub async fn licenses_user_id_get( + &self, + id: &str, + key: Option<&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_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)) } - } 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..54c882a7c 100644 --- a/crates/bitwarden-api-api/src/apis/misc_api.rs +++ b/crates/bitwarden-api-api/src/apis/misc_api.rs @@ -8,115 +8,131 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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, +}; + +/* +#[async_trait] +pub trait MiscApi: Send + Sync { -/// struct for typed errors of method [`bitpay_invoice_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum BitpayInvoicePostError { - UnknownValue(serde_json::Value), + /// POST /bitpay-invoice + /// + /// + async fn bitpay_invoice_post(&self, bit_pay_invoice_request_model: Option) -> Result; + + /// POST /setup-payment + /// + /// + async fn setup_payment_post(&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] +impl MiscApiClient { + pub async fn bitpay_invoice_post( + &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_token) = local_var_configuration.oauth_access_token { + 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?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.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 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); + pub async fn setup_payment_post(&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!("{}/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_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, - })) } } diff --git a/crates/bitwarden-api-api/src/apis/mod.rs b/crates/bitwarden-api-api/src/apis/mod.rs index 66d0f0cdb..d82885488 100644 --- a/crates/bitwarden-api-api/src/apis/mod.rs +++ b/crates/bitwarden-api-api/src/apis/mod.rs @@ -1,21 +1,21 @@ use std::{error, fmt}; #[derive(Debug, Clone)] -pub struct ResponseContent { +pub struct ResponseContent { pub status: reqwest::StatusCode, pub content: String, - pub entity: Option, + pub entity: Option, } #[derive(Debug)] -pub enum Error { +pub enum Error { Reqwest(reqwest::Error), Serde(serde_json::Error), Io(std::io::Error), - ResponseError(ResponseContent), + ResponseError(ResponseContent), } -impl fmt::Display for Error { +impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (module, e) = match self { Error::Reqwest(e) => ("reqwest", e.to_string()), @@ -27,7 +27,7 @@ impl fmt::Display for Error { } } -impl error::Error for Error { +impl error::Error for Error { fn source(&self) -> Option<&(dyn error::Error + 'static)> { Some(match self { Error::Reqwest(e) => e, @@ -38,19 +38,19 @@ impl error::Error for Error { } } -impl From for Error { +impl From for Error { fn from(e: reqwest::Error) -> Self { Error::Reqwest(e) } } -impl From for Error { +impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Serde(e) } } -impl From for Error { +impl From for Error { fn from(e: std::io::Error) -> Self { Error::Io(e) } @@ -178,3 +178,375 @@ pub mod users_api; pub mod web_authn_api; pub mod configuration; + +use std::sync::Arc; + +pub struct ApiClient { + access_policies_api: access_policies_api::AccessPoliciesApiClient, + account_billing_v_next_api: account_billing_v_next_api::AccountBillingVNextApiClient, + accounts_api: accounts_api::AccountsApiClient, + accounts_billing_api: accounts_billing_api::AccountsBillingApiClient, + accounts_key_management_api: accounts_key_management_api::AccountsKeyManagementApiClient, + auth_requests_api: auth_requests_api::AuthRequestsApiClient, + ciphers_api: ciphers_api::CiphersApiClient, + collections_api: collections_api::CollectionsApiClient, + config_api: config_api::ConfigApiClient, + counts_api: counts_api::CountsApiClient, + devices_api: devices_api::DevicesApiClient, + emergency_access_api: emergency_access_api::EmergencyAccessApiClient, + events_api: events_api::EventsApiClient, + folders_api: folders_api::FoldersApiClient, + groups_api: groups_api::GroupsApiClient, + hibp_api: hibp_api::HibpApiClient, + import_ciphers_api: import_ciphers_api::ImportCiphersApiClient, + info_api: info_api::InfoApiClient, + installations_api: installations_api::InstallationsApiClient, + invoices_api: invoices_api::InvoicesApiClient, + licenses_api: licenses_api::LicensesApiClient, + misc_api: misc_api::MiscApiClient, + notifications_api: notifications_api::NotificationsApiClient, + organization_auth_requests_api: + organization_auth_requests_api::OrganizationAuthRequestsApiClient, + organization_billing_api: organization_billing_api::OrganizationBillingApiClient, + organization_billing_v_next_api: + organization_billing_v_next_api::OrganizationBillingVNextApiClient, + organization_connections_api: organization_connections_api::OrganizationConnectionsApiClient, + organization_domain_api: organization_domain_api::OrganizationDomainApiClient, + organization_export_api: organization_export_api::OrganizationExportApiClient, + organization_integration_api: organization_integration_api::OrganizationIntegrationApiClient, + organization_integration_configuration_api: + organization_integration_configuration_api::OrganizationIntegrationConfigurationApiClient, + organization_sponsorships_api: organization_sponsorships_api::OrganizationSponsorshipsApiClient, + organization_users_api: organization_users_api::OrganizationUsersApiClient, + organizations_api: organizations_api::OrganizationsApiClient, + phishing_domains_api: phishing_domains_api::PhishingDomainsApiClient, + plans_api: plans_api::PlansApiClient, + policies_api: policies_api::PoliciesApiClient, + projects_api: projects_api::ProjectsApiClient, + provider_billing_api: provider_billing_api::ProviderBillingApiClient, + provider_billing_v_next_api: provider_billing_v_next_api::ProviderBillingVNextApiClient, + provider_clients_api: provider_clients_api::ProviderClientsApiClient, + provider_organizations_api: provider_organizations_api::ProviderOrganizationsApiClient, + provider_users_api: provider_users_api::ProviderUsersApiClient, + providers_api: providers_api::ProvidersApiClient, + push_api: push_api::PushApiClient, + reports_api: reports_api::ReportsApiClient, + request_sm_access_api: request_sm_access_api::RequestSmAccessApiClient, + secrets_api: secrets_api::SecretsApiClient, + secrets_manager_events_api: secrets_manager_events_api::SecretsManagerEventsApiClient, + secrets_manager_porting_api: secrets_manager_porting_api::SecretsManagerPortingApiClient, + security_task_api: security_task_api::SecurityTaskApiClient, + self_hosted_organization_licenses_api: + self_hosted_organization_licenses_api::SelfHostedOrganizationLicensesApiClient, + self_hosted_organization_sponsorships_api: + self_hosted_organization_sponsorships_api::SelfHostedOrganizationSponsorshipsApiClient, + sends_api: sends_api::SendsApiClient, + service_accounts_api: service_accounts_api::ServiceAccountsApiClient, + settings_api: settings_api::SettingsApiClient, + slack_integration_api: slack_integration_api::SlackIntegrationApiClient, + stripe_api: stripe_api::StripeApiClient, + sync_api: sync_api::SyncApiClient, + tax_api: tax_api::TaxApiClient, + trash_api: trash_api::TrashApiClient, + two_factor_api: two_factor_api::TwoFactorApiClient, + users_api: users_api::UsersApiClient, + web_authn_api: web_authn_api::WebAuthnApiClient, +} + +impl ApiClient { + pub fn new(configuration: Arc) -> Self { + Self { + access_policies_api: access_policies_api::AccessPoliciesApiClient::new(configuration.clone()), + account_billing_v_next_api: account_billing_v_next_api::AccountBillingVNextApiClient::new(configuration.clone()), + accounts_api: accounts_api::AccountsApiClient::new(configuration.clone()), + accounts_billing_api: accounts_billing_api::AccountsBillingApiClient::new(configuration.clone()), + accounts_key_management_api: accounts_key_management_api::AccountsKeyManagementApiClient::new(configuration.clone()), + auth_requests_api: auth_requests_api::AuthRequestsApiClient::new(configuration.clone()), + ciphers_api: ciphers_api::CiphersApiClient::new(configuration.clone()), + collections_api: collections_api::CollectionsApiClient::new(configuration.clone()), + config_api: config_api::ConfigApiClient::new(configuration.clone()), + counts_api: counts_api::CountsApiClient::new(configuration.clone()), + devices_api: devices_api::DevicesApiClient::new(configuration.clone()), + emergency_access_api: emergency_access_api::EmergencyAccessApiClient::new(configuration.clone()), + events_api: events_api::EventsApiClient::new(configuration.clone()), + folders_api: folders_api::FoldersApiClient::new(configuration.clone()), + groups_api: groups_api::GroupsApiClient::new(configuration.clone()), + hibp_api: hibp_api::HibpApiClient::new(configuration.clone()), + import_ciphers_api: import_ciphers_api::ImportCiphersApiClient::new(configuration.clone()), + info_api: info_api::InfoApiClient::new(configuration.clone()), + installations_api: installations_api::InstallationsApiClient::new(configuration.clone()), + invoices_api: invoices_api::InvoicesApiClient::new(configuration.clone()), + licenses_api: licenses_api::LicensesApiClient::new(configuration.clone()), + misc_api: misc_api::MiscApiClient::new(configuration.clone()), + notifications_api: notifications_api::NotificationsApiClient::new(configuration.clone()), + organization_auth_requests_api: organization_auth_requests_api::OrganizationAuthRequestsApiClient::new(configuration.clone()), + organization_billing_api: organization_billing_api::OrganizationBillingApiClient::new(configuration.clone()), + organization_billing_v_next_api: organization_billing_v_next_api::OrganizationBillingVNextApiClient::new(configuration.clone()), + organization_connections_api: organization_connections_api::OrganizationConnectionsApiClient::new(configuration.clone()), + organization_domain_api: organization_domain_api::OrganizationDomainApiClient::new(configuration.clone()), + organization_export_api: organization_export_api::OrganizationExportApiClient::new(configuration.clone()), + organization_integration_api: organization_integration_api::OrganizationIntegrationApiClient::new(configuration.clone()), + organization_integration_configuration_api: organization_integration_configuration_api::OrganizationIntegrationConfigurationApiClient::new(configuration.clone()), + organization_sponsorships_api: organization_sponsorships_api::OrganizationSponsorshipsApiClient::new(configuration.clone()), + organization_users_api: organization_users_api::OrganizationUsersApiClient::new(configuration.clone()), + organizations_api: organizations_api::OrganizationsApiClient::new(configuration.clone()), + phishing_domains_api: phishing_domains_api::PhishingDomainsApiClient::new(configuration.clone()), + plans_api: plans_api::PlansApiClient::new(configuration.clone()), + policies_api: policies_api::PoliciesApiClient::new(configuration.clone()), + projects_api: projects_api::ProjectsApiClient::new(configuration.clone()), + provider_billing_api: provider_billing_api::ProviderBillingApiClient::new(configuration.clone()), + provider_billing_v_next_api: provider_billing_v_next_api::ProviderBillingVNextApiClient::new(configuration.clone()), + provider_clients_api: provider_clients_api::ProviderClientsApiClient::new(configuration.clone()), + provider_organizations_api: provider_organizations_api::ProviderOrganizationsApiClient::new(configuration.clone()), + provider_users_api: provider_users_api::ProviderUsersApiClient::new(configuration.clone()), + providers_api: providers_api::ProvidersApiClient::new(configuration.clone()), + push_api: push_api::PushApiClient::new(configuration.clone()), + reports_api: reports_api::ReportsApiClient::new(configuration.clone()), + request_sm_access_api: request_sm_access_api::RequestSmAccessApiClient::new(configuration.clone()), + secrets_api: secrets_api::SecretsApiClient::new(configuration.clone()), + secrets_manager_events_api: secrets_manager_events_api::SecretsManagerEventsApiClient::new(configuration.clone()), + secrets_manager_porting_api: secrets_manager_porting_api::SecretsManagerPortingApiClient::new(configuration.clone()), + security_task_api: security_task_api::SecurityTaskApiClient::new(configuration.clone()), + self_hosted_organization_licenses_api: self_hosted_organization_licenses_api::SelfHostedOrganizationLicensesApiClient::new(configuration.clone()), + self_hosted_organization_sponsorships_api: self_hosted_organization_sponsorships_api::SelfHostedOrganizationSponsorshipsApiClient::new(configuration.clone()), + sends_api: sends_api::SendsApiClient::new(configuration.clone()), + service_accounts_api: service_accounts_api::ServiceAccountsApiClient::new(configuration.clone()), + settings_api: settings_api::SettingsApiClient::new(configuration.clone()), + slack_integration_api: slack_integration_api::SlackIntegrationApiClient::new(configuration.clone()), + stripe_api: stripe_api::StripeApiClient::new(configuration.clone()), + sync_api: sync_api::SyncApiClient::new(configuration.clone()), + tax_api: tax_api::TaxApiClient::new(configuration.clone()), + trash_api: trash_api::TrashApiClient::new(configuration.clone()), + two_factor_api: two_factor_api::TwoFactorApiClient::new(configuration.clone()), + users_api: users_api::UsersApiClient::new(configuration.clone()), + web_authn_api: web_authn_api::WebAuthnApiClient::new(configuration.clone()), + } + } +} + +impl ApiClient { + pub fn access_policies_api(&self) -> &access_policies_api::AccessPoliciesApiClient { + &self.access_policies_api + } + pub fn account_billing_v_next_api( + &self, + ) -> &account_billing_v_next_api::AccountBillingVNextApiClient { + &self.account_billing_v_next_api + } + pub fn accounts_api(&self) -> &accounts_api::AccountsApiClient { + &self.accounts_api + } + pub fn accounts_billing_api(&self) -> &accounts_billing_api::AccountsBillingApiClient { + &self.accounts_billing_api + } + pub fn accounts_key_management_api( + &self, + ) -> &accounts_key_management_api::AccountsKeyManagementApiClient { + &self.accounts_key_management_api + } + pub fn auth_requests_api(&self) -> &auth_requests_api::AuthRequestsApiClient { + &self.auth_requests_api + } + pub fn ciphers_api(&self) -> &ciphers_api::CiphersApiClient { + &self.ciphers_api + } + pub fn collections_api(&self) -> &collections_api::CollectionsApiClient { + &self.collections_api + } + pub fn config_api(&self) -> &config_api::ConfigApiClient { + &self.config_api + } + pub fn counts_api(&self) -> &counts_api::CountsApiClient { + &self.counts_api + } + pub fn devices_api(&self) -> &devices_api::DevicesApiClient { + &self.devices_api + } + pub fn emergency_access_api(&self) -> &emergency_access_api::EmergencyAccessApiClient { + &self.emergency_access_api + } + pub fn events_api(&self) -> &events_api::EventsApiClient { + &self.events_api + } + pub fn folders_api(&self) -> &folders_api::FoldersApiClient { + &self.folders_api + } + pub fn groups_api(&self) -> &groups_api::GroupsApiClient { + &self.groups_api + } + pub fn hibp_api(&self) -> &hibp_api::HibpApiClient { + &self.hibp_api + } + pub fn import_ciphers_api(&self) -> &import_ciphers_api::ImportCiphersApiClient { + &self.import_ciphers_api + } + pub fn info_api(&self) -> &info_api::InfoApiClient { + &self.info_api + } + pub fn installations_api(&self) -> &installations_api::InstallationsApiClient { + &self.installations_api + } + pub fn invoices_api(&self) -> &invoices_api::InvoicesApiClient { + &self.invoices_api + } + pub fn licenses_api(&self) -> &licenses_api::LicensesApiClient { + &self.licenses_api + } + pub fn misc_api(&self) -> &misc_api::MiscApiClient { + &self.misc_api + } + pub fn notifications_api(&self) -> ¬ifications_api::NotificationsApiClient { + &self.notifications_api + } + pub fn organization_auth_requests_api( + &self, + ) -> &organization_auth_requests_api::OrganizationAuthRequestsApiClient { + &self.organization_auth_requests_api + } + pub fn organization_billing_api( + &self, + ) -> &organization_billing_api::OrganizationBillingApiClient { + &self.organization_billing_api + } + pub fn organization_billing_v_next_api( + &self, + ) -> &organization_billing_v_next_api::OrganizationBillingVNextApiClient { + &self.organization_billing_v_next_api + } + pub fn organization_connections_api( + &self, + ) -> &organization_connections_api::OrganizationConnectionsApiClient { + &self.organization_connections_api + } + pub fn organization_domain_api(&self) -> &organization_domain_api::OrganizationDomainApiClient { + &self.organization_domain_api + } + pub fn organization_export_api(&self) -> &organization_export_api::OrganizationExportApiClient { + &self.organization_export_api + } + pub fn organization_integration_api( + &self, + ) -> &organization_integration_api::OrganizationIntegrationApiClient { + &self.organization_integration_api + } + pub fn organization_integration_configuration_api( + &self, + ) -> &organization_integration_configuration_api::OrganizationIntegrationConfigurationApiClient + { + &self.organization_integration_configuration_api + } + pub fn organization_sponsorships_api( + &self, + ) -> &organization_sponsorships_api::OrganizationSponsorshipsApiClient { + &self.organization_sponsorships_api + } + pub fn organization_users_api(&self) -> &organization_users_api::OrganizationUsersApiClient { + &self.organization_users_api + } + pub fn organizations_api(&self) -> &organizations_api::OrganizationsApiClient { + &self.organizations_api + } + pub fn phishing_domains_api(&self) -> &phishing_domains_api::PhishingDomainsApiClient { + &self.phishing_domains_api + } + pub fn plans_api(&self) -> &plans_api::PlansApiClient { + &self.plans_api + } + pub fn policies_api(&self) -> &policies_api::PoliciesApiClient { + &self.policies_api + } + pub fn projects_api(&self) -> &projects_api::ProjectsApiClient { + &self.projects_api + } + pub fn provider_billing_api(&self) -> &provider_billing_api::ProviderBillingApiClient { + &self.provider_billing_api + } + pub fn provider_billing_v_next_api( + &self, + ) -> &provider_billing_v_next_api::ProviderBillingVNextApiClient { + &self.provider_billing_v_next_api + } + pub fn provider_clients_api(&self) -> &provider_clients_api::ProviderClientsApiClient { + &self.provider_clients_api + } + pub fn provider_organizations_api( + &self, + ) -> &provider_organizations_api::ProviderOrganizationsApiClient { + &self.provider_organizations_api + } + pub fn provider_users_api(&self) -> &provider_users_api::ProviderUsersApiClient { + &self.provider_users_api + } + pub fn providers_api(&self) -> &providers_api::ProvidersApiClient { + &self.providers_api + } + pub fn push_api(&self) -> &push_api::PushApiClient { + &self.push_api + } + pub fn reports_api(&self) -> &reports_api::ReportsApiClient { + &self.reports_api + } + pub fn request_sm_access_api(&self) -> &request_sm_access_api::RequestSmAccessApiClient { + &self.request_sm_access_api + } + pub fn secrets_api(&self) -> &secrets_api::SecretsApiClient { + &self.secrets_api + } + pub fn secrets_manager_events_api( + &self, + ) -> &secrets_manager_events_api::SecretsManagerEventsApiClient { + &self.secrets_manager_events_api + } + pub fn secrets_manager_porting_api( + &self, + ) -> &secrets_manager_porting_api::SecretsManagerPortingApiClient { + &self.secrets_manager_porting_api + } + pub fn security_task_api(&self) -> &security_task_api::SecurityTaskApiClient { + &self.security_task_api + } + pub fn self_hosted_organization_licenses_api( + &self, + ) -> &self_hosted_organization_licenses_api::SelfHostedOrganizationLicensesApiClient { + &self.self_hosted_organization_licenses_api + } + pub fn self_hosted_organization_sponsorships_api( + &self, + ) -> &self_hosted_organization_sponsorships_api::SelfHostedOrganizationSponsorshipsApiClient + { + &self.self_hosted_organization_sponsorships_api + } + pub fn sends_api(&self) -> &sends_api::SendsApiClient { + &self.sends_api + } + pub fn service_accounts_api(&self) -> &service_accounts_api::ServiceAccountsApiClient { + &self.service_accounts_api + } + pub fn settings_api(&self) -> &settings_api::SettingsApiClient { + &self.settings_api + } + pub fn slack_integration_api(&self) -> &slack_integration_api::SlackIntegrationApiClient { + &self.slack_integration_api + } + pub fn stripe_api(&self) -> &stripe_api::StripeApiClient { + &self.stripe_api + } + pub fn sync_api(&self) -> &sync_api::SyncApiClient { + &self.sync_api + } + pub fn tax_api(&self) -> &tax_api::TaxApiClient { + &self.tax_api + } + pub fn trash_api(&self) -> &trash_api::TrashApiClient { + &self.trash_api + } + pub fn two_factor_api(&self) -> &two_factor_api::TwoFactorApiClient { + &self.two_factor_api + } + pub fn users_api(&self) -> &users_api::UsersApiClient { + &self.users_api + } + pub fn web_authn_api(&self) -> &web_authn_api::WebAuthnApiClient { + &self.web_authn_api + } +} diff --git a/crates/bitwarden-api-api/src/apis/notifications_api.rs b/crates/bitwarden-api-api/src/apis/notifications_api.rs index 23524dc14..79d520e4f 100644 --- a/crates/bitwarden-api-api/src/apis/notifications_api.rs +++ b/crates/bitwarden-api-api/src/apis/notifications_api.rs @@ -8,175 +8,184 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`notifications_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum NotificationsGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait NotificationsApi: Send + Sync { + + /// GET /notifications + /// + /// + async fn notifications_get(&self, read_status_filter: Option, deleted_status_filter: Option, continuation_token: Option<&str>, page_size: Option) -> Result; + + /// PATCH /notifications/{id}/delete + /// + /// + async fn notifications_id_delete_patch(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// PATCH /notifications/{id}/read + /// + /// + async fn notifications_id_read_patch(&self, id: uuid::Uuid) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`notifications_id_delete_patch`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum NotificationsIdDeletePatchError { - UnknownValue(serde_json::Value), +pub struct NotificationsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`notifications_id_read_patch`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum NotificationsIdReadPatchError { - UnknownValue(serde_json::Value), +impl NotificationsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl NotificationsApiClient { + pub async fn notifications_get( + &self, + read_status_filter: Option, + deleted_status_filter: Option, + continuation_token: Option<&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_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)) } - } else { - 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_delete_patch(&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_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 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, - })) + pub async fn notifications_id_read_patch(&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_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)) + } } } 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..f47a77854 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,234 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdAuthRequestsGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`organizations_org_id_auth_requests_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdAuthRequestsPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait OrganizationAuthRequestsApi: Send + Sync { + + /// POST /organizations/{orgId}/auth-requests/deny + /// + /// + async fn organizations_org_id_auth_requests_deny_post(&self, org_id: uuid::Uuid, bulk_deny_admin_auth_request_request_model: Option) -> Result<(), Error>; + + /// GET /organizations/{orgId}/auth-requests + /// + /// + async fn organizations_org_id_auth_requests_get(&self, org_id: uuid::Uuid) -> Result; + + /// POST /organizations/{orgId}/auth-requests + /// + /// + async fn organizations_org_id_auth_requests_post(&self, org_id: uuid::Uuid, organization_auth_request_update_many_request_model: Option>) -> Result<(), Error>; + + /// POST /organizations/{orgId}/auth-requests/{requestId} + /// + /// + async fn organizations_org_id_auth_requests_request_id_post(&self, org_id: uuid::Uuid, request_id: uuid::Uuid, admin_auth_request_update_request_model: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`organizations_org_id_auth_requests_request_id_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdAuthRequestsRequestIdPostError { - UnknownValue(serde_json::Value), +pub struct OrganizationAuthRequestsApiClient { + configuration: Arc, } -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, - })) +impl OrganizationAuthRequestsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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`")))), +// #[async_trait] +impl OrganizationAuthRequestsApiClient { + pub async fn organizations_org_id_auth_requests_deny_post( + &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_token) = local_var_configuration.oauth_access_token { + 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?; + + 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 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_get( + &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}/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_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)) + } } -} -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()); + pub async fn organizations_org_id_auth_requests_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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, - })) + + pub async fn organizations_org_id_auth_requests_request_id_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } } 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 0599efcb3..1ce7b6029 100644 --- a/crates/bitwarden-api-api/src/apis/organization_billing_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_billing_api.rs @@ -8,712 +8,676 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 -/// [`organizations_organization_id_billing_change_frequency_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingChangeFrequencyPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingPaymentMethodPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organizations_organization_id_billing_payment_method_verify_bank_account_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingPaymentMethodVerifyBankAccountPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`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_setup_business_unit_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingSetupBusinessUnitPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingTransactionsGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait OrganizationBillingApi: Send + Sync { + + /// POST /organizations/{organizationId}/billing/change-frequency + /// + /// + async fn organizations_organization_id_billing_change_frequency_post(&self, organization_id: uuid::Uuid, change_plan_frequency_request: Option) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing + /// + /// + async fn organizations_organization_id_billing_get(&self, organization_id: uuid::Uuid) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/history + /// + /// + async fn organizations_organization_id_billing_history_get(&self, organization_id: uuid::Uuid) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/invoices + /// + /// + async fn organizations_organization_id_billing_invoices_get(&self, organization_id: uuid::Uuid, status: Option<&str>, start_after: Option<&str>) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/metadata + /// + /// + async fn organizations_organization_id_billing_metadata_get(&self, organization_id: uuid::Uuid) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/payment-method + /// + /// + async fn organizations_organization_id_billing_payment_method_get(&self, organization_id: uuid::Uuid) -> Result<(), Error>; + + /// PUT /organizations/{organizationId}/billing/payment-method + /// + /// + async fn organizations_organization_id_billing_payment_method_put(&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(&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(&self, organization_id: uuid::Uuid, organization_create_request_model: Option) -> Result<(), Error>; + + /// POST /organizations/{organizationId}/billing/setup-business-unit + /// + /// + async fn organizations_organization_id_billing_setup_business_unit_post(&self, organization_id: uuid::Uuid, setup_business_unit_request_body: Option) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/tax-information + /// + /// + async fn organizations_organization_id_billing_tax_information_get(&self, organization_id: uuid::Uuid) -> Result<(), Error>; + + /// PUT /organizations/{organizationId}/billing/tax-information + /// + /// + async fn organizations_organization_id_billing_tax_information_put(&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(&self, organization_id: uuid::Uuid, start_after: Option) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/warnings + /// + /// + async fn organizations_organization_id_billing_warnings_get(&self, organization_id: uuid::Uuid) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`organizations_organization_id_billing_warnings_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingWarningsGetError { - UnknownValue(serde_json::Value), +pub struct OrganizationBillingApiClient { + configuration: Arc, } -pub async fn organizations_organization_id_billing_change_frequency_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - change_plan_frequency_request: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_change_plan_frequency_request = change_plan_frequency_request; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/change-frequency", - 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_change_plan_frequency_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, - })) +impl OrganizationBillingApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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, - })) +// #[async_trait] +impl OrganizationBillingApiClient { + pub async fn organizations_organization_id_billing_change_frequency_post( + &self, + organization_id: uuid::Uuid, + change_plan_frequency_request: 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/change-frequency", + 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_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&change_plan_frequency_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)) + } } -} -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_get( + &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_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 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())]); + pub async fn organizations_organization_id_billing_history_get( + &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_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()); - } - 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()); + pub async fn organizations_organization_id_billing_invoices_get( + &self, + organization_id: uuid::Uuid, + status: Option<&str>, + start_after: Option<&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_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 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()); + pub async fn organizations_organization_id_billing_metadata_get( + &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_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 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()); + pub async fn organizations_organization_id_billing_payment_method_get( + &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_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 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_payment_method_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_payment_method_verify_bank_account_post( + &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_token) = local_var_configuration.oauth_access_token { + 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 = + serde_json::from_str(&local_var_content).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 organizations_organization_id_billing_setup_business_unit_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - setup_business_unit_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_setup_business_unit_request_body = setup_business_unit_request_body; - - let uri_str = format!( - "{}/organizations/{organizationId}/billing/setup-business-unit", - 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_setup_business_unit_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_restart_subscription_post( + &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_token) = local_var_configuration.oauth_access_token { + 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 = + serde_json::from_str(&local_var_content).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 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_setup_business_unit_post( + &self, + organization_id: uuid::Uuid, + setup_business_unit_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/setup-business-unit", + 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_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&setup_business_unit_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)) + } } -} -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()); + pub async fn organizations_organization_id_billing_tax_information_get( + &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_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 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()); + pub async fn organizations_organization_id_billing_tax_information_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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_warnings_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/warnings", - 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 async fn organizations_organization_id_billing_transactions_get( + &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_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 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_warnings_get( + &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/warnings", + 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_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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/organization_billing_v_next_api.rs b/crates/bitwarden-api-api/src/apis/organization_billing_v_next_api.rs index 4d8bc6dcf..76f139780 100644 --- a/crates/bitwarden-api-api/src/apis/organization_billing_v_next_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_billing_v_next_api.rs @@ -8,2424 +8,2393 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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_billing_vnext_address_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingVnextAddressGetError { - UnknownValue(serde_json::Value), -} +/* +#[async_trait] +pub trait OrganizationBillingVNextApi: Send + Sync { -/// struct for typed errors of method [`organizations_organization_id_billing_vnext_address_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingVnextAddressPutError { - UnknownValue(serde_json::Value), -} + /// GET /organizations/{organizationId}/billing/vnext/address + /// + /// + async fn organizations_organization_id_billing_vnext_address_get(&self, organization_id: &str, id: Option, identifier: Option<&str>, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, plan: Option<&str>, plan_type: Option, seats: Option, max_collections: Option, use_policies: Option, use_sso: Option, use_key_connector: Option, use_scim: Option, use_groups: Option, use_directory: Option, use_events: Option, use_totp: Option, use2fa: Option, use_api: Option, use_reset_password: Option, use_secrets_manager: Option, self_host: Option, users_get_premium: Option, use_custom_permissions: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, enabled: Option, license_key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, two_factor_providers: Option<&str>, expiration_date: Option, creation_date: Option, revision_date: Option, max_autoscale_seats: Option, owners_notified_of_autoscaling: Option, status: Option, use_password_manager: Option, sm_seats: Option, sm_service_accounts: Option, max_autoscale_sm_seats: Option, max_autoscale_sm_service_accounts: Option, limit_collection_creation: Option, limit_collection_deletion: Option, allow_admin_access_to_all_collection_items: Option, limit_item_deletion: Option, use_risk_insights: Option, use_organization_domains: Option, use_admin_sponsored_families: Option) -> Result<(), Error>; -/// struct for typed errors of method -/// [`organizations_organization_id_billing_vnext_credit_bitpay_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingVnextCreditBitpayPostError { - UnknownValue(serde_json::Value), -} + /// PUT /organizations/{organizationId}/billing/vnext/address + /// + /// + async fn organizations_organization_id_billing_vnext_address_put(&self, organization_id: &str, id: Option, identifier: Option<&str>, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, plan: Option<&str>, plan_type: Option, seats: Option, max_collections: Option, use_policies: Option, use_sso: Option, use_key_connector: Option, use_scim: Option, use_groups: Option, use_directory: Option, use_events: Option, use_totp: Option, use2fa: Option, use_api: Option, use_reset_password: Option, use_secrets_manager: Option, self_host: Option, users_get_premium: Option, use_custom_permissions: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, enabled: Option, license_key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, two_factor_providers: Option<&str>, expiration_date: Option, creation_date: Option, revision_date: Option, max_autoscale_seats: Option, owners_notified_of_autoscaling: Option, status: Option, use_password_manager: Option, sm_seats: Option, sm_service_accounts: Option, max_autoscale_sm_seats: Option, max_autoscale_sm_service_accounts: Option, limit_collection_creation: Option, limit_collection_deletion: Option, allow_admin_access_to_all_collection_items: Option, limit_item_deletion: Option, use_risk_insights: Option, use_organization_domains: Option, use_admin_sponsored_families: Option, billing_address_request: Option) -> Result<(), Error>; -/// struct for typed errors of method [`organizations_organization_id_billing_vnext_credit_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingVnextCreditGetError { - UnknownValue(serde_json::Value), -} + /// POST /organizations/{organizationId}/billing/vnext/credit/bitpay + /// + /// + async fn organizations_organization_id_billing_vnext_credit_bitpay_post(&self, organization_id: &str, id: Option, identifier: Option<&str>, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, plan: Option<&str>, plan_type: Option, seats: Option, max_collections: Option, use_policies: Option, use_sso: Option, use_key_connector: Option, use_scim: Option, use_groups: Option, use_directory: Option, use_events: Option, use_totp: Option, use2fa: Option, use_api: Option, use_reset_password: Option, use_secrets_manager: Option, self_host: Option, users_get_premium: Option, use_custom_permissions: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, enabled: Option, license_key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, two_factor_providers: Option<&str>, expiration_date: Option, creation_date: Option, revision_date: Option, max_autoscale_seats: Option, owners_notified_of_autoscaling: Option, status: Option, use_password_manager: Option, sm_seats: Option, sm_service_accounts: Option, max_autoscale_sm_seats: Option, max_autoscale_sm_service_accounts: Option, limit_collection_creation: Option, limit_collection_deletion: Option, allow_admin_access_to_all_collection_items: Option, limit_item_deletion: Option, use_risk_insights: Option, use_organization_domains: Option, use_admin_sponsored_families: Option, bit_pay_credit_request: Option) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/billing/vnext/credit + /// + /// + async fn organizations_organization_id_billing_vnext_credit_get(&self, organization_id: &str, id: Option, identifier: Option<&str>, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, plan: Option<&str>, plan_type: Option, seats: Option, max_collections: Option, use_policies: Option, use_sso: Option, use_key_connector: Option, use_scim: Option, use_groups: Option, use_directory: Option, use_events: Option, use_totp: Option, use2fa: Option, use_api: Option, use_reset_password: Option, use_secrets_manager: Option, self_host: Option, users_get_premium: Option, use_custom_permissions: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, enabled: Option, license_key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, two_factor_providers: Option<&str>, expiration_date: Option, creation_date: Option, revision_date: Option, max_autoscale_seats: Option, owners_notified_of_autoscaling: Option, status: Option, use_password_manager: Option, sm_seats: Option, sm_service_accounts: Option, max_autoscale_sm_seats: Option, max_autoscale_sm_service_accounts: Option, limit_collection_creation: Option, limit_collection_deletion: Option, allow_admin_access_to_all_collection_items: Option, limit_item_deletion: Option, use_risk_insights: Option, use_organization_domains: Option, use_admin_sponsored_families: Option) -> Result<(), Error>; -/// struct for typed errors of method -/// [`organizations_organization_id_billing_vnext_payment_method_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingVnextPaymentMethodGetError { - UnknownValue(serde_json::Value), + /// GET /organizations/{organizationId}/billing/vnext/payment-method + /// + /// + async fn organizations_organization_id_billing_vnext_payment_method_get(&self, organization_id: &str, id: Option, identifier: Option<&str>, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, plan: Option<&str>, plan_type: Option, seats: Option, max_collections: Option, use_policies: Option, use_sso: Option, use_key_connector: Option, use_scim: Option, use_groups: Option, use_directory: Option, use_events: Option, use_totp: Option, use2fa: Option, use_api: Option, use_reset_password: Option, use_secrets_manager: Option, self_host: Option, users_get_premium: Option, use_custom_permissions: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, enabled: Option, license_key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, two_factor_providers: Option<&str>, expiration_date: Option, creation_date: Option, revision_date: Option, max_autoscale_seats: Option, owners_notified_of_autoscaling: Option, status: Option, use_password_manager: Option, sm_seats: Option, sm_service_accounts: Option, max_autoscale_sm_seats: Option, max_autoscale_sm_service_accounts: Option, limit_collection_creation: Option, limit_collection_deletion: Option, allow_admin_access_to_all_collection_items: Option, limit_item_deletion: Option, use_risk_insights: Option, use_organization_domains: Option, use_admin_sponsored_families: Option) -> Result<(), Error>; + + /// PUT /organizations/{organizationId}/billing/vnext/payment-method + /// + /// + async fn organizations_organization_id_billing_vnext_payment_method_put(&self, organization_id: &str, id: Option, identifier: Option<&str>, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, plan: Option<&str>, plan_type: Option, seats: Option, max_collections: Option, use_policies: Option, use_sso: Option, use_key_connector: Option, use_scim: Option, use_groups: Option, use_directory: Option, use_events: Option, use_totp: Option, use2fa: Option, use_api: Option, use_reset_password: Option, use_secrets_manager: Option, self_host: Option, users_get_premium: Option, use_custom_permissions: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, enabled: Option, license_key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, two_factor_providers: Option<&str>, expiration_date: Option, creation_date: Option, revision_date: Option, max_autoscale_seats: Option, owners_notified_of_autoscaling: Option, status: Option, use_password_manager: Option, sm_seats: Option, sm_service_accounts: Option, max_autoscale_sm_seats: Option, max_autoscale_sm_service_accounts: Option, limit_collection_creation: Option, limit_collection_deletion: Option, allow_admin_access_to_all_collection_items: Option, limit_item_deletion: Option, use_risk_insights: Option, use_organization_domains: Option, use_admin_sponsored_families: Option, tokenized_payment_method_request: Option) -> Result<(), Error>; + + /// POST /organizations/{organizationId}/billing/vnext/payment-method/verify-bank-account + /// + /// + async fn organizations_organization_id_billing_vnext_payment_method_verify_bank_account_post(&self, organization_id: &str, id: Option, identifier: Option<&str>, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, plan: Option<&str>, plan_type: Option, seats: Option, max_collections: Option, use_policies: Option, use_sso: Option, use_key_connector: Option, use_scim: Option, use_groups: Option, use_directory: Option, use_events: Option, use_totp: Option, use2fa: Option, use_api: Option, use_reset_password: Option, use_secrets_manager: Option, self_host: Option, users_get_premium: Option, use_custom_permissions: Option, storage: Option, max_storage_gb: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, reference_data: Option<&str>, enabled: Option, license_key: Option<&str>, public_key: Option<&str>, private_key: Option<&str>, two_factor_providers: Option<&str>, expiration_date: Option, creation_date: Option, revision_date: Option, max_autoscale_seats: Option, owners_notified_of_autoscaling: Option, status: Option, use_password_manager: Option, sm_seats: Option, sm_service_accounts: Option, max_autoscale_sm_seats: Option, max_autoscale_sm_service_accounts: Option, limit_collection_creation: Option, limit_collection_deletion: Option, allow_admin_access_to_all_collection_items: Option, limit_item_deletion: Option, use_risk_insights: Option, use_organization_domains: Option, use_admin_sponsored_families: Option, verify_bank_account_request: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method -/// [`organizations_organization_id_billing_vnext_payment_method_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingVnextPaymentMethodPutError { - UnknownValue(serde_json::Value), +pub struct OrganizationBillingVNextApiClient { + configuration: Arc, } -/// struct for typed errors of method -/// [`organizations_organization_id_billing_vnext_payment_method_verify_bank_account_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdBillingVnextPaymentMethodVerifyBankAccountPostError { - UnknownValue(serde_json::Value), +impl OrganizationBillingVNextApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn organizations_organization_id_billing_vnext_address_get( - configuration: &configuration::Configuration, - organization_id: &str, - id: Option, - identifier: Option<&str>, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - plan: Option<&str>, - plan_type: Option, - seats: Option, - max_collections: Option, - use_policies: Option, - use_sso: Option, - use_key_connector: Option, - use_scim: Option, - use_groups: Option, - use_directory: Option, - use_events: Option, - use_totp: Option, - use2fa: Option, - use_api: Option, - use_reset_password: Option, - use_secrets_manager: Option, - self_host: Option, - users_get_premium: Option, - use_custom_permissions: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - enabled: Option, - license_key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - two_factor_providers: Option<&str>, - expiration_date: Option, - creation_date: Option, - revision_date: Option, - max_autoscale_seats: Option, - owners_notified_of_autoscaling: Option, - status: Option, - use_password_manager: Option, - sm_seats: Option, - sm_service_accounts: Option, - max_autoscale_sm_seats: Option, - max_autoscale_sm_service_accounts: Option, - limit_collection_creation: Option, - limit_collection_deletion: Option, - allow_admin_access_to_all_collection_items: Option, - limit_item_deletion: Option, - use_risk_insights: Option, - use_organization_domains: Option, - use_admin_sponsored_families: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_id = id; - let p_identifier = identifier; - let p_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_plan = plan; - let p_plan_type = plan_type; - let p_seats = seats; - let p_max_collections = max_collections; - let p_use_policies = use_policies; - let p_use_sso = use_sso; - let p_use_key_connector = use_key_connector; - let p_use_scim = use_scim; - let p_use_groups = use_groups; - let p_use_directory = use_directory; - let p_use_events = use_events; - let p_use_totp = use_totp; - let p_use2fa = use2fa; - let p_use_api = use_api; - let p_use_reset_password = use_reset_password; - let p_use_secrets_manager = use_secrets_manager; - let p_self_host = self_host; - let p_users_get_premium = users_get_premium; - let p_use_custom_permissions = use_custom_permissions; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_enabled = enabled; - let p_license_key = license_key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_two_factor_providers = two_factor_providers; - let p_expiration_date = expiration_date; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_max_autoscale_seats = max_autoscale_seats; - let p_owners_notified_of_autoscaling = owners_notified_of_autoscaling; - let p_status = status; - let p_use_password_manager = use_password_manager; - let p_sm_seats = sm_seats; - let p_sm_service_accounts = sm_service_accounts; - let p_max_autoscale_sm_seats = max_autoscale_sm_seats; - let p_max_autoscale_sm_service_accounts = max_autoscale_sm_service_accounts; - let p_limit_collection_creation = limit_collection_creation; - let p_limit_collection_deletion = limit_collection_deletion; - let p_allow_admin_access_to_all_collection_items = allow_admin_access_to_all_collection_items; - let p_limit_item_deletion = limit_item_deletion; - let p_use_risk_insights = use_risk_insights; - let p_use_organization_domains = use_organization_domains; - let p_use_admin_sponsored_families = use_admin_sponsored_families; +// #[async_trait] +impl OrganizationBillingVNextApiClient { + pub async fn organizations_organization_id_billing_vnext_address_get( + &self, + organization_id: &str, + id: Option, + identifier: Option<&str>, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + plan: Option<&str>, + plan_type: Option, + seats: Option, + max_collections: Option, + use_policies: Option, + use_sso: Option, + use_key_connector: Option, + use_scim: Option, + use_groups: Option, + use_directory: Option, + use_events: Option, + use_totp: Option, + use2fa: Option, + use_api: Option, + use_reset_password: Option, + use_secrets_manager: Option, + self_host: Option, + users_get_premium: Option, + use_custom_permissions: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + enabled: Option, + license_key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + two_factor_providers: Option<&str>, + expiration_date: Option, + creation_date: Option, + revision_date: Option, + max_autoscale_seats: Option, + owners_notified_of_autoscaling: Option, + status: Option, + use_password_manager: Option, + sm_seats: Option, + sm_service_accounts: Option, + max_autoscale_sm_seats: Option, + max_autoscale_sm_service_accounts: Option, + limit_collection_creation: Option, + limit_collection_deletion: Option, + allow_admin_access_to_all_collection_items: Option, + limit_item_deletion: Option, + use_risk_insights: Option, + use_organization_domains: Option, + use_admin_sponsored_families: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/organizations/{organizationId}/billing/vnext/address", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/vnext/address", + local_var_configuration.base_path, + organizationId = crate::apis::urlencode(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) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_identifier { - req_builder = req_builder.query(&[("identifier", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan { - req_builder = req_builder.query(&[("plan", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan_type { - req_builder = req_builder.query(&[("planType", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_seats { - req_builder = req_builder.query(&[("seats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_collections { - req_builder = req_builder.query(&[("maxCollections", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_policies { - req_builder = req_builder.query(&[("usePolicies", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_sso { - req_builder = req_builder.query(&[("useSso", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_key_connector { - req_builder = req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_scim { - req_builder = req_builder.query(&[("useScim", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_groups { - req_builder = req_builder.query(&[("useGroups", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_directory { - req_builder = req_builder.query(&[("useDirectory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_totp { - req_builder = req_builder.query(&[("useTotp", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use2fa { - req_builder = req_builder.query(&[("use2fa", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_api { - req_builder = req_builder.query(&[("useApi", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_reset_password { - req_builder = req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_secrets_manager { - req_builder = req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_self_host { - req_builder = req_builder.query(&[("selfHost", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_users_get_premium { - req_builder = req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_custom_permissions { - req_builder = req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_expiration_date { - req_builder = req_builder.query(&[("expirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_seats { - req_builder = req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_owners_notified_of_autoscaling { - req_builder = - req_builder.query(&[("ownersNotifiedOfAutoscaling", ¶m_value.to_string())]); - } - 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_use_password_manager { - req_builder = req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_seats { - req_builder = req_builder.query(&[("smSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_service_accounts { - req_builder = req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_seats { - req_builder = req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_service_accounts { - req_builder = - req_builder.query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_creation { - req_builder = req_builder.query(&[("limitCollectionCreation", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_deletion { - req_builder = req_builder.query(&[("limitCollectionDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_allow_admin_access_to_all_collection_items { - req_builder = req_builder.query(&[( - "allowAdminAccessToAllCollectionItems", - ¶m_value.to_string(), - )]); - } - if let Some(ref param_value) = p_limit_item_deletion { - req_builder = req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_risk_insights { - req_builder = req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_organization_domains { - req_builder = req_builder.query(&[("useOrganizationDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_admin_sponsored_families { - req_builder = req_builder.query(&[("useAdminSponsoredFamilies", ¶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()); - }; + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = identifier { + local_var_req_builder = + local_var_req_builder.query(&[("identifier", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan { + local_var_req_builder = + local_var_req_builder.query(&[("plan", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan_type { + local_var_req_builder = + local_var_req_builder.query(&[("planType", ¶m_value.to_string())]); + } + if let Some(ref param_value) = seats { + local_var_req_builder = + local_var_req_builder.query(&[("seats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_collections { + local_var_req_builder = + local_var_req_builder.query(&[("maxCollections", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_policies { + local_var_req_builder = + local_var_req_builder.query(&[("usePolicies", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_sso { + local_var_req_builder = + local_var_req_builder.query(&[("useSso", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_scim { + local_var_req_builder = + local_var_req_builder.query(&[("useScim", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_groups { + local_var_req_builder = + local_var_req_builder.query(&[("useGroups", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_directory { + local_var_req_builder = + local_var_req_builder.query(&[("useDirectory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_totp { + local_var_req_builder = + local_var_req_builder.query(&[("useTotp", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use2fa { + local_var_req_builder = + local_var_req_builder.query(&[("use2fa", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_api { + local_var_req_builder = + local_var_req_builder.query(&[("useApi", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_reset_password { + local_var_req_builder = + local_var_req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_secrets_manager { + local_var_req_builder = + local_var_req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = self_host { + local_var_req_builder = + local_var_req_builder.query(&[("selfHost", ¶m_value.to_string())]); + } + if let Some(ref param_value) = users_get_premium { + local_var_req_builder = + local_var_req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_custom_permissions { + local_var_req_builder = + local_var_req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("expirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = owners_notified_of_autoscaling { + local_var_req_builder = local_var_req_builder + .query(&[("ownersNotifiedOfAutoscaling", ¶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 param_value) = use_password_manager { + local_var_req_builder = + local_var_req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("smSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_service_accounts { + local_var_req_builder = + local_var_req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_service_accounts { + local_var_req_builder = local_var_req_builder + .query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_creation { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionCreation", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_deletion { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = allow_admin_access_to_all_collection_items { + local_var_req_builder = local_var_req_builder.query(&[( + "allowAdminAccessToAllCollectionItems", + ¶m_value.to_string(), + )]); + } + if let Some(ref param_value) = limit_item_deletion { + local_var_req_builder = + local_var_req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_risk_insights { + local_var_req_builder = + local_var_req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_organization_domains { + local_var_req_builder = local_var_req_builder + .query(&[("useOrganizationDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_admin_sponsored_families { + local_var_req_builder = local_var_req_builder + .query(&[("useAdminSponsoredFamilies", ¶m_value.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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 organizations_organization_id_billing_vnext_address_put( - configuration: &configuration::Configuration, - organization_id: &str, - id: Option, - identifier: Option<&str>, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - plan: Option<&str>, - plan_type: Option, - seats: Option, - max_collections: Option, - use_policies: Option, - use_sso: Option, - use_key_connector: Option, - use_scim: Option, - use_groups: Option, - use_directory: Option, - use_events: Option, - use_totp: Option, - use2fa: Option, - use_api: Option, - use_reset_password: Option, - use_secrets_manager: Option, - self_host: Option, - users_get_premium: Option, - use_custom_permissions: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - enabled: Option, - license_key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - two_factor_providers: Option<&str>, - expiration_date: Option, - creation_date: Option, - revision_date: Option, - max_autoscale_seats: Option, - owners_notified_of_autoscaling: Option, - status: Option, - use_password_manager: Option, - sm_seats: Option, - sm_service_accounts: Option, - max_autoscale_sm_seats: Option, - max_autoscale_sm_service_accounts: Option, - limit_collection_creation: Option, - limit_collection_deletion: Option, - allow_admin_access_to_all_collection_items: Option, - limit_item_deletion: Option, - use_risk_insights: Option, - use_organization_domains: Option, - use_admin_sponsored_families: Option, - billing_address_request: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_id = id; - let p_identifier = identifier; - let p_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_plan = plan; - let p_plan_type = plan_type; - let p_seats = seats; - let p_max_collections = max_collections; - let p_use_policies = use_policies; - let p_use_sso = use_sso; - let p_use_key_connector = use_key_connector; - let p_use_scim = use_scim; - let p_use_groups = use_groups; - let p_use_directory = use_directory; - let p_use_events = use_events; - let p_use_totp = use_totp; - let p_use2fa = use2fa; - let p_use_api = use_api; - let p_use_reset_password = use_reset_password; - let p_use_secrets_manager = use_secrets_manager; - let p_self_host = self_host; - let p_users_get_premium = users_get_premium; - let p_use_custom_permissions = use_custom_permissions; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_enabled = enabled; - let p_license_key = license_key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_two_factor_providers = two_factor_providers; - let p_expiration_date = expiration_date; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_max_autoscale_seats = max_autoscale_seats; - let p_owners_notified_of_autoscaling = owners_notified_of_autoscaling; - let p_status = status; - let p_use_password_manager = use_password_manager; - let p_sm_seats = sm_seats; - let p_sm_service_accounts = sm_service_accounts; - let p_max_autoscale_sm_seats = max_autoscale_sm_seats; - let p_max_autoscale_sm_service_accounts = max_autoscale_sm_service_accounts; - let p_limit_collection_creation = limit_collection_creation; - let p_limit_collection_deletion = limit_collection_deletion; - let p_allow_admin_access_to_all_collection_items = allow_admin_access_to_all_collection_items; - let p_limit_item_deletion = limit_item_deletion; - let p_use_risk_insights = use_risk_insights; - let p_use_organization_domains = use_organization_domains; - let p_use_admin_sponsored_families = use_admin_sponsored_families; - let p_billing_address_request = billing_address_request; + pub async fn organizations_organization_id_billing_vnext_address_put( + &self, + organization_id: &str, + id: Option, + identifier: Option<&str>, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + plan: Option<&str>, + plan_type: Option, + seats: Option, + max_collections: Option, + use_policies: Option, + use_sso: Option, + use_key_connector: Option, + use_scim: Option, + use_groups: Option, + use_directory: Option, + use_events: Option, + use_totp: Option, + use2fa: Option, + use_api: Option, + use_reset_password: Option, + use_secrets_manager: Option, + self_host: Option, + users_get_premium: Option, + use_custom_permissions: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + enabled: Option, + license_key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + two_factor_providers: Option<&str>, + expiration_date: Option, + creation_date: Option, + revision_date: Option, + max_autoscale_seats: Option, + owners_notified_of_autoscaling: Option, + status: Option, + use_password_manager: Option, + sm_seats: Option, + sm_service_accounts: Option, + max_autoscale_sm_seats: Option, + max_autoscale_sm_service_accounts: Option, + limit_collection_creation: Option, + limit_collection_deletion: Option, + allow_admin_access_to_all_collection_items: Option, + limit_item_deletion: Option, + use_risk_insights: Option, + use_organization_domains: Option, + use_admin_sponsored_families: Option, + billing_address_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/organizations/{organizationId}/billing/vnext/address", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/vnext/address", + local_var_configuration.base_path, + organizationId = crate::apis::urlencode(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 param_value) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_identifier { - req_builder = req_builder.query(&[("identifier", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan { - req_builder = req_builder.query(&[("plan", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan_type { - req_builder = req_builder.query(&[("planType", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_seats { - req_builder = req_builder.query(&[("seats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_collections { - req_builder = req_builder.query(&[("maxCollections", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_policies { - req_builder = req_builder.query(&[("usePolicies", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_sso { - req_builder = req_builder.query(&[("useSso", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_key_connector { - req_builder = req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_scim { - req_builder = req_builder.query(&[("useScim", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_groups { - req_builder = req_builder.query(&[("useGroups", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_directory { - req_builder = req_builder.query(&[("useDirectory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_totp { - req_builder = req_builder.query(&[("useTotp", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use2fa { - req_builder = req_builder.query(&[("use2fa", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_api { - req_builder = req_builder.query(&[("useApi", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_reset_password { - req_builder = req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_secrets_manager { - req_builder = req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_self_host { - req_builder = req_builder.query(&[("selfHost", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_users_get_premium { - req_builder = req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_custom_permissions { - req_builder = req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_expiration_date { - req_builder = req_builder.query(&[("expirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_seats { - req_builder = req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_owners_notified_of_autoscaling { - req_builder = - req_builder.query(&[("ownersNotifiedOfAutoscaling", ¶m_value.to_string())]); - } - 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_use_password_manager { - req_builder = req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_seats { - req_builder = req_builder.query(&[("smSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_service_accounts { - req_builder = req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_seats { - req_builder = req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_service_accounts { - req_builder = - req_builder.query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_creation { - req_builder = req_builder.query(&[("limitCollectionCreation", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_deletion { - req_builder = req_builder.query(&[("limitCollectionDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_allow_admin_access_to_all_collection_items { - req_builder = req_builder.query(&[( - "allowAdminAccessToAllCollectionItems", - ¶m_value.to_string(), - )]); - } - if let Some(ref param_value) = p_limit_item_deletion { - req_builder = req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_risk_insights { - req_builder = req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_organization_domains { - req_builder = req_builder.query(&[("useOrganizationDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_admin_sponsored_families { - req_builder = req_builder.query(&[("useAdminSponsoredFamilies", ¶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_billing_address_request); + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = identifier { + local_var_req_builder = + local_var_req_builder.query(&[("identifier", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan { + local_var_req_builder = + local_var_req_builder.query(&[("plan", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan_type { + local_var_req_builder = + local_var_req_builder.query(&[("planType", ¶m_value.to_string())]); + } + if let Some(ref param_value) = seats { + local_var_req_builder = + local_var_req_builder.query(&[("seats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_collections { + local_var_req_builder = + local_var_req_builder.query(&[("maxCollections", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_policies { + local_var_req_builder = + local_var_req_builder.query(&[("usePolicies", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_sso { + local_var_req_builder = + local_var_req_builder.query(&[("useSso", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_scim { + local_var_req_builder = + local_var_req_builder.query(&[("useScim", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_groups { + local_var_req_builder = + local_var_req_builder.query(&[("useGroups", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_directory { + local_var_req_builder = + local_var_req_builder.query(&[("useDirectory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_totp { + local_var_req_builder = + local_var_req_builder.query(&[("useTotp", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use2fa { + local_var_req_builder = + local_var_req_builder.query(&[("use2fa", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_api { + local_var_req_builder = + local_var_req_builder.query(&[("useApi", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_reset_password { + local_var_req_builder = + local_var_req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_secrets_manager { + local_var_req_builder = + local_var_req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = self_host { + local_var_req_builder = + local_var_req_builder.query(&[("selfHost", ¶m_value.to_string())]); + } + if let Some(ref param_value) = users_get_premium { + local_var_req_builder = + local_var_req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_custom_permissions { + local_var_req_builder = + local_var_req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("expirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = owners_notified_of_autoscaling { + local_var_req_builder = local_var_req_builder + .query(&[("ownersNotifiedOfAutoscaling", ¶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 param_value) = use_password_manager { + local_var_req_builder = + local_var_req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("smSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_service_accounts { + local_var_req_builder = + local_var_req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_service_accounts { + local_var_req_builder = local_var_req_builder + .query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_creation { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionCreation", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_deletion { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = allow_admin_access_to_all_collection_items { + local_var_req_builder = local_var_req_builder.query(&[( + "allowAdminAccessToAllCollectionItems", + ¶m_value.to_string(), + )]); + } + if let Some(ref param_value) = limit_item_deletion { + local_var_req_builder = + local_var_req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_risk_insights { + local_var_req_builder = + local_var_req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_organization_domains { + local_var_req_builder = local_var_req_builder + .query(&[("useOrganizationDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_admin_sponsored_families { + local_var_req_builder = local_var_req_builder + .query(&[("useAdminSponsoredFamilies", ¶m_value.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()); + }; + local_var_req_builder = local_var_req_builder.json(&billing_address_request); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 organizations_organization_id_billing_vnext_credit_bitpay_post( - configuration: &configuration::Configuration, - organization_id: &str, - id: Option, - identifier: Option<&str>, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - plan: Option<&str>, - plan_type: Option, - seats: Option, - max_collections: Option, - use_policies: Option, - use_sso: Option, - use_key_connector: Option, - use_scim: Option, - use_groups: Option, - use_directory: Option, - use_events: Option, - use_totp: Option, - use2fa: Option, - use_api: Option, - use_reset_password: Option, - use_secrets_manager: Option, - self_host: Option, - users_get_premium: Option, - use_custom_permissions: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - enabled: Option, - license_key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - two_factor_providers: Option<&str>, - expiration_date: Option, - creation_date: Option, - revision_date: Option, - max_autoscale_seats: Option, - owners_notified_of_autoscaling: Option, - status: Option, - use_password_manager: Option, - sm_seats: Option, - sm_service_accounts: Option, - max_autoscale_sm_seats: Option, - max_autoscale_sm_service_accounts: Option, - limit_collection_creation: Option, - limit_collection_deletion: Option, - allow_admin_access_to_all_collection_items: Option, - limit_item_deletion: Option, - use_risk_insights: Option, - use_organization_domains: Option, - use_admin_sponsored_families: Option, - bit_pay_credit_request: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_id = id; - let p_identifier = identifier; - let p_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_plan = plan; - let p_plan_type = plan_type; - let p_seats = seats; - let p_max_collections = max_collections; - let p_use_policies = use_policies; - let p_use_sso = use_sso; - let p_use_key_connector = use_key_connector; - let p_use_scim = use_scim; - let p_use_groups = use_groups; - let p_use_directory = use_directory; - let p_use_events = use_events; - let p_use_totp = use_totp; - let p_use2fa = use2fa; - let p_use_api = use_api; - let p_use_reset_password = use_reset_password; - let p_use_secrets_manager = use_secrets_manager; - let p_self_host = self_host; - let p_users_get_premium = users_get_premium; - let p_use_custom_permissions = use_custom_permissions; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_enabled = enabled; - let p_license_key = license_key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_two_factor_providers = two_factor_providers; - let p_expiration_date = expiration_date; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_max_autoscale_seats = max_autoscale_seats; - let p_owners_notified_of_autoscaling = owners_notified_of_autoscaling; - let p_status = status; - let p_use_password_manager = use_password_manager; - let p_sm_seats = sm_seats; - let p_sm_service_accounts = sm_service_accounts; - let p_max_autoscale_sm_seats = max_autoscale_sm_seats; - let p_max_autoscale_sm_service_accounts = max_autoscale_sm_service_accounts; - let p_limit_collection_creation = limit_collection_creation; - let p_limit_collection_deletion = limit_collection_deletion; - let p_allow_admin_access_to_all_collection_items = allow_admin_access_to_all_collection_items; - let p_limit_item_deletion = limit_item_deletion; - let p_use_risk_insights = use_risk_insights; - let p_use_organization_domains = use_organization_domains; - let p_use_admin_sponsored_families = use_admin_sponsored_families; - let p_bit_pay_credit_request = bit_pay_credit_request; + pub async fn organizations_organization_id_billing_vnext_credit_bitpay_post( + &self, + organization_id: &str, + id: Option, + identifier: Option<&str>, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + plan: Option<&str>, + plan_type: Option, + seats: Option, + max_collections: Option, + use_policies: Option, + use_sso: Option, + use_key_connector: Option, + use_scim: Option, + use_groups: Option, + use_directory: Option, + use_events: Option, + use_totp: Option, + use2fa: Option, + use_api: Option, + use_reset_password: Option, + use_secrets_manager: Option, + self_host: Option, + users_get_premium: Option, + use_custom_permissions: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + enabled: Option, + license_key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + two_factor_providers: Option<&str>, + expiration_date: Option, + creation_date: Option, + revision_date: Option, + max_autoscale_seats: Option, + owners_notified_of_autoscaling: Option, + status: Option, + use_password_manager: Option, + sm_seats: Option, + sm_service_accounts: Option, + max_autoscale_sm_seats: Option, + max_autoscale_sm_service_accounts: Option, + limit_collection_creation: Option, + limit_collection_deletion: Option, + allow_admin_access_to_all_collection_items: Option, + limit_item_deletion: Option, + use_risk_insights: Option, + use_organization_domains: Option, + use_admin_sponsored_families: Option, + bit_pay_credit_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/organizations/{organizationId}/billing/vnext/credit/bitpay", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/vnext/credit/bitpay", + local_var_configuration.base_path, + organizationId = crate::apis::urlencode(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 param_value) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_identifier { - req_builder = req_builder.query(&[("identifier", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan { - req_builder = req_builder.query(&[("plan", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan_type { - req_builder = req_builder.query(&[("planType", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_seats { - req_builder = req_builder.query(&[("seats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_collections { - req_builder = req_builder.query(&[("maxCollections", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_policies { - req_builder = req_builder.query(&[("usePolicies", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_sso { - req_builder = req_builder.query(&[("useSso", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_key_connector { - req_builder = req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_scim { - req_builder = req_builder.query(&[("useScim", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_groups { - req_builder = req_builder.query(&[("useGroups", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_directory { - req_builder = req_builder.query(&[("useDirectory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_totp { - req_builder = req_builder.query(&[("useTotp", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use2fa { - req_builder = req_builder.query(&[("use2fa", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_api { - req_builder = req_builder.query(&[("useApi", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_reset_password { - req_builder = req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_secrets_manager { - req_builder = req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_self_host { - req_builder = req_builder.query(&[("selfHost", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_users_get_premium { - req_builder = req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_custom_permissions { - req_builder = req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_expiration_date { - req_builder = req_builder.query(&[("expirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_seats { - req_builder = req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_owners_notified_of_autoscaling { - req_builder = - req_builder.query(&[("ownersNotifiedOfAutoscaling", ¶m_value.to_string())]); - } - 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_use_password_manager { - req_builder = req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_seats { - req_builder = req_builder.query(&[("smSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_service_accounts { - req_builder = req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_seats { - req_builder = req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_service_accounts { - req_builder = - req_builder.query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_creation { - req_builder = req_builder.query(&[("limitCollectionCreation", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_deletion { - req_builder = req_builder.query(&[("limitCollectionDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_allow_admin_access_to_all_collection_items { - req_builder = req_builder.query(&[( - "allowAdminAccessToAllCollectionItems", - ¶m_value.to_string(), - )]); - } - if let Some(ref param_value) = p_limit_item_deletion { - req_builder = req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_risk_insights { - req_builder = req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_organization_domains { - req_builder = req_builder.query(&[("useOrganizationDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_admin_sponsored_families { - req_builder = req_builder.query(&[("useAdminSponsoredFamilies", ¶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_bit_pay_credit_request); + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = identifier { + local_var_req_builder = + local_var_req_builder.query(&[("identifier", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan { + local_var_req_builder = + local_var_req_builder.query(&[("plan", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan_type { + local_var_req_builder = + local_var_req_builder.query(&[("planType", ¶m_value.to_string())]); + } + if let Some(ref param_value) = seats { + local_var_req_builder = + local_var_req_builder.query(&[("seats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_collections { + local_var_req_builder = + local_var_req_builder.query(&[("maxCollections", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_policies { + local_var_req_builder = + local_var_req_builder.query(&[("usePolicies", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_sso { + local_var_req_builder = + local_var_req_builder.query(&[("useSso", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_scim { + local_var_req_builder = + local_var_req_builder.query(&[("useScim", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_groups { + local_var_req_builder = + local_var_req_builder.query(&[("useGroups", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_directory { + local_var_req_builder = + local_var_req_builder.query(&[("useDirectory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_totp { + local_var_req_builder = + local_var_req_builder.query(&[("useTotp", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use2fa { + local_var_req_builder = + local_var_req_builder.query(&[("use2fa", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_api { + local_var_req_builder = + local_var_req_builder.query(&[("useApi", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_reset_password { + local_var_req_builder = + local_var_req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_secrets_manager { + local_var_req_builder = + local_var_req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = self_host { + local_var_req_builder = + local_var_req_builder.query(&[("selfHost", ¶m_value.to_string())]); + } + if let Some(ref param_value) = users_get_premium { + local_var_req_builder = + local_var_req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_custom_permissions { + local_var_req_builder = + local_var_req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("expirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = owners_notified_of_autoscaling { + local_var_req_builder = local_var_req_builder + .query(&[("ownersNotifiedOfAutoscaling", ¶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 param_value) = use_password_manager { + local_var_req_builder = + local_var_req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("smSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_service_accounts { + local_var_req_builder = + local_var_req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_service_accounts { + local_var_req_builder = local_var_req_builder + .query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_creation { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionCreation", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_deletion { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = allow_admin_access_to_all_collection_items { + local_var_req_builder = local_var_req_builder.query(&[( + "allowAdminAccessToAllCollectionItems", + ¶m_value.to_string(), + )]); + } + if let Some(ref param_value) = limit_item_deletion { + local_var_req_builder = + local_var_req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_risk_insights { + local_var_req_builder = + local_var_req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_organization_domains { + local_var_req_builder = local_var_req_builder + .query(&[("useOrganizationDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_admin_sponsored_families { + local_var_req_builder = local_var_req_builder + .query(&[("useAdminSponsoredFamilies", ¶m_value.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()); + }; + local_var_req_builder = local_var_req_builder.json(&bit_pay_credit_request); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 organizations_organization_id_billing_vnext_credit_get( - configuration: &configuration::Configuration, - organization_id: &str, - id: Option, - identifier: Option<&str>, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - plan: Option<&str>, - plan_type: Option, - seats: Option, - max_collections: Option, - use_policies: Option, - use_sso: Option, - use_key_connector: Option, - use_scim: Option, - use_groups: Option, - use_directory: Option, - use_events: Option, - use_totp: Option, - use2fa: Option, - use_api: Option, - use_reset_password: Option, - use_secrets_manager: Option, - self_host: Option, - users_get_premium: Option, - use_custom_permissions: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - enabled: Option, - license_key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - two_factor_providers: Option<&str>, - expiration_date: Option, - creation_date: Option, - revision_date: Option, - max_autoscale_seats: Option, - owners_notified_of_autoscaling: Option, - status: Option, - use_password_manager: Option, - sm_seats: Option, - sm_service_accounts: Option, - max_autoscale_sm_seats: Option, - max_autoscale_sm_service_accounts: Option, - limit_collection_creation: Option, - limit_collection_deletion: Option, - allow_admin_access_to_all_collection_items: Option, - limit_item_deletion: Option, - use_risk_insights: Option, - use_organization_domains: Option, - use_admin_sponsored_families: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_id = id; - let p_identifier = identifier; - let p_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_plan = plan; - let p_plan_type = plan_type; - let p_seats = seats; - let p_max_collections = max_collections; - let p_use_policies = use_policies; - let p_use_sso = use_sso; - let p_use_key_connector = use_key_connector; - let p_use_scim = use_scim; - let p_use_groups = use_groups; - let p_use_directory = use_directory; - let p_use_events = use_events; - let p_use_totp = use_totp; - let p_use2fa = use2fa; - let p_use_api = use_api; - let p_use_reset_password = use_reset_password; - let p_use_secrets_manager = use_secrets_manager; - let p_self_host = self_host; - let p_users_get_premium = users_get_premium; - let p_use_custom_permissions = use_custom_permissions; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_enabled = enabled; - let p_license_key = license_key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_two_factor_providers = two_factor_providers; - let p_expiration_date = expiration_date; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_max_autoscale_seats = max_autoscale_seats; - let p_owners_notified_of_autoscaling = owners_notified_of_autoscaling; - let p_status = status; - let p_use_password_manager = use_password_manager; - let p_sm_seats = sm_seats; - let p_sm_service_accounts = sm_service_accounts; - let p_max_autoscale_sm_seats = max_autoscale_sm_seats; - let p_max_autoscale_sm_service_accounts = max_autoscale_sm_service_accounts; - let p_limit_collection_creation = limit_collection_creation; - let p_limit_collection_deletion = limit_collection_deletion; - let p_allow_admin_access_to_all_collection_items = allow_admin_access_to_all_collection_items; - let p_limit_item_deletion = limit_item_deletion; - let p_use_risk_insights = use_risk_insights; - let p_use_organization_domains = use_organization_domains; - let p_use_admin_sponsored_families = use_admin_sponsored_families; + pub async fn organizations_organization_id_billing_vnext_credit_get( + &self, + organization_id: &str, + id: Option, + identifier: Option<&str>, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + plan: Option<&str>, + plan_type: Option, + seats: Option, + max_collections: Option, + use_policies: Option, + use_sso: Option, + use_key_connector: Option, + use_scim: Option, + use_groups: Option, + use_directory: Option, + use_events: Option, + use_totp: Option, + use2fa: Option, + use_api: Option, + use_reset_password: Option, + use_secrets_manager: Option, + self_host: Option, + users_get_premium: Option, + use_custom_permissions: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + enabled: Option, + license_key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + two_factor_providers: Option<&str>, + expiration_date: Option, + creation_date: Option, + revision_date: Option, + max_autoscale_seats: Option, + owners_notified_of_autoscaling: Option, + status: Option, + use_password_manager: Option, + sm_seats: Option, + sm_service_accounts: Option, + max_autoscale_sm_seats: Option, + max_autoscale_sm_service_accounts: Option, + limit_collection_creation: Option, + limit_collection_deletion: Option, + allow_admin_access_to_all_collection_items: Option, + limit_item_deletion: Option, + use_risk_insights: Option, + use_organization_domains: Option, + use_admin_sponsored_families: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/organizations/{organizationId}/billing/vnext/credit", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/vnext/credit", + local_var_configuration.base_path, + organizationId = crate::apis::urlencode(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) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_identifier { - req_builder = req_builder.query(&[("identifier", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan { - req_builder = req_builder.query(&[("plan", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan_type { - req_builder = req_builder.query(&[("planType", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_seats { - req_builder = req_builder.query(&[("seats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_collections { - req_builder = req_builder.query(&[("maxCollections", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_policies { - req_builder = req_builder.query(&[("usePolicies", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_sso { - req_builder = req_builder.query(&[("useSso", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_key_connector { - req_builder = req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_scim { - req_builder = req_builder.query(&[("useScim", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_groups { - req_builder = req_builder.query(&[("useGroups", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_directory { - req_builder = req_builder.query(&[("useDirectory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_totp { - req_builder = req_builder.query(&[("useTotp", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use2fa { - req_builder = req_builder.query(&[("use2fa", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_api { - req_builder = req_builder.query(&[("useApi", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_reset_password { - req_builder = req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_secrets_manager { - req_builder = req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_self_host { - req_builder = req_builder.query(&[("selfHost", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_users_get_premium { - req_builder = req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_custom_permissions { - req_builder = req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_expiration_date { - req_builder = req_builder.query(&[("expirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_seats { - req_builder = req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_owners_notified_of_autoscaling { - req_builder = - req_builder.query(&[("ownersNotifiedOfAutoscaling", ¶m_value.to_string())]); - } - 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_use_password_manager { - req_builder = req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_seats { - req_builder = req_builder.query(&[("smSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_service_accounts { - req_builder = req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_seats { - req_builder = req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_service_accounts { - req_builder = - req_builder.query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_creation { - req_builder = req_builder.query(&[("limitCollectionCreation", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_deletion { - req_builder = req_builder.query(&[("limitCollectionDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_allow_admin_access_to_all_collection_items { - req_builder = req_builder.query(&[( - "allowAdminAccessToAllCollectionItems", - ¶m_value.to_string(), - )]); - } - if let Some(ref param_value) = p_limit_item_deletion { - req_builder = req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_risk_insights { - req_builder = req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_organization_domains { - req_builder = req_builder.query(&[("useOrganizationDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_admin_sponsored_families { - req_builder = req_builder.query(&[("useAdminSponsoredFamilies", ¶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()); - }; + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = identifier { + local_var_req_builder = + local_var_req_builder.query(&[("identifier", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan { + local_var_req_builder = + local_var_req_builder.query(&[("plan", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan_type { + local_var_req_builder = + local_var_req_builder.query(&[("planType", ¶m_value.to_string())]); + } + if let Some(ref param_value) = seats { + local_var_req_builder = + local_var_req_builder.query(&[("seats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_collections { + local_var_req_builder = + local_var_req_builder.query(&[("maxCollections", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_policies { + local_var_req_builder = + local_var_req_builder.query(&[("usePolicies", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_sso { + local_var_req_builder = + local_var_req_builder.query(&[("useSso", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_scim { + local_var_req_builder = + local_var_req_builder.query(&[("useScim", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_groups { + local_var_req_builder = + local_var_req_builder.query(&[("useGroups", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_directory { + local_var_req_builder = + local_var_req_builder.query(&[("useDirectory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_totp { + local_var_req_builder = + local_var_req_builder.query(&[("useTotp", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use2fa { + local_var_req_builder = + local_var_req_builder.query(&[("use2fa", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_api { + local_var_req_builder = + local_var_req_builder.query(&[("useApi", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_reset_password { + local_var_req_builder = + local_var_req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_secrets_manager { + local_var_req_builder = + local_var_req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = self_host { + local_var_req_builder = + local_var_req_builder.query(&[("selfHost", ¶m_value.to_string())]); + } + if let Some(ref param_value) = users_get_premium { + local_var_req_builder = + local_var_req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_custom_permissions { + local_var_req_builder = + local_var_req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("expirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = owners_notified_of_autoscaling { + local_var_req_builder = local_var_req_builder + .query(&[("ownersNotifiedOfAutoscaling", ¶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 param_value) = use_password_manager { + local_var_req_builder = + local_var_req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("smSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_service_accounts { + local_var_req_builder = + local_var_req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_service_accounts { + local_var_req_builder = local_var_req_builder + .query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_creation { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionCreation", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_deletion { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = allow_admin_access_to_all_collection_items { + local_var_req_builder = local_var_req_builder.query(&[( + "allowAdminAccessToAllCollectionItems", + ¶m_value.to_string(), + )]); + } + if let Some(ref param_value) = limit_item_deletion { + local_var_req_builder = + local_var_req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_risk_insights { + local_var_req_builder = + local_var_req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_organization_domains { + local_var_req_builder = local_var_req_builder + .query(&[("useOrganizationDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_admin_sponsored_families { + local_var_req_builder = local_var_req_builder + .query(&[("useAdminSponsoredFamilies", ¶m_value.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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 organizations_organization_id_billing_vnext_payment_method_get( - configuration: &configuration::Configuration, - organization_id: &str, - id: Option, - identifier: Option<&str>, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - plan: Option<&str>, - plan_type: Option, - seats: Option, - max_collections: Option, - use_policies: Option, - use_sso: Option, - use_key_connector: Option, - use_scim: Option, - use_groups: Option, - use_directory: Option, - use_events: Option, - use_totp: Option, - use2fa: Option, - use_api: Option, - use_reset_password: Option, - use_secrets_manager: Option, - self_host: Option, - users_get_premium: Option, - use_custom_permissions: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - enabled: Option, - license_key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - two_factor_providers: Option<&str>, - expiration_date: Option, - creation_date: Option, - revision_date: Option, - max_autoscale_seats: Option, - owners_notified_of_autoscaling: Option, - status: Option, - use_password_manager: Option, - sm_seats: Option, - sm_service_accounts: Option, - max_autoscale_sm_seats: Option, - max_autoscale_sm_service_accounts: Option, - limit_collection_creation: Option, - limit_collection_deletion: Option, - allow_admin_access_to_all_collection_items: Option, - limit_item_deletion: Option, - use_risk_insights: Option, - use_organization_domains: Option, - use_admin_sponsored_families: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_id = id; - let p_identifier = identifier; - let p_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_plan = plan; - let p_plan_type = plan_type; - let p_seats = seats; - let p_max_collections = max_collections; - let p_use_policies = use_policies; - let p_use_sso = use_sso; - let p_use_key_connector = use_key_connector; - let p_use_scim = use_scim; - let p_use_groups = use_groups; - let p_use_directory = use_directory; - let p_use_events = use_events; - let p_use_totp = use_totp; - let p_use2fa = use2fa; - let p_use_api = use_api; - let p_use_reset_password = use_reset_password; - let p_use_secrets_manager = use_secrets_manager; - let p_self_host = self_host; - let p_users_get_premium = users_get_premium; - let p_use_custom_permissions = use_custom_permissions; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_enabled = enabled; - let p_license_key = license_key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_two_factor_providers = two_factor_providers; - let p_expiration_date = expiration_date; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_max_autoscale_seats = max_autoscale_seats; - let p_owners_notified_of_autoscaling = owners_notified_of_autoscaling; - let p_status = status; - let p_use_password_manager = use_password_manager; - let p_sm_seats = sm_seats; - let p_sm_service_accounts = sm_service_accounts; - let p_max_autoscale_sm_seats = max_autoscale_sm_seats; - let p_max_autoscale_sm_service_accounts = max_autoscale_sm_service_accounts; - let p_limit_collection_creation = limit_collection_creation; - let p_limit_collection_deletion = limit_collection_deletion; - let p_allow_admin_access_to_all_collection_items = allow_admin_access_to_all_collection_items; - let p_limit_item_deletion = limit_item_deletion; - let p_use_risk_insights = use_risk_insights; - let p_use_organization_domains = use_organization_domains; - let p_use_admin_sponsored_families = use_admin_sponsored_families; + pub async fn organizations_organization_id_billing_vnext_payment_method_get( + &self, + organization_id: &str, + id: Option, + identifier: Option<&str>, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + plan: Option<&str>, + plan_type: Option, + seats: Option, + max_collections: Option, + use_policies: Option, + use_sso: Option, + use_key_connector: Option, + use_scim: Option, + use_groups: Option, + use_directory: Option, + use_events: Option, + use_totp: Option, + use2fa: Option, + use_api: Option, + use_reset_password: Option, + use_secrets_manager: Option, + self_host: Option, + users_get_premium: Option, + use_custom_permissions: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + enabled: Option, + license_key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + two_factor_providers: Option<&str>, + expiration_date: Option, + creation_date: Option, + revision_date: Option, + max_autoscale_seats: Option, + owners_notified_of_autoscaling: Option, + status: Option, + use_password_manager: Option, + sm_seats: Option, + sm_service_accounts: Option, + max_autoscale_sm_seats: Option, + max_autoscale_sm_service_accounts: Option, + limit_collection_creation: Option, + limit_collection_deletion: Option, + allow_admin_access_to_all_collection_items: Option, + limit_item_deletion: Option, + use_risk_insights: Option, + use_organization_domains: Option, + use_admin_sponsored_families: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/organizations/{organizationId}/billing/vnext/payment-method", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/vnext/payment-method", + local_var_configuration.base_path, + organizationId = crate::apis::urlencode(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) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_identifier { - req_builder = req_builder.query(&[("identifier", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan { - req_builder = req_builder.query(&[("plan", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan_type { - req_builder = req_builder.query(&[("planType", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_seats { - req_builder = req_builder.query(&[("seats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_collections { - req_builder = req_builder.query(&[("maxCollections", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_policies { - req_builder = req_builder.query(&[("usePolicies", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_sso { - req_builder = req_builder.query(&[("useSso", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_key_connector { - req_builder = req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_scim { - req_builder = req_builder.query(&[("useScim", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_groups { - req_builder = req_builder.query(&[("useGroups", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_directory { - req_builder = req_builder.query(&[("useDirectory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_totp { - req_builder = req_builder.query(&[("useTotp", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use2fa { - req_builder = req_builder.query(&[("use2fa", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_api { - req_builder = req_builder.query(&[("useApi", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_reset_password { - req_builder = req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_secrets_manager { - req_builder = req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_self_host { - req_builder = req_builder.query(&[("selfHost", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_users_get_premium { - req_builder = req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_custom_permissions { - req_builder = req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_expiration_date { - req_builder = req_builder.query(&[("expirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_seats { - req_builder = req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_owners_notified_of_autoscaling { - req_builder = - req_builder.query(&[("ownersNotifiedOfAutoscaling", ¶m_value.to_string())]); - } - 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_use_password_manager { - req_builder = req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_seats { - req_builder = req_builder.query(&[("smSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_service_accounts { - req_builder = req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_seats { - req_builder = req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_service_accounts { - req_builder = - req_builder.query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_creation { - req_builder = req_builder.query(&[("limitCollectionCreation", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_deletion { - req_builder = req_builder.query(&[("limitCollectionDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_allow_admin_access_to_all_collection_items { - req_builder = req_builder.query(&[( - "allowAdminAccessToAllCollectionItems", - ¶m_value.to_string(), - )]); - } - if let Some(ref param_value) = p_limit_item_deletion { - req_builder = req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_risk_insights { - req_builder = req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_organization_domains { - req_builder = req_builder.query(&[("useOrganizationDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_admin_sponsored_families { - req_builder = req_builder.query(&[("useAdminSponsoredFamilies", ¶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()); - }; + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = identifier { + local_var_req_builder = + local_var_req_builder.query(&[("identifier", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan { + local_var_req_builder = + local_var_req_builder.query(&[("plan", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan_type { + local_var_req_builder = + local_var_req_builder.query(&[("planType", ¶m_value.to_string())]); + } + if let Some(ref param_value) = seats { + local_var_req_builder = + local_var_req_builder.query(&[("seats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_collections { + local_var_req_builder = + local_var_req_builder.query(&[("maxCollections", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_policies { + local_var_req_builder = + local_var_req_builder.query(&[("usePolicies", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_sso { + local_var_req_builder = + local_var_req_builder.query(&[("useSso", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_scim { + local_var_req_builder = + local_var_req_builder.query(&[("useScim", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_groups { + local_var_req_builder = + local_var_req_builder.query(&[("useGroups", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_directory { + local_var_req_builder = + local_var_req_builder.query(&[("useDirectory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_totp { + local_var_req_builder = + local_var_req_builder.query(&[("useTotp", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use2fa { + local_var_req_builder = + local_var_req_builder.query(&[("use2fa", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_api { + local_var_req_builder = + local_var_req_builder.query(&[("useApi", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_reset_password { + local_var_req_builder = + local_var_req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_secrets_manager { + local_var_req_builder = + local_var_req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = self_host { + local_var_req_builder = + local_var_req_builder.query(&[("selfHost", ¶m_value.to_string())]); + } + if let Some(ref param_value) = users_get_premium { + local_var_req_builder = + local_var_req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_custom_permissions { + local_var_req_builder = + local_var_req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("expirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = owners_notified_of_autoscaling { + local_var_req_builder = local_var_req_builder + .query(&[("ownersNotifiedOfAutoscaling", ¶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 param_value) = use_password_manager { + local_var_req_builder = + local_var_req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("smSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_service_accounts { + local_var_req_builder = + local_var_req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_service_accounts { + local_var_req_builder = local_var_req_builder + .query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_creation { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionCreation", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_deletion { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = allow_admin_access_to_all_collection_items { + local_var_req_builder = local_var_req_builder.query(&[( + "allowAdminAccessToAllCollectionItems", + ¶m_value.to_string(), + )]); + } + if let Some(ref param_value) = limit_item_deletion { + local_var_req_builder = + local_var_req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_risk_insights { + local_var_req_builder = + local_var_req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_organization_domains { + local_var_req_builder = local_var_req_builder + .query(&[("useOrganizationDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_admin_sponsored_families { + local_var_req_builder = local_var_req_builder + .query(&[("useAdminSponsoredFamilies", ¶m_value.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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 organizations_organization_id_billing_vnext_payment_method_put( - configuration: &configuration::Configuration, - organization_id: &str, - id: Option, - identifier: Option<&str>, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - plan: Option<&str>, - plan_type: Option, - seats: Option, - max_collections: Option, - use_policies: Option, - use_sso: Option, - use_key_connector: Option, - use_scim: Option, - use_groups: Option, - use_directory: Option, - use_events: Option, - use_totp: Option, - use2fa: Option, - use_api: Option, - use_reset_password: Option, - use_secrets_manager: Option, - self_host: Option, - users_get_premium: Option, - use_custom_permissions: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - enabled: Option, - license_key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - two_factor_providers: Option<&str>, - expiration_date: Option, - creation_date: Option, - revision_date: Option, - max_autoscale_seats: Option, - owners_notified_of_autoscaling: Option, - status: Option, - use_password_manager: Option, - sm_seats: Option, - sm_service_accounts: Option, - max_autoscale_sm_seats: Option, - max_autoscale_sm_service_accounts: Option, - limit_collection_creation: Option, - limit_collection_deletion: Option, - allow_admin_access_to_all_collection_items: Option, - limit_item_deletion: Option, - use_risk_insights: Option, - use_organization_domains: Option, - use_admin_sponsored_families: Option, - tokenized_payment_method_request: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_id = id; - let p_identifier = identifier; - let p_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_plan = plan; - let p_plan_type = plan_type; - let p_seats = seats; - let p_max_collections = max_collections; - let p_use_policies = use_policies; - let p_use_sso = use_sso; - let p_use_key_connector = use_key_connector; - let p_use_scim = use_scim; - let p_use_groups = use_groups; - let p_use_directory = use_directory; - let p_use_events = use_events; - let p_use_totp = use_totp; - let p_use2fa = use2fa; - let p_use_api = use_api; - let p_use_reset_password = use_reset_password; - let p_use_secrets_manager = use_secrets_manager; - let p_self_host = self_host; - let p_users_get_premium = users_get_premium; - let p_use_custom_permissions = use_custom_permissions; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_enabled = enabled; - let p_license_key = license_key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_two_factor_providers = two_factor_providers; - let p_expiration_date = expiration_date; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_max_autoscale_seats = max_autoscale_seats; - let p_owners_notified_of_autoscaling = owners_notified_of_autoscaling; - let p_status = status; - let p_use_password_manager = use_password_manager; - let p_sm_seats = sm_seats; - let p_sm_service_accounts = sm_service_accounts; - let p_max_autoscale_sm_seats = max_autoscale_sm_seats; - let p_max_autoscale_sm_service_accounts = max_autoscale_sm_service_accounts; - let p_limit_collection_creation = limit_collection_creation; - let p_limit_collection_deletion = limit_collection_deletion; - let p_allow_admin_access_to_all_collection_items = allow_admin_access_to_all_collection_items; - let p_limit_item_deletion = limit_item_deletion; - let p_use_risk_insights = use_risk_insights; - let p_use_organization_domains = use_organization_domains; - let p_use_admin_sponsored_families = use_admin_sponsored_families; - let p_tokenized_payment_method_request = tokenized_payment_method_request; + pub async fn organizations_organization_id_billing_vnext_payment_method_put( + &self, + organization_id: &str, + id: Option, + identifier: Option<&str>, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + plan: Option<&str>, + plan_type: Option, + seats: Option, + max_collections: Option, + use_policies: Option, + use_sso: Option, + use_key_connector: Option, + use_scim: Option, + use_groups: Option, + use_directory: Option, + use_events: Option, + use_totp: Option, + use2fa: Option, + use_api: Option, + use_reset_password: Option, + use_secrets_manager: Option, + self_host: Option, + users_get_premium: Option, + use_custom_permissions: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + enabled: Option, + license_key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + two_factor_providers: Option<&str>, + expiration_date: Option, + creation_date: Option, + revision_date: Option, + max_autoscale_seats: Option, + owners_notified_of_autoscaling: Option, + status: Option, + use_password_manager: Option, + sm_seats: Option, + sm_service_accounts: Option, + max_autoscale_sm_seats: Option, + max_autoscale_sm_service_accounts: Option, + limit_collection_creation: Option, + limit_collection_deletion: Option, + allow_admin_access_to_all_collection_items: Option, + limit_item_deletion: Option, + use_risk_insights: Option, + use_organization_domains: Option, + use_admin_sponsored_families: Option, + tokenized_payment_method_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/organizations/{organizationId}/billing/vnext/payment-method", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/vnext/payment-method", + local_var_configuration.base_path, + organizationId = crate::apis::urlencode(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 param_value) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_identifier { - req_builder = req_builder.query(&[("identifier", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan { - req_builder = req_builder.query(&[("plan", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan_type { - req_builder = req_builder.query(&[("planType", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_seats { - req_builder = req_builder.query(&[("seats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_collections { - req_builder = req_builder.query(&[("maxCollections", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_policies { - req_builder = req_builder.query(&[("usePolicies", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_sso { - req_builder = req_builder.query(&[("useSso", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_key_connector { - req_builder = req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_scim { - req_builder = req_builder.query(&[("useScim", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_groups { - req_builder = req_builder.query(&[("useGroups", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_directory { - req_builder = req_builder.query(&[("useDirectory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_totp { - req_builder = req_builder.query(&[("useTotp", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use2fa { - req_builder = req_builder.query(&[("use2fa", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_api { - req_builder = req_builder.query(&[("useApi", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_reset_password { - req_builder = req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_secrets_manager { - req_builder = req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_self_host { - req_builder = req_builder.query(&[("selfHost", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_users_get_premium { - req_builder = req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_custom_permissions { - req_builder = req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_expiration_date { - req_builder = req_builder.query(&[("expirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_seats { - req_builder = req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_owners_notified_of_autoscaling { - req_builder = - req_builder.query(&[("ownersNotifiedOfAutoscaling", ¶m_value.to_string())]); - } - 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_use_password_manager { - req_builder = req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_seats { - req_builder = req_builder.query(&[("smSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_service_accounts { - req_builder = req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_seats { - req_builder = req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_service_accounts { - req_builder = - req_builder.query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_creation { - req_builder = req_builder.query(&[("limitCollectionCreation", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_deletion { - req_builder = req_builder.query(&[("limitCollectionDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_allow_admin_access_to_all_collection_items { - req_builder = req_builder.query(&[( - "allowAdminAccessToAllCollectionItems", - ¶m_value.to_string(), - )]); - } - if let Some(ref param_value) = p_limit_item_deletion { - req_builder = req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_risk_insights { - req_builder = req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_organization_domains { - req_builder = req_builder.query(&[("useOrganizationDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_admin_sponsored_families { - req_builder = req_builder.query(&[("useAdminSponsoredFamilies", ¶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_tokenized_payment_method_request); + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = identifier { + local_var_req_builder = + local_var_req_builder.query(&[("identifier", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan { + local_var_req_builder = + local_var_req_builder.query(&[("plan", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan_type { + local_var_req_builder = + local_var_req_builder.query(&[("planType", ¶m_value.to_string())]); + } + if let Some(ref param_value) = seats { + local_var_req_builder = + local_var_req_builder.query(&[("seats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_collections { + local_var_req_builder = + local_var_req_builder.query(&[("maxCollections", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_policies { + local_var_req_builder = + local_var_req_builder.query(&[("usePolicies", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_sso { + local_var_req_builder = + local_var_req_builder.query(&[("useSso", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_scim { + local_var_req_builder = + local_var_req_builder.query(&[("useScim", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_groups { + local_var_req_builder = + local_var_req_builder.query(&[("useGroups", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_directory { + local_var_req_builder = + local_var_req_builder.query(&[("useDirectory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_totp { + local_var_req_builder = + local_var_req_builder.query(&[("useTotp", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use2fa { + local_var_req_builder = + local_var_req_builder.query(&[("use2fa", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_api { + local_var_req_builder = + local_var_req_builder.query(&[("useApi", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_reset_password { + local_var_req_builder = + local_var_req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_secrets_manager { + local_var_req_builder = + local_var_req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = self_host { + local_var_req_builder = + local_var_req_builder.query(&[("selfHost", ¶m_value.to_string())]); + } + if let Some(ref param_value) = users_get_premium { + local_var_req_builder = + local_var_req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_custom_permissions { + local_var_req_builder = + local_var_req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("expirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = owners_notified_of_autoscaling { + local_var_req_builder = local_var_req_builder + .query(&[("ownersNotifiedOfAutoscaling", ¶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 param_value) = use_password_manager { + local_var_req_builder = + local_var_req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("smSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_service_accounts { + local_var_req_builder = + local_var_req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_service_accounts { + local_var_req_builder = local_var_req_builder + .query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_creation { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionCreation", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_deletion { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = allow_admin_access_to_all_collection_items { + local_var_req_builder = local_var_req_builder.query(&[( + "allowAdminAccessToAllCollectionItems", + ¶m_value.to_string(), + )]); + } + if let Some(ref param_value) = limit_item_deletion { + local_var_req_builder = + local_var_req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_risk_insights { + local_var_req_builder = + local_var_req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_organization_domains { + local_var_req_builder = local_var_req_builder + .query(&[("useOrganizationDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_admin_sponsored_families { + local_var_req_builder = local_var_req_builder + .query(&[("useAdminSponsoredFamilies", ¶m_value.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()); + }; + local_var_req_builder = local_var_req_builder.json(&tokenized_payment_method_request); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 organizations_organization_id_billing_vnext_payment_method_verify_bank_account_post( - configuration: &configuration::Configuration, - organization_id: &str, - id: Option, - identifier: Option<&str>, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - plan: Option<&str>, - plan_type: Option, - seats: Option, - max_collections: Option, - use_policies: Option, - use_sso: Option, - use_key_connector: Option, - use_scim: Option, - use_groups: Option, - use_directory: Option, - use_events: Option, - use_totp: Option, - use2fa: Option, - use_api: Option, - use_reset_password: Option, - use_secrets_manager: Option, - self_host: Option, - users_get_premium: Option, - use_custom_permissions: Option, - storage: Option, - max_storage_gb: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - reference_data: Option<&str>, - enabled: Option, - license_key: Option<&str>, - public_key: Option<&str>, - private_key: Option<&str>, - two_factor_providers: Option<&str>, - expiration_date: Option, - creation_date: Option, - revision_date: Option, - max_autoscale_seats: Option, - owners_notified_of_autoscaling: Option, - status: Option, - use_password_manager: Option, - sm_seats: Option, - sm_service_accounts: Option, - max_autoscale_sm_seats: Option, - max_autoscale_sm_service_accounts: Option, - limit_collection_creation: Option, - limit_collection_deletion: Option, - allow_admin_access_to_all_collection_items: Option, - limit_item_deletion: Option, - use_risk_insights: Option, - use_organization_domains: Option, - use_admin_sponsored_families: Option, - verify_bank_account_request: Option, -) -> Result<(), Error> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_id = id; - let p_identifier = identifier; - let p_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_plan = plan; - let p_plan_type = plan_type; - let p_seats = seats; - let p_max_collections = max_collections; - let p_use_policies = use_policies; - let p_use_sso = use_sso; - let p_use_key_connector = use_key_connector; - let p_use_scim = use_scim; - let p_use_groups = use_groups; - let p_use_directory = use_directory; - let p_use_events = use_events; - let p_use_totp = use_totp; - let p_use2fa = use2fa; - let p_use_api = use_api; - let p_use_reset_password = use_reset_password; - let p_use_secrets_manager = use_secrets_manager; - let p_self_host = self_host; - let p_users_get_premium = users_get_premium; - let p_use_custom_permissions = use_custom_permissions; - let p_storage = storage; - let p_max_storage_gb = max_storage_gb; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_reference_data = reference_data; - let p_enabled = enabled; - let p_license_key = license_key; - let p_public_key = public_key; - let p_private_key = private_key; - let p_two_factor_providers = two_factor_providers; - let p_expiration_date = expiration_date; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_max_autoscale_seats = max_autoscale_seats; - let p_owners_notified_of_autoscaling = owners_notified_of_autoscaling; - let p_status = status; - let p_use_password_manager = use_password_manager; - let p_sm_seats = sm_seats; - let p_sm_service_accounts = sm_service_accounts; - let p_max_autoscale_sm_seats = max_autoscale_sm_seats; - let p_max_autoscale_sm_service_accounts = max_autoscale_sm_service_accounts; - let p_limit_collection_creation = limit_collection_creation; - let p_limit_collection_deletion = limit_collection_deletion; - let p_allow_admin_access_to_all_collection_items = allow_admin_access_to_all_collection_items; - let p_limit_item_deletion = limit_item_deletion; - let p_use_risk_insights = use_risk_insights; - let p_use_organization_domains = use_organization_domains; - let p_use_admin_sponsored_families = use_admin_sponsored_families; - let p_verify_bank_account_request = verify_bank_account_request; + pub async fn organizations_organization_id_billing_vnext_payment_method_verify_bank_account_post( + &self, + organization_id: &str, + id: Option, + identifier: Option<&str>, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + plan: Option<&str>, + plan_type: Option, + seats: Option, + max_collections: Option, + use_policies: Option, + use_sso: Option, + use_key_connector: Option, + use_scim: Option, + use_groups: Option, + use_directory: Option, + use_events: Option, + use_totp: Option, + use2fa: Option, + use_api: Option, + use_reset_password: Option, + use_secrets_manager: Option, + self_host: Option, + users_get_premium: Option, + use_custom_permissions: Option, + storage: Option, + max_storage_gb: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + reference_data: Option<&str>, + enabled: Option, + license_key: Option<&str>, + public_key: Option<&str>, + private_key: Option<&str>, + two_factor_providers: Option<&str>, + expiration_date: Option, + creation_date: Option, + revision_date: Option, + max_autoscale_seats: Option, + owners_notified_of_autoscaling: Option, + status: Option, + use_password_manager: Option, + sm_seats: Option, + sm_service_accounts: Option, + max_autoscale_sm_seats: Option, + max_autoscale_sm_service_accounts: Option, + limit_collection_creation: Option, + limit_collection_deletion: Option, + allow_admin_access_to_all_collection_items: Option, + limit_item_deletion: Option, + use_risk_insights: Option, + use_organization_domains: Option, + use_admin_sponsored_families: Option, + verify_bank_account_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/organizations/{organizationId}/billing/vnext/payment-method/verify-bank-account", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/vnext/payment-method/verify-bank-account", + local_var_configuration.base_path, + organizationId = crate::apis::urlencode(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 param_value) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_identifier { - req_builder = req_builder.query(&[("identifier", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan { - req_builder = req_builder.query(&[("plan", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_plan_type { - req_builder = req_builder.query(&[("planType", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_seats { - req_builder = req_builder.query(&[("seats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_collections { - req_builder = req_builder.query(&[("maxCollections", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_policies { - req_builder = req_builder.query(&[("usePolicies", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_sso { - req_builder = req_builder.query(&[("useSso", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_key_connector { - req_builder = req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_scim { - req_builder = req_builder.query(&[("useScim", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_groups { - req_builder = req_builder.query(&[("useGroups", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_directory { - req_builder = req_builder.query(&[("useDirectory", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_totp { - req_builder = req_builder.query(&[("useTotp", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use2fa { - req_builder = req_builder.query(&[("use2fa", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_api { - req_builder = req_builder.query(&[("useApi", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_reset_password { - req_builder = req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_secrets_manager { - req_builder = req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_self_host { - req_builder = req_builder.query(&[("selfHost", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_users_get_premium { - req_builder = req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_custom_permissions { - req_builder = req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_storage { - req_builder = req_builder.query(&[("storage", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_storage_gb { - req_builder = req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_reference_data { - req_builder = req_builder.query(&[("referenceData", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_license_key { - req_builder = req_builder.query(&[("licenseKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_public_key { - req_builder = req_builder.query(&[("publicKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_private_key { - req_builder = req_builder.query(&[("privateKey", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_two_factor_providers { - req_builder = req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_expiration_date { - req_builder = req_builder.query(&[("expirationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_seats { - req_builder = req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_owners_notified_of_autoscaling { - req_builder = - req_builder.query(&[("ownersNotifiedOfAutoscaling", ¶m_value.to_string())]); - } - 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_use_password_manager { - req_builder = req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_seats { - req_builder = req_builder.query(&[("smSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_sm_service_accounts { - req_builder = req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_seats { - req_builder = req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_max_autoscale_sm_service_accounts { - req_builder = - req_builder.query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_creation { - req_builder = req_builder.query(&[("limitCollectionCreation", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_limit_collection_deletion { - req_builder = req_builder.query(&[("limitCollectionDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_allow_admin_access_to_all_collection_items { - req_builder = req_builder.query(&[( - "allowAdminAccessToAllCollectionItems", - ¶m_value.to_string(), - )]); - } - if let Some(ref param_value) = p_limit_item_deletion { - req_builder = req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_risk_insights { - req_builder = req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_organization_domains { - req_builder = req_builder.query(&[("useOrganizationDomains", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_use_admin_sponsored_families { - req_builder = req_builder.query(&[("useAdminSponsoredFamilies", ¶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_verify_bank_account_request); + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = identifier { + local_var_req_builder = + local_var_req_builder.query(&[("identifier", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan { + local_var_req_builder = + local_var_req_builder.query(&[("plan", ¶m_value.to_string())]); + } + if let Some(ref param_value) = plan_type { + local_var_req_builder = + local_var_req_builder.query(&[("planType", ¶m_value.to_string())]); + } + if let Some(ref param_value) = seats { + local_var_req_builder = + local_var_req_builder.query(&[("seats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_collections { + local_var_req_builder = + local_var_req_builder.query(&[("maxCollections", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_policies { + local_var_req_builder = + local_var_req_builder.query(&[("usePolicies", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_sso { + local_var_req_builder = + local_var_req_builder.query(&[("useSso", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_key_connector { + local_var_req_builder = + local_var_req_builder.query(&[("useKeyConnector", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_scim { + local_var_req_builder = + local_var_req_builder.query(&[("useScim", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_groups { + local_var_req_builder = + local_var_req_builder.query(&[("useGroups", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_directory { + local_var_req_builder = + local_var_req_builder.query(&[("useDirectory", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_totp { + local_var_req_builder = + local_var_req_builder.query(&[("useTotp", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use2fa { + local_var_req_builder = + local_var_req_builder.query(&[("use2fa", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_api { + local_var_req_builder = + local_var_req_builder.query(&[("useApi", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_reset_password { + local_var_req_builder = + local_var_req_builder.query(&[("useResetPassword", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_secrets_manager { + local_var_req_builder = + local_var_req_builder.query(&[("useSecretsManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = self_host { + local_var_req_builder = + local_var_req_builder.query(&[("selfHost", ¶m_value.to_string())]); + } + if let Some(ref param_value) = users_get_premium { + local_var_req_builder = + local_var_req_builder.query(&[("usersGetPremium", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_custom_permissions { + local_var_req_builder = + local_var_req_builder.query(&[("useCustomPermissions", ¶m_value.to_string())]); + } + if let Some(ref param_value) = storage { + local_var_req_builder = + local_var_req_builder.query(&[("storage", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_storage_gb { + local_var_req_builder = + local_var_req_builder.query(&[("maxStorageGb", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = reference_data { + local_var_req_builder = + local_var_req_builder.query(&[("referenceData", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = license_key { + local_var_req_builder = + local_var_req_builder.query(&[("licenseKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = public_key { + local_var_req_builder = + local_var_req_builder.query(&[("publicKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = private_key { + local_var_req_builder = + local_var_req_builder.query(&[("privateKey", ¶m_value.to_string())]); + } + if let Some(ref param_value) = two_factor_providers { + local_var_req_builder = + local_var_req_builder.query(&[("twoFactorProviders", ¶m_value.to_string())]); + } + if let Some(ref param_value) = expiration_date { + local_var_req_builder = + local_var_req_builder.query(&[("expirationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = owners_notified_of_autoscaling { + local_var_req_builder = local_var_req_builder + .query(&[("ownersNotifiedOfAutoscaling", ¶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 param_value) = use_password_manager { + local_var_req_builder = + local_var_req_builder.query(&[("usePasswordManager", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("smSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = sm_service_accounts { + local_var_req_builder = + local_var_req_builder.query(&[("smServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_seats { + local_var_req_builder = + local_var_req_builder.query(&[("maxAutoscaleSmSeats", ¶m_value.to_string())]); + } + if let Some(ref param_value) = max_autoscale_sm_service_accounts { + local_var_req_builder = local_var_req_builder + .query(&[("maxAutoscaleSmServiceAccounts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_creation { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionCreation", ¶m_value.to_string())]); + } + if let Some(ref param_value) = limit_collection_deletion { + local_var_req_builder = local_var_req_builder + .query(&[("limitCollectionDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = allow_admin_access_to_all_collection_items { + local_var_req_builder = local_var_req_builder.query(&[( + "allowAdminAccessToAllCollectionItems", + ¶m_value.to_string(), + )]); + } + if let Some(ref param_value) = limit_item_deletion { + local_var_req_builder = + local_var_req_builder.query(&[("limitItemDeletion", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_risk_insights { + local_var_req_builder = + local_var_req_builder.query(&[("useRiskInsights", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_organization_domains { + local_var_req_builder = local_var_req_builder + .query(&[("useOrganizationDomains", ¶m_value.to_string())]); + } + if let Some(ref param_value) = use_admin_sponsored_families { + local_var_req_builder = local_var_req_builder + .query(&[("useAdminSponsoredFamilies", ¶m_value.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()); + }; + local_var_req_builder = local_var_req_builder.json(&verify_bank_account_request); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if !status.is_client_error() && !status.is_server_error() { - Ok(()) - } else { - let content = resp.text().await?; - let entity: Option< - OrganizationsOrganizationIdBillingVnextPaymentMethodVerifyBankAccountPostError, - > = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + 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)) + } } } 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..230747626 100644 --- a/crates/bitwarden-api-api/src/apis/organization_connections_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_connections_api.rs @@ -8,340 +8,332 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`organizations_connections_enabled_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsConnectionsEnabledGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organizations_connections_organization_connection_id_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsConnectionsOrganizationConnectionIdDeleteError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organizations_connections_organization_connection_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsConnectionsOrganizationConnectionIdDeletePostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`organizations_connections_organization_connection_id_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsConnectionsOrganizationConnectionIdPutError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait OrganizationConnectionsApi: Send + Sync { + + /// GET /organizations/connections/enabled + /// + /// + async fn organizations_connections_enabled_get(&self, ) -> Result; + + /// DELETE /organizations/connections/{organizationConnectionId} + /// + /// + async fn organizations_connections_organization_connection_id_delete(&self, organization_connection_id: uuid::Uuid) -> Result<(), Error>; + + /// POST /organizations/connections/{organizationConnectionId}/delete + /// + /// + async fn organizations_connections_organization_connection_id_delete_post(&self, organization_connection_id: uuid::Uuid) -> Result<(), Error>; + + /// PUT /organizations/connections/{organizationConnectionId} + /// + /// + async fn organizations_connections_organization_connection_id_put(&self, organization_connection_id: uuid::Uuid, organization_connection_request_model: Option) -> Result; + + /// GET /organizations/connections/{organizationId}/{type} + /// + /// + async fn organizations_connections_organization_id_type_get(&self, organization_id: uuid::Uuid, r#type: models::OrganizationConnectionType) -> Result; + + /// POST /organizations/connections + /// + /// + async fn organizations_connections_post(&self, organization_connection_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`organizations_connections_organization_id_type_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsConnectionsOrganizationIdTypeGetError { - UnknownValue(serde_json::Value), +pub struct OrganizationConnectionsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`organizations_connections_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsConnectionsPostError { - UnknownValue(serde_json::Value), +impl OrganizationConnectionsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl OrganizationConnectionsApiClient { + pub async fn organizations_connections_enabled_get(&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_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)) } - } else { - 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( + &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_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 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_delete_post( + &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_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 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`")))), + pub async fn organizations_connections_organization_connection_id_put( + &self, + organization_connection_id: uuid::Uuid, + 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/{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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_connections_organization_id_type_get( + &self, + organization_id: uuid::Uuid, + r#type: models::OrganizationConnectionType, + ) -> Result { + 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_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)) } - } else { - 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`")))), + pub async fn organizations_connections_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..4404f83e6 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,461 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdDomainGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdDomainIdRemovePostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait OrganizationDomainApi: Send + Sync { + + /// POST /organizations/domain/sso/details + /// + /// + async fn organizations_domain_sso_details_post(&self, organization_domain_sso_details_request_model: Option) -> Result; + + /// POST /organizations/domain/sso/verified + /// + /// + async fn organizations_domain_sso_verified_post(&self, organization_domain_sso_details_request_model: Option) -> Result; + + /// GET /organizations/{orgId}/domain + /// + /// + async fn organizations_org_id_domain_get(&self, org_id: uuid::Uuid) -> Result; + + /// DELETE /organizations/{orgId}/domain/{id} + /// + /// + async fn organizations_org_id_domain_id_delete(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>; + + /// GET /organizations/{orgId}/domain/{id} + /// + /// + async fn organizations_org_id_domain_id_get(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result; + + /// POST /organizations/{orgId}/domain/{id}/remove + /// + /// + async fn organizations_org_id_domain_id_remove_post(&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(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result; + + /// POST /organizations/{orgId}/domain + /// + /// + async fn organizations_org_id_domain_post(&self, org_id: uuid::Uuid, organization_domain_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`organizations_org_id_domain_id_verify_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdDomainIdVerifyPostError { - UnknownValue(serde_json::Value), +pub struct OrganizationDomainApiClient { + configuration: Arc, } -/// struct for typed errors of method [`organizations_org_id_domain_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdDomainPostError { - UnknownValue(serde_json::Value), +impl OrganizationDomainApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl OrganizationDomainApiClient { + pub async fn organizations_domain_sso_details_post( + &self, + organization_domain_sso_details_request_model: Option< + models::OrganizationDomainSsoDetailsRequestModel, + >, + ) -> Result { + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_domain_sso_verified_post( + &self, + organization_domain_sso_details_request_model: Option< + models::OrganizationDomainSsoDetailsRequestModel, + >, + ) -> Result { + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_domain_get( + &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}/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_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)) } - } else { - 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_delete( + &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_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 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`")))), + pub async fn organizations_org_id_domain_id_get( + &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_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)) } - } else { - 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_remove_post( + &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_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 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`")))), + pub async fn organizations_org_id_domain_id_verify_post( + &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}/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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_domain_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..abcb8c770 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,77 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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, +}; + +/* +#[async_trait] +pub trait OrganizationExportApi: Send + Sync { + + /// GET /organizations/{organizationId}/export + /// + /// + async fn organizations_organization_id_export_get(&self, organization_id: uuid::Uuid) -> Result<(), Error>; +} +*/ -/// 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), +pub struct OrganizationExportApiClient { + configuration: Arc, } -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()); +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] +impl OrganizationExportApiClient { + pub async fn organizations_organization_id_export_get( + &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_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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/organization_integration_api.rs b/crates/bitwarden-api-api/src/apis/organization_integration_api.rs index 206a411ce..16b3c652c 100644 --- a/crates/bitwarden-api-api/src/apis/organization_integration_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_integration_api.rs @@ -8,309 +8,293 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`organizations_organization_id_integrations_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organizations_organization_id_integrations_integration_id_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdDeleteError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method -/// [`organizations_organization_id_integrations_integration_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdDeletePostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait OrganizationIntegrationApi: Send + Sync { + + /// GET /organizations/{organizationId}/integrations + /// + /// + async fn organizations_organization_id_integrations_get(&self, organization_id: uuid::Uuid) -> Result, Error>; + + /// DELETE /organizations/{organizationId}/integrations/{integrationId} + /// + /// + async fn organizations_organization_id_integrations_integration_id_delete(&self, organization_id: uuid::Uuid, integration_id: uuid::Uuid) -> Result<(), Error>; + + /// POST /organizations/{organizationId}/integrations/{integrationId}/delete + /// + /// + async fn organizations_organization_id_integrations_integration_id_delete_post(&self, organization_id: uuid::Uuid, integration_id: uuid::Uuid) -> Result<(), Error>; + + /// PUT /organizations/{organizationId}/integrations/{integrationId} + /// + /// + async fn organizations_organization_id_integrations_integration_id_put(&self, organization_id: uuid::Uuid, integration_id: uuid::Uuid, organization_integration_request_model: Option) -> Result; + + /// POST /organizations/{organizationId}/integrations + /// + /// + async fn organizations_organization_id_integrations_post(&self, organization_id: uuid::Uuid, organization_integration_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method -/// [`organizations_organization_id_integrations_integration_id_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdPutError { - UnknownValue(serde_json::Value), +pub struct OrganizationIntegrationApiClient { + configuration: Arc, } -/// struct for typed errors of method [`organizations_organization_id_integrations_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsPostError { - UnknownValue(serde_json::Value), +impl OrganizationIntegrationApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn organizations_organization_id_integrations_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, -) -> Result< - Vec, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/integrations", - 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 `Vec<models::OrganizationIntegrationResponseModel>`"))), - 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::OrganizationIntegrationResponseModel>`")))), +// #[async_trait] +impl OrganizationIntegrationApiClient { + pub async fn organizations_organization_id_integrations_get( + &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}/integrations", + 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_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::OrganizationIntegrationResponseModel>`"))), + ContentType::Unsupported(local_var_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::OrganizationIntegrationResponseModel>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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 organizations_organization_id_integrations_integration_id_delete( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - integration_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_integration_id = integration_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/integrations/{integrationId}", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()), - integrationId = crate::apis::urlencode(p_integration_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_organization_id_integrations_integration_id_delete( + &self, + organization_id: uuid::Uuid, + integration_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}/integrations/{integrationId}", + local_var_configuration.base_path, + organizationId = organization_id, + integrationId = integration_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_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 organizations_organization_id_integrations_integration_id_delete_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - integration_id: uuid::Uuid, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_integration_id = integration_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/integrations/{integrationId}/delete", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()), - integrationId = crate::apis::urlencode(p_integration_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_organization_id_integrations_integration_id_delete_post( + &self, + organization_id: uuid::Uuid, + integration_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}/integrations/{integrationId}/delete", + local_var_configuration.base_path, + organizationId = organization_id, + integrationId = integration_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_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 organizations_organization_id_integrations_integration_id_put( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - integration_id: uuid::Uuid, - organization_integration_request_model: Option, -) -> Result< - models::OrganizationIntegrationResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_integration_id = integration_id; - let p_organization_integration_request_model = organization_integration_request_model; - - let uri_str = format!( - "{}/organizations/{organizationId}/integrations/{integrationId}", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()), - integrationId = crate::apis::urlencode(p_integration_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_integration_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::OrganizationIntegrationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationIntegrationResponseModel`")))), + pub async fn organizations_organization_id_integrations_integration_id_put( + &self, + organization_id: uuid::Uuid, + integration_id: uuid::Uuid, + organization_integration_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}/integrations/{integrationId}", + local_var_configuration.base_path, + organizationId = organization_id, + integrationId = integration_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_token) = local_var_configuration.oauth_access_token { + 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_integration_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::OrganizationIntegrationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationIntegrationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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 organizations_organization_id_integrations_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - organization_integration_request_model: Option, -) -> Result< - models::OrganizationIntegrationResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_organization_integration_request_model = organization_integration_request_model; - - let uri_str = format!( - "{}/organizations/{organizationId}/integrations", - 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_integration_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::OrganizationIntegrationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationIntegrationResponseModel`")))), + pub async fn organizations_organization_id_integrations_post( + &self, + organization_id: uuid::Uuid, + organization_integration_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}/integrations", + 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_token) = local_var_configuration.oauth_access_token { + 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_integration_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::OrganizationIntegrationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationIntegrationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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, - })) } } diff --git a/crates/bitwarden-api-api/src/apis/organization_integration_configuration_api.rs b/crates/bitwarden-api-api/src/apis/organization_integration_configuration_api.rs index 529990514..749100c09 100644 --- a/crates/bitwarden-api-api/src/apis/organization_integration_configuration_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_integration_configuration_api.rs @@ -8,308 +8,291 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 -/// [`organizations_organization_id_integrations_integration_id_configurations_configuration_id_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdConfigurationsConfigurationIdDeleteError -{ - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organizations_organization_id_integrations_integration_id_configurations_configuration_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdConfigurationsConfigurationIdDeletePostError -{ - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organizations_organization_id_integrations_integration_id_configurations_configuration_id_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdConfigurationsConfigurationIdPutError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method -/// [`organizations_organization_id_integrations_integration_id_configurations_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdConfigurationsGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait OrganizationIntegrationConfigurationApi: Send + Sync { + + /// DELETE /organizations/{organizationId}/integrations/{integrationId}/configurations/{configurationId} + /// + /// + async fn organizations_organization_id_integrations_integration_id_configurations_configuration_id_delete(&self, organization_id: uuid::Uuid, integration_id: uuid::Uuid, configuration_id: uuid::Uuid) -> Result<(), Error>; + + /// POST /organizations/{organizationId}/integrations/{integrationId}/configurations/{configurationId}/delete + /// + /// + async fn organizations_organization_id_integrations_integration_id_configurations_configuration_id_delete_post(&self, organization_id: uuid::Uuid, integration_id: uuid::Uuid, configuration_id: uuid::Uuid) -> Result<(), Error>; + + /// PUT /organizations/{organizationId}/integrations/{integrationId}/configurations/{configurationId} + /// + /// + async fn organizations_organization_id_integrations_integration_id_configurations_configuration_id_put(&self, organization_id: uuid::Uuid, integration_id: uuid::Uuid, configuration_id: uuid::Uuid, organization_integration_configuration_request_model: Option) -> Result; + + /// GET /organizations/{organizationId}/integrations/{integrationId}/configurations + /// + /// + async fn organizations_organization_id_integrations_integration_id_configurations_get(&self, organization_id: uuid::Uuid, integration_id: uuid::Uuid) -> Result, Error>; + + /// POST /organizations/{organizationId}/integrations/{integrationId}/configurations + /// + /// + async fn organizations_organization_id_integrations_integration_id_configurations_post(&self, organization_id: uuid::Uuid, integration_id: uuid::Uuid, organization_integration_configuration_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method -/// [`organizations_organization_id_integrations_integration_id_configurations_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdConfigurationsPostError { - UnknownValue(serde_json::Value), +pub struct OrganizationIntegrationConfigurationApiClient { + configuration: Arc, } - -pub async fn organizations_organization_id_integrations_integration_id_configurations_configuration_id_delete(configuration: &configuration::Configuration, organization_id: uuid::Uuid, integration_id: uuid::Uuid, configuration_id: uuid::Uuid) -> Result<(), Error>{ - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_integration_id = integration_id; - let p_configuration_id = configuration_id; - - let uri_str = format!("{}/organizations/{organizationId}/integrations/{integrationId}/configurations/{configurationId}", configuration.base_path, organizationId=crate::apis::urlencode(p_organization_id.to_string()), integrationId=crate::apis::urlencode(p_integration_id.to_string()), configurationId=crate::apis::urlencode(p_configuration_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, - })) +impl OrganizationIntegrationConfigurationApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -pub async fn organizations_organization_id_integrations_integration_id_configurations_configuration_id_delete_post(configuration: &configuration::Configuration, organization_id: uuid::Uuid, integration_id: uuid::Uuid, configuration_id: uuid::Uuid) -> Result<(), Error>{ - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_integration_id = integration_id; - let p_configuration_id = configuration_id; - - let uri_str = format!("{}/organizations/{organizationId}/integrations/{integrationId}/configurations/{configurationId}/delete", configuration.base_path, organizationId=crate::apis::urlencode(p_organization_id.to_string()), integrationId=crate::apis::urlencode(p_integration_id.to_string()), configurationId=crate::apis::urlencode(p_configuration_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, - })) +// #[async_trait] +impl OrganizationIntegrationConfigurationApiClient { + pub async fn organizations_organization_id_integrations_integration_id_configurations_configuration_id_delete( + &self, + organization_id: uuid::Uuid, + integration_id: uuid::Uuid, + configuration_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}/integrations/{integrationId}/configurations/{configurationId}", local_var_configuration.base_path, organizationId=organization_id, integrationId=integration_id, configurationId=configuration_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_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 organizations_organization_id_integrations_integration_id_configurations_configuration_id_put( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - integration_id: uuid::Uuid, - configuration_id: uuid::Uuid, - organization_integration_configuration_request_model: Option< - models::OrganizationIntegrationConfigurationRequestModel, - >, -) -> Result< - models::OrganizationIntegrationConfigurationResponseModel, - Error< - OrganizationsOrganizationIdIntegrationsIntegrationIdConfigurationsConfigurationIdPutError, - >, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_integration_id = integration_id; - let p_configuration_id = configuration_id; - let p_organization_integration_configuration_request_model = - organization_integration_configuration_request_model; - - let uri_str = format!("{}/organizations/{organizationId}/integrations/{integrationId}/configurations/{configurationId}", configuration.base_path, organizationId=crate::apis::urlencode(p_organization_id.to_string()), integrationId=crate::apis::urlencode(p_integration_id.to_string()), configurationId=crate::apis::urlencode(p_configuration_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_integration_configuration_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::OrganizationIntegrationConfigurationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationIntegrationConfigurationResponseModel`")))), + pub async fn organizations_organization_id_integrations_integration_id_configurations_configuration_id_delete_post( + &self, + organization_id: uuid::Uuid, + integration_id: uuid::Uuid, + configuration_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}/integrations/{integrationId}/configurations/{configurationId}/delete", local_var_configuration.base_path, organizationId=organization_id, integrationId=integration_id, configurationId=configuration_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_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 organizations_organization_id_integrations_integration_id_configurations_get( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - integration_id: uuid::Uuid, -) -> Result< - Vec, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_integration_id = integration_id; - - let uri_str = format!( - "{}/organizations/{organizationId}/integrations/{integrationId}/configurations", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()), - integrationId = crate::apis::urlencode(p_integration_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::OrganizationIntegrationConfigurationResponseModel>`"))), - 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::OrganizationIntegrationConfigurationResponseModel>`")))), + pub async fn organizations_organization_id_integrations_integration_id_configurations_configuration_id_put( + &self, + organization_id: uuid::Uuid, + integration_id: uuid::Uuid, + configuration_id: uuid::Uuid, + organization_integration_configuration_request_model: Option< + models::OrganizationIntegrationConfigurationRequestModel, + >, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!("{}/organizations/{organizationId}/integrations/{integrationId}/configurations/{configurationId}", local_var_configuration.base_path, organizationId=organization_id, integrationId=integration_id, configurationId=configuration_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_token) = local_var_configuration.oauth_access_token { + 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_integration_configuration_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::OrganizationIntegrationConfigurationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationIntegrationConfigurationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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< - OrganizationsOrganizationIdIntegrationsIntegrationIdConfigurationsGetError, - > = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } -} -pub async fn organizations_organization_id_integrations_integration_id_configurations_post( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - integration_id: uuid::Uuid, - organization_integration_configuration_request_model: Option< - models::OrganizationIntegrationConfigurationRequestModel, - >, -) -> Result< - models::OrganizationIntegrationConfigurationResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_integration_id = integration_id; - let p_organization_integration_configuration_request_model = - organization_integration_configuration_request_model; - - let uri_str = format!( - "{}/organizations/{organizationId}/integrations/{integrationId}/configurations", - configuration.base_path, - organizationId = crate::apis::urlencode(p_organization_id.to_string()), - integrationId = crate::apis::urlencode(p_integration_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()); + pub async fn organizations_organization_id_integrations_integration_id_configurations_get( + &self, + organization_id: uuid::Uuid, + integration_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}/integrations/{integrationId}/configurations", + local_var_configuration.base_path, + organizationId = organization_id, + integrationId = integration_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_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::OrganizationIntegrationConfigurationResponseModel>`"))), + ContentType::Unsupported(local_var_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::OrganizationIntegrationConfigurationResponseModel>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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_organization_integration_configuration_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::OrganizationIntegrationConfigurationResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationIntegrationConfigurationResponseModel`")))), + + pub async fn organizations_organization_id_integrations_integration_id_configurations_post( + &self, + organization_id: uuid::Uuid, + integration_id: uuid::Uuid, + organization_integration_configuration_request_model: Option< + models::OrganizationIntegrationConfigurationRequestModel, + >, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/integrations/{integrationId}/configurations", + local_var_configuration.base_path, + organizationId = organization_id, + integrationId = integration_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_token) = local_var_configuration.oauth_access_token { + 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_integration_configuration_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::OrganizationIntegrationConfigurationResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationIntegrationConfigurationResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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< - OrganizationsOrganizationIdIntegrationsIntegrationIdConfigurationsPostError, - > = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) } } 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 2bf464a76..18cb02908 100644 --- a/crates/bitwarden-api-api/src/apis/organization_sponsorships_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_sponsorships_api.rs @@ -8,665 +8,617 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdDeleteError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organization_sponsorship_sponsored_sponsored_org_id_remove_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdRemovePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterprisePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`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_sponsored_friendly_name_revoke_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSponsoringOrgIdSponsoredFriendlyNameRevokeDeleteError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`organization_sponsorship_sponsoring_org_id_sponsored_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSponsoringOrgIdSponsoredGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSponsoringOrganizationIdDeleteError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organization_sponsorship_sponsoring_organization_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSponsoringOrganizationIdDeletePostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`organization_sponsorship_sync_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSyncPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait OrganizationSponsorshipsApi: Send + Sync { + + /// POST /organization/sponsorship/redeem + /// + /// + async fn organization_sponsorship_redeem_post(&self, sponsorship_token: Option<&str>, organization_sponsorship_redeem_request_model: Option) -> Result<(), Error>; + + /// DELETE /organization/sponsorship/sponsored/{sponsoredOrgId} + /// + /// + async fn organization_sponsorship_sponsored_sponsored_org_id_delete(&self, sponsored_org_id: uuid::Uuid) -> Result<(), Error>; + + /// POST /organization/sponsorship/sponsored/{sponsoredOrgId}/remove + /// + /// + async fn organization_sponsorship_sponsored_sponsored_org_id_remove_post(&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(&self, sponsoring_org_id: uuid::Uuid, organization_sponsorship_create_request_model: Option) -> Result<(), Error>; + + /// POST /organization/sponsorship/{sponsoringOrgId}/families-for-enterprise/resend + /// + /// + async fn organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post(&self, sponsoring_org_id: uuid::Uuid, sponsored_friendly_name: Option<&str>) -> Result<(), Error>; + + /// DELETE /organization/sponsorship/{sponsoringOrgId}/{sponsoredFriendlyName}/revoke + /// + /// + async fn organization_sponsorship_sponsoring_org_id_sponsored_friendly_name_revoke_delete(&self, sponsoring_org_id: uuid::Uuid, sponsored_friendly_name: &str) -> Result<(), Error>; + + /// GET /organization/sponsorship/{sponsoringOrgId}/sponsored + /// + /// + async fn organization_sponsorship_sponsoring_org_id_sponsored_get(&self, sponsoring_org_id: uuid::Uuid) -> Result; + + /// GET /organization/sponsorship/{sponsoringOrgId}/sync-status + /// + /// + async fn organization_sponsorship_sponsoring_org_id_sync_status_get(&self, sponsoring_org_id: uuid::Uuid) -> Result<(), Error>; + + /// DELETE /organization/sponsorship/{sponsoringOrganizationId} + /// + /// + async fn organization_sponsorship_sponsoring_organization_id_delete(&self, sponsoring_organization_id: uuid::Uuid) -> Result<(), Error>; + + /// POST /organization/sponsorship/{sponsoringOrganizationId}/delete + /// + /// + async fn organization_sponsorship_sponsoring_organization_id_delete_post(&self, sponsoring_organization_id: uuid::Uuid) -> Result<(), Error>; + + /// POST /organization/sponsorship/sync + /// + /// + async fn organization_sponsorship_sync_post(&self, organization_sponsorship_sync_request_model: Option) -> Result; + + /// POST /organization/sponsorship/validate-token + /// + /// + async fn organization_sponsorship_validate_token_post(&self, sponsorship_token: Option<&str>) -> Result; } +*/ -/// struct for typed errors of method [`organization_sponsorship_validate_token_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipValidateTokenPostError { - UnknownValue(serde_json::Value), +pub struct OrganizationSponsorshipsApiClient { + configuration: Arc, } -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, - })) +impl OrganizationSponsorshipsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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, - })) +// #[async_trait] +impl OrganizationSponsorshipsApiClient { + pub async fn organization_sponsorship_redeem_post( + &self, + sponsorship_token: Option<&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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_sponsored_sponsored_org_id_delete( + &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_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 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_sponsored_sponsored_org_id_remove_post( + &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_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 organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post( - configuration: &configuration::Configuration, - sponsoring_org_id: uuid::Uuid, - sponsored_friendly_name: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_org_id = sponsoring_org_id; - let p_sponsored_friendly_name = sponsored_friendly_name; - - 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 param_value) = p_sponsored_friendly_name { - req_builder = req_builder.query(&[("sponsoredFriendlyName", ¶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< - OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterpriseResendPostError, - > = 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( + &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_token) = local_var_configuration.oauth_access_token { + 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 = + serde_json::from_str(&local_var_content).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 organization_sponsorship_sponsoring_org_id_sponsored_friendly_name_revoke_delete( - configuration: &configuration::Configuration, - sponsoring_org_id: uuid::Uuid, - sponsored_friendly_name: &str, -) -> Result<(), Error> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_org_id = sponsoring_org_id; - let p_sponsored_friendly_name = sponsored_friendly_name; - - let uri_str = format!( - "{}/organization/sponsorship/{sponsoringOrgId}/{sponsoredFriendlyName}/revoke", - configuration.base_path, - sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string()), - sponsoredFriendlyName = crate::apis::urlencode(p_sponsored_friendly_name) - ); - 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< - OrganizationSponsorshipSponsoringOrgIdSponsoredFriendlyNameRevokeDeleteError, - > = 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( + &self, + sponsoring_org_id: uuid::Uuid, + sponsored_friendly_name: Option<&str>, + ) -> 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 param_value) = sponsored_friendly_name { + local_var_req_builder = + local_var_req_builder.query(&[("sponsoredFriendlyName", ¶m_value.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 = 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 organization_sponsorship_sponsoring_org_id_sponsored_get( - configuration: &configuration::Configuration, - sponsoring_org_id: uuid::Uuid, -) -> Result< - models::OrganizationSponsorshipInvitesResponseModelListResponseModel, - 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}/sponsored", - 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(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSponsorshipInvitesResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationSponsorshipInvitesResponseModelListResponseModel`")))), + pub async fn organization_sponsorship_sponsoring_org_id_sponsored_friendly_name_revoke_delete( + &self, + sponsoring_org_id: uuid::Uuid, + sponsored_friendly_name: &str, + ) -> 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}/{sponsoredFriendlyName}/revoke", + local_var_configuration.base_path, + sponsoringOrgId = sponsoring_org_id, + sponsoredFriendlyName = crate::apis::urlencode(sponsored_friendly_name) + ); + 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_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 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_org_id_sponsored_get( + &self, + sponsoring_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!( + "{}/organization/sponsorship/{sponsoringOrgId}/sponsored", + 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_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::OrganizationSponsorshipInvitesResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationSponsorshipInvitesResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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 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_org_id_sync_status_get( + &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_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 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_sponsoring_organization_id_delete( + &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_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 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`")))), + pub async fn organization_sponsorship_sponsoring_organization_id_delete_post( + &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_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 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()); + pub async fn organization_sponsorship_sync_post( + &self, + organization_sponsorship_sync_request_model: Option< + models::OrganizationSponsorshipSyncRequestModel, + >, + ) -> Result { + 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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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`")))), + + pub async fn organization_sponsorship_validate_token_post( + &self, + sponsorship_token: Option<&str>, + ) -> Result { + 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_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)) } - } 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 2936f5316..21613f2f5 100644 --- a/crates/bitwarden-api-api/src/apis/organization_users_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_users_api.rs @@ -8,2067 +8,1844 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersIdGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersMiniDetailsGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organizations_org_id_users_organization_user_id_accept_init_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersOrganizationUserIdAcceptInitPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdUsersRevokePutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`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`")))), +/* +#[async_trait] +pub trait OrganizationUsersApi: Send + Sync { + + /// POST /organizations/{orgId}/users/account-recovery-details + /// + /// + async fn organizations_org_id_users_account_recovery_details_post(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// POST /organizations/{orgId}/users/confirm + /// + /// + async fn organizations_org_id_users_confirm_post(&self, org_id: uuid::Uuid, organization_user_bulk_confirm_request_model: Option) -> Result; + + /// DELETE /organizations/{orgId}/users + /// + /// + async fn organizations_org_id_users_delete(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// DELETE /organizations/{orgId}/users/delete-account + /// + /// + async fn organizations_org_id_users_delete_account_delete(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// POST /organizations/{orgId}/users/delete-account + /// + /// + async fn organizations_org_id_users_delete_account_post(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// PATCH /organizations/{orgId}/users/enable-secrets-manager + /// + /// + async fn organizations_org_id_users_enable_secrets_manager_patch(&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(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result<(), Error>; + + /// GET /organizations/{orgId}/users + /// + /// + async fn organizations_org_id_users_get(&self, org_id: uuid::Uuid, include_groups: Option, include_collections: Option) -> Result; + + /// POST /organizations/{orgId}/users/{id}/confirm + /// + /// + async fn organizations_org_id_users_id_confirm_post(&self, org_id: uuid::Uuid, id: uuid::Uuid, organization_user_confirm_request_model: Option) -> Result<(), Error>; + + /// DELETE /organizations/{orgId}/users/{id} + /// + /// + async fn organizations_org_id_users_id_delete(&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(&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(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>; + + /// GET /organizations/{orgId}/users/{id} + /// + /// + async fn organizations_org_id_users_id_get(&self, org_id: uuid::Uuid, id: uuid::Uuid, include_groups: Option) -> Result; + + /// POST /organizations/{orgId}/users/{id} + /// + /// + async fn organizations_org_id_users_id_post(&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(&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(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /organizations/{orgId}/users/{id}/remove + /// + /// + async fn organizations_org_id_users_id_remove_post(&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(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result; + + /// PUT /organizations/{orgId}/users/{id}/reset-password + /// + /// + async fn organizations_org_id_users_id_reset_password_put(&self, org_id: uuid::Uuid, id: uuid::Uuid, organization_user_reset_password_request_model: Option) -> Result<(), Error>; + + /// PATCH /organizations/{orgId}/users/{id}/restore + /// + /// + async fn organizations_org_id_users_id_restore_patch(&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(&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(&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(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /organizations/{orgId}/users/invite + /// + /// + async fn organizations_org_id_users_invite_post(&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(&self, org_id: uuid::Uuid) -> Result; + + /// POST /organizations/{orgId}/users/{organizationUserId}/accept-init + /// + /// + async fn organizations_org_id_users_organization_user_id_accept_init_post(&self, org_id: uuid::Uuid, organization_user_id: uuid::Uuid, organization_user_accept_init_request_model: Option) -> Result<(), Error>; + + /// POST /organizations/{orgId}/users/{organizationUserId}/accept + /// + /// + async fn organizations_org_id_users_organization_user_id_accept_post(&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(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// POST /organizations/{orgId}/users/reinvite + /// + /// + async fn organizations_org_id_users_reinvite_post(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// POST /organizations/{orgId}/users/remove + /// + /// + async fn organizations_org_id_users_remove_post(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// PATCH /organizations/{orgId}/users/restore + /// + /// + async fn organizations_org_id_users_restore_patch(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// PUT /organizations/{orgId}/users/restore + /// + /// + async fn organizations_org_id_users_restore_put(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// PATCH /organizations/{orgId}/users/revoke + /// + /// + async fn organizations_org_id_users_revoke_patch(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// PUT /organizations/{orgId}/users/revoke + /// + /// + async fn organizations_org_id_users_revoke_put(&self, org_id: uuid::Uuid, organization_user_bulk_request_model: Option) -> Result; + + /// PUT /organizations/{orgId}/users/{userId}/reset-password-enrollment + /// + /// + async fn organizations_org_id_users_user_id_reset_password_enrollment_put(&self, org_id: uuid::Uuid, user_id: uuid::Uuid, organization_user_reset_password_enrollment_request_model: Option) -> Result<(), Error>; +} +*/ + +pub struct OrganizationUsersApiClient { + configuration: Arc, +} + +impl OrganizationUsersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +// #[async_trait] +impl OrganizationUsersApiClient { + pub async fn organizations_org_id_users_account_recovery_details_post( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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: uuid::Uuid, - 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.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_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`")))), + pub async fn organizations_org_id_users_confirm_post( + &self, + org_id: uuid::Uuid, + organization_user_bulk_confirm_request_model: Option< + models::OrganizationUserBulkConfirmRequestModel, + >, + ) -> Result { + 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 = 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_users_delete( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_users_delete_account_delete( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_users_delete_account_post( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_patch( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_enable_secrets_manager_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn organizations_org_id_users_get( + &self, + org_id: uuid::Uuid, + include_groups: Option, + include_collections: Option, + ) -> Result { + 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_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)) } - } else { - 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: uuid::Uuid, - id: uuid::Uuid, - 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.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_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_confirm_post( + &self, + org_id: uuid::Uuid, + 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!( + "{}/organizations/{orgId}/users/{id}/confirm", + 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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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( + &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}", + 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_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 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_delete( + &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_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 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_delete_account_post( + &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_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 organizations_org_id_users_id_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, - include_groups: Option, -) -> Result> -{ - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_id = id; - let p_include_groups = include_groups; - - 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::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`")))), + pub async fn organizations_org_id_users_id_get( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + include_groups: Option, + ) -> Result { + 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::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_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)) } - } else { - 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_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -pub async fn organizations_org_id_users_id_reinvite_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}/reinvite", - 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_reinvite_post( + &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}/reinvite", + 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_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 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_remove_post( + &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_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 organizations_org_id_users_id_reset_password_details_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - id: uuid::Uuid, -) -> 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.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::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`")))), + pub async fn organizations_org_id_users_id_reset_password_details_get( + &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}/users/{id}/reset-password-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_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)) } - } else { - 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: uuid::Uuid, - id: uuid::Uuid, - 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.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_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_reset_password_put( + &self, + org_id: uuid::Uuid, + id: uuid::Uuid, + 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 = 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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_patch( + &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_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 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_restore_put( + &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_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 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_patch( + &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_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 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_id_revoke_put( + &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_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 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_invite_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn organizations_org_id_users_mini_details_get( + &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}/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_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)) } - } else { - 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_init_post( + &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_token) = local_var_configuration.oauth_access_token { + 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 = + serde_json::from_str(&local_var_content).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 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_organization_user_id_accept_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -pub async fn organizations_org_id_users_public_keys_post( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - 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.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::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`")))), + pub async fn organizations_org_id_users_public_keys_post( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/users/public-keys", + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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: 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/reinvite", - 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`")))), + pub async fn organizations_org_id_users_reinvite_post( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/users/reinvite", + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_users_remove_post( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_users_restore_patch( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_users_restore_put( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_users_revoke_patch( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_org_id_users_revoke_put( + &self, + org_id: uuid::Uuid, + organization_user_bulk_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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, - })) + pub async fn organizations_org_id_users_user_id_reset_password_enrollment_put( + &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_token) = local_var_configuration.oauth_access_token { + 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 = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/organizations_api.rs b/crates/bitwarden-api-api/src/apis/organizations_api.rs index 653cf455b..a8bd0a3fb 100644 --- a/crates/bitwarden-api-api/src/apis/organizations_api.rs +++ b/crates/bitwarden-api-api/src/apis/organizations_api.rs @@ -8,1982 +8,1833 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdApiKeyPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdCollectionManagementPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdDeleteRecoverTokenPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdKeysGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdLeavePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`organizations_id_license_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdLicenseGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdPublicKeyGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdRotateApiKeyPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdSmSubscriptionPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdSsoPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdSubscribeSecretsManagerPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdSubscriptionPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdTaxPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdentifierAutoEnrollStatusGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`")))), +/* +#[async_trait] +pub trait OrganizationsApi: Send + Sync { + + /// POST /organizations/create-without-payment + /// + /// + async fn organizations_create_without_payment_post(&self, organization_no_payment_create_request: Option) -> Result; + + /// GET /organizations + /// + /// + async fn organizations_get(&self, ) -> Result; + + /// GET /organizations/{id}/api-key-information/{type} + /// + /// + async fn organizations_id_api_key_information_type_get(&self, id: uuid::Uuid, r#type: models::OrganizationApiKeyType) -> Result; + + /// POST /organizations/{id}/api-key + /// + /// + async fn organizations_id_api_key_post(&self, id: &str, organization_api_key_request_model: Option) -> Result; + + /// POST /organizations/{id}/cancel + /// + /// + async fn organizations_id_cancel_post(&self, id: uuid::Uuid, subscription_cancellation_request_model: Option) -> Result<(), Error>; + + /// PUT /organizations/{id}/collection-management + /// + /// + async fn organizations_id_collection_management_put(&self, id: uuid::Uuid, organization_collection_management_update_request_model: Option) -> Result; + + /// DELETE /organizations/{id} + /// + /// + async fn organizations_id_delete(&self, id: &str, secret_verification_request_model: Option) -> Result<(), Error>; + + /// POST /organizations/{id}/delete + /// + /// + async fn organizations_id_delete_post(&self, id: &str, secret_verification_request_model: Option) -> Result<(), Error>; + + /// POST /organizations/{id}/delete-recover-token + /// + /// + async fn organizations_id_delete_recover_token_post(&self, id: uuid::Uuid, organization_verify_delete_recover_request_model: Option) -> Result<(), Error>; + + /// GET /organizations/{id} + /// + /// + async fn organizations_id_get(&self, id: &str) -> Result; + + /// GET /organizations/{id}/keys + /// + /// + async fn organizations_id_keys_get(&self, id: &str) -> Result; + + /// POST /organizations/{id}/keys + /// + /// + async fn organizations_id_keys_post(&self, id: uuid::Uuid, organization_keys_request_model: Option) -> Result; + + /// POST /organizations/{id}/leave + /// + /// + async fn organizations_id_leave_post(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// GET /organizations/{id}/license + /// + /// + async fn organizations_id_license_get(&self, id: uuid::Uuid, installation_id: Option) -> Result; + + /// GET /organizations/{id}/plan-type + /// + /// + async fn organizations_id_plan_type_get(&self, id: &str) -> Result; + + /// POST /organizations/{id} + /// + /// + async fn organizations_id_post(&self, id: &str, organization_update_request_model: Option) -> Result; + + /// GET /organizations/{id}/public-key + /// + /// + async fn organizations_id_public_key_get(&self, id: &str) -> Result; + + /// PUT /organizations/{id} + /// + /// + async fn organizations_id_put(&self, id: &str, organization_update_request_model: Option) -> Result; + + /// POST /organizations/{id}/reinstate + /// + /// + async fn organizations_id_reinstate_post(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /organizations/{id}/rotate-api-key + /// + /// + async fn organizations_id_rotate_api_key_post(&self, id: &str, organization_api_key_request_model: Option) -> Result; + + /// POST /organizations/{id}/seat + /// + /// + async fn organizations_id_seat_post(&self, id: uuid::Uuid, organization_seat_request_model: Option) -> Result; + + /// POST /organizations/{id}/sm-subscription + /// + /// + async fn organizations_id_sm_subscription_post(&self, id: uuid::Uuid, secrets_manager_subscription_update_request_model: Option) -> Result; + + /// GET /organizations/{id}/sso + /// + /// + async fn organizations_id_sso_get(&self, id: uuid::Uuid) -> Result; + + /// POST /organizations/{id}/sso + /// + /// + async fn organizations_id_sso_post(&self, id: uuid::Uuid, organization_sso_request_model: Option) -> Result; + + /// POST /organizations/{id}/storage + /// + /// + async fn organizations_id_storage_post(&self, id: &str, storage_request_model: Option) -> Result; + + /// POST /organizations/{id}/subscribe-secrets-manager + /// + /// + async fn organizations_id_subscribe_secrets_manager_post(&self, id: uuid::Uuid, secrets_manager_subscribe_request_model: Option) -> Result; + + /// GET /organizations/{id}/subscription + /// + /// + async fn organizations_id_subscription_get(&self, id: uuid::Uuid) -> Result; + + /// POST /organizations/{id}/subscription + /// + /// + async fn organizations_id_subscription_post(&self, id: uuid::Uuid, organization_subscription_update_request_model: Option) -> Result; + + /// GET /organizations/{id}/tax + /// + /// + async fn organizations_id_tax_get(&self, id: uuid::Uuid) -> Result; + + /// PUT /organizations/{id}/tax + /// + /// + async fn organizations_id_tax_put(&self, id: uuid::Uuid, expanded_tax_info_update_request_model: Option) -> Result<(), Error>; + + /// POST /organizations/{id}/upgrade + /// + /// + async fn organizations_id_upgrade_post(&self, id: uuid::Uuid, organization_upgrade_request_model: Option) -> Result; + + /// POST /organizations/{id}/verify-bank + /// + /// + async fn organizations_id_verify_bank_post(&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(&self, identifier: &str) -> Result; + + /// POST /organizations + /// + /// + async fn organizations_post(&self, organization_create_request_model: Option) -> Result; +} +*/ + +pub struct OrganizationsApiClient { + configuration: Arc, +} + +impl OrganizationsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +// #[async_trait] +impl OrganizationsApiClient { + pub async fn organizations_create_without_payment_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_get( + &self, + ) -> 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::GET, local_var_uri_str.as_str()); + + if let Some(ref 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)) } - } else { - 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`")))), + pub async fn organizations_id_api_key_information_type_get( + &self, + id: uuid::Uuid, + r#type: models::OrganizationApiKeyType, + ) -> 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-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_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)) } - } else { - 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`")))), + pub async fn organizations_id_api_key_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_cancel_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn organizations_id_collection_management_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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 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_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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 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_delete_recover_token_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn organizations_id_get( + &self, + id: &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_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)) } - } else { - 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`")))), + pub async fn organizations_id_keys_get( + &self, + id: &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_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)) } - } else { - 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: uuid::Uuid, - 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.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_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`")))), + pub async fn organizations_id_keys_post( + &self, + id: uuid::Uuid, + 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 = 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_leave_post(&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_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 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`")))), + pub async fn organizations_id_license_get( + &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_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)) } - } else { - 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`")))), + pub async fn organizations_id_plan_type_get( + &self, + id: &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_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)) } - } else { - 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`")))), + pub async fn organizations_id_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_public_key_get( + &self, + id: &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_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)) } - } else { - 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`")))), + pub async fn organizations_id_put( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_reinstate_post(&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_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 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`")))), + pub async fn organizations_id_rotate_api_key_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_seat_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_sm_subscription_post( + &self, + id: uuid::Uuid, + secrets_manager_subscription_update_request_model: Option< + models::SecretsManagerSubscriptionUpdateRequestModel, + >, + ) -> Result { + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_sso_get( + &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_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)) } - } else { - 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`")))), + pub async fn organizations_id_sso_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_storage_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_subscribe_secrets_manager_post( + &self, + id: uuid::Uuid, + secrets_manager_subscribe_request_model: Option< + models::SecretsManagerSubscribeRequestModel, + >, + ) -> Result { + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_subscription_get( + &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}/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_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)) } - } else { - 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`")))), + pub async fn organizations_id_subscription_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_tax_get( + &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}/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_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)) } - } else { - 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_tax_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn organizations_id_upgrade_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_id_verify_bank_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn organizations_identifier_auto_enroll_status_get( + &self, + identifier: &str, + ) -> Result { + 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_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)) } - } else { - 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`")))), + pub async fn organizations_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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/phishing_domains_api.rs b/crates/bitwarden-api-api/src/apis/phishing_domains_api.rs index 4e963327a..7d1011e65 100644 --- a/crates/bitwarden-api-api/src/apis/phishing_domains_api.rs +++ b/crates/bitwarden-api-api/src/apis/phishing_domains_api.rs @@ -8,106 +8,130 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`phishing_domains_checksum_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PhishingDomainsChecksumGetError { - UnknownValue(serde_json::Value), -} +/* +#[async_trait] +pub trait PhishingDomainsApi: Send + Sync { -/// struct for typed errors of method [`phishing_domains_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PhishingDomainsGetError { - UnknownValue(serde_json::Value), + /// GET /phishing-domains/checksum + /// + /// + async fn phishing_domains_checksum_get(&self, ) -> Result; + + /// GET /phishing-domains + /// + /// + async fn phishing_domains_get(&self, ) -> Result, Error>; } +*/ -pub async fn phishing_domains_checksum_get( - configuration: &configuration::Configuration, -) -> Result> { - let uri_str = format!("{}/phishing-domains/checksum", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +pub struct PhishingDomainsApiClient { + configuration: Arc, +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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, - })) +impl PhishingDomainsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -pub async fn phishing_domains_get( - configuration: &configuration::Configuration, -) -> Result, Error> { - let uri_str = format!("{}/phishing-domains", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); +// #[async_trait] +impl PhishingDomainsApiClient { + pub async fn phishing_domains_checksum_get(&self) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/phishing-domains/checksum", + 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_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, 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)) + } } - 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>`")))), + + pub async fn phishing_domains_get(&self) -> Result, Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!("{}/phishing-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 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)) } - } 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..7d63f0e44 100644 --- a/crates/bitwarden-api-api/src/apis/plans_api.rs +++ b/crates/bitwarden-api-api/src/apis/plans_api.rs @@ -8,57 +8,80 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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, +}; + +/* +#[async_trait] +pub trait PlansApi: Send + Sync { -/// struct for typed errors of method [`plans_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PlansGetError { - UnknownValue(serde_json::Value), + /// GET /plans + /// + /// + async fn plans_get(&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] +impl PlansApiClient { + pub async fn plans_get(&self) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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()); + + if let Some(ref 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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content_type = resp - .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_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/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, - })) } } diff --git a/crates/bitwarden-api-api/src/apis/policies_api.rs b/crates/bitwarden-api-api/src/apis/policies_api.rs index 0418f6fa9..ce4ef1eaa 100644 --- a/crates/bitwarden-api-api/src/apis/policies_api.rs +++ b/crates/bitwarden-api-api/src/apis/policies_api.rs @@ -8,382 +8,373 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdPoliciesMasterPasswordGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`organizations_org_id_policies_token_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdPoliciesTokenGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait PoliciesApi: Send + Sync { + + /// GET /organizations/{orgId}/policies + /// + /// + async fn organizations_org_id_policies_get(&self, org_id: &str) -> Result; + + /// GET /organizations/{orgId}/policies/invited-user + /// + /// + async fn organizations_org_id_policies_invited_user_get(&self, org_id: uuid::Uuid, user_id: Option) -> Result; + + /// GET /organizations/{orgId}/policies/master-password + /// + /// + async fn organizations_org_id_policies_master_password_get(&self, org_id: uuid::Uuid) -> Result; + + /// GET /organizations/{orgId}/policies/token + /// + /// + async fn organizations_org_id_policies_token_get(&self, org_id: uuid::Uuid, email: Option<&str>, token: Option<&str>, organization_user_id: Option) -> Result; + + /// GET /organizations/{orgId}/policies/{type} + /// + /// + async fn organizations_org_id_policies_type_get(&self, org_id: uuid::Uuid, r#type: i32) -> Result; + + /// PUT /organizations/{orgId}/policies/{type} + /// + /// + async fn organizations_org_id_policies_type_put(&self, org_id: uuid::Uuid, r#type: models::PolicyType, policy_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`organizations_org_id_policies_type_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdPoliciesTypeGetError { - UnknownValue(serde_json::Value), +pub struct PoliciesApiClient { + configuration: Arc, } -/// struct for typed errors of method [`organizations_org_id_policies_type_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrgIdPoliciesTypePutError { - UnknownValue(serde_json::Value), +impl PoliciesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl PoliciesApiClient { + pub async fn organizations_org_id_policies_get( + &self, + org_id: &str, + ) -> Result { + 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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_policies_invited_user_get( + &self, + org_id: uuid::Uuid, + user_id: 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/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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_policies_master_password_get( + &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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_policies_token_get( + &self, + org_id: uuid::Uuid, + email: Option<&str>, + token: Option<&str>, + organization_user_id: 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/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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_policies_type_get( + &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_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)) } - } else { - 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`")))), + pub async fn organizations_org_id_policies_type_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..74ce4e311 100644 --- a/crates/bitwarden-api-api/src/apis/projects_api.rs +++ b/crates/bitwarden-api-api/src/apis/projects_api.rs @@ -8,305 +8,304 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdProjectsPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`projects_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProjectsDeletePostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait ProjectsApi: Send + Sync { + + /// GET /organizations/{organizationId}/projects + /// + /// + async fn organizations_organization_id_projects_get(&self, organization_id: uuid::Uuid) -> Result; + + /// POST /organizations/{organizationId}/projects + /// + /// + async fn organizations_organization_id_projects_post(&self, organization_id: uuid::Uuid, project_create_request_model: Option) -> Result; + + /// POST /projects/delete + /// + /// + async fn projects_delete_post(&self, uuid_colon_colon_uuid: Option>) -> Result; + + /// GET /projects/{id} + /// + /// + async fn projects_id_get(&self, id: uuid::Uuid) -> Result; + + /// PUT /projects/{id} + /// + /// + async fn projects_id_put(&self, id: uuid::Uuid, project_update_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`projects_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProjectsIdGetError { - UnknownValue(serde_json::Value), +pub struct ProjectsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`projects_id_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProjectsIdPutError { - UnknownValue(serde_json::Value), +impl ProjectsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl ProjectsApiClient { + pub async fn organizations_organization_id_projects_get( + &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!( + "{}/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_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)) } - } else { - 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`")))), + pub async fn organizations_organization_id_projects_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn projects_delete_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn projects_id_get( + &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_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)) } - } else { - 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`")))), + pub async fn projects_id_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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 f70d9ca9f..8d62d5b15 100644 --- a/crates/bitwarden-api-api/src/apis/provider_billing_api.rs +++ b/crates/bitwarden-api-api/src/apis/provider_billing_api.rs @@ -8,352 +8,349 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingInvoicesInvoiceIdGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`providers_provider_id_billing_payment_method_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingPaymentMethodPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`providers_provider_id_billing_payment_method_verify_bank_account_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingPaymentMethodVerifyBankAccountPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingTaxInformationGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait ProviderBillingApi: Send + Sync { + + /// GET /providers/{providerId}/billing/invoices + /// + /// + async fn providers_provider_id_billing_invoices_get(&self, provider_id: uuid::Uuid) -> Result<(), Error>; + + /// GET /providers/{providerId}/billing/invoices/{invoiceId} + /// + /// + async fn providers_provider_id_billing_invoices_invoice_id_get(&self, provider_id: uuid::Uuid, invoice_id: &str) -> Result<(), Error>; + + /// PUT /providers/{providerId}/billing/payment-method + /// + /// + async fn providers_provider_id_billing_payment_method_put(&self, provider_id: uuid::Uuid, update_payment_method_request_body: Option) -> Result<(), Error>; + + /// POST /providers/{providerId}/billing/payment-method/verify-bank-account + /// + /// + async fn providers_provider_id_billing_payment_method_verify_bank_account_post(&self, provider_id: uuid::Uuid, verify_bank_account_request_body: Option) -> Result<(), Error>; + + /// GET /providers/{providerId}/billing/subscription + /// + /// + async fn providers_provider_id_billing_subscription_get(&self, provider_id: uuid::Uuid) -> Result<(), Error>; + + /// GET /providers/{providerId}/billing/tax-information + /// + /// + async fn providers_provider_id_billing_tax_information_get(&self, provider_id: uuid::Uuid) -> Result<(), Error>; + + /// PUT /providers/{providerId}/billing/tax-information + /// + /// + async fn providers_provider_id_billing_tax_information_put(&self, provider_id: uuid::Uuid, tax_information_request_body: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`providers_provider_id_billing_tax_information_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingTaxInformationPutError { - UnknownValue(serde_json::Value), +pub struct ProviderBillingApiClient { + configuration: Arc, } -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, - })) +impl ProviderBillingApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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, - })) +// #[async_trait] +impl ProviderBillingApiClient { + pub async fn providers_provider_id_billing_invoices_get( + &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_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 providers_provider_id_billing_payment_method_put( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - update_payment_method_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_update_payment_method_request_body = update_payment_method_request_body; - - let uri_str = format!( - "{}/providers/{providerId}/billing/payment-method", - 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()); + pub async fn providers_provider_id_billing_invoices_invoice_id_get( + &self, + provider_id: uuid::Uuid, + invoice_id: &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_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 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 providers_provider_id_billing_payment_method_verify_bank_account_post( - configuration: &configuration::Configuration, - provider_id: uuid::Uuid, - verify_bank_account_request_body: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_verify_bank_account_request_body = verify_bank_account_request_body; - - let uri_str = format!( - "{}/providers/{providerId}/billing/payment-method/verify-bank-account", - 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_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 = - serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + pub async fn providers_provider_id_billing_payment_method_put( + &self, + provider_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!( + "{}/providers/{providerId}/billing/payment-method", + 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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_payment_method_verify_bank_account_post( + &self, + provider_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!( + "{}/providers/{providerId}/billing/payment-method/verify-bank-account", + 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_token) = local_var_configuration.oauth_access_token { + 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 = + serde_json::from_str(&local_var_content).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 providers_provider_id_billing_tax_information_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/tax-information", - 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()); + pub async fn providers_provider_id_billing_subscription_get( + &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()); + + if let Some(ref 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 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()); + pub async fn providers_provider_id_billing_tax_information_get( + &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/tax-information", + 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_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 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 providers_provider_id_billing_tax_information_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/provider_billing_v_next_api.rs b/crates/bitwarden-api-api/src/apis/provider_billing_v_next_api.rs index 7a762e33e..cb38d4788 100644 --- a/crates/bitwarden-api-api/src/apis/provider_billing_v_next_api.rs +++ b/crates/bitwarden-api-api/src/apis/provider_billing_v_next_api.rs @@ -8,1054 +8,1049 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`providers_provider_id_billing_vnext_address_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingVnextAddressGetError { - UnknownValue(serde_json::Value), -} +/* +#[async_trait] +pub trait ProviderBillingVNextApi: Send + Sync { -/// struct for typed errors of method [`providers_provider_id_billing_vnext_address_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingVnextAddressPutError { - UnknownValue(serde_json::Value), -} + /// GET /providers/{providerId}/billing/vnext/address + /// + /// + async fn providers_provider_id_billing_vnext_address_get(&self, provider_id: &str, id: Option, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, billing_phone: Option<&str>, status: Option, use_events: Option, r#type: Option, enabled: Option, creation_date: Option, revision_date: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, discount_id: Option<&str>) -> Result<(), Error>; -/// struct for typed errors of method [`providers_provider_id_billing_vnext_credit_bitpay_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingVnextCreditBitpayPostError { - UnknownValue(serde_json::Value), -} + /// PUT /providers/{providerId}/billing/vnext/address + /// + /// + async fn providers_provider_id_billing_vnext_address_put(&self, provider_id: &str, id: Option, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, billing_phone: Option<&str>, status: Option, use_events: Option, r#type: Option, enabled: Option, creation_date: Option, revision_date: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, discount_id: Option<&str>, billing_address_request: Option) -> Result<(), Error>; -/// struct for typed errors of method [`providers_provider_id_billing_vnext_credit_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingVnextCreditGetError { - UnknownValue(serde_json::Value), -} + /// POST /providers/{providerId}/billing/vnext/credit/bitpay + /// + /// + async fn providers_provider_id_billing_vnext_credit_bitpay_post(&self, provider_id: &str, id: Option, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, billing_phone: Option<&str>, status: Option, use_events: Option, r#type: Option, enabled: Option, creation_date: Option, revision_date: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, discount_id: Option<&str>, bit_pay_credit_request: Option) -> Result<(), Error>; -/// struct for typed errors of method [`providers_provider_id_billing_vnext_payment_method_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingVnextPaymentMethodGetError { - UnknownValue(serde_json::Value), + /// GET /providers/{providerId}/billing/vnext/credit + /// + /// + async fn providers_provider_id_billing_vnext_credit_get(&self, provider_id: &str, id: Option, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, billing_phone: Option<&str>, status: Option, use_events: Option, r#type: Option, enabled: Option, creation_date: Option, revision_date: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, discount_id: Option<&str>) -> Result<(), Error>; + + /// GET /providers/{providerId}/billing/vnext/payment-method + /// + /// + async fn providers_provider_id_billing_vnext_payment_method_get(&self, provider_id: &str, id: Option, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, billing_phone: Option<&str>, status: Option, use_events: Option, r#type: Option, enabled: Option, creation_date: Option, revision_date: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, discount_id: Option<&str>) -> Result<(), Error>; + + /// PUT /providers/{providerId}/billing/vnext/payment-method + /// + /// + async fn providers_provider_id_billing_vnext_payment_method_put(&self, provider_id: &str, id: Option, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, billing_phone: Option<&str>, status: Option, use_events: Option, r#type: Option, enabled: Option, creation_date: Option, revision_date: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, discount_id: Option<&str>, tokenized_payment_method_request: Option) -> Result<(), Error>; + + /// POST /providers/{providerId}/billing/vnext/payment-method/verify-bank-account + /// + /// + async fn providers_provider_id_billing_vnext_payment_method_verify_bank_account_post(&self, provider_id: &str, id: Option, name: Option<&str>, business_name: Option<&str>, business_address1: Option<&str>, business_address2: Option<&str>, business_address3: Option<&str>, business_country: Option<&str>, business_tax_number: Option<&str>, billing_email: Option<&str>, billing_phone: Option<&str>, status: Option, use_events: Option, r#type: Option, enabled: Option, creation_date: Option, revision_date: Option, gateway: Option, gateway_customer_id: Option<&str>, gateway_subscription_id: Option<&str>, discount_id: Option<&str>, verify_bank_account_request: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`providers_provider_id_billing_vnext_payment_method_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingVnextPaymentMethodPutError { - UnknownValue(serde_json::Value), +pub struct ProviderBillingVNextApiClient { + configuration: Arc, } -/// struct for typed errors of method -/// [`providers_provider_id_billing_vnext_payment_method_verify_bank_account_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdBillingVnextPaymentMethodVerifyBankAccountPostError { - UnknownValue(serde_json::Value), +impl ProviderBillingVNextApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn providers_provider_id_billing_vnext_address_get( - configuration: &configuration::Configuration, - provider_id: &str, - id: Option, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - billing_phone: Option<&str>, - status: Option, - use_events: Option, - r#type: Option, - enabled: Option, - creation_date: Option, - revision_date: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - discount_id: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - let p_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_billing_phone = billing_phone; - let p_status = status; - let p_use_events = use_events; - let p_type = r#type; - let p_enabled = enabled; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_discount_id = discount_id; +// #[async_trait] +impl ProviderBillingVNextApiClient { + pub async fn providers_provider_id_billing_vnext_address_get( + &self, + provider_id: &str, + id: Option, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + billing_phone: Option<&str>, + status: Option, + use_events: Option, + r#type: Option, + enabled: Option, + creation_date: Option, + revision_date: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + discount_id: Option<&str>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/providers/{providerId}/billing/vnext/address", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/vnext/address", + local_var_configuration.base_path, + providerId = crate::apis::urlencode(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) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_phone { - req_builder = req_builder.query(&[("billingPhone", ¶m_value.to_string())]); - } - 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_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_type { - req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_discount_id { - req_builder = req_builder.query(&[("discountId", ¶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()); - }; + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_phone { + local_var_req_builder = + local_var_req_builder.query(&[("billingPhone", ¶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 param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = r#type { + local_var_req_builder = + local_var_req_builder.query(&[("type", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = discount_id { + local_var_req_builder = + local_var_req_builder.query(&[("discountId", ¶m_value.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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 providers_provider_id_billing_vnext_address_put( - configuration: &configuration::Configuration, - provider_id: &str, - id: Option, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - billing_phone: Option<&str>, - status: Option, - use_events: Option, - r#type: Option, - enabled: Option, - creation_date: Option, - revision_date: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - discount_id: Option<&str>, - billing_address_request: 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_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_billing_phone = billing_phone; - let p_status = status; - let p_use_events = use_events; - let p_type = r#type; - let p_enabled = enabled; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_discount_id = discount_id; - let p_billing_address_request = billing_address_request; + pub async fn providers_provider_id_billing_vnext_address_put( + &self, + provider_id: &str, + id: Option, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + billing_phone: Option<&str>, + status: Option, + use_events: Option, + r#type: Option, + enabled: Option, + creation_date: Option, + revision_date: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + discount_id: Option<&str>, + billing_address_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/providers/{providerId}/billing/vnext/address", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/vnext/address", + local_var_configuration.base_path, + providerId = crate::apis::urlencode(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 param_value) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_phone { - req_builder = req_builder.query(&[("billingPhone", ¶m_value.to_string())]); - } - 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_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_type { - req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_discount_id { - req_builder = req_builder.query(&[("discountId", ¶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_billing_address_request); + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_phone { + local_var_req_builder = + local_var_req_builder.query(&[("billingPhone", ¶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 param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = r#type { + local_var_req_builder = + local_var_req_builder.query(&[("type", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = discount_id { + local_var_req_builder = + local_var_req_builder.query(&[("discountId", ¶m_value.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()); + }; + local_var_req_builder = local_var_req_builder.json(&billing_address_request); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 providers_provider_id_billing_vnext_credit_bitpay_post( - configuration: &configuration::Configuration, - provider_id: &str, - id: Option, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - billing_phone: Option<&str>, - status: Option, - use_events: Option, - r#type: Option, - enabled: Option, - creation_date: Option, - revision_date: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - discount_id: Option<&str>, - bit_pay_credit_request: 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_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_billing_phone = billing_phone; - let p_status = status; - let p_use_events = use_events; - let p_type = r#type; - let p_enabled = enabled; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_discount_id = discount_id; - let p_bit_pay_credit_request = bit_pay_credit_request; + pub async fn providers_provider_id_billing_vnext_credit_bitpay_post( + &self, + provider_id: &str, + id: Option, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + billing_phone: Option<&str>, + status: Option, + use_events: Option, + r#type: Option, + enabled: Option, + creation_date: Option, + revision_date: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + discount_id: Option<&str>, + bit_pay_credit_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/providers/{providerId}/billing/vnext/credit/bitpay", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/vnext/credit/bitpay", + local_var_configuration.base_path, + providerId = crate::apis::urlencode(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 param_value) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_phone { - req_builder = req_builder.query(&[("billingPhone", ¶m_value.to_string())]); - } - 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_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_type { - req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_discount_id { - req_builder = req_builder.query(&[("discountId", ¶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_bit_pay_credit_request); + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_phone { + local_var_req_builder = + local_var_req_builder.query(&[("billingPhone", ¶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 param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = r#type { + local_var_req_builder = + local_var_req_builder.query(&[("type", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = discount_id { + local_var_req_builder = + local_var_req_builder.query(&[("discountId", ¶m_value.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()); + }; + local_var_req_builder = local_var_req_builder.json(&bit_pay_credit_request); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 providers_provider_id_billing_vnext_credit_get( - configuration: &configuration::Configuration, - provider_id: &str, - id: Option, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - billing_phone: Option<&str>, - status: Option, - use_events: Option, - r#type: Option, - enabled: Option, - creation_date: Option, - revision_date: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - discount_id: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - let p_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_billing_phone = billing_phone; - let p_status = status; - let p_use_events = use_events; - let p_type = r#type; - let p_enabled = enabled; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_discount_id = discount_id; + pub async fn providers_provider_id_billing_vnext_credit_get( + &self, + provider_id: &str, + id: Option, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + billing_phone: Option<&str>, + status: Option, + use_events: Option, + r#type: Option, + enabled: Option, + creation_date: Option, + revision_date: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + discount_id: Option<&str>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/providers/{providerId}/billing/vnext/credit", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/vnext/credit", + local_var_configuration.base_path, + providerId = crate::apis::urlencode(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) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_phone { - req_builder = req_builder.query(&[("billingPhone", ¶m_value.to_string())]); - } - 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_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_type { - req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_discount_id { - req_builder = req_builder.query(&[("discountId", ¶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()); - }; + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_phone { + local_var_req_builder = + local_var_req_builder.query(&[("billingPhone", ¶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 param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = r#type { + local_var_req_builder = + local_var_req_builder.query(&[("type", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = discount_id { + local_var_req_builder = + local_var_req_builder.query(&[("discountId", ¶m_value.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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 providers_provider_id_billing_vnext_payment_method_get( - configuration: &configuration::Configuration, - provider_id: &str, - id: Option, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - billing_phone: Option<&str>, - status: Option, - use_events: Option, - r#type: Option, - enabled: Option, - creation_date: Option, - revision_date: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - discount_id: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_provider_id = provider_id; - let p_id = id; - let p_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_billing_phone = billing_phone; - let p_status = status; - let p_use_events = use_events; - let p_type = r#type; - let p_enabled = enabled; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_discount_id = discount_id; + pub async fn providers_provider_id_billing_vnext_payment_method_get( + &self, + provider_id: &str, + id: Option, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + billing_phone: Option<&str>, + status: Option, + use_events: Option, + r#type: Option, + enabled: Option, + creation_date: Option, + revision_date: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + discount_id: Option<&str>, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/providers/{providerId}/billing/vnext/payment-method", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/vnext/payment-method", + local_var_configuration.base_path, + providerId = crate::apis::urlencode(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) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_phone { - req_builder = req_builder.query(&[("billingPhone", ¶m_value.to_string())]); - } - 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_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_type { - req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_discount_id { - req_builder = req_builder.query(&[("discountId", ¶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()); - }; + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_phone { + local_var_req_builder = + local_var_req_builder.query(&[("billingPhone", ¶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 param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = r#type { + local_var_req_builder = + local_var_req_builder.query(&[("type", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = discount_id { + local_var_req_builder = + local_var_req_builder.query(&[("discountId", ¶m_value.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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 providers_provider_id_billing_vnext_payment_method_put( - configuration: &configuration::Configuration, - provider_id: &str, - id: Option, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - billing_phone: Option<&str>, - status: Option, - use_events: Option, - r#type: Option, - enabled: Option, - creation_date: Option, - revision_date: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - discount_id: Option<&str>, - tokenized_payment_method_request: 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_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_billing_phone = billing_phone; - let p_status = status; - let p_use_events = use_events; - let p_type = r#type; - let p_enabled = enabled; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_discount_id = discount_id; - let p_tokenized_payment_method_request = tokenized_payment_method_request; + pub async fn providers_provider_id_billing_vnext_payment_method_put( + &self, + provider_id: &str, + id: Option, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + billing_phone: Option<&str>, + status: Option, + use_events: Option, + r#type: Option, + enabled: Option, + creation_date: Option, + revision_date: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + discount_id: Option<&str>, + tokenized_payment_method_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/providers/{providerId}/billing/vnext/payment-method", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/vnext/payment-method", + local_var_configuration.base_path, + providerId = crate::apis::urlencode(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 param_value) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_phone { - req_builder = req_builder.query(&[("billingPhone", ¶m_value.to_string())]); - } - 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_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_type { - req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_discount_id { - req_builder = req_builder.query(&[("discountId", ¶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_tokenized_payment_method_request); + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_phone { + local_var_req_builder = + local_var_req_builder.query(&[("billingPhone", ¶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 param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = r#type { + local_var_req_builder = + local_var_req_builder.query(&[("type", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = discount_id { + local_var_req_builder = + local_var_req_builder.query(&[("discountId", ¶m_value.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()); + }; + local_var_req_builder = local_var_req_builder.json(&tokenized_payment_method_request); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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 providers_provider_id_billing_vnext_payment_method_verify_bank_account_post( - configuration: &configuration::Configuration, - provider_id: &str, - id: Option, - name: Option<&str>, - business_name: Option<&str>, - business_address1: Option<&str>, - business_address2: Option<&str>, - business_address3: Option<&str>, - business_country: Option<&str>, - business_tax_number: Option<&str>, - billing_email: Option<&str>, - billing_phone: Option<&str>, - status: Option, - use_events: Option, - r#type: Option, - enabled: Option, - creation_date: Option, - revision_date: Option, - gateway: Option, - gateway_customer_id: Option<&str>, - gateway_subscription_id: Option<&str>, - discount_id: Option<&str>, - verify_bank_account_request: 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_name = name; - let p_business_name = business_name; - let p_business_address1 = business_address1; - let p_business_address2 = business_address2; - let p_business_address3 = business_address3; - let p_business_country = business_country; - let p_business_tax_number = business_tax_number; - let p_billing_email = billing_email; - let p_billing_phone = billing_phone; - let p_status = status; - let p_use_events = use_events; - let p_type = r#type; - let p_enabled = enabled; - let p_creation_date = creation_date; - let p_revision_date = revision_date; - let p_gateway = gateway; - let p_gateway_customer_id = gateway_customer_id; - let p_gateway_subscription_id = gateway_subscription_id; - let p_discount_id = discount_id; - let p_verify_bank_account_request = verify_bank_account_request; + pub async fn providers_provider_id_billing_vnext_payment_method_verify_bank_account_post( + &self, + provider_id: &str, + id: Option, + name: Option<&str>, + business_name: Option<&str>, + business_address1: Option<&str>, + business_address2: Option<&str>, + business_address3: Option<&str>, + business_country: Option<&str>, + business_tax_number: Option<&str>, + billing_email: Option<&str>, + billing_phone: Option<&str>, + status: Option, + use_events: Option, + r#type: Option, + enabled: Option, + creation_date: Option, + revision_date: Option, + gateway: Option, + gateway_customer_id: Option<&str>, + gateway_subscription_id: Option<&str>, + discount_id: Option<&str>, + verify_bank_account_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; - let uri_str = format!( - "{}/providers/{providerId}/billing/vnext/payment-method/verify-bank-account", - configuration.base_path, - providerId = crate::apis::urlencode(p_provider_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/vnext/payment-method/verify-bank-account", + local_var_configuration.base_path, + providerId = crate::apis::urlencode(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 param_value) = p_id { - req_builder = req_builder.query(&[("id", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_name { - req_builder = req_builder.query(&[("name", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_name { - req_builder = req_builder.query(&[("businessName", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address1 { - req_builder = req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address2 { - req_builder = req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_address3 { - req_builder = req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_country { - req_builder = req_builder.query(&[("businessCountry", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_business_tax_number { - req_builder = req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_email { - req_builder = req_builder.query(&[("billingEmail", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_billing_phone { - req_builder = req_builder.query(&[("billingPhone", ¶m_value.to_string())]); - } - 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_use_events { - req_builder = req_builder.query(&[("useEvents", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_type { - req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_enabled { - req_builder = req_builder.query(&[("enabled", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_creation_date { - req_builder = req_builder.query(&[("creationDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_revision_date { - req_builder = req_builder.query(&[("revisionDate", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway { - req_builder = req_builder.query(&[("gateway", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_customer_id { - req_builder = req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_gateway_subscription_id { - req_builder = req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_discount_id { - req_builder = req_builder.query(&[("discountId", ¶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_verify_bank_account_request); + if let Some(ref param_value) = id { + local_var_req_builder = + local_var_req_builder.query(&[("id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = name { + local_var_req_builder = + local_var_req_builder.query(&[("name", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_name { + local_var_req_builder = + local_var_req_builder.query(&[("businessName", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address1 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress1", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address2 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress2", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_address3 { + local_var_req_builder = + local_var_req_builder.query(&[("businessAddress3", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_country { + local_var_req_builder = + local_var_req_builder.query(&[("businessCountry", ¶m_value.to_string())]); + } + if let Some(ref param_value) = business_tax_number { + local_var_req_builder = + local_var_req_builder.query(&[("businessTaxNumber", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_email { + local_var_req_builder = + local_var_req_builder.query(&[("billingEmail", ¶m_value.to_string())]); + } + if let Some(ref param_value) = billing_phone { + local_var_req_builder = + local_var_req_builder.query(&[("billingPhone", ¶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 param_value) = use_events { + local_var_req_builder = + local_var_req_builder.query(&[("useEvents", ¶m_value.to_string())]); + } + if let Some(ref param_value) = r#type { + local_var_req_builder = + local_var_req_builder.query(&[("type", ¶m_value.to_string())]); + } + if let Some(ref param_value) = enabled { + local_var_req_builder = + local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]); + } + if let Some(ref param_value) = creation_date { + local_var_req_builder = + local_var_req_builder.query(&[("creationDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = revision_date { + local_var_req_builder = + local_var_req_builder.query(&[("revisionDate", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway { + local_var_req_builder = + local_var_req_builder.query(&[("gateway", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_customer_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewayCustomerId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = gateway_subscription_id { + local_var_req_builder = + local_var_req_builder.query(&[("gatewaySubscriptionId", ¶m_value.to_string())]); + } + if let Some(ref param_value) = discount_id { + local_var_req_builder = + local_var_req_builder.query(&[("discountId", ¶m_value.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()); + }; + local_var_req_builder = local_var_req_builder.json(&verify_bank_account_request); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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)) + } } } 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..a2cd754ca 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,223 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdClientsExistingPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`providers_provider_id_clients_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdClientsPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait ProviderClientsApi: Send + Sync { + + /// GET /providers/{providerId}/clients/addable + /// + /// + async fn providers_provider_id_clients_addable_get(&self, provider_id: uuid::Uuid) -> Result<(), Error>; + + /// POST /providers/{providerId}/clients/existing + /// + /// + async fn providers_provider_id_clients_existing_post(&self, provider_id: uuid::Uuid, add_existing_organization_request_body: Option) -> Result<(), Error>; + + /// POST /providers/{providerId}/clients + /// + /// + async fn providers_provider_id_clients_post(&self, provider_id: uuid::Uuid, create_client_organization_request_body: Option) -> Result<(), Error>; + + /// PUT /providers/{providerId}/clients/{providerOrganizationId} + /// + /// + async fn providers_provider_id_clients_provider_organization_id_put(&self, provider_id: uuid::Uuid, provider_organization_id: uuid::Uuid, update_client_organization_request_body: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`providers_provider_id_clients_provider_organization_id_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdClientsProviderOrganizationIdPutError { - UnknownValue(serde_json::Value), +pub struct ProviderClientsApiClient { + configuration: Arc, } -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, - })) +impl ProviderClientsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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, - })) +// #[async_trait] +impl ProviderClientsApiClient { + pub async fn providers_provider_id_clients_addable_get( + &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_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 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()); + pub async fn providers_provider_id_clients_existing_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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()); + pub async fn providers_provider_id_clients_post( + &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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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, - })) + + pub async fn providers_provider_id_clients_provider_organization_id_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } } 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..121dd99dd 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,288 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdOrganizationsIdDeleteError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`providers_provider_id_organizations_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdOrganizationsIdDeletePostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait ProviderOrganizationsApi: Send + Sync { + + /// POST /providers/{providerId}/organizations/add + /// + /// + async fn providers_provider_id_organizations_add_post(&self, provider_id: uuid::Uuid, provider_organization_add_request_model: Option) -> Result<(), Error>; + + /// GET /providers/{providerId}/organizations + /// + /// + async fn providers_provider_id_organizations_get(&self, provider_id: uuid::Uuid) -> Result; + + /// DELETE /providers/{providerId}/organizations/{id} + /// + /// + async fn providers_provider_id_organizations_id_delete(&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(&self, provider_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /providers/{providerId}/organizations + /// + /// + async fn providers_provider_id_organizations_post(&self, provider_id: uuid::Uuid, provider_organization_create_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`providers_provider_id_organizations_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdOrganizationsPostError { - UnknownValue(serde_json::Value), +pub struct ProviderOrganizationsApiClient { + configuration: Arc, } -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, - })) +impl ProviderOrganizationsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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`")))), +// #[async_trait] +impl ProviderOrganizationsApiClient { + pub async fn providers_provider_id_organizations_add_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_get( + &self, + provider_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}/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_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)) + } } -} -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_id_delete( + &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_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 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()); + pub async fn providers_provider_id_organizations_id_delete_post( + &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_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 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`")))), + + pub async fn providers_provider_id_organizations_post( + &self, + provider_id: uuid::Uuid, + provider_organization_create_request_model: Option< + models::ProviderOrganizationCreateRequestModel, + >, + ) -> Result { + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..663f7f3f3 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,802 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdUsersIdReinvitePostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`providers_provider_id_users_invite_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdUsersInvitePostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait ProviderUsersApi: Send + Sync { + + /// POST /providers/{providerId}/users/confirm + /// + /// + async fn providers_provider_id_users_confirm_post(&self, provider_id: uuid::Uuid, provider_user_bulk_confirm_request_model: Option) -> Result; + + /// DELETE /providers/{providerId}/users + /// + /// + async fn providers_provider_id_users_delete(&self, provider_id: uuid::Uuid, provider_user_bulk_request_model: Option) -> Result; + + /// POST /providers/{providerId}/users/delete + /// + /// + async fn providers_provider_id_users_delete_post(&self, provider_id: uuid::Uuid, provider_user_bulk_request_model: Option) -> Result; + + /// GET /providers/{providerId}/users + /// + /// + async fn providers_provider_id_users_get(&self, provider_id: uuid::Uuid) -> Result; + + /// POST /providers/{providerId}/users/{id}/accept + /// + /// + async fn providers_provider_id_users_id_accept_post(&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(&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(&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(&self, provider_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>; + + /// GET /providers/{providerId}/users/{id} + /// + /// + async fn providers_provider_id_users_id_get(&self, provider_id: uuid::Uuid, id: uuid::Uuid) -> Result; + + /// POST /providers/{providerId}/users/{id} + /// + /// + async fn providers_provider_id_users_id_post(&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(&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(&self, provider_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /providers/{providerId}/users/invite + /// + /// + async fn providers_provider_id_users_invite_post(&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(&self, provider_id: uuid::Uuid, provider_user_bulk_request_model: Option) -> Result; + + /// POST /providers/{providerId}/users/reinvite + /// + /// + async fn providers_provider_id_users_reinvite_post(&self, provider_id: uuid::Uuid, provider_user_bulk_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`providers_provider_id_users_public_keys_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdUsersPublicKeysPostError { - UnknownValue(serde_json::Value), +pub struct ProviderUsersApiClient { + configuration: Arc, } -/// struct for typed errors of method [`providers_provider_id_users_reinvite_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersProviderIdUsersReinvitePostError { - UnknownValue(serde_json::Value), +impl ProviderUsersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl ProviderUsersApiClient { + pub async fn providers_provider_id_users_confirm_post( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_confirm_request_model: Option< + models::ProviderUserBulkConfirmRequestModel, + >, + ) -> Result { + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn providers_provider_id_users_delete( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_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/{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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn providers_provider_id_users_delete_post( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_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/{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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn providers_provider_id_users_get( + &self, + provider_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", + 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_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)) } - } else { - 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_accept_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_confirm_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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( + &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_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 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_delete_post( + &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_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 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`")))), + pub async fn providers_provider_id_users_id_get( + &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_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)) } - } else { - 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_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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_id_reinvite_post( + &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_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 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_invite_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn providers_provider_id_users_public_keys_post( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_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/{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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn providers_provider_id_users_reinvite_post( + &self, + provider_id: uuid::Uuid, + provider_user_bulk_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/{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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..74e5ddadd 100644 --- a/crates/bitwarden-api-api/src/apis/providers_api.rs +++ b/crates/bitwarden-api-api/src/apis/providers_api.rs @@ -8,400 +8,386 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersIdDeleteRecoverTokenPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersIdPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`providers_id_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersIdPutError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait ProvidersApi: Send + Sync { + + /// DELETE /providers/{id} + /// + /// + async fn providers_id_delete(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /providers/{id}/delete + /// + /// + async fn providers_id_delete_post(&self, id: uuid::Uuid) -> Result<(), Error>; + + /// POST /providers/{id}/delete-recover-token + /// + /// + async fn providers_id_delete_recover_token_post(&self, id: uuid::Uuid, provider_verify_delete_recover_request_model: Option) -> Result<(), Error>; + + /// GET /providers/{id} + /// + /// + async fn providers_id_get(&self, id: uuid::Uuid) -> Result; + + /// POST /providers/{id} + /// + /// + async fn providers_id_post(&self, id: uuid::Uuid, provider_update_request_model: Option) -> Result; + + /// PUT /providers/{id} + /// + /// + async fn providers_id_put(&self, id: uuid::Uuid, provider_update_request_model: Option) -> Result; + + /// POST /providers/{id}/setup + /// + /// + async fn providers_id_setup_post(&self, id: uuid::Uuid, provider_setup_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`providers_id_setup_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProvidersIdSetupPostError { - UnknownValue(serde_json::Value), +pub struct ProvidersApiClient { + configuration: Arc, } -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, - })) +impl ProvidersApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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, - })) +// #[async_trait] +impl ProvidersApiClient { + pub async fn providers_id_delete(&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_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 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_delete_post(&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_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 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`")))), + pub async fn providers_id_delete_recover_token_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn providers_id_get( + &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_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)) } - } else { - 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`")))), + pub async fn providers_id_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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()); + pub async fn providers_id_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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`")))), + + pub async fn providers_id_setup_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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 51c4665b3..9707f9616 100644 --- a/crates/bitwarden-api-api/src/apis/push_api.rs +++ b/crates/bitwarden-api-api/src/apis/push_api.rs @@ -8,229 +8,244 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PushDeleteOrganizationPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`push_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PushDeletePostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`push_register_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PushRegisterPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait PushApi: Send + Sync { + + /// PUT /push/add-organization + /// + /// + async fn push_add_organization_put(&self, push_update_request_model: Option) -> Result<(), Error>; + + /// PUT /push/delete-organization + /// + /// + async fn push_delete_organization_put(&self, push_update_request_model: Option) -> Result<(), Error>; + + /// POST /push/delete + /// + /// + async fn push_delete_post(&self, push_device_request_model: Option) -> Result<(), Error>; + + /// POST /push/register + /// + /// + async fn push_register_post(&self, push_registration_request_model: Option) -> Result<(), Error>; + + /// POST /push/send + /// + /// + async fn push_send_post(&self, json_element_push_send_request_model: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`push_send_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PushSendPostError { - UnknownValue(serde_json::Value), +pub struct PushApiClient { + configuration: Arc, } -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, - })) +impl PushApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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()); +// #[async_trait] +impl PushApiClient { + pub async fn push_add_organization_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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()); + pub async fn push_delete_organization_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - 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_delete_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -pub async fn push_send_post( - configuration: &configuration::Configuration, - json_element_push_send_request_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_json_element_push_send_request_model = json_element_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()); + pub async fn push_register_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - req_builder = req_builder.json(&p_json_element_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, - })) + + pub async fn push_send_post( + &self, + json_element_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_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&json_element_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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/reports_api.rs b/crates/bitwarden-api-api/src/apis/reports_api.rs index 0daec6ffb..f235bcfd8 100644 --- a/crates/bitwarden-api-api/src/apis/reports_api.rs +++ b/crates/bitwarden-api-api/src/apis/reports_api.rs @@ -8,756 +8,714 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsMemberCipherDetailsOrgIdGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`reports_organization_report_summary_org_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsOrganizationReportSummaryOrgIdGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`reports_organization_report_summary_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsOrganizationReportSummaryPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`reports_organization_report_summary_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsOrganizationReportSummaryPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`reports_organization_reports_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsOrganizationReportsDeleteError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`reports_organization_reports_latest_org_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsOrganizationReportsLatestOrgIdGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`reports_organization_reports_org_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsOrganizationReportsOrgIdGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`reports_organization_reports_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsOrganizationReportsPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`reports_password_health_report_application_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsPasswordHealthReportApplicationDeleteError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`reports_password_health_report_application_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsPasswordHealthReportApplicationPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait ReportsApi: Send + Sync { + + /// GET /reports/member-access/{orgId} + /// + /// + async fn reports_member_access_org_id_get(&self, org_id: uuid::Uuid) -> Result, Error>; + + /// GET /reports/member-cipher-details/{orgId} + /// + /// + async fn reports_member_cipher_details_org_id_get(&self, org_id: uuid::Uuid) -> Result, Error>; + + /// GET /reports/organization-report-summary/{orgId} + /// + /// + async fn reports_organization_report_summary_org_id_get(&self, org_id: uuid::Uuid, from: Option, to: Option) -> Result, Error>; + + /// POST /reports/organization-report-summary + /// + /// + async fn reports_organization_report_summary_post(&self, organization_report_summary_model: Option) -> Result<(), Error>; + + /// PUT /reports/organization-report-summary + /// + /// + async fn reports_organization_report_summary_put(&self, organization_report_summary_model: Option) -> Result<(), Error>; + + /// DELETE /reports/organization-reports + /// + /// + async fn reports_organization_reports_delete(&self, drop_organization_report_request: Option) -> Result<(), Error>; + + /// GET /reports/organization-reports/latest/{orgId} + /// + /// + async fn reports_organization_reports_latest_org_id_get(&self, org_id: uuid::Uuid) -> Result; + + /// GET /reports/organization-reports/{orgId} + /// + /// + async fn reports_organization_reports_org_id_get(&self, org_id: uuid::Uuid) -> Result, Error>; + + /// POST /reports/organization-reports + /// + /// + async fn reports_organization_reports_post(&self, add_organization_report_request: Option) -> Result; + + /// DELETE /reports/password-health-report-application + /// + /// + async fn reports_password_health_report_application_delete(&self, drop_password_health_report_application_request: Option) -> Result<(), Error>; + + /// POST /reports/password-health-report-application + /// + /// + async fn reports_password_health_report_application_post(&self, password_health_report_application_model: Option) -> Result; + + /// GET /reports/password-health-report-applications/{orgId} + /// + /// + async fn reports_password_health_report_applications_org_id_get(&self, org_id: uuid::Uuid) -> Result, Error>; + + /// POST /reports/password-health-report-applications + /// + /// + async fn reports_password_health_report_applications_post(&self, password_health_report_application_model: Option>) -> Result, Error>; } +*/ -/// struct for typed errors of method [`reports_password_health_report_applications_org_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsPasswordHealthReportApplicationsOrgIdGetError { - UnknownValue(serde_json::Value), +pub struct ReportsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`reports_password_health_report_applications_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ReportsPasswordHealthReportApplicationsPostError { - UnknownValue(serde_json::Value), +impl ReportsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn reports_member_access_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-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::MemberAccessDetailReportResponseModel>`"))), - 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::MemberAccessDetailReportResponseModel>`")))), +// #[async_trait] +impl ReportsApiClient { + pub async fn reports_member_access_org_id_get( + &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_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::MemberAccessDetailReportResponseModel>`"))), + ContentType::Unsupported(local_var_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::MemberAccessDetailReportResponseModel>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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 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>`")))), + pub async fn reports_member_cipher_details_org_id_get( + &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-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_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)) } - } else { - 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_organization_report_summary_org_id_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, - from: Option, - to: Option, -) -> Result< - Vec, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - let p_from = from; - let p_to = to; - - let uri_str = format!( - "{}/reports/organization-report-summary/{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 param_value) = p_from { - req_builder = req_builder.query(&[("from", ¶m_value.to_string())]); - } - if let Some(ref param_value) = p_to { - req_builder = req_builder.query(&[("to", ¶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 `Vec<models::OrganizationReportSummaryModel>`"))), - 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::OrganizationReportSummaryModel>`")))), + pub async fn reports_organization_report_summary_org_id_get( + &self, + org_id: uuid::Uuid, + from: Option, + to: Option, + ) -> Result, Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/reports/organization-report-summary/{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 param_value) = from { + local_var_req_builder = + local_var_req_builder.query(&[("from", ¶m_value.to_string())]); + } + if let Some(ref param_value) = to { + local_var_req_builder = + local_var_req_builder.query(&[("to", ¶m_value.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 `Vec<models::OrganizationReportSummaryModel>`"))), + ContentType::Unsupported(local_var_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::OrganizationReportSummaryModel>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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 reports_organization_report_summary_post( - configuration: &configuration::Configuration, - organization_report_summary_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_report_summary_model = organization_report_summary_model; - - let uri_str = format!( - "{}/reports/organization-report-summary", - 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_report_summary_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 reports_organization_report_summary_post( + &self, + organization_report_summary_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/reports/organization-report-summary", + 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_token) = local_var_configuration.oauth_access_token { + 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_report_summary_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 reports_organization_report_summary_put( - configuration: &configuration::Configuration, - organization_report_summary_model: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_report_summary_model = organization_report_summary_model; - - let uri_str = format!( - "{}/reports/organization-report-summary", - 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_organization_report_summary_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 reports_organization_report_summary_put( + &self, + organization_report_summary_model: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/reports/organization-report-summary", + 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_token) = local_var_configuration.oauth_access_token { + 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_report_summary_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 reports_organization_reports_delete( - configuration: &configuration::Configuration, - drop_organization_report_request: Option, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_drop_organization_report_request = drop_organization_report_request; - let uri_str = format!("{}/reports/organization-reports", 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_organization_report_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_organization_reports_delete( + &self, + drop_organization_report_request: Option, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/reports/organization-reports", + 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_token) = local_var_configuration.oauth_access_token { + 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_organization_report_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)) + } } -} -pub async fn reports_organization_reports_latest_org_id_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!( - "{}/reports/organization-reports/latest/{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 `models::OrganizationReport`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationReport`")))), + pub async fn reports_organization_reports_latest_org_id_get( + &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!( + "{}/reports/organization-reports/latest/{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_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::OrganizationReport`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationReport`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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 reports_organization_reports_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/organization-reports/{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::OrganizationReport>`"))), - 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::OrganizationReport>`")))), + pub async fn reports_organization_reports_org_id_get( + &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/organization-reports/{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_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::OrganizationReport>`"))), + ContentType::Unsupported(local_var_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::OrganizationReport>`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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 reports_organization_reports_post( - configuration: &configuration::Configuration, - add_organization_report_request: Option, -) -> Result> { - // add a prefix to parameters to efficiently prevent name collisions - let p_add_organization_report_request = add_organization_report_request; - let uri_str = format!("{}/reports/organization-reports", 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_add_organization_report_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::OrganizationReport`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationReport`")))), + pub async fn reports_organization_reports_post( + &self, + add_organization_report_request: Option, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/reports/organization-reports", + 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_token) = local_var_configuration.oauth_access_token { + 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_organization_report_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::OrganizationReport`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationReport`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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 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_delete( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn reports_password_health_report_application_post( + &self, + password_health_report_application_model: Option< + models::PasswordHealthReportApplicationModel, + >, + ) -> Result { + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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>`")))), + pub async fn reports_password_health_report_applications_org_id_get( + &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/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_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)) } - } else { - 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>`")))), + pub async fn reports_password_health_report_applications_post( + &self, + password_health_report_application_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!( + "{}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..0d472727d 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,77 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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), -} +/* +#[async_trait] +pub trait RequestSmAccessApi: Send + Sync { -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; + /// POST /request-access/request-sm-access + /// + /// + async fn request_access_request_sm_access_post(&self, request_sm_access_request_model: Option) -> Result<(), Error>; +} +*/ - 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] +impl RequestSmAccessApiClient { + pub async fn request_access_request_sm_access_post( + &self, + request_sm_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!( + "{}/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 let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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 req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/secrets_api.rs b/crates/bitwarden-api-api/src/apis/secrets_api.rs index a75c7d8c4..c65b91bcf 100644 --- a/crates/bitwarden-api-api/src/apis/secrets_api.rs +++ b/crates/bitwarden-api-api/src/apis/secrets_api.rs @@ -8,482 +8,468 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ProjectsProjectIdSecretsGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SecretsGetByIdsPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait SecretsApi: Send + Sync { + + /// GET /organizations/{organizationId}/secrets + /// + /// + async fn organizations_organization_id_secrets_get(&self, organization_id: uuid::Uuid) -> Result; + + /// POST /organizations/{organizationId}/secrets + /// + /// + async fn organizations_organization_id_secrets_post(&self, organization_id: uuid::Uuid, secret_create_request_model: Option) -> Result; + + /// GET /organizations/{organizationId}/secrets/sync + /// + /// + async fn organizations_organization_id_secrets_sync_get(&self, organization_id: uuid::Uuid, last_synced_date: Option) -> Result; + + /// GET /projects/{projectId}/secrets + /// + /// + async fn projects_project_id_secrets_get(&self, project_id: uuid::Uuid) -> Result; + + /// POST /secrets/delete + /// + /// + async fn secrets_delete_post(&self, uuid_colon_colon_uuid: Option>) -> Result; + + /// POST /secrets/get-by-ids + /// + /// + async fn secrets_get_by_ids_post(&self, get_secrets_request_model: Option) -> Result; + + /// GET /secrets/{id} + /// + /// + async fn secrets_id_get(&self, id: uuid::Uuid) -> Result; + + /// PUT /secrets/{id} + /// + /// + async fn secrets_id_put(&self, id: uuid::Uuid, secret_update_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`secrets_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SecretsIdGetError { - UnknownValue(serde_json::Value), +pub struct SecretsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`secrets_id_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SecretsIdPutError { - UnknownValue(serde_json::Value), +impl SecretsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl SecretsApiClient { + pub async fn organizations_organization_id_secrets_get( + &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!( + "{}/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_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)) } - } else { - 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`")))), + pub async fn organizations_organization_id_secrets_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_organization_id_secrets_sync_get( + &self, + organization_id: uuid::Uuid, + last_synced_date: 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/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_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)) } - } else { - 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`")))), + pub async fn projects_project_id_secrets_get( + &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_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)) } - } else { - 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`")))), + pub async fn secrets_delete_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn secrets_get_by_ids_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn secrets_id_get( + &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_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)) } - } else { - 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`")))), + pub async fn secrets_id_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..524e08649 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,102 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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), -} +/* +#[async_trait] +pub trait SecretsManagerEventsApi: Send + Sync { -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; + /// GET /sm/events/service-accounts/{serviceAccountId} + /// + /// + async fn sm_events_service_accounts_service_account_id_get(&self, service_account_id: uuid::Uuid, start: Option, end: Option, continuation_token: Option<&str>) -> Result; +} +*/ - 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())]); - } - 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()); +impl SecretsManagerEventsApiClient { + 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] +impl SecretsManagerEventsApiClient { + pub async fn sm_events_service_accounts_service_account_id_get( + &self, + service_account_id: uuid::Uuid, + start: Option, + end: Option, + continuation_token: Option<&str>, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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 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_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content_type = resp - .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_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/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::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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(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, - })) } } 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..2c4278564 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,133 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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_organization_id_export_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SmOrganizationIdExportGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait SecretsManagerPortingApi: Send + Sync { + + /// GET /sm/{organizationId}/export + /// + /// + async fn sm_organization_id_export_get(&self, organization_id: uuid::Uuid) -> Result; + + /// POST /sm/{organizationId}/import + /// + /// + async fn sm_organization_id_import_post(&self, organization_id: uuid::Uuid, sm_import_request_model: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`sm_organization_id_import_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SmOrganizationIdImportPostError { - UnknownValue(serde_json::Value), +pub struct SecretsManagerPortingApiClient { + configuration: Arc, } -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, - })) +impl SecretsManagerPortingApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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()); +// #[async_trait] +impl SecretsManagerPortingApiClient { + pub async fn sm_organization_id_export_get( + &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_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)) + } } - 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, - })) + + pub async fn sm_organization_id_import_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } } 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..84a075a58 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,246 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`tasks_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TasksGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// 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), +/* +#[async_trait] +pub trait SecurityTaskApi: Send + Sync { + + /// GET /tasks + /// + /// + async fn tasks_get(&self, status: Option) -> Result; + + /// POST /tasks/{orgId}/bulk-create + /// + /// + async fn tasks_org_id_bulk_create_post(&self, org_id: uuid::Uuid, bulk_create_security_tasks_request_model: Option) -> Result; + + /// GET /tasks/organization + /// + /// + async fn tasks_organization_get(&self, organization_id: Option, status: Option) -> Result; + + /// PATCH /tasks/{taskId}/complete + /// + /// + async fn tasks_task_id_complete_patch(&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; - - let uri_str = format!("{}/tasks", 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 user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::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`")))), +// #[async_trait] +impl SecurityTaskApiClient { + pub async fn tasks_get( + &self, + status: Option, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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())]); + } + if let Some(ref 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)) } - } else { - 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_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`")))), + pub async fn tasks_org_id_bulk_create_post( + &self, + org_id: uuid::Uuid, + bulk_create_security_tasks_request_model: Option< + models::BulkCreateSecurityTasksRequestModel, + >, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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; - - let uri_str = format!("{}/tasks/organization", 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 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`")))), + pub async fn tasks_organization_get( + &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_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)) } - } else { - 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, - })) + pub async fn tasks_task_id_complete_patch(&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_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)) + } } } 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..9c063ce0e 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,196 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`organizations_licenses_self_hosted_id_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsLicensesSelfHostedIdPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`organizations_licenses_self_hosted_id_sync_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsLicensesSelfHostedIdSyncPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait SelfHostedOrganizationLicensesApi: Send + Sync { + + /// POST /organizations/licenses/self-hosted/{id} + /// + /// + async fn organizations_licenses_self_hosted_id_post(&self, id: &str, license: std::path::PathBuf) -> Result<(), Error>; + + /// POST /organizations/licenses/self-hosted/{id}/sync + /// + /// + async fn organizations_licenses_self_hosted_id_sync_post(&self, id: &str) -> Result<(), Error>; + + /// POST /organizations/licenses/self-hosted + /// + /// + async fn organizations_licenses_self_hosted_post(&self, key: &str, keys_period_public_key: &str, keys_period_encrypted_private_key: &str, license: std::path::PathBuf, collection_name: Option<&str>) -> Result; } +*/ -/// struct for typed errors of method [`organizations_licenses_self_hosted_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsLicensesSelfHostedPostError { - UnknownValue(serde_json::Value), +pub struct SelfHostedOrganizationLicensesApiClient { + configuration: Arc, } -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, - })) +impl SelfHostedOrganizationLicensesApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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, - })) +// #[async_trait] +impl SelfHostedOrganizationLicensesApiClient { + pub async fn organizations_licenses_self_hosted_id_post( + &self, + id: &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_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 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()); + pub async fn organizations_licenses_self_hosted_id_sync_post( + &self, + id: &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_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 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`")))), + + pub async fn organizations_licenses_self_hosted_post( + &self, + key: &str, + keys_period_public_key: &str, + keys_period_encrypted_private_key: &str, + license: std::path::PathBuf, + collection_name: Option<&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_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)) } - } 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 cc46f990f..10b3a22ca 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,284 +8,265 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`organization_sponsorship_self_hosted_org_id_sponsored_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSelfHostedOrgIdSponsoredGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method -/// [`organization_sponsorship_self_hosted_sponsoring_org_id_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeleteError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method -/// [`organization_sponsorship_self_hosted_sponsoring_org_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeletePostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait SelfHostedOrganizationSponsorshipsApi: Send + Sync { + + /// GET /organization/sponsorship/self-hosted/{orgId}/sponsored + /// + /// + async fn organization_sponsorship_self_hosted_org_id_sponsored_get(&self, org_id: uuid::Uuid) -> Result; + + /// DELETE /organization/sponsorship/self-hosted/{sponsoringOrgId} + /// + /// + async fn organization_sponsorship_self_hosted_sponsoring_org_id_delete(&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(&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(&self, sponsoring_org_id: uuid::Uuid, organization_sponsorship_create_request_model: Option) -> Result<(), Error>; + + /// DELETE /organization/sponsorship/self-hosted/{sponsoringOrgId}/{sponsoredFriendlyName}/revoke + /// + /// + async fn organization_sponsorship_self_hosted_sponsoring_org_id_sponsored_friendly_name_revoke_delete(&self, sponsoring_org_id: uuid::Uuid, sponsored_friendly_name: &str) -> Result<(), Error>; } +*/ -/// struct for typed errors of method -/// [`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 struct SelfHostedOrganizationSponsorshipsApiClient { + configuration: Arc, } -/// struct for typed errors of method -/// [`organization_sponsorship_self_hosted_sponsoring_org_id_sponsored_friendly_name_revoke_delete`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdSponsoredFriendlyNameRevokeDeleteError { - UnknownValue(serde_json::Value), +impl SelfHostedOrganizationSponsorshipsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -pub async fn organization_sponsorship_self_hosted_org_id_sponsored_get( - configuration: &configuration::Configuration, - org_id: uuid::Uuid, -) -> Result< - models::OrganizationSponsorshipInvitesResponseModelListResponseModel, - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_org_id = org_id; - - let uri_str = format!( - "{}/organization/sponsorship/self-hosted/{orgId}/sponsored", - 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::OrganizationSponsorshipInvitesResponseModelListResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationSponsorshipInvitesResponseModelListResponseModel`")))), +// #[async_trait] +impl SelfHostedOrganizationSponsorshipsApiClient { + pub async fn organization_sponsorship_self_hosted_org_id_sponsored_get( + &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!( + "{}/organization/sponsorship/self-hosted/{orgId}/sponsored", + 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_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::OrganizationSponsorshipInvitesResponseModelListResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationSponsorshipInvitesResponseModelListResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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 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( + &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_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 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_delete_post( + &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_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 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, - })) + pub async fn organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post( + &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_token) = local_var_configuration.oauth_access_token { + 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 = + serde_json::from_str(&local_var_content).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 organization_sponsorship_self_hosted_sponsoring_org_id_sponsored_friendly_name_revoke_delete( - configuration: &configuration::Configuration, - sponsoring_org_id: uuid::Uuid, - sponsored_friendly_name: &str, -) -> Result< - (), - Error, -> { - // add a prefix to parameters to efficiently prevent name collisions - let p_sponsoring_org_id = sponsoring_org_id; - let p_sponsored_friendly_name = sponsored_friendly_name; - - let uri_str = format!( - "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}/{sponsoredFriendlyName}/revoke", - configuration.base_path, - sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string()), - sponsoredFriendlyName = crate::apis::urlencode(p_sponsored_friendly_name) - ); - 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< - OrganizationSponsorshipSelfHostedSponsoringOrgIdSponsoredFriendlyNameRevokeDeleteError, - > = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) + pub async fn organization_sponsorship_self_hosted_sponsoring_org_id_sponsored_friendly_name_revoke_delete( + &self, + sponsoring_org_id: uuid::Uuid, + sponsored_friendly_name: &str, + ) -> 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}/{sponsoredFriendlyName}/revoke", local_var_configuration.base_path, sponsoringOrgId=sponsoring_org_id, sponsoredFriendlyName=crate::apis::urlencode(sponsored_friendly_name)); + 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_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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/sends_api.rs b/crates/bitwarden-api-api/src/apis/sends_api.rs index dadbcecd2..5f4b6c01c 100644 --- a/crates/bitwarden-api-api/src/apis/sends_api.rs +++ b/crates/bitwarden-api-api/src/apis/sends_api.rs @@ -8,648 +8,616 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SendsEncodedSendIdAccessFileFileIdPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SendsFileValidateAzurePostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SendsIdFileFileIdPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SendsIdPutError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`sends_id_remove_password_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SendsIdRemovePasswordPutError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait SendsApi: Send + Sync { + + /// POST /sends/access/{id} + /// + /// + async fn sends_access_id_post(&self, id: &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(&self, encoded_send_id: &str, file_id: &str, send_access_request_model: Option) -> Result<(), Error>; + + /// POST /sends/file/v2 + /// + /// + async fn sends_file_v2_post(&self, send_request_model: Option) -> Result; + + /// POST /sends/file/validate/azure + /// + /// + async fn sends_file_validate_azure_post(&self, ) -> Result<(), Error>; + + /// GET /sends + /// + /// + async fn sends_get(&self, ) -> Result; + + /// DELETE /sends/{id} + /// + /// + async fn sends_id_delete(&self, id: &str) -> Result<(), Error>; + + /// GET /sends/{id}/file/{fileId} + /// + /// + async fn sends_id_file_file_id_get(&self, id: &str, file_id: &str) -> Result; + + /// POST /sends/{id}/file/{fileId} + /// + /// + async fn sends_id_file_file_id_post(&self, id: &str, file_id: &str) -> Result<(), Error>; + + /// GET /sends/{id} + /// + /// + async fn sends_id_get(&self, id: &str) -> Result; + + /// PUT /sends/{id} + /// + /// + async fn sends_id_put(&self, id: &str, send_request_model: Option) -> Result; + + /// PUT /sends/{id}/remove-password + /// + /// + async fn sends_id_remove_password_put(&self, id: &str) -> Result; + + /// POST /sends + /// + /// + async fn sends_post(&self, send_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`sends_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SendsPostError { - UnknownValue(serde_json::Value), +pub struct SendsApiClient { + configuration: Arc, } -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, - })) +impl SendsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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, - })) +// #[async_trait] +impl SendsApiClient { + pub async fn sends_access_id_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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`")))), + pub async fn sends_encoded_send_id_access_file_file_id_post( + &self, + encoded_send_id: &str, + file_id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_file_v2_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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`")))), + pub async fn sends_file_validate_azure_post(&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_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 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_get(&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_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)) + } } -} -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`")))), + pub async fn sends_id_delete(&self, id: &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_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 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_file_file_id_get( + &self, + id: &str, + file_id: &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_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)) + } } -} -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`")))), + pub async fn sends_id_file_file_id_post(&self, id: &str, file_id: &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_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 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`")))), + pub async fn sends_id_get(&self, id: &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_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)) } - } else { - 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`")))), + pub async fn sends_id_put( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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()); + pub async fn sends_id_remove_password_put( + &self, + id: &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_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)) + } } - 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`")))), + + pub async fn sends_post( + &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()); + + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..f0a939326 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,468 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdServiceAccountsPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ServiceAccountsIdAccessTokensPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`service_accounts_id_access_tokens_revoke_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ServiceAccountsIdAccessTokensRevokePostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait ServiceAccountsApi: Send + Sync { + + /// GET /organizations/{organizationId}/service-accounts + /// + /// + async fn organizations_organization_id_service_accounts_get(&self, organization_id: uuid::Uuid, include_access_to_secrets: Option) -> Result; + + /// POST /organizations/{organizationId}/service-accounts + /// + /// + async fn organizations_organization_id_service_accounts_post(&self, organization_id: uuid::Uuid, service_account_create_request_model: Option) -> Result; + + /// POST /service-accounts/delete + /// + /// + async fn service_accounts_delete_post(&self, uuid_colon_colon_uuid: Option>) -> Result; + + /// GET /service-accounts/{id}/access-tokens + /// + /// + async fn service_accounts_id_access_tokens_get(&self, id: uuid::Uuid) -> Result; + + /// POST /service-accounts/{id}/access-tokens + /// + /// + async fn service_accounts_id_access_tokens_post(&self, id: uuid::Uuid, access_token_create_request_model: Option) -> Result; + + /// POST /service-accounts/{id}/access-tokens/revoke + /// + /// + async fn service_accounts_id_access_tokens_revoke_post(&self, id: uuid::Uuid, revoke_access_tokens_request: Option) -> Result<(), Error>; + + /// GET /service-accounts/{id} + /// + /// + async fn service_accounts_id_get(&self, id: uuid::Uuid) -> Result; + + /// PUT /service-accounts/{id} + /// + /// + async fn service_accounts_id_put(&self, id: uuid::Uuid, service_account_update_request_model: Option) -> Result; } +*/ -/// struct for typed errors of method [`service_accounts_id_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ServiceAccountsIdGetError { - UnknownValue(serde_json::Value), +pub struct ServiceAccountsApiClient { + configuration: Arc, } -/// struct for typed errors of method [`service_accounts_id_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum ServiceAccountsIdPutError { - UnknownValue(serde_json::Value), +impl ServiceAccountsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl ServiceAccountsApiClient { + pub async fn organizations_organization_id_service_accounts_get( + &self, + organization_id: uuid::Uuid, + include_access_to_secrets: Option, + ) -> Result { + 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_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)) } - } else { - 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`")))), + pub async fn organizations_organization_id_service_accounts_post( + &self, + organization_id: uuid::Uuid, + service_account_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}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn service_accounts_delete_post( + &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!( + "{}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn service_accounts_id_access_tokens_get( + &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}/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_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)) } - } else { - 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`")))), + pub async fn service_accounts_id_access_tokens_post( + &self, + id: uuid::Uuid, + access_token_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!( + "{}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_access_tokens_revoke_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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`")))), + pub async fn service_accounts_id_get( + &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_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)) } - } else { - 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`")))), + pub async fn service_accounts_id_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..710694063 100644 --- a/crates/bitwarden-api-api/src/apis/settings_api.rs +++ b/crates/bitwarden-api-api/src/apis/settings_api.rs @@ -8,174 +8,189 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`settings_domains_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SettingsDomainsGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait SettingsApi: Send + Sync { + + /// GET /settings/domains + /// + /// + async fn settings_domains_get(&self, excluded: Option) -> Result; + + /// POST /settings/domains + /// + /// + async fn settings_domains_post(&self, update_domains_request_model: Option) -> Result; + + /// PUT /settings/domains + /// + /// + async fn settings_domains_put(&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; - - let uri_str = format!("{}/settings/domains", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - 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`")))), +// #[async_trait] +impl SettingsApiClient { + pub async fn settings_domains_get( + &self, + excluded: Option, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_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; - let uri_str = format!("{}/settings/domains", 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_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`")))), + pub async fn settings_domains_post( + &self, + update_domains_request_model: Option, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_token) = local_var_configuration.oauth_access_token { + 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; - let uri_str = format!("{}/settings/domains", 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_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`")))), + pub async fn settings_domains_put( + &self, + update_domains_request_model: Option, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_token) = local_var_configuration.oauth_access_token { + 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, - })) } } diff --git a/crates/bitwarden-api-api/src/apis/slack_integration_api.rs b/crates/bitwarden-api-api/src/apis/slack_integration_api.rs index 095cc239e..92f6f2d84 100644 --- a/crates/bitwarden-api-api/src/apis/slack_integration_api.rs +++ b/crates/bitwarden-api-api/src/apis/slack_integration_api.rs @@ -8,107 +8,126 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`create_async`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CreateAsyncError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait SlackIntegrationApi: Send + Sync { + + /// GET /organizations/{organizationId}/integrations/slack/create + /// + /// + async fn create_async(&self, organization_id: uuid::Uuid, code: Option<&str>) -> Result<(), Error>; + + /// GET /organizations/{organizationId}/integrations/slack/redirect + /// + /// + async fn organizations_organization_id_integrations_slack_redirect_get(&self, organization_id: uuid::Uuid) -> Result<(), Error>; } +*/ -/// struct for typed errors of method -/// [`organizations_organization_id_integrations_slack_redirect_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsOrganizationIdIntegrationsSlackRedirectGetError { - UnknownValue(serde_json::Value), +pub struct SlackIntegrationApiClient { + configuration: Arc, } -pub async fn create_async( - configuration: &configuration::Configuration, - organization_id: uuid::Uuid, - code: Option<&str>, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_organization_id = organization_id; - let p_code = code; - - let uri_str = format!( - "{}/organizations/{organizationId}/integrations/slack/create", - 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_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(); - - 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, - })) +impl SlackIntegrationApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -pub async fn organizations_organization_id_integrations_slack_redirect_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}/integrations/slack/redirect", - 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()); +// #[async_trait] +impl SlackIntegrationApiClient { + pub async fn create_async( + &self, + organization_id: uuid::Uuid, + code: Option<&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}/integrations/slack/create", + 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) = code { + local_var_req_builder = + local_var_req_builder.query(&[("code", ¶m_value.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 = 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, - })) + + pub async fn organizations_organization_id_integrations_slack_redirect_get( + &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}/integrations/slack/redirect", + 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_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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/stripe_api.rs b/crates/bitwarden-api-api/src/apis/stripe_api.rs index 7585964ea..35dfca4b4 100644 --- a/crates/bitwarden-api-api/src/apis/stripe_api.rs +++ b/crates/bitwarden-api-api/src/apis/stripe_api.rs @@ -8,133 +8,154 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`setup_intent_bank_account_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SetupIntentBankAccountPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`setup_intent_card_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SetupIntentCardPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait StripeApi: Send + Sync { + + /// POST /setup-intent/bank-account + /// + /// + async fn setup_intent_bank_account_post(&self, ) -> Result<(), Error>; + + /// POST /setup-intent/card + /// + /// + async fn setup_intent_card_post(&self, ) -> Result<(), Error>; + + /// GET /tax/is-country-supported + /// + /// + async fn tax_is_country_supported_get(&self, country: Option<&str>) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`tax_is_country_supported_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TaxIsCountrySupportedGetError { - UnknownValue(serde_json::Value), +pub struct StripeApiClient { + configuration: Arc, } -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, - })) +impl StripeApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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()); +// #[async_trait] +impl StripeApiClient { + pub async fn setup_intent_bank_account_post(&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_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 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()); + pub async fn setup_intent_card_post(&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_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 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(&self, country: Option<&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_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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/sync_api.rs b/crates/bitwarden-api-api/src/apis/sync_api.rs index 4cf9f4d73..56448e109 100644 --- a/crates/bitwarden-api-api/src/apis/sync_api.rs +++ b/crates/bitwarden-api-api/src/apis/sync_api.rs @@ -8,64 +8,87 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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), -} +/* +#[async_trait] +pub trait SyncApi: Send + Sync { -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; + /// GET /sync + /// + /// + async fn sync_get(&self, exclude_domains: Option) -> Result; +} +*/ - 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()); - }; +} + +// #[async_trait] +impl SyncApiClient { + pub async fn sync_get( + &self, + exclude_domains: Option, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content_type = resp - .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_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/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::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`")))), + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(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, - })) } } diff --git a/crates/bitwarden-api-api/src/apis/tax_api.rs b/crates/bitwarden-api-api/src/apis/tax_api.rs index 92b33ea4e..a9d1198b4 100644 --- a/crates/bitwarden-api-api/src/apis/tax_api.rs +++ b/crates/bitwarden-api-api/src/apis/tax_api.rs @@ -8,60 +8,80 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`tax_preview_amount_organization_trial_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TaxPreviewAmountOrganizationTrialPostError { - UnknownValue(serde_json::Value), -} +/* +#[async_trait] +pub trait TaxApi: Send + Sync { -pub async fn tax_preview_amount_organization_trial_post( - configuration: &configuration::Configuration, - preview_tax_amount_for_organization_trial_request_body: Option< - models::PreviewTaxAmountForOrganizationTrialRequestBody, - >, -) -> Result<(), Error> { - // add a prefix to parameters to efficiently prevent name collisions - let p_preview_tax_amount_for_organization_trial_request_body = - preview_tax_amount_for_organization_trial_request_body; + /// POST /tax/preview-amount/organization-trial + /// + /// + async fn tax_preview_amount_organization_trial_post(&self, preview_tax_amount_for_organization_trial_request_body: Option) -> Result<(), Error>; +} +*/ - let uri_str = format!( - "{}/tax/preview-amount/organization-trial", - configuration.base_path - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::POST, &uri_str); +pub struct TaxApiClient { + configuration: Arc, +} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); +impl TaxApiClient { + 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_tax_amount_for_organization_trial_request_body); +} + +// #[async_trait] +impl TaxApiClient { + pub async fn tax_preview_amount_organization_trial_post( + &self, + preview_tax_amount_for_organization_trial_request_body: Option< + models::PreviewTaxAmountForOrganizationTrialRequestBody, + >, + ) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + let local_var_uri_str = format!( + "{}/tax/preview-amount/organization-trial", + 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_token) = local_var_configuration.oauth_access_token { + 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_tax_amount_for_organization_trial_request_body); - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - 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 !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)) + } } } diff --git a/crates/bitwarden-api-api/src/apis/trash_api.rs b/crates/bitwarden-api-api/src/apis/trash_api.rs index 88f1b8950..50a171917 100644 --- a/crates/bitwarden-api-api/src/apis/trash_api.rs +++ b/crates/bitwarden-api-api/src/apis/trash_api.rs @@ -8,171 +8,179 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`secrets_organization_id_trash_empty_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SecretsOrganizationIdTrashEmptyPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`secrets_organization_id_trash_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SecretsOrganizationIdTrashGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait TrashApi: Send + Sync { + + /// POST /secrets/{organizationId}/trash/empty + /// + /// + async fn secrets_organization_id_trash_empty_post(&self, organization_id: uuid::Uuid, uuid_colon_colon_uuid: Option>) -> Result<(), Error>; + + /// GET /secrets/{organizationId}/trash + /// + /// + async fn secrets_organization_id_trash_get(&self, organization_id: uuid::Uuid) -> Result; + + /// POST /secrets/{organizationId}/trash/restore + /// + /// + async fn secrets_organization_id_trash_restore_post(&self, organization_id: uuid::Uuid, uuid_colon_colon_uuid: Option>) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`secrets_organization_id_trash_restore_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SecretsOrganizationIdTrashRestorePostError { - UnknownValue(serde_json::Value), +pub struct TrashApiClient { + configuration: Arc, } -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, - })) +impl TrashApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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`")))), +// #[async_trait] +impl TrashApiClient { + pub async fn secrets_organization_id_trash_empty_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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()); + pub async fn secrets_organization_id_trash_get( + &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!( + "{}/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_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)) + } } - 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_restore_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } } 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..a4e873aee 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,1714 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdTwoFactorGetDuoPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TwoFactorAuthenticatorPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TwoFactorDeviceVerificationSettingsPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TwoFactorDisablePutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TwoFactorDuoPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TwoFactorEmailPutError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TwoFactorGetEmailPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TwoFactorGetYubikeyPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TwoFactorSendEmailPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TwoFactorWebauthnPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TwoFactorYubikeyPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`")))), +/* +#[async_trait] +pub trait TwoFactorApi: Send + Sync { + + /// POST /organizations/{id}/two-factor/disable + /// + /// + async fn organizations_id_two_factor_disable_post(&self, id: &str, two_factor_provider_request_model: Option) -> Result; + + /// PUT /organizations/{id}/two-factor/disable + /// + /// + async fn organizations_id_two_factor_disable_put(&self, id: &str, two_factor_provider_request_model: Option) -> Result; + + /// POST /organizations/{id}/two-factor/duo + /// + /// + async fn organizations_id_two_factor_duo_post(&self, id: &str, update_two_factor_duo_request_model: Option) -> Result; + + /// PUT /organizations/{id}/two-factor/duo + /// + /// + async fn organizations_id_two_factor_duo_put(&self, id: &str, update_two_factor_duo_request_model: Option) -> Result; + + /// GET /organizations/{id}/two-factor + /// + /// + async fn organizations_id_two_factor_get(&self, id: &str) -> Result; + + /// POST /organizations/{id}/two-factor/get-duo + /// + /// + async fn organizations_id_two_factor_get_duo_post(&self, id: &str, secret_verification_request_model: Option) -> Result; + + /// DELETE /two-factor/authenticator + /// + /// + async fn two_factor_authenticator_delete(&self, two_factor_authenticator_disable_request_model: Option) -> Result; + + /// POST /two-factor/authenticator + /// + /// + async fn two_factor_authenticator_post(&self, update_two_factor_authenticator_request_model: Option) -> Result; + + /// PUT /two-factor/authenticator + /// + /// + async fn two_factor_authenticator_put(&self, update_two_factor_authenticator_request_model: Option) -> Result; + + /// PUT /two-factor/device-verification-settings + /// + /// + async fn two_factor_device_verification_settings_put(&self, device_verification_request_model: Option) -> Result; + + /// POST /two-factor/disable + /// + /// + async fn two_factor_disable_post(&self, two_factor_provider_request_model: Option) -> Result; + + /// PUT /two-factor/disable + /// + /// + async fn two_factor_disable_put(&self, two_factor_provider_request_model: Option) -> Result; + + /// POST /two-factor/duo + /// + /// + async fn two_factor_duo_post(&self, update_two_factor_duo_request_model: Option) -> Result; + + /// PUT /two-factor/duo + /// + /// + async fn two_factor_duo_put(&self, update_two_factor_duo_request_model: Option) -> Result; + + /// POST /two-factor/email + /// + /// + async fn two_factor_email_post(&self, update_two_factor_email_request_model: Option) -> Result; + + /// PUT /two-factor/email + /// + /// + async fn two_factor_email_put(&self, update_two_factor_email_request_model: Option) -> Result; + + /// GET /two-factor + /// + /// + async fn two_factor_get(&self, ) -> Result; + + /// POST /two-factor/get-authenticator + /// + /// + async fn two_factor_get_authenticator_post(&self, secret_verification_request_model: Option) -> Result; + + /// GET /two-factor/get-device-verification-settings + /// + /// + async fn two_factor_get_device_verification_settings_get(&self, ) -> Result; + + /// POST /two-factor/get-duo + /// + /// + async fn two_factor_get_duo_post(&self, secret_verification_request_model: Option) -> Result; + + /// POST /two-factor/get-email + /// + /// + async fn two_factor_get_email_post(&self, secret_verification_request_model: Option) -> Result; + + /// POST /two-factor/get-recover + /// + /// + async fn two_factor_get_recover_post(&self, secret_verification_request_model: Option) -> Result; + + /// POST /two-factor/get-webauthn + /// + /// + async fn two_factor_get_webauthn_post(&self, secret_verification_request_model: Option) -> Result; + + /// POST /two-factor/get-yubikey + /// + /// + async fn two_factor_get_yubikey_post(&self, secret_verification_request_model: Option) -> Result; + + /// POST /two-factor/recover + /// + /// + async fn two_factor_recover_post(&self, two_factor_recovery_request_model: Option) -> Result<(), Error>; + + /// POST /two-factor/send-email-login + /// + /// + async fn two_factor_send_email_login_post(&self, two_factor_email_request_model: Option) -> Result<(), Error>; + + /// POST /two-factor/send-email + /// + /// + async fn two_factor_send_email_post(&self, two_factor_email_request_model: Option) -> Result<(), Error>; + + /// DELETE /two-factor/webauthn + /// + /// + async fn two_factor_webauthn_delete(&self, two_factor_web_authn_delete_request_model: Option) -> Result; + + /// POST /two-factor/webauthn + /// + /// + async fn two_factor_webauthn_post(&self, two_factor_web_authn_request_model: Option) -> Result; + + /// PUT /two-factor/webauthn + /// + /// + async fn two_factor_webauthn_put(&self, two_factor_web_authn_request_model: Option) -> Result; + + /// POST /two-factor/yubikey + /// + /// + async fn two_factor_yubikey_post(&self, update_two_factor_yubico_otp_request_model: Option) -> Result; + + /// PUT /two-factor/yubikey + /// + /// + async fn two_factor_yubikey_put(&self, update_two_factor_yubico_otp_request_model: Option) -> Result; +} +*/ + +pub struct TwoFactorApiClient { + configuration: Arc, +} + +impl TwoFactorApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } +} + +// #[async_trait] +impl TwoFactorApiClient { + pub async fn organizations_id_two_factor_disable_post( + &self, + id: &str, + 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!( + "{}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_two_factor_disable_put( + &self, + id: &str, + 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!( + "{}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_two_factor_duo_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_two_factor_duo_put( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn organizations_id_two_factor_get( + &self, + id: &str, + ) -> 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", + 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_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)) } - } else { - 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`")))), + pub async fn organizations_id_two_factor_get_duo_post( + &self, + id: &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_authenticator_delete( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_authenticator_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_authenticator_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_device_verification_settings_put( + &self, + device_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/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_disable_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_disable_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_duo_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_duo_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_email_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_email_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_get( + &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_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)) } - } else { - 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`")))), + pub async fn two_factor_get_authenticator_post( + &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-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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_get_device_verification_settings_get( + &self, + ) -> Result { + 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_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)) } - } else { - 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`")))), + pub async fn two_factor_get_duo_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_get_email_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_get_recover_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_get_webauthn_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_get_yubikey_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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_recover_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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_login_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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_send_email_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} - -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`")))), + pub async fn two_factor_webauthn_delete( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_webauthn_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_webauthn_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_yubikey_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn two_factor_yubikey_put( + &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_token) = local_var_configuration.oauth_access_token { + 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)) } - } 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..84ef70d6b 100644 --- a/crates/bitwarden-api-api/src/apis/users_api.rs +++ b/crates/bitwarden-api-api/src/apis/users_api.rs @@ -8,65 +8,87 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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), -} +/* +#[async_trait] +pub trait UsersApi: Send + Sync { -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; + /// GET /users/{id}/public-key + /// + /// + async fn users_id_public_key_get(&self, id: &str) -> Result; +} +*/ - 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()); - }; +} + +// #[async_trait] +impl UsersApiClient { + pub async fn users_id_public_key_get( + &self, + id: &str, + ) -> Result { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content_type = resp - .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_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/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::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`")))), + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(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, - })) } } 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..eb8c9f26b 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,324 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum WebauthnAttestationOptionsPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`webauthn_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum WebauthnGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`webauthn_id_delete_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum WebauthnIdDeletePostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait WebAuthnApi: Send + Sync { + + /// POST /webauthn/assertion-options + /// + /// + async fn webauthn_assertion_options_post(&self, secret_verification_request_model: Option) -> Result; + + /// POST /webauthn/attestation-options + /// + /// + async fn webauthn_attestation_options_post(&self, secret_verification_request_model: Option) -> Result; + + /// GET /webauthn + /// + /// + async fn webauthn_get(&self, ) -> Result; + + /// POST /webauthn/{id}/delete + /// + /// + async fn webauthn_id_delete_post(&self, id: uuid::Uuid, secret_verification_request_model: Option) -> Result<(), Error>; + + /// POST /webauthn + /// + /// + async fn webauthn_post(&self, web_authn_login_credential_create_request_model: Option) -> Result<(), Error>; + + /// PUT /webauthn + /// + /// + async fn webauthn_put(&self, web_authn_login_credential_update_request_model: Option) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`webauthn_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum WebauthnPostError { - UnknownValue(serde_json::Value), +pub struct WebAuthnApiClient { + configuration: Arc, } -/// struct for typed errors of method [`webauthn_put`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum WebauthnPutError { - UnknownValue(serde_json::Value), +impl WebAuthnApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } + } } -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`")))), +// #[async_trait] +impl WebAuthnApiClient { + pub async fn webauthn_assertion_options_post( + &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!( + "{}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn webauthn_attestation_options_post( + &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!( + "{}/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_token) = local_var_configuration.oauth_access_token { + 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)) } - } else { - 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`")))), + pub async fn webauthn_get( + &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_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)) } - } else { - 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_id_delete_post( + &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_token) = local_var_configuration.oauth_access_token { + 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 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_post( + &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_token) = local_var_configuration.oauth_access_token { + 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)) + } } -} -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, - })) + pub async fn webauthn_put( + &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; + 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_token) = local_var_configuration.oauth_access_token { + 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)) + } } } 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-api/src/models/mod.rs b/crates/bitwarden-api-api/src/models/mod.rs index 0529112f4..b0a58821d 100644 --- a/crates/bitwarden-api-api/src/models/mod.rs +++ b/crates/bitwarden-api-api/src/models/mod.rs @@ -934,42 +934,3 @@ pub mod web_authn_prf_status; pub use self::web_authn_prf_status::WebAuthnPrfStatus; pub mod web_push_auth_request_model; pub use self::web_push_auth_request_model::WebPushAuthRequestModel; -/* -use serde::{Deserialize, Deserializer, Serializer}; -use serde_with::{de::DeserializeAsWrap, ser::SerializeAsWrap, DeserializeAs, SerializeAs}; -use std::marker::PhantomData; - -pub(crate) struct DoubleOption(PhantomData); - -impl SerializeAs>> for DoubleOption -where - TAs: SerializeAs, -{ - fn serialize_as(values: &Option>, serializer: S) -> Result - where - S: Serializer, - { - match values { - None => serializer.serialize_unit(), - Some(None) => serializer.serialize_none(), - Some(Some(v)) => serializer.serialize_some(&SerializeAsWrap::::new(v)), - } - } -} - -impl<'de, T, TAs> DeserializeAs<'de, Option>> for DoubleOption -where - TAs: DeserializeAs<'de, T>, - T: std::fmt::Debug, -{ - fn deserialize_as(deserializer: D) -> Result>, D::Error> - where - D: Deserializer<'de>, - { - Ok(Some( - DeserializeAsWrap::, Option>::deserialize(deserializer)? - .into_inner(), - )) - } -} -*/ diff --git a/crates/bitwarden-api-identity/.openapi-generator-ignore b/crates/bitwarden-api-identity/.openapi-generator-ignore index 0a3fec13f..bbda31728 100644 --- a/crates/bitwarden-api-identity/.openapi-generator-ignore +++ b/crates/bitwarden-api-identity/.openapi-generator-ignore @@ -25,3 +25,7 @@ docs/*.md .travis.yml git_push.sh +.gitignore + +# We handle dependency updates with renovate, so we don't want to overwrite Cargo.toml +Cargo.toml diff --git a/crates/bitwarden-api-identity/.openapi-generator/FILES b/crates/bitwarden-api-identity/.openapi-generator/FILES index 75bb5f304..ec6263894 100644 --- a/crates/bitwarden-api-identity/.openapi-generator/FILES +++ b/crates/bitwarden-api-identity/.openapi-generator/FILES @@ -1,5 +1,3 @@ -.gitignore -Cargo.toml README.md src/apis/accounts_api.rs src/apis/configuration.rs diff --git a/crates/bitwarden-api-identity/.openapi-generator/VERSION b/crates/bitwarden-api-identity/.openapi-generator/VERSION index eb1dc6a51..e465da431 100644 --- a/crates/bitwarden-api-identity/.openapi-generator/VERSION +++ b/crates/bitwarden-api-identity/.openapi-generator/VERSION @@ -1 +1 @@ -7.13.0 +7.14.0 diff --git a/crates/bitwarden-api-identity/README.md b/crates/bitwarden-api-identity/README.md index 838deefae..506e233ce 100644 --- a/crates/bitwarden-api-identity/README.md +++ b/crates/bitwarden-api-identity/README.md @@ -11,7 +11,7 @@ client. - API version: v1 - Package version: 1.0.0 -- Generator version: 7.13.0 +- Generator version: 7.14.0 - Build package: `org.openapitools.codegen.languages.RustClientCodegen` ## Installation @@ -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 3618c3d58..ba1f80d1a 100644 --- a/crates/bitwarden-api-identity/src/apis/accounts_api.rs +++ b/crates/bitwarden-api-identity/src/apis/accounts_api.rs @@ -8,313 +8,312 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsRegisterFinishPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`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`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsRegisterVerificationEmailClickedPostError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`accounts_trial_send_verification_email_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsTrialSendVerificationEmailPostError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait AccountsApi: Send + Sync { + + /// POST /accounts/prelogin + /// + /// + async fn accounts_prelogin_post(&self, prelogin_request_model: Option) -> Result; + + /// POST /accounts/register/finish + /// + /// + async fn accounts_register_finish_post(&self, register_finish_request_model: Option) -> Result; + + /// POST /accounts/register/send-verification-email + /// + /// + async fn accounts_register_send_verification_email_post(&self, register_send_verification_email_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/register/verification-email-clicked + /// + /// + async fn accounts_register_verification_email_clicked_post(&self, register_verification_email_clicked_request_model: Option) -> Result<(), Error>; + + /// POST /accounts/trial/send-verification-email + /// + /// + async fn accounts_trial_send_verification_email_post(&self, trial_send_verification_email_request_model: Option) -> Result<(), Error>; + + /// GET /accounts/webauthn/assertion-options + /// + /// + async fn accounts_webauthn_assertion_options_get(&self, ) -> Result; } +*/ -/// struct for typed errors of method [`accounts_webauthn_assertion_options_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsWebauthnAssertionOptionsGetError { - UnknownValue(serde_json::Value), +pub struct AccountsApiClient { + configuration: Arc, } -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, - })) +impl AccountsApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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::RegisterFinishResponseModel`"))), - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegisterFinishResponseModel`")))), +// #[async_trait] +impl AccountsApiClient { + pub async fn accounts_prelogin_post( + &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()); + + 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)) } - } else { - 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_finish_post( + &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()); + + 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::RegisterFinishResponseModel`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::RegisterFinishResponseModel`")))), + } + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).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_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_register_send_verification_email_post( + &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()); + + 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)) + } } -} -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_register_verification_email_clicked_post( + &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()); + + 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)) + } } -} -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()); + pub async fn accounts_trial_send_verification_email_post( + &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()); + + 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)) + } } - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(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`")))), + pub async fn accounts_webauthn_assertion_options_get( + &self, + ) -> Result { + 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()); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(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)) } - } 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..19a25cde9 100644 --- a/crates/bitwarden-api-identity/src/apis/info_api.rs +++ b/crates/bitwarden-api-identity/src/apis/info_api.rs @@ -8,135 +8,152 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`alive_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AliveGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`now_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum NowGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait InfoApi: Send + Sync { + + /// GET /alive + /// + /// + async fn alive_get(&self, ) -> Result; + + /// GET /now + /// + /// + async fn now_get(&self, ) -> Result; + + /// GET /version + /// + /// + async fn version_get(&self, ) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`version_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum VersionGetError { - UnknownValue(serde_json::Value), +pub struct InfoApiClient { + configuration: Arc, } -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); - - 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 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, - })) +impl InfoApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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); - - 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 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_trait] +impl InfoApiClient { + pub async fn alive_get(&self) -> Result { + let local_var_configuration = &self.configuration; + + 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 local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.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 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); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + pub async fn now_get(&self) -> Result { + let local_var_configuration = &self.configuration; + + 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()); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.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(); - - 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 version_get(&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()); + + let local_var_req = local_var_req_builder.build()?; + 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)) + } } } diff --git a/crates/bitwarden-api-identity/src/apis/mod.rs b/crates/bitwarden-api-identity/src/apis/mod.rs index 9fbb0e914..9c9e76306 100644 --- a/crates/bitwarden-api-identity/src/apis/mod.rs +++ b/crates/bitwarden-api-identity/src/apis/mod.rs @@ -1,21 +1,21 @@ use std::{error, fmt}; #[derive(Debug, Clone)] -pub struct ResponseContent { +pub struct ResponseContent { pub status: reqwest::StatusCode, pub content: String, - pub entity: Option, + pub entity: Option, } #[derive(Debug)] -pub enum Error { +pub enum Error { Reqwest(reqwest::Error), Serde(serde_json::Error), Io(std::io::Error), - ResponseError(ResponseContent), + ResponseError(ResponseContent), } -impl fmt::Display for Error { +impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (module, e) = match self { Error::Reqwest(e) => ("reqwest", e.to_string()), @@ -27,7 +27,7 @@ impl fmt::Display for Error { } } -impl error::Error for Error { +impl error::Error for Error { fn source(&self) -> Option<&(dyn error::Error + 'static)> { Some(match self { Error::Reqwest(e) => e, @@ -38,19 +38,19 @@ impl error::Error for Error { } } -impl From for Error { +impl From for Error { fn from(e: reqwest::Error) -> Self { Error::Reqwest(e) } } -impl From for Error { +impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Serde(e) } } -impl From for Error { +impl From for Error { fn from(e: std::io::Error) -> Self { Error::Io(e) } @@ -117,3 +117,33 @@ pub mod info_api; pub mod sso_api; pub mod configuration; + +use std::sync::Arc; + +pub struct ApiClient { + accounts_api: accounts_api::AccountsApiClient, + info_api: info_api::InfoApiClient, + sso_api: sso_api::SsoApiClient, +} + +impl ApiClient { + pub fn new(configuration: Arc) -> Self { + Self { + accounts_api: accounts_api::AccountsApiClient::new(configuration.clone()), + info_api: info_api::InfoApiClient::new(configuration.clone()), + sso_api: sso_api::SsoApiClient::new(configuration.clone()), + } + } +} + +impl ApiClient { + pub fn accounts_api(&self) -> &accounts_api::AccountsApiClient { + &self.accounts_api + } + pub fn info_api(&self) -> &info_api::InfoApiClient { + &self.info_api + } + pub fn sso_api(&self) -> &sso_api::SsoApiClient { + &self.sso_api + } +} diff --git a/crates/bitwarden-api-identity/src/apis/sso_api.rs b/crates/bitwarden-api-identity/src/apis/sso_api.rs index 31030869b..c723e309e 100644 --- a/crates/bitwarden-api-identity/src/apis/sso_api.rs +++ b/crates/bitwarden-api-identity/src/apis/sso_api.rs @@ -8,184 +8,202 @@ * Generated by: https://openapi-generator.tech */ +//use async_trait::async_trait; +use std::sync::Arc; + 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 [`sso_external_callback_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SsoExternalCallbackGetError { - UnknownValue(serde_json::Value), -} +use super::{configuration, Error}; +use crate::{ + apis::{ContentType, ResponseContent}, + models, +}; -/// struct for typed errors of method [`sso_external_challenge_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SsoExternalChallengeGetError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`sso_login_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SsoLoginGetError { - UnknownValue(serde_json::Value), +/* +#[async_trait] +pub trait SsoApi: Send + Sync { + + /// GET /sso/ExternalCallback + /// + /// + async fn sso_external_callback_get(&self, ) -> Result<(), Error>; + + /// GET /sso/ExternalChallenge + /// + /// + async fn sso_external_challenge_get(&self, domain_hint: Option<&str>, return_url: Option<&str>, user_identifier: Option<&str>, sso_token: Option<&str>) -> Result<(), Error>; + + /// GET /sso/Login + /// + /// + async fn sso_login_get(&self, return_url: Option<&str>) -> Result<(), Error>; + + /// GET /sso/PreValidate + /// + /// + async fn sso_pre_validate_get(&self, domain_hint: Option<&str>) -> Result<(), Error>; } +*/ -/// struct for typed errors of method [`sso_pre_validate_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum SsoPreValidateGetError { - UnknownValue(serde_json::Value), +pub struct SsoApiClient { + configuration: Arc, } -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); - - 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(); - - 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, - })) +impl SsoApiClient { + pub fn new(configuration: Arc) -> Self { + Self { configuration } } } -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()); +// #[async_trait] +impl SsoApiClient { + pub async fn sso_external_callback_get(&self) -> Result<(), Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + 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()); + + let local_var_req = local_var_req_builder.build()?; + 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, - })) - } -} - -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; - - let uri_str = format!("{}/sso/Login", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref param_value) = p_return_url { - req_builder = req_builder.query(&[("returnUrl", ¶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()); + pub async fn sso_external_challenge_get( + &self, + domain_hint: Option<&str>, + return_url: Option<&str>, + user_identifier: Option<&str>, + sso_token: Option<&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())]); + } + + let local_var_req = local_var_req_builder.build()?; + 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, - })) - } -} - -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; - - let uri_str = format!("{}/sso/PreValidate", 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 user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + pub async fn sso_login_get(&self, return_url: Option<&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())]); + } + + let local_var_req = local_var_req_builder.build()?; + 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, - })) + pub async fn sso_pre_validate_get(&self, domain_hint: Option<&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())]); + } + + let local_var_req = local_var_req_builder.build()?; + 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)) + } } } 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-api-identity/src/models/mod.rs b/crates/bitwarden-api-identity/src/models/mod.rs index fd1579eca..b7f4fbccc 100644 --- a/crates/bitwarden-api-identity/src/models/mod.rs +++ b/crates/bitwarden-api-identity/src/models/mod.rs @@ -34,42 +34,3 @@ pub mod user_verification_requirement; pub use self::user_verification_requirement::UserVerificationRequirement; pub mod web_authn_login_assertion_options_response_model; pub use self::web_authn_login_assertion_options_response_model::WebAuthnLoginAssertionOptionsResponseModel; -/* -use serde::{Deserialize, Deserializer, Serializer}; -use serde_with::{de::DeserializeAsWrap, ser::SerializeAsWrap, DeserializeAs, SerializeAs}; -use std::marker::PhantomData; - -pub(crate) struct DoubleOption(PhantomData); - -impl SerializeAs>> for DoubleOption -where - TAs: SerializeAs, -{ - fn serialize_as(values: &Option>, serializer: S) -> Result - where - S: Serializer, - { - match values { - None => serializer.serialize_unit(), - Some(None) => serializer.serialize_none(), - Some(Some(v)) => serializer.serialize_some(&SerializeAsWrap::::new(v)), - } - } -} - -impl<'de, T, TAs> DeserializeAs<'de, Option>> for DoubleOption -where - TAs: DeserializeAs<'de, T>, - T: std::fmt::Debug, -{ - fn deserialize_as(deserializer: D) -> Result>, D::Error> - where - D: Deserializer<'de>, - { - Ok(Some( - DeserializeAsWrap::, Option>::deserialize(deserializer)? - .into_inner(), - )) - } -} -*/ diff --git a/crates/bitwarden-core/src/auth/api/request/mod.rs b/crates/bitwarden-core/src/auth/api/request/mod.rs index 19f91e524..2d3349973 100644 --- a/crates/bitwarden-core/src/auth/api/request/mod.rs +++ b/crates/bitwarden-core/src/auth/api/request/mod.rs @@ -33,21 +33,19 @@ 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", ) .header(reqwest::header::ACCEPT, "application/json") - .header("Device-Type", configurations.device_type as usize); + .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 52d20b6a7..263a2e762 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); @@ -81,7 +79,7 @@ pub(crate) async fn complete_auth_request( &auth_req.email, &auth_req.auth_request_id, &auth_req.access_code, - config.device_type, + config.device_type(), &auth_req.device_identifier, ) .send(&config) diff --git a/crates/bitwarden-core/src/auth/login/prelogin.rs b/crates/bitwarden-core/src/auth/login/prelogin.rs index 5d5d58e6b..35622cddf 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..9afa2b9ba 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/client/client.rs b/crates/bitwarden-core/src/client/client.rs index 4a2db6a80..bc6fa2903 100644 --- a/crates/bitwarden-core/src/client/client.rs +++ b/crates/bitwarden-core/src/client/client.rs @@ -66,13 +66,15 @@ impl Client { HeaderValue::from_str(&(settings.device_type as u8).to_string()) .expect("All numbers are valid ASCII"), ); - let client_builder = new_client_builder().default_headers(headers); + let client_builder = new_client_builder() + .default_headers(headers) + .user_agent(settings.user_agent); let client = client_builder.build().expect("Build should not fail"); let identity = bitwarden_api_identity::apis::configuration::Configuration { base_path: settings.identity_url, - user_agent: Some(settings.user_agent.clone()), + user_agent: None, client: client.clone(), basic_auth: None, oauth_access_token: None, @@ -82,7 +84,7 @@ impl Client { let api = bitwarden_api_api::apis::configuration::Configuration { base_path: settings.api_url, - user_agent: Some(settings.user_agent), + user_agent: None, client, basic_auth: None, oauth_access_token: None, @@ -97,11 +99,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 847ef16d5..734924f40 100644 --- a/crates/bitwarden-core/src/client/internal.rs +++ b/crates/bitwarden-core/src/client/internal.rs @@ -48,11 +48,67 @@ impl From<&InitUserCryptoRequest> for UserKeyState { } #[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 device_type: DeviceType, + identity_client: Arc, + api_client: Arc, + pub(crate) identity_config: Arc, + pub(crate) api_config: Arc, + 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); + } + + // Expose getters for the API clients, so we can more easily change them to use trait objects in + // the future. + + pub fn api_client(&self) -> &bitwarden_api_api::apis::ApiClient { + &self.api_client + } + + pub fn identity_client(&self) -> &bitwarden_api_identity::apis::ApiClient { + &self.identity_client + } + + pub fn device_type(&self) -> DeviceType { + self.device_type + } } /// Access and refresh tokens used for authentication and authorization. @@ -95,7 +151,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)] @@ -167,14 +223,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)] @@ -194,7 +246,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/error.rs b/crates/bitwarden-core/src/error.rs index 996d7d43d..8e51a68bb 100644 --- a/crates/bitwarden-core/src/error.rs +++ b/crates/bitwarden-core/src/error.rs @@ -11,8 +11,8 @@ use thiserror::Error; macro_rules! impl_bitwarden_error { ($name:ident, $error:ident) => { - impl From<$name> for $error { - fn from(e: $name) -> Self { + impl From<$name> for $error { + fn from(e: $name) -> Self { match e { $name::Reqwest(e) => Self::Reqwest(e), $name::ResponseError(e) => Self::ResponseContent { 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..d9945ccb4 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-test/src/api.rs b/crates/bitwarden-test/src/api.rs index 265dee15b..216545652 100644 --- a/crates/bitwarden-test/src/api.rs +++ b/crates/bitwarden-test/src/api.rs @@ -1,9 +1,13 @@ +use std::sync::Arc; + use bitwarden_api_api::apis::configuration::Configuration; /// Helper for testing the Bitwarden API using wiremock. /// /// Warning: when using `Mock::expected` ensure `server` is not dropped before the test completes, -pub async fn start_api_mock(mocks: Vec) -> (wiremock::MockServer, Configuration) { +pub async fn start_api_mock( + mocks: Vec, +) -> (wiremock::MockServer, bitwarden_api_api::apis::ApiClient) { let server = wiremock::MockServer::start().await; for mock in mocks { @@ -20,5 +24,7 @@ pub async fn start_api_mock(mocks: Vec) -> (wiremock::MockServer api_key: None, }; - (server, config) + let api_client = bitwarden_api_api::apis::ApiClient::new(Arc::new(config)); + + (server, api_client) } diff --git a/crates/bitwarden-vault/src/folder/create.rs b/crates/bitwarden-vault/src/folder/create.rs index 115fbce9e..a29da9bd4 100644 --- a/crates/bitwarden-vault/src/folder/create.rs +++ b/crates/bitwarden-vault/src/folder/create.rs @@ -1,4 +1,4 @@ -use bitwarden_api_api::{apis::folders_api, models::FolderRequestModel}; +use bitwarden_api_api::models::FolderRequestModel; use bitwarden_core::{ key_management::{KeyIds, SymmetricKeyId}, require, ApiError, MissingFieldError, @@ -63,12 +63,15 @@ pub enum CreateFolderError { pub(super) async fn create_folder + ?Sized>( key_store: &KeyStore, - api_config: &bitwarden_api_api::apis::configuration::Configuration, + api_client: &bitwarden_api_api::apis::ApiClient, repository: &R, request: FolderAddEditRequest, ) -> Result { let folder_request = key_store.encrypt(request)?; - let resp = folders_api::folders_post(api_config, Some(folder_request)) + + let resp = api_client + .folders_api() + .folders_post(Some(folder_request)) .await .map_err(ApiError::from)?; @@ -102,7 +105,7 @@ mod tests { let folder_id = uuid!("25afb11c-9c95-4db5-8bac-c21cb204a3f1"); - let (_server, api_config) = start_api_mock(vec![Mock::given(matchers::path("/folders")) + let (_server, api_client) = start_api_mock(vec![Mock::given(matchers::path("/folders")) .respond_with(move |req: &Request| { let body: FolderRequestModel = req.body_json().unwrap(); ResponseTemplate::new(201).set_body_json(FolderResponseModel { @@ -119,7 +122,7 @@ mod tests { let result = create_folder( &store, - &api_config, + &api_client, &repository, FolderAddEditRequest { name: "test".to_string(), @@ -161,7 +164,7 @@ mod tests { SymmetricCryptoKey::make_aes256_cbc_hmac_key(), ); - let (_server, api_config) = start_api_mock(vec![ + let (_server, api_client) = start_api_mock(vec![ Mock::given(matchers::path("/folders")).respond_with(ResponseTemplate::new(500)) ]) .await; @@ -170,7 +173,7 @@ mod tests { let result = create_folder( &store, - &api_config, + &api_client, &repository, FolderAddEditRequest { name: "test".to_string(), diff --git a/crates/bitwarden-vault/src/folder/edit.rs b/crates/bitwarden-vault/src/folder/edit.rs index d93c637fd..8d21ab549 100644 --- a/crates/bitwarden-vault/src/folder/edit.rs +++ b/crates/bitwarden-vault/src/folder/edit.rs @@ -1,4 +1,3 @@ -use bitwarden_api_api::apis::folders_api; use bitwarden_core::{key_management::KeyIds, ApiError, MissingFieldError}; use bitwarden_crypto::{CryptoError, KeyStore}; use bitwarden_error::bitwarden_error; @@ -31,7 +30,7 @@ pub enum EditFolderError { pub(super) async fn edit_folder + ?Sized>( key_store: &KeyStore, - api_config: &bitwarden_api_api::apis::configuration::Configuration, + api_client: &bitwarden_api_api::apis::ApiClient, repository: &R, folder_id: &str, request: FolderAddEditRequest, @@ -44,7 +43,9 @@ pub(super) async fn edit_folder + ?Sized>( let folder_request = key_store.encrypt(request)?; - let resp = folders_api::folders_id_put(api_config, folder_id, Some(folder_request)) + let resp = api_client + .folders_api() + .folders_id_put(folder_id, Some(folder_request)) .await .map_err(ApiError::from)?; @@ -61,10 +62,7 @@ pub(super) async fn edit_folder + ?Sized>( #[cfg(test)] mod tests { - use bitwarden_api_api::{ - apis::configuration::Configuration, - models::{FolderRequestModel, FolderResponseModel}, - }; + use bitwarden_api_api::models::{FolderRequestModel, FolderResponseModel}; use bitwarden_core::key_management::SymmetricKeyId; use bitwarden_crypto::{PrimitiveEncryptable, SymmetricCryptoKey}; use bitwarden_test::{start_api_mock, MemoryRepository}; @@ -105,9 +103,8 @@ mod tests { let folder_id = uuid!("25afb11c-9c95-4db5-8bac-c21cb204a3f1"); - let (_server, api_config) = start_api_mock(vec![Mock::given(matchers::path(format!( - "/folders/{}", - folder_id + let (_server, api_client) = start_api_mock(vec![Mock::given(matchers::path(format!( + "/folders/{folder_id}", ))) .respond_with(move |req: &Request| { let body: FolderRequestModel = req.body_json().unwrap(); @@ -126,7 +123,7 @@ mod tests { let result = edit_folder( &store, - &api_config, + &api_client, &repository, &folder_id.to_string(), FolderAddEditRequest { @@ -153,9 +150,11 @@ mod tests { let repository = MemoryRepository::::default(); let folder_id = uuid!("25afb11c-9c95-4db5-8bac-c21cb204a3f1"); + let (_server, api_client) = start_api_mock(vec![]).await; + let result = edit_folder( &store, - &Configuration::default(), + &api_client, &repository, &folder_id.to_string(), FolderAddEditRequest { @@ -182,9 +181,8 @@ mod tests { let folder_id = uuid!("25afb11c-9c95-4db5-8bac-c21cb204a3f1"); - let (_server, api_config) = start_api_mock(vec![Mock::given(matchers::path(format!( - "/folders/{}", - folder_id + let (_server, api_client) = start_api_mock(vec![Mock::given(matchers::path(format!( + "/folders/{folder_id}", ))) .respond_with(ResponseTemplate::new(500))]) .await; @@ -194,7 +192,7 @@ mod tests { let result = edit_folder( &store, - &api_config, + &api_client, &repository, &folder_id.to_string(), FolderAddEditRequest { diff --git a/crates/bitwarden-vault/src/folder/folder_client.rs b/crates/bitwarden-vault/src/folder/folder_client.rs index 63370bab6..a3f839ea8 100644 --- a/crates/bitwarden-vault/src/folder/folder_client.rs +++ b/crates/bitwarden-vault/src/folder/folder_client.rs @@ -65,7 +65,7 @@ impl FoldersClient { let config = self.client.internal.get_api_configurations().await; let repository = self.get_repository()?; - create_folder(key_store, &config.api, repository.as_ref(), request).await + create_folder(key_store, config.api_client(), repository.as_ref(), request).await } /// Edit the [Folder] and save it to the server. @@ -80,7 +80,7 @@ impl FoldersClient { edit_folder( key_store, - &config.api, + config.api_client(), repository.as_ref(), folder_id, request, diff --git a/crates/bitwarden-vault/src/sync.rs b/crates/bitwarden-vault/src/sync.rs index 63bdb8ffe..64bd3ab8b 100644 --- a/crates/bitwarden-vault/src/sync.rs +++ b/crates/bitwarden-vault/src/sync.rs @@ -35,7 +35,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/openapitools.json b/openapitools.json index 151c200f7..a82623d64 100644 --- a/openapitools.json +++ b/openapitools.json @@ -2,6 +2,6 @@ "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", "spaces": 2, "generator-cli": { - "version": "7.13.0" + "version": "7.14.0" } } diff --git a/package-lock.json b/package-lock.json index ac7363aea..fed0a4ecb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,18 +9,134 @@ "version": "0.0.0", "license": "SEE LICENSE IN LICENSE", "devDependencies": { - "@openapitools/openapi-generator-cli": "2.20.2", + "@openapitools/openapi-generator-cli": "2.21.4", "prettier": "3.5.3" } }, - "node_modules/@babel/runtime": { - "version": "7.27.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.6.tgz", - "integrity": "sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==", + "node_modules/@isaacs/balanced-match": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz", + "integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==", "dev": true, "license": "MIT", "engines": { - "node": ">=6.9.0" + "node": "20 || >=22" + } + }, + "node_modules/@isaacs/brace-expansion": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz", + "integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@isaacs/balanced-match": "^4.0.1" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/@lukeed/csprng": { @@ -34,9 +150,9 @@ } }, "node_modules/@nestjs/axios": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-4.0.0.tgz", - "integrity": "sha512-1cB+Jyltu/uUPNQrpUimRHEQHrnQrpLzVj6dU3dgn6iDDDdahr10TgHFGTmw5VuJ9GzKZsCLDL78VSwJAs/9JQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-4.0.1.tgz", + "integrity": "sha512-68pFJgu+/AZbWkGu65Z3r55bTsCPlgyKaV4BSG8yUAD72q1PPuyVRgUwFv6BxdnibTUHlyxm06FmYWNC+bjN7A==", "dev": true, "license": "MIT", "peerDependencies": { @@ -46,13 +162,13 @@ } }, "node_modules/@nestjs/common": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.1.1.tgz", - "integrity": "sha512-crzp+1qeZ5EGL0nFTPy9NrVMAaUWewV5AwtQyv6SQ9yQPXwRl9W9hm1pt0nAtUu5QbYMbSuo7lYcF81EjM+nCA==", + "version": "11.1.5", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.1.5.tgz", + "integrity": "sha512-DQpWdr3ShO0BHWkHl3I4W/jR6R3pDtxyBlmrpTuZF+PXxQyBXNvsUne0Wyo6QHPEDi+pAz9XchBFoKbqOhcdTg==", "dev": true, "license": "MIT", "dependencies": { - "file-type": "20.5.0", + "file-type": "21.0.0", "iterare": "1.2.1", "load-esm": "1.0.2", "tslib": "2.8.1", @@ -78,9 +194,9 @@ } }, "node_modules/@nestjs/core": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-11.1.1.tgz", - "integrity": "sha512-UFoUAgLKFT+RwHTANJdr0dF7p0qS9QjkaUPjg8aafnjM/qxxxrUVDB49nVvyMlk+Hr1+vvcNaOHbWWQBxoZcHA==", + "version": "11.1.5", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-11.1.5.tgz", + "integrity": "sha512-Qr25MEY9t8VsMETy7eXQ0cNXqu0lzuFrrTr+f+1G57ABCtV5Pogm7n9bF71OU2bnkDD32Bi4hQLeFR90cku3Tw==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -163,25 +279,25 @@ "license": "MIT" }, "node_modules/@openapitools/openapi-generator-cli": { - "version": "2.20.2", - "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.20.2.tgz", - "integrity": "sha512-dNFwQcQu6+rmEWSJj4KUx468+p6Co7nfpVgi5QEfVhzKj7wBytz9GEhCN2qmVgtg3ZX8H6nxbXI8cjh7hAxAqg==", + "version": "2.21.4", + "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.21.4.tgz", + "integrity": "sha512-s2OBgiNml0DL0ebkvAMQxZi7c8SUQMHssTUJwWsFDv4kVtBVDV4UzsCh9gQEXlNjuEcEgZoa5BIOai2sT0sE8g==", "dev": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@nestjs/axios": "4.0.0", - "@nestjs/common": "11.1.1", - "@nestjs/core": "11.1.1", + "@nestjs/axios": "4.0.1", + "@nestjs/common": "11.1.5", + "@nestjs/core": "11.1.5", "@nuxtjs/opencollective": "0.3.2", - "axios": "1.9.0", + "axios": "1.11.0", "chalk": "4.1.2", "commander": "8.3.0", "compare-versions": "4.1.4", - "concurrently": "6.5.1", + "concurrently": "9.2.0", "console.table": "0.10.0", "fs-extra": "11.3.0", - "glob": "9.3.5", + "glob": "11.0.3", "inquirer": "8.2.6", "lodash": "4.17.21", "proxy-agent": "6.5.0", @@ -306,24 +422,17 @@ "license": "MIT" }, "node_modules/axios": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.9.0.tgz", - "integrity": "sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.11.0.tgz", + "integrity": "sha512-1Lx3WLFQWm3ooKDYZD1eXmoGO9fxYQjrycfHFC8P0sCfQVXyROp0p9PFWBehewBOdCwHc+f/b8I0fMto5eSfwA==", "dev": true, "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", + "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -367,16 +476,6 @@ "readable-stream": "^3.4.0" } }, - "node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", @@ -477,15 +576,18 @@ } }, "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "dev": true, "license": "ISC", "dependencies": { "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" } }, "node_modules/cliui/node_modules/wrap-ansi": { @@ -567,39 +669,29 @@ "license": "MIT" }, "node_modules/concurrently": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-6.5.1.tgz", - "integrity": "sha512-FlSwNpGjWQfRwPLXvJ/OgysbBxPkWpiVjy1042b0U7on7S7qwwMIILRj7WTN1mTgqa582bG6NFuScOoh6Zgdag==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.0.tgz", + "integrity": "sha512-IsB/fiXTupmagMW4MNp2lx2cdSN2FfZq78vF90LBB+zZHArbIQZjQtzXCiXnvTxCZSvXanTqFLWBjw2UkLx1SQ==", "dev": true, "license": "MIT", "dependencies": { - "chalk": "^4.1.0", - "date-fns": "^2.16.1", + "chalk": "^4.1.2", "lodash": "^4.17.21", - "rxjs": "^6.6.3", - "spawn-command": "^0.0.2-1", - "supports-color": "^8.1.0", + "rxjs": "^7.8.1", + "shell-quote": "^1.8.1", + "supports-color": "^8.1.1", "tree-kill": "^1.2.2", - "yargs": "^16.2.0" + "yargs": "^17.7.2" }, "bin": { - "concurrently": "bin/concurrently.js" + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" }, "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/concurrently/node_modules/rxjs": { - "version": "6.6.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", - "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "tslib": "^1.9.0" + "node": ">=18" }, - "engines": { - "npm": ">=2.0.0" + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" } }, "node_modules/concurrently/node_modules/supports-color": { @@ -618,13 +710,6 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/concurrently/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true, - "license": "0BSD" - }, "node_modules/consola": { "version": "3.4.2", "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.2.tgz", @@ -648,31 +733,29 @@ "node": "> 0.10" } }, - "node_modules/data-uri-to-buffer": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz", - "integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==", + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, "engines": { - "node": ">= 14" + "node": ">= 8" } }, - "node_modules/date-fns": { - "version": "2.30.0", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", - "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "node_modules/data-uri-to-buffer": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz", + "integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==", "dev": true, "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.21.0" - }, "engines": { - "node": ">=0.11" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/date-fns" + "node": ">= 14" } }, "node_modules/debug": { @@ -746,6 +829,13 @@ "node": ">= 0.4" } }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, + "license": "MIT" + }, "node_modules/easy-table": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/easy-table/-/easy-table-1.1.0.tgz", @@ -934,28 +1024,28 @@ } }, "node_modules/file-type": { - "version": "20.5.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-20.5.0.tgz", - "integrity": "sha512-BfHZtG/l9iMm4Ecianu7P8HRD2tBHLtjXinm4X62XBOYzi7CYA7jyqfJzOvXHqzVrVPYqBo2/GvbARMaaJkKVg==", + "version": "21.0.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-21.0.0.tgz", + "integrity": "sha512-ek5xNX2YBYlXhiUXui3D/BXa3LdqPmoLJ7rqEx2bKJ7EAUEfmXgW0Das7Dc6Nr9MvqaOnIqiPV0mZk/r/UpNAg==", "dev": true, "license": "MIT", "dependencies": { - "@tokenizer/inflate": "^0.2.6", - "strtok3": "^10.2.0", + "@tokenizer/inflate": "^0.2.7", + "strtok3": "^10.2.2", "token-types": "^6.0.0", "uint8array-extras": "^1.4.0" }, "engines": { - "node": ">=18" + "node": ">=20" }, "funding": { "url": "https://github.com/sindresorhus/file-type?sponsor=1" } }, "node_modules/follow-redirects": { - "version": "1.15.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", - "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", "dev": true, "funding": [ { @@ -973,10 +1063,40 @@ } } }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/foreground-child/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/form-data": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.3.tgz", - "integrity": "sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", "dev": true, "license": "MIT", "dependencies": { @@ -1005,13 +1125,6 @@ "node": ">=14.14" } }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true, - "license": "ISC" - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -1087,19 +1200,24 @@ } }, "node_modules/glob": { - "version": "9.3.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-9.3.5.tgz", - "integrity": "sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==", + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", + "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", "dev": true, "license": "ISC", "dependencies": { - "fs.realpath": "^1.0.0", - "minimatch": "^8.0.2", - "minipass": "^4.2.4", - "path-scurry": "^1.6.1" + "foreground-child": "^3.3.1", + "jackspeak": "^4.1.1", + "minimatch": "^10.0.3", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -1320,6 +1438,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, "node_modules/iterare": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz", @@ -1330,6 +1455,22 @@ "node": ">=6" } }, + "node_modules/jackspeak": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz", + "integrity": "sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/jsbn": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", @@ -1395,11 +1536,14 @@ } }, "node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.1.0.tgz", + "integrity": "sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==", "dev": true, - "license": "ISC" + "license": "ISC", + "engines": { + "node": "20 || >=22" + } }, "node_modules/math-intrinsics": { "version": "1.1.0", @@ -1445,29 +1589,29 @@ } }, "node_modules/minimatch": { - "version": "8.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-8.0.4.tgz", - "integrity": "sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==", + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", + "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", "dev": true, "license": "ISC", "dependencies": { - "brace-expansion": "^2.0.1" + "@isaacs/brace-expansion": "^5.0.0" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/minipass": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz", - "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "dev": true, "license": "ISC", "engines": { - "node": ">=8" + "node": ">=16 || 14 >=14.17" } }, "node_modules/ms": { @@ -1599,33 +1743,40 @@ "node": ">= 14" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" }, "engines": { - "node": ">=16 || 14 >=14.18" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/path-scurry/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/path-to-regexp": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", @@ -1783,6 +1934,42 @@ "dev": true, "license": "MIT" }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/shell-quote": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz", + "integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -1842,12 +2029,6 @@ "node": ">=0.10.0" } }, - "node_modules/spawn-command": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", - "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==", - "dev": true - }, "node_modules/sprintf-js": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", @@ -1880,6 +2061,22 @@ "node": ">=8" } }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -1893,10 +2090,24 @@ "node": ">=8" } }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strtok3": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-10.3.1.tgz", - "integrity": "sha512-3JWEZM6mfix/GCJBBUrkA8p2Id2pBkyTkVCJKto55w080QBKZ+8R171fGrbiSp+yMO/u6F8/yUh7K4V9K+YCnw==", + "version": "10.3.4", + "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-10.3.4.tgz", + "integrity": "sha512-KIy5nylvC5le1OdaaoCJ07L+8iQzJHGH6pWDuzS+d07Cu7n1MZ2x26P8ZKIWfbK02+XIL8Mp4RkWeqdUCrDMfg==", "dev": true, "license": "MIT", "dependencies": { @@ -1944,9 +2155,9 @@ } }, "node_modules/token-types": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/token-types/-/token-types-6.0.0.tgz", - "integrity": "sha512-lbDrTLVsHhOMljPscd0yitpozq7Ga2M5Cvez5AjGg8GASBjtt6iERCAJ93yommPmz62fb45oFIXHEZ3u9bfJEA==", + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/token-types/-/token-types-6.0.4.tgz", + "integrity": "sha512-MD9MjpVNhVyH4fyd5rKphjvt/1qj+PtQUz65aFqAZA6XniWAuSFRjLk3e2VALEFlh9OwBpXUN7rfeqSnT/Fmkw==", "dev": true, "license": "MIT", "dependencies": { @@ -2069,6 +2280,22 @@ "webidl-conversions": "^3.0.0" } }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", @@ -2084,6 +2311,25 @@ "node": ">=8" } }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -2095,32 +2341,32 @@ } }, "node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", "dev": true, "license": "MIT", "dependencies": { - "cliui": "^7.0.2", + "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", - "string-width": "^4.2.0", + "string-width": "^4.2.3", "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" + "yargs-parser": "^21.1.1" }, "engines": { - "node": ">=10" + "node": ">=12" } }, "node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true, "license": "ISC", "engines": { - "node": ">=10" + "node": ">=12" } } } diff --git a/package.json b/package.json index 39917a8a0..0ad896fff 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "devDependencies": { - "@openapitools/openapi-generator-cli": "2.20.2", + "@openapitools/openapi-generator-cli": "2.21.4", "prettier": "3.5.3" } } diff --git a/support/build-api.sh b/support/build-api.sh index e45c4c298..96b0955dd 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,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,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/.travis.yml b/support/openapi-template/.travis.yml deleted file mode 100644 index 22761ba7e..000000000 --- a/support/openapi-template/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: rust diff --git a/support/openapi-template/Cargo.mustache b/support/openapi-template/Cargo.mustache index cdaf12fc9..30f73e878 100644 --- a/support/openapi-template/Cargo.mustache +++ b/support/openapi-template/Cargo.mustache @@ -1,18 +1,35 @@ [package] name = "{{{packageName}}}" -{{#description}} +version = "{{#lambdaVersion}}{{{packageVersion}}}{{/lambdaVersion}}" +{{#infoEmail}} +authors = ["{{{.}}}"] +{{/infoEmail}} +{{^infoEmail}} +authors = ["OpenAPI Generator team and contributors"] +{{/infoEmail}} +{{#appDescription}} description = "{{{.}}}" -{{/description}} -categories = ["api-bindings"] - -version.workspace = true -authors.workspace = true -edition.workspace = true -rust-version.workspace = true -homepage.workspace = true -repository.workspace = true -license-file.workspace = true -keywords.workspace = true +{{/appDescription}} +{{#licenseInfo}} +license = "{{.}}" +{{/licenseInfo}} +{{^licenseInfo}} +# Override this license by providing a License Object in the OpenAPI. +license = "Unlicense" +{{/licenseInfo}} +edition = "2021" +{{#publishRustRegistry}} +publish = ["{{.}}"] +{{/publishRustRegistry}} +{{#repositoryUrl}} +repository = "{{.}}" +{{/repositoryUrl}} +{{#documentationUrl}} +documentation = "{{.}}" +{{/documentationUrl}} +{{#homePageUrl}} +homepage = "{{.}}" +{{/homePageUrl}} [dependencies] serde = { version = "^1.0", features = ["derive"] } @@ -46,13 +63,13 @@ secrecy = "0.8.0" {{/withAWSV4Signature}} {{#reqwest}} {{^supportAsync}} -reqwest = { version = "^0.12", default-features = false, features = ["json", "blocking", "multipart", "http2"] } +reqwest = { version = "^0.12", default-features = false, features = ["json", "blocking", "multipart"] } {{#supportMiddleware}} reqwest-middleware = { version = "^0.4", features = ["json", "blocking", "multipart"] } {{/supportMiddleware}} {{/supportAsync}} {{#supportAsync}} -reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart", "http2"] } +reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart"] } {{#supportMiddleware}} reqwest-middleware = { version = "^0.4", features = ["json", "multipart"] } {{/supportMiddleware}} @@ -65,7 +82,7 @@ google-cloud-token = "^0.1" {{/reqwest}} {{#reqwestTrait}} async-trait = "^0.1" -reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart", "http2"] } +reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart"] } {{#supportMiddleware}} reqwest-middleware = { version = "^0.4", features = ["json", "multipart"] } {{/supportMiddleware}} diff --git a/support/openapi-template/api_doc.mustache b/support/openapi-template/api_doc.mustache deleted file mode 100644 index f8ea52038..000000000 --- a/support/openapi-template/api_doc.mustache +++ /dev/null @@ -1,47 +0,0 @@ -# {{{invokerPackage}}}\{{{classname}}}{{#description}} - -{{{.}}}{{/description}} - -All URIs are relative to *{{{basePath}}}* - -Method | HTTP request | Description -------------- | ------------- | ------------- -{{#operations}}{{#operation}}[**{{{operationId}}}**]({{{classname}}}.md#{{{operationId}}}) | **{{{httpMethod}}}** {{{path}}} | {{{summary}}} -{{/operation}}{{/operations}} - -{{#operations}} -{{#operation}} - -## {{{operationId}}} - -> {{#returnType}}{{{.}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}) -{{{summary}}}{{#notes}} - -{{{.}}}{{/notes}} - -### Parameters - -{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} -Name | Type | Description | Required | Notes -------------- | ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} -{{#allParams}} -**{{{paramName}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{baseType}}}.md){{/isPrimitiveType}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}} | {{#required}}[required]{{/required}} |{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} -{{/allParams}} - -### Return type - -{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{{returnBaseType}}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}} (empty response body){{/returnType}} - -### Authorization - -{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} - -### HTTP request headers - -- **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} -- **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}} - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -{{/operation}} -{{/operations}} diff --git a/support/openapi-template/git_push.sh.mustache b/support/openapi-template/git_push.sh.mustache deleted file mode 100755 index 0e3776ae6..000000000 --- a/support/openapi-template/git_push.sh.mustache +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ -# -# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" - -git_user_id=$1 -git_repo_id=$2 -release_note=$3 -git_host=$4 - -if [ "$git_host" = "" ]; then - git_host="{{{gitHost}}}" - echo "[INFO] No command line input provided. Set \$git_host to $git_host" -fi - -if [ "$git_user_id" = "" ]; then - git_user_id="{{{gitUserId}}}" - echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" -fi - -if [ "$git_repo_id" = "" ]; then - git_repo_id="{{{gitRepoId}}}" - echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" -fi - -if [ "$release_note" = "" ]; then - release_note="{{{releaseNote}}}" - echo "[INFO] No command line input provided. Set \$release_note to $release_note" -fi - -# Initialize the local directory as a Git repository -git init - -# Adds the files in the local repository and stages them for commit. -git add . - -# Commits the tracked changes and prepares them to be pushed to a remote repository. -git commit -m "$release_note" - -# Sets the new remote -git_remote=$(git remote) -if [ "$git_remote" = "" ]; then # git remote not defined - - if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git - else - git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git - fi - -fi - -git pull origin master - -# Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" -git push origin master 2>&1 | grep -v 'To https' diff --git a/support/openapi-template/gitignore.mustache b/support/openapi-template/gitignore.mustache deleted file mode 100644 index 6aa106405..000000000 --- a/support/openapi-template/gitignore.mustache +++ /dev/null @@ -1,3 +0,0 @@ -/target/ -**/*.rs.bk -Cargo.lock diff --git a/support/openapi-template/hyper/api.mustache b/support/openapi-template/hyper/api.mustache deleted file mode 100644 index 9c0f7fd31..000000000 --- a/support/openapi-template/hyper/api.mustache +++ /dev/null @@ -1,182 +0,0 @@ -{{>partial_header}} -use std::sync::Arc; -use std::borrow::Borrow; -use std::pin::Pin; -#[allow(unused_imports)] -use std::option::Option; - -use hyper; -use hyper_util::client::legacy::connect::Connect; -use futures::Future; - -use crate::models; -use super::{Error, configuration}; -use super::request as __internal_request; - -pub struct {{{classname}}}Client - where C: Clone + std::marker::Send + Sync + 'static { - configuration: Arc>, -} - -impl {{{classname}}}Client - where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Arc>) -> {{{classname}}}Client { - {{{classname}}}Client { - configuration, - } - } -} - -pub trait {{{classname}}}: Send + Sync { -{{#operations}} -{{#operation}} - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin> + Send>>; -{{/operation}} -{{/operations}} -} - -impl{{{classname}}} for {{{classname}}}Client - where C: Clone + std::marker::Send + Sync { - {{#operations}} - {{#operation}} - #[allow(unused_mut)] - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin> + Send>> { - let mut req = __internal_request::Request::new(hyper::Method::{{{httpMethod.toUpperCase}}}, "{{{path}}}".to_string()) - {{#hasAuthMethods}} - {{#authMethods}} - {{#isApiKey}} - .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ - in_header: {{#isKeyInHeader}}true{{/isKeyInHeader}}{{^isKeyInHeader}}false{{/isKeyInHeader}}, - in_query: {{#isKeyInQuery}}true{{/isKeyInQuery}}{{^isKeyInQuery}}false{{/isKeyInQuery}}, - param_name: "{{{keyParamName}}}".to_owned(), - })) - {{/isApiKey}} - {{#isBasicBasic}} - .with_auth(__internal_request::Auth::Basic) - {{/isBasicBasic}} - {{#isOAuth}} - .with_auth(__internal_request::Auth::Oauth) - {{/isOAuth}} - {{/authMethods}} - {{/hasAuthMethods}} - ; - {{#queryParams}} - {{#required}} - {{^isNullable}} - req = req.with_query_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_query_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_query_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(ref s) = {{{paramName}}} { - {{#isArray}} - let query_value = s.iter().map(|s| s.to_string()).collect::>().join(","); - {{/isArray}} - {{^isArray}} - let query_value = match serde_json::to_string(s) { - Ok(value) => value, - Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), - }; - {{/isArray}} - req = req.with_query_param("{{{baseName}}}".to_string(), query_value); - } - {{/required}} - {{/queryParams}} - {{#pathParams}} - {{#required}} - {{^isNullable}} - req = req.with_path_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_path_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_path_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_path_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/pathParams}} - {{#hasHeaderParams}} - {{#headerParams}} - {{#required}} - {{^isNullable}} - req = req.with_header_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_header_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_header_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_header_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/headerParams}} - {{/hasHeaderParams}} - {{#hasFormParams}} - {{#formParams}} - {{#isFile}} - {{#required}} - {{^isNullable}} - req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); }, - None => { req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); - } - {{/required}} - {{/isFile}} - {{^isFile}} - {{#required}} - {{^isNullable}} - req = req.with_form_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_form_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_form_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_form_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/isFile}} - {{/formParams}} - {{/hasFormParams}} - {{#hasBodyParam}} - {{#bodyParams}} - req = req.with_body_param({{{paramName}}}); - {{/bodyParams}} - {{/hasBodyParam}} - {{^returnType}} - req = req.returns_nothing(); - {{/returnType}} - - req.execute(self.configuration.borrow()) - } - -{{/operation}} -{{/operations}} -} diff --git a/support/openapi-template/hyper/api_mod.mustache b/support/openapi-template/hyper/api_mod.mustache deleted file mode 100644 index 67baa441c..000000000 --- a/support/openapi-template/hyper/api_mod.mustache +++ /dev/null @@ -1,83 +0,0 @@ -use std::fmt; -use std::fmt::Debug; - -use hyper; -use hyper::http; -use hyper_util::client::legacy::connect::Connect; -use serde_json; - -#[derive(Debug)] -pub enum Error { - Api(ApiError), - Header(http::header::InvalidHeaderValue), - Http(http::Error), - Hyper(hyper::Error), - HyperClient(hyper_util::client::legacy::Error), - Serde(serde_json::Error), - UriError(http::uri::InvalidUri), -} - -pub struct ApiError { - pub code: hyper::StatusCode, - pub body: hyper::body::Incoming, -} - -impl Debug for ApiError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("ApiError") - .field("code", &self.code) - .field("body", &"hyper::body::Incoming") - .finish() - } -} - -impl From<(hyper::StatusCode, hyper::body::Incoming)> for Error { - fn from(e: (hyper::StatusCode, hyper::body::Incoming)) -> Self { - Error::Api(ApiError { - code: e.0, - body: e.1, - }) - } -} - -impl From for Error { - fn from(e: http::Error) -> Self { - Error::Http(e) - } -} - -impl From for Error { - fn from(e: hyper_util::client::legacy::Error) -> Self { - Error::HyperClient(e) - } -} - -impl From for Error { - fn from(e: hyper::Error) -> Self { - Error::Hyper(e) - } -} - -impl From for Error { - fn from(e: serde_json::Error) -> Self { - Error::Serde(e) - } -} - -mod request; - -{{#apiInfo}} -{{#apis}} -mod {{{classFilename}}}; -{{#operations}} -{{#operation}} -{{#-last}} -pub use self::{{{classFilename}}}::{ {{{classname}}}, {{{classname}}}Client }; -{{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} - -pub mod configuration; -pub mod client; diff --git a/support/openapi-template/hyper/client.mustache b/support/openapi-template/hyper/client.mustache deleted file mode 100644 index d54e33488..000000000 --- a/support/openapi-template/hyper/client.mustache +++ /dev/null @@ -1,55 +0,0 @@ -use std::sync::Arc; - -use hyper; -use hyper_util::client::legacy::connect::Connect; -use super::configuration::Configuration; - -pub struct APIClient { -{{#apiInfo}} -{{#apis}} -{{#operations}} -{{#operation}} - {{#-last}} - {{{classFilename}}}: Box, - {{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} -} - -impl APIClient { - pub fn new(configuration: Configuration) -> APIClient - where C: Clone + std::marker::Send + Sync + 'static { - let rc = Arc::new(configuration); - - APIClient { -{{#apiInfo}} -{{#apis}} -{{#operations}} -{{#operation}} - {{#-last}} - {{{classFilename}}}: Box::new(crate::apis::{{{classname}}}Client::new(rc.clone())), - {{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} - } - } - -{{#apiInfo}} -{{#apis}} -{{#operations}} -{{#operation}} -{{#-last}} - pub fn {{{classFilename}}}(&self) -> &dyn crate::apis::{{{classname}}}{ - self.{{{classFilename}}}.as_ref() - } - -{{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} -} diff --git a/support/openapi-template/hyper/configuration.mustache b/support/openapi-template/hyper/configuration.mustache deleted file mode 100644 index 43a48ff2a..000000000 --- a/support/openapi-template/hyper/configuration.mustache +++ /dev/null @@ -1,83 +0,0 @@ -{{>partial_header}} -use hyper; -use hyper_util::client::legacy::Client; -use hyper_util::client::legacy::connect::Connect; -use hyper_util::client::legacy::connect::HttpConnector; -use hyper_util::rt::TokioExecutor; - -pub struct Configuration - where C: Clone + std::marker::Send + Sync + 'static { - pub base_path: String, - pub user_agent: Option, - pub client: Client, - pub basic_auth: Option, - pub oauth_access_token: Option, - pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one -} - -pub type BasicAuth = (String, Option); - -pub struct ApiKey { - pub prefix: Option, - pub key: String, -} - -impl Configuration { - /// Construct a default [`Configuration`](Self) with a hyper client using a default - /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector). - /// - /// Use [`with_client`](Configuration::with_client) to construct a Configuration with a - /// custom hyper client. - /// - /// # Example - /// - /// ``` - /// # use {{externCrateName}}::apis::configuration::Configuration; - /// let api_config = Configuration { - /// basic_auth: Some(("user".into(), None)), - /// ..Configuration::new() - /// }; - /// ``` - pub fn new() -> Configuration { - Configuration::default() - } -} - -impl Configuration - where C: Clone + std::marker::Send + Sync { - - /// Construct a new Configuration with a custom hyper client. - /// - /// # Example - /// - /// ``` - /// # use core::time::Duration; - /// # use {{externCrateName}}::apis::configuration::Configuration; - /// use hyper_util::client::legacy::Client; - /// use hyper_util::rt::TokioExecutor; - /// - /// let client = Client::builder(TokioExecutor::new()) - /// .pool_idle_timeout(Duration::from_secs(30)) - /// .build_http(); - /// - /// let api_config = Configuration::with_client(client); - /// ``` - pub fn with_client(client: Client) -> Configuration { - Configuration { - base_path: "{{{basePath}}}".to_owned(), - user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}}, - client, - basic_auth: None, - oauth_access_token: None, - api_key: None, - } - } -} - -impl Default for Configuration { - fn default() -> Self { - let client = Client::builder(TokioExecutor::new()).build_http(); - Configuration::with_client(client) - } -} diff --git a/support/openapi-template/hyper0x/api.mustache b/support/openapi-template/hyper0x/api.mustache deleted file mode 100644 index fe1a65c79..000000000 --- a/support/openapi-template/hyper0x/api.mustache +++ /dev/null @@ -1,181 +0,0 @@ -{{>partial_header}} -use std::rc::Rc; -use std::borrow::Borrow; -use std::pin::Pin; -#[allow(unused_imports)] -use std::option::Option; - -use hyper; -use futures::Future; - -use crate::models; -use super::{Error, configuration}; -use super::request as __internal_request; - -pub struct {{{classname}}}Client - where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, -} - -impl {{{classname}}}Client - where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> {{{classname}}}Client { - {{{classname}}}Client { - configuration, - } - } -} - -pub trait {{{classname}}} { -{{#operations}} -{{#operation}} - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin>>>; -{{/operation}} -{{/operations}} -} - -impl{{{classname}}} for {{{classname}}}Client - where C: Clone + std::marker::Send + Sync { - {{#operations}} - {{#operation}} - #[allow(unused_mut)] - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin>>> { - let mut req = __internal_request::Request::new(hyper::Method::{{{httpMethod.toUpperCase}}}, "{{{path}}}".to_string()) - {{#hasAuthMethods}} - {{#authMethods}} - {{#isApiKey}} - .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ - in_header: {{#isKeyInHeader}}true{{/isKeyInHeader}}{{^isKeyInHeader}}false{{/isKeyInHeader}}, - in_query: {{#isKeyInQuery}}true{{/isKeyInQuery}}{{^isKeyInQuery}}false{{/isKeyInQuery}}, - param_name: "{{{keyParamName}}}".to_owned(), - })) - {{/isApiKey}} - {{#isBasicBasic}} - .with_auth(__internal_request::Auth::Basic) - {{/isBasicBasic}} - {{#isOAuth}} - .with_auth(__internal_request::Auth::Oauth) - {{/isOAuth}} - {{/authMethods}} - {{/hasAuthMethods}} - ; - {{#queryParams}} - {{#required}} - {{^isNullable}} - req = req.with_query_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_query_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_query_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(ref s) = {{{paramName}}} { - {{#isArray}} - let query_value = s.iter().map(|s| s.to_string()).collect::>().join(","); - {{/isArray}} - {{^isArray}} - let query_value = match serde_json::to_string(s) { - Ok(value) => value, - Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), - }; - {{/isArray}} - req = req.with_query_param("{{{baseName}}}".to_string(), query_value); - } - {{/required}} - {{/queryParams}} - {{#pathParams}} - {{#required}} - {{^isNullable}} - req = req.with_path_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_path_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_path_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_path_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/pathParams}} - {{#hasHeaderParams}} - {{#headerParams}} - {{#required}} - {{^isNullable}} - req = req.with_header_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_header_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_header_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_header_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/headerParams}} - {{/hasHeaderParams}} - {{#hasFormParams}} - {{#formParams}} - {{#isFile}} - {{#required}} - {{^isNullable}} - req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); }, - None => { req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); - } - {{/required}} - {{/isFile}} - {{^isFile}} - {{#required}} - {{^isNullable}} - req = req.with_form_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_form_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_form_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_form_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/isFile}} - {{/formParams}} - {{/hasFormParams}} - {{#hasBodyParam}} - {{#bodyParams}} - req = req.with_body_param({{{paramName}}}); - {{/bodyParams}} - {{/hasBodyParam}} - {{^returnType}} - req = req.returns_nothing(); - {{/returnType}} - - req.execute(self.configuration.borrow()) - } - -{{/operation}} -{{/operations}} -} diff --git a/support/openapi-template/hyper0x/api_mod.mustache b/support/openapi-template/hyper0x/api_mod.mustache deleted file mode 100644 index 51a42ef36..000000000 --- a/support/openapi-template/hyper0x/api_mod.mustache +++ /dev/null @@ -1,64 +0,0 @@ -use http; -use hyper; -use serde_json; - -#[derive(Debug)] -pub enum Error { - Api(ApiError), - Header(hyper::http::header::InvalidHeaderValue), - Http(http::Error), - Hyper(hyper::Error), - Serde(serde_json::Error), - UriError(http::uri::InvalidUri), -} - -#[derive(Debug)] -pub struct ApiError { - pub code: hyper::StatusCode, - pub body: hyper::body::Body, -} - -impl From<(hyper::StatusCode, hyper::body::Body)> for Error { - fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { - Error::Api(ApiError { - code: e.0, - body: e.1, - }) - } -} - -impl From for Error { - fn from(e: http::Error) -> Self { - Error::Http(e) - } -} - -impl From for Error { - fn from(e: hyper::Error) -> Self { - Error::Hyper(e) - } -} - -impl From for Error { - fn from(e: serde_json::Error) -> Self { - Error::Serde(e) - } -} - -mod request; - -{{#apiInfo}} -{{#apis}} -mod {{{classFilename}}}; -{{#operations}} -{{#operation}} -{{#-last}} -pub use self::{{{classFilename}}}::{ {{{classname}}}, {{{classname}}}Client }; -{{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} - -pub mod configuration; -pub mod client; diff --git a/support/openapi-template/hyper0x/client.mustache b/support/openapi-template/hyper0x/client.mustache deleted file mode 100644 index 25124d94b..000000000 --- a/support/openapi-template/hyper0x/client.mustache +++ /dev/null @@ -1,54 +0,0 @@ -use std::rc::Rc; - -use hyper; -use super::configuration::Configuration; - -pub struct APIClient { -{{#apiInfo}} -{{#apis}} -{{#operations}} -{{#operation}} - {{#-last}} - {{{classFilename}}}: Box, - {{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} -} - -impl APIClient { - pub fn new(configuration: Configuration) -> APIClient - where C: Clone + std::marker::Send + Sync + 'static { - let rc = Rc::new(configuration); - - APIClient { -{{#apiInfo}} -{{#apis}} -{{#operations}} -{{#operation}} - {{#-last}} - {{{classFilename}}}: Box::new(crate::apis::{{{classname}}}Client::new(rc.clone())), - {{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} - } - } - -{{#apiInfo}} -{{#apis}} -{{#operations}} -{{#operation}} -{{#-last}} - pub fn {{{classFilename}}}(&self) -> &dyn crate::apis::{{{classname}}}{ - self.{{{classFilename}}}.as_ref() - } - -{{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} -} diff --git a/support/openapi-template/hyper0x/configuration.mustache b/support/openapi-template/hyper0x/configuration.mustache deleted file mode 100644 index ee6f407d3..000000000 --- a/support/openapi-template/hyper0x/configuration.mustache +++ /dev/null @@ -1,34 +0,0 @@ -{{>partial_header}} -use hyper; - -pub struct Configuration - where C: Clone + std::marker::Send + Sync + 'static { - pub base_path: String, - pub user_agent: Option, - pub client: hyper::client::Client, - pub basic_auth: Option, - pub oauth_access_token: Option, - pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one -} - -pub type BasicAuth = (String, Option); - -pub struct ApiKey { - pub prefix: Option, - pub key: String, -} - -impl Configuration - where C: Clone + std::marker::Send + Sync { - pub fn new(client: hyper::client::Client) -> Configuration { - Configuration { - base_path: "{{{basePath}}}".to_owned(), - user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}}, - client, - basic_auth: None, - oauth_access_token: None, - api_key: None, - } - } -} 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/model_doc.mustache b/support/openapi-template/model_doc.mustache deleted file mode 100644 index 2aba75968..000000000 --- a/support/openapi-template/model_doc.mustache +++ /dev/null @@ -1,54 +0,0 @@ -{{#models}}{{#model}}# {{{classname}}} -{{#isEnum}} - -## Enum Variants - -| Name | Value | -|---- | -----|{{#allowableValues}}{{#enumVars}} -| {{name}} | {{value}} |{{/enumVars}}{{/allowableValues}} - -{{/isEnum}} -{{#discriminator}} - -## Enum Variants - -| Name | Value | -|---- | -----|{{#vendorExtensions}}{{#x-mapped-models}} -| {{modelName}} | {{mappingName}} |{{/x-mapped-models}}{{/vendorExtensions}} -{{#vendorExtensions}} -{{#x-mapped-models}} - -## {{modelName}} - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -{{#vars}}**{{{name}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{complexType}}}.md){{/isPrimitiveType}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}} | {{^required}}[optional]{{/required}}{{#isReadOnly}}[readonly]{{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} -{{/vars}} -{{/x-mapped-models}} -{{/vendorExtensions}} -{{/discriminator}} -{{^discriminator}} -{{^isEnum}} -{{#oneOf.isEmpty}} - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -{{#vars}}**{{{name}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{complexType}}}.md){{/isPrimitiveType}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}} | {{^required}}[optional]{{/required}}{{#isReadOnly}}[readonly]{{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} -{{/vars}} -{{/oneOf.isEmpty}} -{{^oneOf.isEmpty}} - -## Enum Variants - -| Name | Description | -|---- | -----|{{#oneOf}} -| {{{.}}} | {{description}} |{{/oneOf}} -{{/oneOf.isEmpty}} -{{/isEnum}} -{{/discriminator}} - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - -{{/model}}{{/models}} diff --git a/support/openapi-template/model_mod.mustache b/support/openapi-template/model_mod.mustache index c184bab07..06bf92f01 100644 --- a/support/openapi-template/model_mod.mustache +++ b/support/openapi-template/model_mod.mustache @@ -4,44 +4,3 @@ pub mod {{{classFilename}}}; pub use self::{{{classFilename}}}::{{{classname}}}; {{/model}} {{/models}} -/* -{{#serdeAsDoubleOption}} -use serde::{Deserialize, Deserializer, Serializer}; -use serde_with::{de::DeserializeAsWrap, ser::SerializeAsWrap, DeserializeAs, SerializeAs}; -use std::marker::PhantomData; - -pub(crate) struct DoubleOption(PhantomData); - -impl SerializeAs>> for DoubleOption -where - TAs: SerializeAs, -{ - fn serialize_as(values: &Option>, serializer: S) -> Result - where - S: Serializer, - { - match values { - None => serializer.serialize_unit(), - Some(None) => serializer.serialize_none(), - Some(Some(v)) => serializer.serialize_some(&SerializeAsWrap::::new(v)), - } - } -} - -impl<'de, T, TAs> DeserializeAs<'de, Option>> for DoubleOption -where - TAs: DeserializeAs<'de, T>, - T: std::fmt::Debug, -{ - fn deserialize_as(deserializer: D) -> Result>, D::Error> - where - D: Deserializer<'de>, - { - Ok(Some( - DeserializeAsWrap::, Option>::deserialize(deserializer)? - .into_inner(), - )) - } -} -{{/serdeAsDoubleOption}} -*/ \ No newline at end of file diff --git a/support/openapi-template/request.rs b/support/openapi-template/request.rs deleted file mode 100644 index a6f7b74cc..000000000 --- a/support/openapi-template/request.rs +++ /dev/null @@ -1,247 +0,0 @@ -use std::collections::HashMap; -use std::pin::Pin; - -use futures; -use futures::Future; -use futures::future::*; -use http_body_util::BodyExt; -use hyper; -use hyper_util::client::legacy::connect::Connect; -use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT}; -use serde; -use serde_json; - -use super::{configuration, Error}; - -pub(crate) struct ApiKey { - pub in_header: bool, - pub in_query: bool, - pub param_name: String, -} - -impl ApiKey { - fn key(&self, prefix: &Option, key: &str) -> String { - match prefix { - None => key.to_owned(), - Some(ref prefix) => format!("{} {}", prefix, key), - } - } -} - -#[allow(dead_code)] -pub(crate) enum Auth { - None, - ApiKey(ApiKey), - Basic, - Oauth, -} - -/// If the authorization type is unspecified then it will be automatically detected based -/// on the configuration. This functionality is useful when the OpenAPI definition does not -/// include an authorization scheme. -pub(crate) struct Request { - auth: Option, - method: hyper::Method, - path: String, - query_params: HashMap, - no_return_type: bool, - path_params: HashMap, - form_params: HashMap, - header_params: HashMap, - // TODO: multiple body params are possible technically, but not supported here. - serialized_body: Option, -} - -#[allow(dead_code)] -impl Request { - pub fn new(method: hyper::Method, path: String) -> Self { - Request { - auth: None, - method, - path, - query_params: HashMap::new(), - path_params: HashMap::new(), - form_params: HashMap::new(), - header_params: HashMap::new(), - serialized_body: None, - no_return_type: false, - } - } - - pub fn with_body_param(mut self, param: T) -> Self { - self.serialized_body = Some(serde_json::to_string(¶m).unwrap()); - self - } - - pub fn with_header_param(mut self, basename: String, param: String) -> Self { - self.header_params.insert(basename, param); - self - } - - #[allow(unused)] - pub fn with_query_param(mut self, basename: String, param: String) -> Self { - self.query_params.insert(basename, param); - self - } - - #[allow(unused)] - pub fn with_path_param(mut self, basename: String, param: String) -> Self { - self.path_params.insert(basename, param); - self - } - - #[allow(unused)] - pub fn with_form_param(mut self, basename: String, param: String) -> Self { - self.form_params.insert(basename, param); - self - } - - pub fn returns_nothing(mut self) -> Self { - self.no_return_type = true; - self - } - - pub fn with_auth(mut self, auth: Auth) -> Self { - self.auth = Some(auth); - self - } - - pub fn execute<'a, C, U>( - self, - conf: &configuration::Configuration, - ) -> Pin> + 'a + Send>> - where - C: Connect + Clone + std::marker::Send + Sync, - U: Sized + std::marker::Send + 'a, - for<'de> U: serde::Deserialize<'de>, - { - let mut query_string = ::url::form_urlencoded::Serializer::new("".to_owned()); - - let mut path = self.path; - for (k, v) in self.path_params { - // replace {id} with the value of the id path param - path = path.replace(&format!("{{{}}}", k), &v); - } - - for (key, val) in self.query_params { - query_string.append_pair(&key, &val); - } - - let mut uri_str = format!("{}{}", conf.base_path, path); - - let query_string_str = query_string.finish(); - if !query_string_str.is_empty() { - uri_str += "?"; - uri_str += &query_string_str; - } - let uri: hyper::Uri = match uri_str.parse() { - Err(e) => return Box::pin(futures::future::err(Error::UriError(e))), - Ok(u) => u, - }; - - let mut req_builder = hyper::Request::builder() - .uri(uri) - .method(self.method); - - // Detect the authorization type if it hasn't been set. - let auth = self.auth.unwrap_or_else(|| - if conf.api_key.is_some() { - panic!("Cannot automatically set the API key from the configuration, it must be specified in the OpenAPI definition") - } else if conf.oauth_access_token.is_some() { - Auth::Oauth - } else if conf.basic_auth.is_some() { - Auth::Basic - } else { - Auth::None - } - ); - match auth { - Auth::ApiKey(apikey) => { - if let Some(ref key) = conf.api_key { - let val = apikey.key(&key.prefix, &key.key); - if apikey.in_query { - query_string.append_pair(&apikey.param_name, &val); - } - if apikey.in_header { - req_builder = req_builder.header(&apikey.param_name, val); - } - } - } - Auth::Basic => { - if let Some(ref auth_conf) = conf.basic_auth { - let mut text = auth_conf.0.clone(); - text.push(':'); - if let Some(ref pass) = auth_conf.1 { - text.push_str(&pass[..]); - } - let encoded = base64::encode(&text); - req_builder = req_builder.header(AUTHORIZATION, encoded); - } - } - Auth::Oauth => { - if let Some(ref token) = conf.oauth_access_token { - let text = "Bearer ".to_owned() + token; - req_builder = req_builder.header(AUTHORIZATION, text); - } - } - Auth::None => {} - } - - if let Some(ref user_agent) = conf.user_agent { - req_builder = req_builder.header(USER_AGENT, match HeaderValue::from_str(user_agent) { - Ok(header_value) => header_value, - Err(e) => return Box::pin(futures::future::err(super::Error::Header(e))) - }); - } - - for (k, v) in self.header_params { - req_builder = req_builder.header(&k, v); - } - - let req_headers = req_builder.headers_mut().unwrap(); - let request_result = if self.form_params.len() > 0 { - req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/x-www-form-urlencoded")); - let mut enc = ::url::form_urlencoded::Serializer::new("".to_owned()); - for (k, v) in self.form_params { - enc.append_pair(&k, &v); - } - req_builder.body(enc.finish()) - } else if let Some(body) = self.serialized_body { - req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); - req_headers.insert(CONTENT_LENGTH, body.len().into()); - req_builder.body(body) - } else { - req_builder.body(String::new()) - }; - let request = match request_result { - Ok(request) => request, - Err(e) => return Box::pin(futures::future::err(Error::from(e))) - }; - - let no_return_type = self.no_return_type; - Box::pin(conf.client - .request(request) - .map_err(|e| Error::from(e)) - .and_then(move |response| { - let status = response.status(); - if !status.is_success() { - futures::future::err::(Error::from((status, response.into_body()))).boxed() - } else if no_return_type { - // This is a hack; if there's no_ret_type, U is (), but serde_json gives an - // error when deserializing "" into (), so deserialize 'null' into it - // instead. - // An alternate option would be to require U: Default, and then return - // U::default() here instead since () implements that, but then we'd - // need to impl default for all models. - futures::future::ok::(serde_json::from_str("null").expect("serde null value")).boxed() - } else { - let collect = response.into_body().collect().map_err(Error::from); - collect.map(|collected| { - collected.and_then(|collected| { - serde_json::from_slice(&collected.to_bytes()).map_err(Error::from) - }) - }).boxed() - } - })) - } -} diff --git a/support/openapi-template/reqwest-trait/api.mustache b/support/openapi-template/reqwest-trait/api.mustache index ae7ea7d4e..788352ea6 100644 --- a/support/openapi-template/reqwest-trait/api.mustache +++ b/support/openapi-template/reqwest-trait/api.mustache @@ -1,6 +1,6 @@ {{>partial_header}} -use async_trait::async_trait; +//use async_trait::async_trait; {{#mockall}} #[cfg(feature = "mockall")] use mockall::automock; @@ -12,6 +12,7 @@ use crate::{apis::ResponseContent, models}; use super::{Error, configuration}; use crate::apis::ContentType; +/* {{#mockall}} #[cfg_attr(feature = "mockall", automock)] {{/mockall}} @@ -26,46 +27,45 @@ 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 - }}, Error<{{{operationIdCamelCase}}}Error>>; + }}, Error>; {{/vendorExtensions.x-group-parameters}} {{^vendorExtensions.x-group-parameters}} async fn {{{operationId}}}{{! - ### Lifetimes - }}<{{#allParams}}'{{#lambda.lifetimeName}}{{{paramName}}}{{/lambda.lifetimeName}}{{^-last}}, {{/-last}}{{/allParams}}>{{! ### 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}}&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>>; + }}, Error>; {{/vendorExtensions.x-group-parameters}} {{/operation}} {{/operations}} } +*/ pub struct {{{classname}}}Client { configuration: Arc @@ -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))] @@ -99,7 +99,7 @@ pub struct {{{operationIdCamelCase}}}Params { ### &str and Vec<&str> }}{{^isUuid}}{{#isString}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isString}}{{/isUuid}}{{! ### UUIDs - }}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}String{{#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 @@ -115,8 +115,8 @@ pub struct {{{operationIdCamelCase}}}Params { {{/operation}} {{/operations}} -#[async_trait] -impl {{classname}} for {{classname}}Client { +// #[async_trait] +impl {{classname}}Client { {{#operations}} {{#operation}} {{#description}} @@ -126,7 +126,7 @@ impl {{classname}} for {{classname}}Client { /// {{{.}}} {{/notes}} {{#vendorExtensions.x-group-parameters}} - async fn {{{operationId}}}(&self, {{#allParams}}{{#-first}} params: {{{operationIdCamelCase}}}Params {{/-first}}{{/allParams}}{{! + pub async fn {{{operationId}}}(&self, {{#allParams}}{{#-first}} params: {{{operationIdCamelCase}}}Params {{/-first}}{{/allParams}}{{! ### Function return type }}) -> Result<{{! ### Multi response support @@ -134,7 +134,7 @@ impl {{classname}} for {{classname}}Client { ### Regular return type }}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}{{! ### Error Type - }}, Error<{{{operationIdCamelCase}}}Error>> { + }}, Error> { {{#allParams}}{{#-first}} let {{{operationIdCamelCase}}}Params { {{#allParams}} @@ -145,37 +145,34 @@ impl {{classname}} for {{classname}}Client { {{/vendorExtensions.x-group-parameters}} {{^vendorExtensions.x-group-parameters}} - async fn {{{operationId}}}{{! - ### Lifetimes - }}<{{#allParams}}'{{#lambda.lifetimeName}}{{{paramName}}}{{/lambda.lifetimeName}}{{^-last}}, {{/-last}}{{/allParams}}>{{! + pub async fn {{{operationId}}}{{! ### 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}}&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 }}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}{{! ### Regular return type - }}, Error<{{{operationIdCamelCase}}}Error>> { + }}, Error> { {{/vendorExtensions.x-group-parameters}} let local_var_configuration = &self.configuration; 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}} @@ -245,6 +242,7 @@ impl {{classname}} for {{classname}}Client { _ => local_var_req_builder.query(&[("{{{baseName}}}", ¶m_value.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; {{/isArray}} + {{^isArray}} {{#isDeepObject}} {{^isExplode}} let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?); @@ -276,6 +274,7 @@ impl {{classname}} for {{classname}}Client { {{/isModel}} {{/isObject}} {{/isDeepObject}} + {{/isArray}} } {{/required}} {{/queryParams}} @@ -319,9 +318,10 @@ impl {{classname}} for {{classname}}Client { } {{/withAWSV4Signature}} {{/hasAuthMethods}} + {{! We set the user-agent to the reqwest client by default if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } + } }} {{#hasHeaderParams}} {{#headerParams}} {{#required}} @@ -503,7 +503,7 @@ impl {{classname}} for {{classname}}Client { Ok(local_var_result) {{/supportMultipleResponses}} } else { - let local_var_entity: Option<{{{operationIdCamelCase}}}Error> = serde_json::from_str(&local_var_content).ok(); + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } @@ -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 { @@ -534,25 +534,3 @@ pub enum {{{operationIdCamelCase}}}Success { {{/operation}} {{/operations}} {{/supportMultipleResponses}} -{{#operations}} -{{#operation}} -/// struct for typed errors of method [`{{operationId}}`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum {{{operationIdCamelCase}}}Error { - {{#responses}} - {{#is4xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/is4xx}} - {{#is5xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/is5xx}} - {{#isDefault}} - DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/isDefault}} - {{/responses}} - UnknownValue(serde_json::Value), -} - -{{/operation}} -{{/operations}} diff --git a/support/openapi-template/reqwest-trait/api_mod.mustache b/support/openapi-template/reqwest-trait/api_mod.mustache index 41a4ba0f8..a00289fef 100644 --- a/support/openapi-template/reqwest-trait/api_mod.mustache +++ b/support/openapi-template/reqwest-trait/api_mod.mustache @@ -5,21 +5,21 @@ use aws_sigv4; {{/withAWSV4Signature}} #[derive(Debug, Clone)] -pub struct ResponseContent { +pub struct ResponseContent { pub status: reqwest::StatusCode, pub content: String, - pub entity: Option, + pub entity: Option, } #[derive(Debug)] -pub enum Error { +pub enum Error { Reqwest(reqwest::Error), {{#supportMiddleware}} ReqwestMiddleware(reqwest_middleware::Error), {{/supportMiddleware}} Serde(serde_json::Error), Io(std::io::Error), - ResponseError(ResponseContent), + ResponseError(ResponseContent), {{#withAWSV4Signature}} AWSV4SignatureError(aws_sigv4::http_request::Error), {{/withAWSV4Signature}} @@ -28,7 +28,7 @@ pub enum Error { {{/supportTokenSource}} } -impl fmt::Display for Error { +impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (module, e) = match self { Error::Reqwest(e) => ("reqwest", e.to_string()), @@ -49,7 +49,7 @@ impl fmt::Display for Error { } } -impl error::Error for Error { +impl error::Error for Error { fn source(&self) -> Option<&(dyn error::Error + 'static)> { Some(match self { Error::Reqwest(e) => e, @@ -69,27 +69,27 @@ impl error::Error for Error { } } -impl From for Error { +impl From for Error { fn from(e: reqwest::Error) -> Self { Error::Reqwest(e) } } {{#supportMiddleware}} -impl From for Error { +impl From for Error { fn from(e: reqwest_middleware::Error) -> Self { Error::ReqwestMiddleware(e) } } {{/supportMiddleware}} -impl From for Error { +impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Serde(e) } } -impl From for Error { +impl From for Error { fn from(e: std::io::Error) -> Self { Error::Io(e) } @@ -160,18 +160,10 @@ pub mod configuration; {{#topLevelApiClient}} use std::sync::Arc; -pub trait Api { - {{#apiInfo}} - {{#apis}} - fn {{{classFilename}}}(&self) -> &dyn {{{classFilename}}}::{{classname}}; - {{/apis}} - {{/apiInfo}} -} - pub struct ApiClient { {{#apiInfo}} {{#apis}} - {{{classFilename}}}: Box, + {{{classFilename}}}: {{{classFilename}}}::{{classname}}Client, {{/apis}} {{/apiInfo}} } @@ -181,18 +173,18 @@ impl ApiClient { Self { {{#apiInfo}} {{#apis}} - {{{classFilename}}}: Box::new({{{classFilename}}}::{{classname}}Client::new(configuration.clone())), + {{{classFilename}}}: {{{classFilename}}}::{{classname}}Client::new(configuration.clone()), {{/apis}} {{/apiInfo}} } } } -impl Api for ApiClient { +impl ApiClient { {{#apiInfo}} {{#apis}} - fn {{{classFilename}}}(&self) -> &dyn {{{classFilename}}}::{{classname}} { - self.{{{classFilename}}}.as_ref() + pub fn {{{classFilename}}}(&self) -> &{{{classFilename}}}::{{classname}}Client { + &self.{{{classFilename}}} } {{/apis}} {{/apiInfo}} diff --git a/support/openapi-template/reqwest/api.mustache b/support/openapi-template/reqwest/api.mustache deleted file mode 100644 index cd4a8ccf8..000000000 --- a/support/openapi-template/reqwest/api.mustache +++ /dev/null @@ -1,515 +0,0 @@ -{{>partial_header}} - -use reqwest; -use serde::{Deserialize, Serialize, de::Error as _}; -use crate::{apis::ResponseContent, models}; -use super::{Error, configuration, ContentType}; - -{{#operations}} -{{#operation}} -{{#vendorExtensions.x-group-parameters}} -{{#allParams}} -{{#-first}} -/// struct for passing parameters to the method [`{{operationId}}`] -#[derive(Clone, Debug)] -pub struct {{{operationIdCamelCase}}}Params { -{{/-first}} - {{#description}} - /// {{{.}}} - {{/description}} - pub {{{paramName}}}: {{! - ### Option Start - }}{{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{! - ### &str and Vec<&str> - }}{{^isUuid}}{{#isString}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isString}}{{/isUuid}}{{! - ### UUIDs - }}{{#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}} -{{#-last}} -} - -{{/-last}} -{{/allParams}} -{{/vendorExtensions.x-group-parameters}} -{{/operation}} -{{/operations}} - -{{#supportMultipleResponses}} -{{#operations}} -{{#operation}} -/// struct for typed successes of method [`{{operationId}}`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum {{{operationIdCamelCase}}}Success { - {{#responses}} - {{#is2xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/is2xx}} - {{#is3xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/is3xx}} - {{/responses}} - UnknownValue(serde_json::Value), -} - -{{/operation}} -{{/operations}} -{{/supportMultipleResponses}} -{{#operations}} -{{#operation}} -/// struct for typed errors of method [`{{operationId}}`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum {{{operationIdCamelCase}}}Error { - {{#responses}} - {{#is4xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/is4xx}} - {{#is5xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/is5xx}} - {{#isDefault}} - DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/isDefault}} - {{/responses}} - UnknownValue(serde_json::Value), -} - -{{/operation}} -{{/operations}} - -{{#operations}} -{{#operation}} -{{#description}} -/// {{{.}}} -{{/description}} -{{#notes}} -/// {{{.}}} -{{/notes}} -{{#vendorExtensions.x-group-parameters}} -pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration{{#allParams}}{{#-first}}, {{! -### Params -}}params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}{{! -### Function return type -}}) -> Result<{{! -### Response File Support -}}{{#isResponseFile}}{{#supportAsync}}reqwest::Response{{/supportAsync}}{{^supportAsync}}reqwest::blocking::Response{{/supportAsync}}{{/isResponseFile}}{{! -### Regular Responses -}}{{^isResponseFile}}{{! -### Multi response support -}}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{! -### Regular return type -}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}{{/isResponseFile}}{{! -### Error Type -}}, Error<{{{operationIdCamelCase}}}Error>> { -{{/vendorExtensions.x-group-parameters}} -{{^vendorExtensions.x-group-parameters}} -pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration, {{#allParams}}{{{paramName}}}: {{! -### Option Start -}}{{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{! -### &str and Vec<&str> -}}{{#isString}}{{#isArray}}Vec<{{/isArray}}{{^isUuid}}&str{{/isUuid}}{{#isArray}}>{{/isArray}}{{/isString}}{{! -### UUIDs -}}{{#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}}{{! -### Function return type -}}) -> Result<{{! -### Response File Support -}}{{#isResponseFile}}{{#supportAsync}}reqwest::Response{{/supportAsync}}{{^supportAsync}}reqwest::blocking::Response{{/supportAsync}}{{/isResponseFile}}{{! -### Regular Responses -}}{{^isResponseFile}}{{! -### Multi response support -}}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{! -### Regular return type -}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}{{/isResponseFile}}{{! -### Error Type -}}, Error<{{{operationIdCamelCase}}}Error>> { - {{#allParams.0}} - // add a prefix to parameters to efficiently prevent name collisions - {{/allParams.0}} - {{#allParams}} - let {{{vendorExtensions.x-rust-param-identifier}}} = {{{paramName}}}; - {{/allParams}} -{{/vendorExtensions.x-group-parameters}} - - let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{vendorExtensions.x-rust-param-identifier}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{#isUuid}}.to_string(){{/isUuid}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}.to_string(){{/isContainer}}{{/isPrimitiveType}}{{/isUuid}}{{/isString}}{{#isString}}){{/isString}}{{/pathParams}}); - let mut req_builder = configuration.client.request(reqwest::Method::{{{httpMethod}}}, &uri_str); - - {{#queryParams}} - {{#required}} - {{#isArray}} - req_builder = match "{{collectionFormat}}" { - "multi" => req_builder.query(&{{{vendorExtensions.x-rust-param-identifier}}}.into_iter().map(|p| ("{{{baseName}}}".to_owned(), p.to_string())).collect::>()), - _ => req_builder.query(&[("{{{baseName}}}", &{{{vendorExtensions.x-rust-param-identifier}}}.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), - }; - {{/isArray}} - {{^isArray}} - {{^isNullable}} - req_builder = req_builder.query(&[("{{{baseName}}}", &{{{vendorExtensions.x-rust-param-identifier}}}.to_string())]); - {{/isNullable}} - {{#isNullable}} - {{#isDeepObject}} - if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - {{^isExplode}} - let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?); - req_builder = req_builder.query(¶ms); - {{/isExplode}} - {{#isExplode}} - {{#isModel}} - req_builder = req_builder.query(¶m_value); - {{/isModel}} - {{#isMap}} - let mut query_params = Vec::with_capacity(param_value.len()); - for (key, value) in param_value.iter() { - query_params.push((key.to_string(), serde_json::to_string(value)?)); - } - req_builder = req_builder.query(&query_params); - {{/isMap}} - {{/isExplode}} - }; - {{/isDeepObject}} - {{^isDeepObject}} - {{#isObject}} - if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]); - }; - {{/isObject}} - {{#isModel}} - if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]); - }; - {{/isModel}} - {{/isDeepObject}} - {{^isObject}} - {{^isModel}} - if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - req_builder = req_builder.query(&[("{{{baseName}}}", ¶m_value.to_string())]); - }; - {{/isModel}} - {{/isObject}} - {{/isNullable}} - {{/isArray}} - {{/required}} - {{^required}} - if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - {{#isArray}} - req_builder = match "{{collectionFormat}}" { - "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("{{{baseName}}}".to_owned(), p.to_string())).collect::>()), - _ => req_builder.query(&[("{{{baseName}}}", ¶m_value.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), - }; - {{/isArray}} - {{^isArray}} - {{#isDeepObject}} - {{^isExplode}} - let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?); - req_builder = req_builder.query(¶ms); - {{/isExplode}} - {{#isExplode}} - {{#isModel}} - req_builder = req_builder.query(¶m_value); - {{/isModel}} - {{#isMap}} - let mut query_params = Vec::with_capacity(param_value.len()); - for (key, value) in param_value.iter() { - query_params.push((key.to_string(), serde_json::to_string(value)?)); - } - req_builder = req_builder.query(&query_params); - {{/isMap}} - {{/isExplode}} - {{/isDeepObject}} - {{^isDeepObject}} - {{#isObject}} - req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]); - {{/isObject}} - {{#isModel}} - req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]); - {{/isModel}} - {{^isObject}} - {{^isModel}} - req_builder = req_builder.query(&[("{{{baseName}}}", ¶m_value.to_string())]); - {{/isModel}} - {{/isObject}} - {{/isDeepObject}} - {{/isArray}} - } - {{/required}} - {{/queryParams}} - {{#hasAuthMethods}} - {{#authMethods}} - {{#isApiKey}} - {{#isKeyInQuery}} - if let Some(ref apikey) = configuration.api_key { - let key = apikey.key.clone(); - let value = match apikey.prefix { - Some(ref prefix) => format!("{} {}", prefix, key), - None => key, - }; - req_builder = req_builder.query(&[("{{{keyParamName}}}", value)]); - } - {{/isKeyInQuery}} - {{/isApiKey}} - {{/authMethods}} - {{/hasAuthMethods}} - {{#hasAuthMethods}} - {{#withAWSV4Signature}} - if let Some(ref aws_v4_key) = configuration.aws_v4_key { - let new_headers = match aws_v4_key.sign( - &uri_str, - "{{{httpMethod}}}", - {{#hasBodyParam}} - {{#bodyParams}} - &serde_json::to_string(&{{{vendorExtensions.x-rust-param-identifier}}}).expect("param should serialize to string"), - {{/bodyParams}} - {{/hasBodyParam}} - {{^hasBodyParam}} - "", - {{/hasBodyParam}} - ) { - Ok(new_headers) => new_headers, - Err(err) => return Err(Error::AWSV4SignatureError(err)), - }; - for (name, value) in new_headers.iter() { - req_builder = req_builder.header(name.as_str(), value.as_str()); - } - } - {{/withAWSV4Signature}} - {{/hasAuthMethods}} - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - {{#hasHeaderParams}} - {{#headerParams}} - {{#required}} - {{^isNullable}} - req_builder = req_builder.header("{{{baseName}}}", {{{vendorExtensions.x-rust-param-identifier}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{vendorExtensions.x-rust-param-identifier}}} { - Some(param_value) => { req_builder = req_builder.header("{{{baseName}}}", param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req_builder = req_builder.header("{{{baseName}}}", ""); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - req_builder = req_builder.header("{{{baseName}}}", param_value{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/headerParams}} - {{/hasHeaderParams}} - {{#hasAuthMethods}} - {{#authMethods}} - {{#supportTokenSource}} - // Obtain a token from source provider. - // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; - // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); - {{/supportTokenSource}} - {{^supportTokenSource}} - {{#isApiKey}} - {{#isKeyInHeader}} - if let Some(ref apikey) = configuration.api_key { - let key = apikey.key.clone(); - let value = match apikey.prefix { - Some(ref prefix) => format!("{} {}", prefix, key), - None => key, - }; - req_builder = req_builder.header("{{{keyParamName}}}", value); - }; - {{/isKeyInHeader}} - {{/isApiKey}} - {{#isBasic}} - {{#isBasicBasic}} - if let Some(ref auth_conf) = configuration.basic_auth { - req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned()); - }; - {{/isBasicBasic}} - {{#isBasicBearer}} - if let Some(ref token) = configuration.bearer_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - {{/isBasicBearer}} - {{/isBasic}} - {{#isOAuth}} - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); - }; - {{/isOAuth}} - {{/supportTokenSource}} - {{/authMethods}} - {{/hasAuthMethods}} - {{#isMultipart}} - {{#hasFormParams}} - let mut multipart_form = reqwest{{^supportAsync}}::blocking{{/supportAsync}}::multipart::Form::new(); - {{#formParams}} - {{#isFile}} - {{^supportAsync}} - {{#required}} - {{^isNullable}} - multipart_form = multipart_form.file("{{{baseName}}}", {{{vendorExtensions.x-rust-param-identifier}}})?; - {{/isNullable}} - {{#isNullable}} - match {{{vendorExtensions.x-rust-param-identifier}}} { - Some(param_value) => { multipart_form = multipart_form.file("{{{baseName}}}", param_value)?; }, - None => { unimplemented!("Required nullable form file param not supported"); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - multipart_form = multipart_form.file("{{{baseName}}}", param_value)?; - } - {{/required}} - {{/supportAsync}} - {{#supportAsync}} - // TODO: support file upload for '{{{baseName}}}' parameter - {{/supportAsync}} - {{/isFile}} - {{^isFile}} - {{#required}} - {{^isNullable}} - multipart_form = multipart_form.text("{{{baseName}}}", {{{vendorExtensions.x-rust-param-identifier}}}{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{vendorExtensions.x-rust-param-identifier}}} { - Some(param_value) => { multipart_form = multipart_form.text("{{{baseName}}}", param_value{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string()); }, - None => { multipart_form = multipart_form.text("{{{baseName}}}", ""); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - multipart_form = multipart_form.text("{{{baseName}}}", param_value{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/isFile}} - {{/formParams}} - req_builder = req_builder.multipart(multipart_form); - {{/hasFormParams}} - {{/isMultipart}} - {{^isMultipart}} - {{#hasFormParams}} - let mut multipart_form_params = std::collections::HashMap::new(); - {{#formParams}} - {{#isFile}} - {{#required}} - {{^isNullable}} - multipart_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); - {{/isNullable}} - {{#isNullable}} - match {{{vendorExtensions.x-rust-param-identifier}}} { - Some(param_value) => { multipart_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); }, - None => { unimplemented!("Required nullable file form param not supported with x-www-form-urlencoded content"); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - multipart_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); - } - {{/required}} - {{/isFile}} - {{^isFile}} - {{#required}} - {{^isNullable}} - multipart_form_params.insert("{{{baseName}}}", {{{vendorExtensions.x-rust-param-identifier}}}{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{vendorExtensions.x-rust-param-identifier}}} { - Some(param_value) => { multipart_form_params.insert("{{{baseName}}}", param_value{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string()); }, - None => { multipart_form_params.insert("{{{baseName}}}", ""); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - multipart_form_params.insert("{{{baseName}}}", param_value{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/isFile}} - {{/formParams}} - req_builder = req_builder.form(&multipart_form_params); - {{/hasFormParams}} - {{/isMultipart}} - {{#hasBodyParam}} - {{#bodyParams}} - {{#isFile}} - req_builder = req_builder.body({{{vendorExtensions.x-rust-param-identifier}}}); - {{/isFile}} - {{^isFile}} - req_builder = req_builder.json(&{{{vendorExtensions.x-rust-param-identifier}}}); - {{/isFile}} - {{/bodyParams}} - {{/hasBodyParam}} - - let req = req_builder.build()?; - let resp = configuration.client.execute(req){{#supportAsync}}.await{{/supportAsync}}?; - - let status = resp.status(); - {{^supportMultipleResponses}} - {{^isResponseFile}} - {{#returnType}} - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - {{/returnType}} - {{/isResponseFile}} - {{/supportMultipleResponses}} - - if !status.is_client_error() && !status.is_server_error() { - {{^supportMultipleResponses}} - {{#isResponseFile}} - Ok(resp) - {{/isResponseFile}} - {{^isResponseFile}} - {{^returnType}} - Ok(()) - {{/returnType}} - {{#returnType}} - let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - {{#vendorExtensions.x-supports-plain-text}} - ContentType::Text => return Ok(content), - {{/vendorExtensions.x-supports-plain-text}} - {{^vendorExtensions.x-supports-plain-text}} - ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `{{returnType}}`"))), - {{/vendorExtensions.x-supports-plain-text}} - ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `{{returnType}}`")))), - } - {{/returnType}} - {{/isResponseFile}} - {{/supportMultipleResponses}} - {{#supportMultipleResponses}} - {{#isResponseFile}} - Ok(resp) - {{/isResponseFile}} - {{^isResponseFile}} - let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?; - let entity: Option<{{{operationIdCamelCase}}}Success> = serde_json::from_str(&content).ok(); - Ok(ResponseContent { status, content, entity }) - {{/isResponseFile}} - {{/supportMultipleResponses}} - } else { - let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?; - let entity: Option<{{{operationIdCamelCase}}}Error> = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { status, content, entity })) - } -} - -{{/operation}} -{{/operations}} diff --git a/support/openapi-template/reqwest/api_mod.mustache b/support/openapi-template/reqwest/api_mod.mustache deleted file mode 100644 index 4d5df28e9..000000000 --- a/support/openapi-template/reqwest/api_mod.mustache +++ /dev/null @@ -1,164 +0,0 @@ -use std::error; -use std::fmt; -{{#withAWSV4Signature}} -use aws_sigv4; -{{/withAWSV4Signature}} - -#[derive(Debug, Clone)] -pub struct ResponseContent { - pub status: reqwest::StatusCode, - pub content: String, - pub entity: Option, -} - -#[derive(Debug)] -pub enum Error { - Reqwest(reqwest::Error), - {{#supportMiddleware}} - ReqwestMiddleware(reqwest_middleware::Error), - {{/supportMiddleware}} - Serde(serde_json::Error), - Io(std::io::Error), - ResponseError(ResponseContent), - {{#withAWSV4Signature}} - AWSV4SignatureError(aws_sigv4::http_request::Error), - {{/withAWSV4Signature}} - {{#supportAsync}} - {{#supportTokenSource}} - TokenSource(Box), - {{/supportTokenSource}} - {{/supportAsync}} -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let (module, e) = match self { - Error::Reqwest(e) => ("reqwest", e.to_string()), - {{#supportMiddleware}} - Error::ReqwestMiddleware(e) => ("reqwest-middleware", e.to_string()), - {{/supportMiddleware}} - Error::Serde(e) => ("serde", e.to_string()), - Error::Io(e) => ("IO", e.to_string()), - Error::ResponseError(e) => ("response", format!("status code {}", e.status)), - {{#withAWSV4Signature}} - Error::AWSV4SignatureError(e) => ("aws v4 signature", e.to_string()), - {{/withAWSV4Signature}} - {{#supportAsync}} - {{#supportTokenSource}} - Error::TokenSource(e) => ("token source failure", e.to_string()), - {{/supportTokenSource}} - {{/supportAsync}} - }; - write!(f, "error in {}: {}", module, e) - } -} - -impl error::Error for Error { - fn source(&self) -> Option<&(dyn error::Error + 'static)> { - Some(match self { - Error::Reqwest(e) => e, - {{#supportMiddleware}} - Error::ReqwestMiddleware(e) => e, - {{/supportMiddleware}} - Error::Serde(e) => e, - Error::Io(e) => e, - Error::ResponseError(_) => return None, - {{#withAWSV4Signature}} - Error::AWSV4SignatureError(_) => return None, - {{/withAWSV4Signature}} - {{#supportAsync}} - {{#supportTokenSource}} - Error::TokenSource(e) => &**e, - {{/supportTokenSource}} - {{/supportAsync}} - }) - } -} - -impl From for Error { - fn from(e: reqwest::Error) -> Self { - Error::Reqwest(e) - } -} - -{{#supportMiddleware}} -impl From for Error { - fn from(e: reqwest_middleware::Error) -> Self { - Error::ReqwestMiddleware(e) - } -} - -{{/supportMiddleware}} -impl From for Error { - fn from(e: serde_json::Error) -> Self { - Error::Serde(e) - } -} - -impl From for Error { - fn from(e: std::io::Error) -> Self { - Error::Io(e) - } -} - -pub fn urlencode>(s: T) -> String { - ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() -} - -pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { - if let serde_json::Value::Object(object) = value { - let mut params = vec![]; - - for (key, value) in object { - match value { - serde_json::Value::Object(_) => params.append(&mut parse_deep_object( - &format!("{}[{}]", prefix, key), - value, - )), - serde_json::Value::Array(array) => { - for (i, value) in array.iter().enumerate() { - params.append(&mut parse_deep_object( - &format!("{}[{}][{}]", prefix, key, i), - value, - )); - } - }, - serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())), - _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), - } - } - - return params; - } - - unimplemented!("Only objects are supported with style=deepObject") -} - -/// Internal use only -/// A content type supported by this client. -#[allow(dead_code)] -enum ContentType { - Json, - Text, - Unsupported(String) -} - -impl From<&str> for ContentType { - fn from(content_type: &str) -> Self { - if content_type.starts_with("application") && content_type.contains("json") { - return Self::Json; - } else if content_type.starts_with("text/plain") { - return Self::Text; - } else { - return Self::Unsupported(content_type.to_string()); - } - } -} - -{{#apiInfo}} -{{#apis}} -pub mod {{{classFilename}}}; -{{/apis}} -{{/apiInfo}} - -pub mod configuration; diff --git a/support/openapi-template/reqwest/configuration.mustache b/support/openapi-template/reqwest/configuration.mustache deleted file mode 100644 index e29c73b17..000000000 --- a/support/openapi-template/reqwest/configuration.mustache +++ /dev/null @@ -1,122 +0,0 @@ -{{>partial_header}} - -{{#withAWSV4Signature}} -use std::time::SystemTime; -use aws_sigv4::http_request::{sign, SigningSettings, SigningParams, SignableRequest}; -use http; -use secrecy::{SecretString, ExposeSecret}; -{{/withAWSV4Signature}} -{{#supportTokenSource}} -use std::sync::Arc; -use google_cloud_token::TokenSource; -use async_trait::async_trait; -{{/supportTokenSource}} - -#[derive(Debug, Clone)] -pub struct Configuration { - pub base_path: String, - pub user_agent: Option, - pub client: {{#supportMiddleware}}reqwest_middleware::ClientWithMiddleware{{/supportMiddleware}}{{^supportMiddleware}}reqwest{{^supportAsync}}::blocking{{/supportAsync}}::Client{{/supportMiddleware}}, - {{^supportTokenSource}} - pub basic_auth: Option, - pub oauth_access_token: Option, - pub bearer_access_token: Option, - pub api_key: Option, - {{/supportTokenSource}} - {{#withAWSV4Signature}} - pub aws_v4_key: Option, - {{/withAWSV4Signature}} - {{#supportAsync}} - {{#supportTokenSource}} - pub token_source: Arc, - {{/supportTokenSource}} - {{/supportAsync}} -} -{{^supportTokenSource}} - -pub type BasicAuth = (String, Option); - -#[derive(Debug, Clone)] -pub struct ApiKey { - pub prefix: Option, - pub key: String, -} -{{/supportTokenSource}} - -{{#withAWSV4Signature}} -#[derive(Debug, Clone)] -pub struct AWSv4Key { - pub access_key: String, - pub secret_key: SecretString, - pub region: String, - pub service: String, -} - -impl AWSv4Key { - pub fn sign(&self, uri: &str, method: &str, body: &str) -> Result, aws_sigv4::http_request::Error> { - let request = http::Request::builder() - .uri(uri) - .method(method) - .body(body).unwrap(); - let signing_settings = SigningSettings::default(); - let signing_params = SigningParams::builder() - .access_key(self.access_key.as_str()) - .secret_key(self.secret_key.expose_secret().as_str()) - .region(self.region.as_str()) - .service_name(self.service.as_str()) - .time(SystemTime::now()) - .settings(signing_settings) - .build() - .unwrap(); - let signable_request = SignableRequest::from(&request); - let (mut signing_instructions, _signature) = sign(signable_request, &signing_params)?.into_parts(); - let mut additional_headers = Vec::<(String, String)>::new(); - if let Some(new_headers) = signing_instructions.take_headers() { - for (name, value) in new_headers.into_iter() { - additional_headers.push((name.expect("header should have name").to_string(), - value.to_str().expect("header value should be a string").to_string())); - } - } - Ok(additional_headers) - } -} -{{/withAWSV4Signature}} - -impl Configuration { - pub fn new() -> Configuration { - Configuration::default() - } -} - -impl Default for Configuration { - fn default() -> Self { - Configuration { - base_path: "{{{basePath}}}".to_owned(), - user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}}, - client: {{#supportMiddleware}}reqwest_middleware::ClientBuilder::new(reqwest{{^supportAsync}}::blocking{{/supportAsync}}::Client::new()).build(){{/supportMiddleware}}{{^supportMiddleware}}reqwest{{^supportAsync}}::blocking{{/supportAsync}}::Client::new(){{/supportMiddleware}}, - {{^supportTokenSource}} - basic_auth: None, - oauth_access_token: None, - bearer_access_token: None, - api_key: None, - {{/supportTokenSource}} - {{#withAWSV4Signature}} - aws_v4_key: None, - {{/withAWSV4Signature}} - {{#supportTokenSource}} - token_source: Arc::new(NoopTokenSource{}), - {{/supportTokenSource}} - } - } -} -{{#supportTokenSource}} -#[derive(Debug)] -struct NoopTokenSource{} - -#[async_trait] -impl TokenSource for NoopTokenSource { - async fn token(&self) -> Result> { - panic!("This is dummy token source. You can use TokenSourceProvider from 'google_cloud_auth' crate, or any other compatible crate.") - } -} -{{/supportTokenSource}}