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 reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`settings_domains_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum SettingsDomainsGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`settings_domains_post`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum SettingsDomainsPostError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`settings_domains_put`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum SettingsDomainsPutError {
35    UnknownValue(serde_json::Value),
36}
37
38pub async fn settings_domains_get(
39    configuration: &configuration::Configuration,
40    excluded: Option<bool>,
41) -> Result<models::DomainsResponseModel, Error<SettingsDomainsGetError>> {
42    let local_var_configuration = configuration;
43
44    let local_var_client = &local_var_configuration.client;
45
46    let local_var_uri_str = format!("{}/settings/domains", local_var_configuration.base_path);
47    let mut local_var_req_builder =
48        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
49
50    if let Some(ref local_var_str) = excluded {
51        local_var_req_builder =
52            local_var_req_builder.query(&[("excluded", &local_var_str.to_string())]);
53    }
54    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
55        local_var_req_builder =
56            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
57    }
58    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
59        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
60    };
61
62    let local_var_req = local_var_req_builder.build()?;
63    let local_var_resp = local_var_client.execute(local_var_req).await?;
64
65    let local_var_status = local_var_resp.status();
66    let local_var_content = local_var_resp.text().await?;
67
68    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
69        serde_json::from_str(&local_var_content).map_err(Error::from)
70    } else {
71        let local_var_entity: Option<SettingsDomainsGetError> =
72            serde_json::from_str(&local_var_content).ok();
73        let local_var_error = ResponseContent {
74            status: local_var_status,
75            content: local_var_content,
76            entity: local_var_entity,
77        };
78        Err(Error::ResponseError(local_var_error))
79    }
80}
81
82pub async fn settings_domains_post(
83    configuration: &configuration::Configuration,
84    update_domains_request_model: Option<models::UpdateDomainsRequestModel>,
85) -> Result<models::DomainsResponseModel, Error<SettingsDomainsPostError>> {
86    let local_var_configuration = configuration;
87
88    let local_var_client = &local_var_configuration.client;
89
90    let local_var_uri_str = format!("{}/settings/domains", local_var_configuration.base_path);
91    let mut local_var_req_builder =
92        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
93
94    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
95        local_var_req_builder =
96            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
97    }
98    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
99        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
100    };
101    local_var_req_builder = local_var_req_builder.json(&update_domains_request_model);
102
103    let local_var_req = local_var_req_builder.build()?;
104    let local_var_resp = local_var_client.execute(local_var_req).await?;
105
106    let local_var_status = local_var_resp.status();
107    let local_var_content = local_var_resp.text().await?;
108
109    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
110        serde_json::from_str(&local_var_content).map_err(Error::from)
111    } else {
112        let local_var_entity: Option<SettingsDomainsPostError> =
113            serde_json::from_str(&local_var_content).ok();
114        let local_var_error = ResponseContent {
115            status: local_var_status,
116            content: local_var_content,
117            entity: local_var_entity,
118        };
119        Err(Error::ResponseError(local_var_error))
120    }
121}
122
123pub async fn settings_domains_put(
124    configuration: &configuration::Configuration,
125    update_domains_request_model: Option<models::UpdateDomainsRequestModel>,
126) -> Result<models::DomainsResponseModel, Error<SettingsDomainsPutError>> {
127    let local_var_configuration = configuration;
128
129    let local_var_client = &local_var_configuration.client;
130
131    let local_var_uri_str = format!("{}/settings/domains", local_var_configuration.base_path);
132    let mut local_var_req_builder =
133        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
134
135    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
136        local_var_req_builder =
137            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
138    }
139    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
140        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
141    };
142    local_var_req_builder = local_var_req_builder.json(&update_domains_request_model);
143
144    let local_var_req = local_var_req_builder.build()?;
145    let local_var_resp = local_var_client.execute(local_var_req).await?;
146
147    let local_var_status = local_var_resp.status();
148    let local_var_content = local_var_resp.text().await?;
149
150    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
151        serde_json::from_str(&local_var_content).map_err(Error::from)
152    } else {
153        let local_var_entity: Option<SettingsDomainsPutError> =
154            serde_json::from_str(&local_var_content).ok();
155        let local_var_error = ResponseContent {
156            status: local_var_status,
157            content: local_var_content,
158            entity: local_var_entity,
159        };
160        Err(Error::ResponseError(local_var_error))
161    }
162}