Skip to main content

bitwarden_api_api/apis/
providers_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 ProvidersApi: Send + Sync {
29    /// DELETE /providers/{id}
30    async fn delete<'a>(&self, id: uuid::Uuid) -> Result<(), Error<DeleteError>>;
31
32    /// GET /providers/{id}
33    async fn get<'a>(
34        &self,
35        id: uuid::Uuid,
36    ) -> Result<models::ProviderResponseModel, Error<GetError>>;
37
38    /// POST /providers/{id}/delete-recover-token
39    async fn post_delete_recover_token<'a>(
40        &self,
41        id: uuid::Uuid,
42        provider_verify_delete_recover_request_model: Option<
43            models::ProviderVerifyDeleteRecoverRequestModel,
44        >,
45    ) -> Result<(), Error<PostDeleteRecoverTokenError>>;
46
47    /// PUT /providers/{id}
48    async fn put<'a>(
49        &self,
50        id: uuid::Uuid,
51        provider_update_request_model: Option<models::ProviderUpdateRequestModel>,
52    ) -> Result<models::ProviderResponseModel, Error<PutError>>;
53
54    /// POST /providers/{id}/setup
55    async fn setup<'a>(
56        &self,
57        id: uuid::Uuid,
58        provider_setup_request_model: Option<models::ProviderSetupRequestModel>,
59    ) -> Result<models::ProviderResponseModel, Error<SetupError>>;
60}
61
62pub struct ProvidersApiClient {
63    configuration: Arc<configuration::Configuration>,
64}
65
66impl ProvidersApiClient {
67    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
68        Self { configuration }
69    }
70}
71
72#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
73#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
74impl ProvidersApi for ProvidersApiClient {
75    async fn delete<'a>(&self, id: uuid::Uuid) -> Result<(), Error<DeleteError>> {
76        let local_var_configuration = &self.configuration;
77
78        let local_var_client = &local_var_configuration.client;
79
80        let local_var_uri_str = format!(
81            "{}/providers/{id}",
82            local_var_configuration.base_path,
83            id = id
84        );
85        let mut local_var_req_builder =
86            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
87
88        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
89
90        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
91    }
92
93    async fn get<'a>(
94        &self,
95        id: uuid::Uuid,
96    ) -> Result<models::ProviderResponseModel, Error<GetError>> {
97        let local_var_configuration = &self.configuration;
98
99        let local_var_client = &local_var_configuration.client;
100
101        let local_var_uri_str = format!(
102            "{}/providers/{id}",
103            local_var_configuration.base_path,
104            id = id
105        );
106        let mut local_var_req_builder =
107            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
108
109        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
110
111        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
112    }
113
114    async fn post_delete_recover_token<'a>(
115        &self,
116        id: uuid::Uuid,
117        provider_verify_delete_recover_request_model: Option<
118            models::ProviderVerifyDeleteRecoverRequestModel,
119        >,
120    ) -> Result<(), Error<PostDeleteRecoverTokenError>> {
121        let local_var_configuration = &self.configuration;
122
123        let local_var_client = &local_var_configuration.client;
124
125        let local_var_uri_str = format!(
126            "{}/providers/{id}/delete-recover-token",
127            local_var_configuration.base_path,
128            id = id
129        );
130        let mut local_var_req_builder =
131            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
132
133        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
134        local_var_req_builder =
135            local_var_req_builder.json(&provider_verify_delete_recover_request_model);
136
137        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
138    }
139
140    async fn put<'a>(
141        &self,
142        id: uuid::Uuid,
143        provider_update_request_model: Option<models::ProviderUpdateRequestModel>,
144    ) -> Result<models::ProviderResponseModel, Error<PutError>> {
145        let local_var_configuration = &self.configuration;
146
147        let local_var_client = &local_var_configuration.client;
148
149        let local_var_uri_str = format!(
150            "{}/providers/{id}",
151            local_var_configuration.base_path,
152            id = id
153        );
154        let mut local_var_req_builder =
155            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
156
157        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
158        local_var_req_builder = local_var_req_builder.json(&provider_update_request_model);
159
160        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
161    }
162
163    async fn setup<'a>(
164        &self,
165        id: uuid::Uuid,
166        provider_setup_request_model: Option<models::ProviderSetupRequestModel>,
167    ) -> Result<models::ProviderResponseModel, Error<SetupError>> {
168        let local_var_configuration = &self.configuration;
169
170        let local_var_client = &local_var_configuration.client;
171
172        let local_var_uri_str = format!(
173            "{}/providers/{id}/setup",
174            local_var_configuration.base_path,
175            id = id
176        );
177        let mut local_var_req_builder =
178            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
179
180        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
181        local_var_req_builder = local_var_req_builder.json(&provider_setup_request_model);
182
183        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
184    }
185}
186
187/// struct for typed errors of method [`ProvidersApi::delete`]
188#[derive(Debug, Clone, Serialize, Deserialize)]
189#[serde(untagged)]
190pub enum DeleteError {
191    UnknownValue(serde_json::Value),
192}
193/// struct for typed errors of method [`ProvidersApi::get`]
194#[derive(Debug, Clone, Serialize, Deserialize)]
195#[serde(untagged)]
196pub enum GetError {
197    UnknownValue(serde_json::Value),
198}
199/// struct for typed errors of method [`ProvidersApi::post_delete_recover_token`]
200#[derive(Debug, Clone, Serialize, Deserialize)]
201#[serde(untagged)]
202pub enum PostDeleteRecoverTokenError {
203    UnknownValue(serde_json::Value),
204}
205/// struct for typed errors of method [`ProvidersApi::put`]
206#[derive(Debug, Clone, Serialize, Deserialize)]
207#[serde(untagged)]
208pub enum PutError {
209    UnknownValue(serde_json::Value),
210}
211/// struct for typed errors of method [`ProvidersApi::setup`]
212#[derive(Debug, Clone, Serialize, Deserialize)]
213#[serde(untagged)]
214pub enum SetupError {
215    UnknownValue(serde_json::Value),
216}