Skip to main content

bitwarden_api_api/apis/
settings_api.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21    apis::{AuthRequired, ContentType, ResponseContent},
22    models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait SettingsApi: Send + Sync {
29    /// GET /settings/domains
30    async fn get_domains<'a>(
31        &self,
32        excluded: Option<bool>,
33    ) -> Result<models::DomainsResponseModel, Error<GetDomainsError>>;
34
35    /// PUT /settings/domains
36    async fn put_domains<'a>(
37        &self,
38        update_domains_request_model: Option<models::UpdateDomainsRequestModel>,
39    ) -> Result<models::DomainsResponseModel, Error<PutDomainsError>>;
40}
41
42pub struct SettingsApiClient {
43    configuration: Arc<configuration::Configuration>,
44}
45
46impl SettingsApiClient {
47    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
48        Self { configuration }
49    }
50}
51
52#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
53#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
54impl SettingsApi for SettingsApiClient {
55    async fn get_domains<'a>(
56        &self,
57        excluded: Option<bool>,
58    ) -> Result<models::DomainsResponseModel, Error<GetDomainsError>> {
59        let local_var_configuration = &self.configuration;
60
61        let local_var_client = &local_var_configuration.client;
62
63        let local_var_uri_str = format!("{}/settings/domains", local_var_configuration.base_path);
64        let mut local_var_req_builder =
65            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
66
67        if let Some(ref param_value) = excluded {
68            local_var_req_builder =
69                local_var_req_builder.query(&[("excluded", &param_value.to_string())]);
70        }
71        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
72
73        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
74    }
75
76    async fn put_domains<'a>(
77        &self,
78        update_domains_request_model: Option<models::UpdateDomainsRequestModel>,
79    ) -> Result<models::DomainsResponseModel, Error<PutDomainsError>> {
80        let local_var_configuration = &self.configuration;
81
82        let local_var_client = &local_var_configuration.client;
83
84        let local_var_uri_str = format!("{}/settings/domains", local_var_configuration.base_path);
85        let mut local_var_req_builder =
86            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
87
88        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
89        local_var_req_builder = local_var_req_builder.json(&update_domains_request_model);
90
91        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
92    }
93}
94
95/// struct for typed errors of method [`SettingsApi::get_domains`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum GetDomainsError {
99    UnknownValue(serde_json::Value),
100}
101/// struct for typed errors of method [`SettingsApi::put_domains`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum PutDomainsError {
105    UnknownValue(serde_json::Value),
106}