Skip to main content

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