bitwarden_api_api/apis/
organization_auth_requests_api.rs1use reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum OrganizationsOrgIdAuthRequestsDenyPostError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum OrganizationsOrgIdAuthRequestsGetError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum OrganizationsOrgIdAuthRequestsPostError {
35 UnknownValue(serde_json::Value),
36}
37
38#[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 p_org_id = org_id;
54 let p_bulk_deny_admin_auth_request_request_model = bulk_deny_admin_auth_request_request_model;
55
56 let uri_str = format!(
57 "{}/organizations/{orgId}/auth-requests/deny",
58 configuration.base_path,
59 orgId = crate::apis::urlencode(p_org_id.to_string())
60 );
61 let mut req_builder = configuration
62 .client
63 .request(reqwest::Method::POST, &uri_str);
64
65 if let Some(ref user_agent) = configuration.user_agent {
66 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
67 }
68 if let Some(ref token) = configuration.oauth_access_token {
69 req_builder = req_builder.bearer_auth(token.to_owned());
70 };
71 req_builder = req_builder.json(&p_bulk_deny_admin_auth_request_request_model);
72
73 let req = req_builder.build()?;
74 let resp = configuration.client.execute(req).await?;
75
76 let status = resp.status();
77
78 if !status.is_client_error() && !status.is_server_error() {
79 Ok(())
80 } else {
81 let content = resp.text().await?;
82 let entity: Option<OrganizationsOrgIdAuthRequestsDenyPostError> =
83 serde_json::from_str(&content).ok();
84 Err(Error::ResponseError(ResponseContent {
85 status,
86 content,
87 entity,
88 }))
89 }
90}
91
92pub async fn organizations_org_id_auth_requests_get(
93 configuration: &configuration::Configuration,
94 org_id: uuid::Uuid,
95) -> Result<
96 models::PendingOrganizationAuthRequestResponseModelListResponseModel,
97 Error<OrganizationsOrgIdAuthRequestsGetError>,
98> {
99 let p_org_id = org_id;
101
102 let uri_str = format!(
103 "{}/organizations/{orgId}/auth-requests",
104 configuration.base_path,
105 orgId = crate::apis::urlencode(p_org_id.to_string())
106 );
107 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
108
109 if let Some(ref user_agent) = configuration.user_agent {
110 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
111 }
112 if let Some(ref token) = configuration.oauth_access_token {
113 req_builder = req_builder.bearer_auth(token.to_owned());
114 };
115
116 let req = req_builder.build()?;
117 let resp = configuration.client.execute(req).await?;
118
119 let status = resp.status();
120 let content_type = resp
121 .headers()
122 .get("content-type")
123 .and_then(|v| v.to_str().ok())
124 .unwrap_or("application/octet-stream");
125 let content_type = super::ContentType::from(content_type);
126
127 if !status.is_client_error() && !status.is_server_error() {
128 let content = resp.text().await?;
129 match content_type {
130 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
131 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PendingOrganizationAuthRequestResponseModelListResponseModel`"))),
132 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PendingOrganizationAuthRequestResponseModelListResponseModel`")))),
133 }
134 } else {
135 let content = resp.text().await?;
136 let entity: Option<OrganizationsOrgIdAuthRequestsGetError> =
137 serde_json::from_str(&content).ok();
138 Err(Error::ResponseError(ResponseContent {
139 status,
140 content,
141 entity,
142 }))
143 }
144}
145
146pub async fn organizations_org_id_auth_requests_post(
147 configuration: &configuration::Configuration,
148 org_id: uuid::Uuid,
149 organization_auth_request_update_many_request_model: Option<
150 Vec<models::OrganizationAuthRequestUpdateManyRequestModel>,
151 >,
152) -> Result<(), Error<OrganizationsOrgIdAuthRequestsPostError>> {
153 let p_org_id = org_id;
155 let p_organization_auth_request_update_many_request_model =
156 organization_auth_request_update_many_request_model;
157
158 let uri_str = format!(
159 "{}/organizations/{orgId}/auth-requests",
160 configuration.base_path,
161 orgId = crate::apis::urlencode(p_org_id.to_string())
162 );
163 let mut req_builder = configuration
164 .client
165 .request(reqwest::Method::POST, &uri_str);
166
167 if let Some(ref user_agent) = configuration.user_agent {
168 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
169 }
170 if let Some(ref token) = configuration.oauth_access_token {
171 req_builder = req_builder.bearer_auth(token.to_owned());
172 };
173 req_builder = req_builder.json(&p_organization_auth_request_update_many_request_model);
174
175 let req = req_builder.build()?;
176 let resp = configuration.client.execute(req).await?;
177
178 let status = resp.status();
179
180 if !status.is_client_error() && !status.is_server_error() {
181 Ok(())
182 } else {
183 let content = resp.text().await?;
184 let entity: Option<OrganizationsOrgIdAuthRequestsPostError> =
185 serde_json::from_str(&content).ok();
186 Err(Error::ResponseError(ResponseContent {
187 status,
188 content,
189 entity,
190 }))
191 }
192}
193
194pub async fn organizations_org_id_auth_requests_request_id_post(
195 configuration: &configuration::Configuration,
196 org_id: uuid::Uuid,
197 request_id: uuid::Uuid,
198 admin_auth_request_update_request_model: Option<models::AdminAuthRequestUpdateRequestModel>,
199) -> Result<(), Error<OrganizationsOrgIdAuthRequestsRequestIdPostError>> {
200 let p_org_id = org_id;
202 let p_request_id = request_id;
203 let p_admin_auth_request_update_request_model = admin_auth_request_update_request_model;
204
205 let uri_str = format!(
206 "{}/organizations/{orgId}/auth-requests/{requestId}",
207 configuration.base_path,
208 orgId = crate::apis::urlencode(p_org_id.to_string()),
209 requestId = crate::apis::urlencode(p_request_id.to_string())
210 );
211 let mut req_builder = configuration
212 .client
213 .request(reqwest::Method::POST, &uri_str);
214
215 if let Some(ref user_agent) = configuration.user_agent {
216 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
217 }
218 if let Some(ref token) = configuration.oauth_access_token {
219 req_builder = req_builder.bearer_auth(token.to_owned());
220 };
221 req_builder = req_builder.json(&p_admin_auth_request_update_request_model);
222
223 let req = req_builder.build()?;
224 let resp = configuration.client.execute(req).await?;
225
226 let status = resp.status();
227
228 if !status.is_client_error() && !status.is_server_error() {
229 Ok(())
230 } else {
231 let content = resp.text().await?;
232 let entity: Option<OrganizationsOrgIdAuthRequestsRequestIdPostError> =
233 serde_json::from_str(&content).ok();
234 Err(Error::ResponseError(ResponseContent {
235 status,
236 content,
237 entity,
238 }))
239 }
240}