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 reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`organizations_org_id_auth_requests_deny_post`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum OrganizationsOrgIdAuthRequestsDenyPostError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`organizations_org_id_auth_requests_get`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum OrganizationsOrgIdAuthRequestsGetError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`organizations_org_id_auth_requests_post`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum OrganizationsOrgIdAuthRequestsPostError {
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`organizations_org_id_auth_requests_request_id_post`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum OrganizationsOrgIdAuthRequestsRequestIdPostError {
42    UnknownValue(serde_json::Value),
43}
44
45pub async fn organizations_org_id_auth_requests_deny_post(
46    configuration: &configuration::Configuration,
47    org_id: uuid::Uuid,
48    bulk_deny_admin_auth_request_request_model: Option<
49        models::BulkDenyAdminAuthRequestRequestModel,
50    >,
51) -> Result<(), Error<OrganizationsOrgIdAuthRequestsDenyPostError>> {
52    let local_var_configuration = configuration;
53
54    let local_var_client = &local_var_configuration.client;
55
56    let local_var_uri_str = format!(
57        "{}/organizations/{orgId}/auth-requests/deny",
58        local_var_configuration.base_path,
59        orgId = crate::apis::urlencode(org_id.to_string())
60    );
61    let mut local_var_req_builder =
62        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
63
64    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
65        local_var_req_builder =
66            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
67    }
68    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
69        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
70    };
71    local_var_req_builder = local_var_req_builder.json(&bulk_deny_admin_auth_request_request_model);
72
73    let local_var_req = local_var_req_builder.build()?;
74    let local_var_resp = local_var_client.execute(local_var_req).await?;
75
76    let local_var_status = local_var_resp.status();
77    let local_var_content = local_var_resp.text().await?;
78
79    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
80        Ok(())
81    } else {
82        let local_var_entity: Option<OrganizationsOrgIdAuthRequestsDenyPostError> =
83            serde_json::from_str(&local_var_content).ok();
84        let local_var_error = ResponseContent {
85            status: local_var_status,
86            content: local_var_content,
87            entity: local_var_entity,
88        };
89        Err(Error::ResponseError(local_var_error))
90    }
91}
92
93pub async fn organizations_org_id_auth_requests_get(
94    configuration: &configuration::Configuration,
95    org_id: uuid::Uuid,
96) -> Result<
97    models::PendingOrganizationAuthRequestResponseModelListResponseModel,
98    Error<OrganizationsOrgIdAuthRequestsGetError>,
99> {
100    let local_var_configuration = configuration;
101
102    let local_var_client = &local_var_configuration.client;
103
104    let local_var_uri_str = format!(
105        "{}/organizations/{orgId}/auth-requests",
106        local_var_configuration.base_path,
107        orgId = crate::apis::urlencode(org_id.to_string())
108    );
109    let mut local_var_req_builder =
110        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
111
112    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
113        local_var_req_builder =
114            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
115    }
116    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
117        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
118    };
119
120    let local_var_req = local_var_req_builder.build()?;
121    let local_var_resp = local_var_client.execute(local_var_req).await?;
122
123    let local_var_status = local_var_resp.status();
124    let local_var_content = local_var_resp.text().await?;
125
126    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
127        serde_json::from_str(&local_var_content).map_err(Error::from)
128    } else {
129        let local_var_entity: Option<OrganizationsOrgIdAuthRequestsGetError> =
130            serde_json::from_str(&local_var_content).ok();
131        let local_var_error = ResponseContent {
132            status: local_var_status,
133            content: local_var_content,
134            entity: local_var_entity,
135        };
136        Err(Error::ResponseError(local_var_error))
137    }
138}
139
140pub async fn organizations_org_id_auth_requests_post(
141    configuration: &configuration::Configuration,
142    org_id: uuid::Uuid,
143    organization_auth_request_update_many_request_model: Option<
144        Vec<models::OrganizationAuthRequestUpdateManyRequestModel>,
145    >,
146) -> Result<(), Error<OrganizationsOrgIdAuthRequestsPostError>> {
147    let local_var_configuration = configuration;
148
149    let local_var_client = &local_var_configuration.client;
150
151    let local_var_uri_str = format!(
152        "{}/organizations/{orgId}/auth-requests",
153        local_var_configuration.base_path,
154        orgId = crate::apis::urlencode(org_id.to_string())
155    );
156    let mut local_var_req_builder =
157        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
158
159    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
160        local_var_req_builder =
161            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
162    }
163    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
164        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
165    };
166    local_var_req_builder =
167        local_var_req_builder.json(&organization_auth_request_update_many_request_model);
168
169    let local_var_req = local_var_req_builder.build()?;
170    let local_var_resp = local_var_client.execute(local_var_req).await?;
171
172    let local_var_status = local_var_resp.status();
173    let local_var_content = local_var_resp.text().await?;
174
175    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
176        Ok(())
177    } else {
178        let local_var_entity: Option<OrganizationsOrgIdAuthRequestsPostError> =
179            serde_json::from_str(&local_var_content).ok();
180        let local_var_error = ResponseContent {
181            status: local_var_status,
182            content: local_var_content,
183            entity: local_var_entity,
184        };
185        Err(Error::ResponseError(local_var_error))
186    }
187}
188
189pub async fn organizations_org_id_auth_requests_request_id_post(
190    configuration: &configuration::Configuration,
191    org_id: uuid::Uuid,
192    request_id: uuid::Uuid,
193    admin_auth_request_update_request_model: Option<models::AdminAuthRequestUpdateRequestModel>,
194) -> Result<(), Error<OrganizationsOrgIdAuthRequestsRequestIdPostError>> {
195    let local_var_configuration = configuration;
196
197    let local_var_client = &local_var_configuration.client;
198
199    let local_var_uri_str = format!(
200        "{}/organizations/{orgId}/auth-requests/{requestId}",
201        local_var_configuration.base_path,
202        orgId = crate::apis::urlencode(org_id.to_string()),
203        requestId = crate::apis::urlencode(request_id.to_string())
204    );
205    let mut local_var_req_builder =
206        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
207
208    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
209        local_var_req_builder =
210            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
211    }
212    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
213        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
214    };
215    local_var_req_builder = local_var_req_builder.json(&admin_auth_request_update_request_model);
216
217    let local_var_req = local_var_req_builder.build()?;
218    let local_var_resp = local_var_client.execute(local_var_req).await?;
219
220    let local_var_status = local_var_resp.status();
221    let local_var_content = local_var_resp.text().await?;
222
223    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
224        Ok(())
225    } else {
226        let local_var_entity: Option<OrganizationsOrgIdAuthRequestsRequestIdPostError> =
227            serde_json::from_str(&local_var_content).ok();
228        let local_var_error = ResponseContent {
229            status: local_var_status,
230            content: local_var_content,
231            entity: local_var_entity,
232        };
233        Err(Error::ResponseError(local_var_error))
234    }
235}