1use 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 AuthRequestsAdminRequestPostError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum AuthRequestsGetError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum AuthRequestsIdGetError {
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum AuthRequestsIdPutError {
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum AuthRequestsIdResponseGetError {
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum AuthRequestsPendingGetError {
56 UnknownValue(serde_json::Value),
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum AuthRequestsPostError {
63 UnknownValue(serde_json::Value),
64}
65
66pub async fn auth_requests_admin_request_post(
67 configuration: &configuration::Configuration,
68 auth_request_create_request_model: Option<models::AuthRequestCreateRequestModel>,
69) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsAdminRequestPostError>> {
70 let p_auth_request_create_request_model = auth_request_create_request_model;
72
73 let uri_str = format!("{}/auth-requests/admin-request", configuration.base_path);
74 let mut req_builder = configuration
75 .client
76 .request(reqwest::Method::POST, &uri_str);
77
78 if let Some(ref user_agent) = configuration.user_agent {
79 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
80 }
81 if let Some(ref token) = configuration.oauth_access_token {
82 req_builder = req_builder.bearer_auth(token.to_owned());
83 };
84 req_builder = req_builder.json(&p_auth_request_create_request_model);
85
86 let req = req_builder.build()?;
87 let resp = configuration.client.execute(req).await?;
88
89 let status = resp.status();
90 let content_type = resp
91 .headers()
92 .get("content-type")
93 .and_then(|v| v.to_str().ok())
94 .unwrap_or("application/octet-stream");
95 let content_type = super::ContentType::from(content_type);
96
97 if !status.is_client_error() && !status.is_server_error() {
98 let content = resp.text().await?;
99 match content_type {
100 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
101 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))),
102 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::AuthRequestResponseModel`")))),
103 }
104 } else {
105 let content = resp.text().await?;
106 let entity: Option<AuthRequestsAdminRequestPostError> = serde_json::from_str(&content).ok();
107 Err(Error::ResponseError(ResponseContent {
108 status,
109 content,
110 entity,
111 }))
112 }
113}
114
115pub async fn auth_requests_get(
116 configuration: &configuration::Configuration,
117) -> Result<models::AuthRequestResponseModelListResponseModel, Error<AuthRequestsGetError>> {
118 let uri_str = format!("{}/auth-requests", configuration.base_path);
119 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
120
121 if let Some(ref user_agent) = configuration.user_agent {
122 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
123 }
124 if let Some(ref token) = configuration.oauth_access_token {
125 req_builder = req_builder.bearer_auth(token.to_owned());
126 };
127
128 let req = req_builder.build()?;
129 let resp = configuration.client.execute(req).await?;
130
131 let status = resp.status();
132 let content_type = resp
133 .headers()
134 .get("content-type")
135 .and_then(|v| v.to_str().ok())
136 .unwrap_or("application/octet-stream");
137 let content_type = super::ContentType::from(content_type);
138
139 if !status.is_client_error() && !status.is_server_error() {
140 let content = resp.text().await?;
141 match content_type {
142 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
143 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModelListResponseModel`"))),
144 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::AuthRequestResponseModelListResponseModel`")))),
145 }
146 } else {
147 let content = resp.text().await?;
148 let entity: Option<AuthRequestsGetError> = serde_json::from_str(&content).ok();
149 Err(Error::ResponseError(ResponseContent {
150 status,
151 content,
152 entity,
153 }))
154 }
155}
156
157pub async fn auth_requests_id_get(
158 configuration: &configuration::Configuration,
159 id: uuid::Uuid,
160) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsIdGetError>> {
161 let p_id = id;
163
164 let uri_str = format!(
165 "{}/auth-requests/{id}",
166 configuration.base_path,
167 id = crate::apis::urlencode(p_id.to_string())
168 );
169 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
170
171 if let Some(ref user_agent) = configuration.user_agent {
172 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
173 }
174 if let Some(ref token) = configuration.oauth_access_token {
175 req_builder = req_builder.bearer_auth(token.to_owned());
176 };
177
178 let req = req_builder.build()?;
179 let resp = configuration.client.execute(req).await?;
180
181 let status = resp.status();
182 let content_type = resp
183 .headers()
184 .get("content-type")
185 .and_then(|v| v.to_str().ok())
186 .unwrap_or("application/octet-stream");
187 let content_type = super::ContentType::from(content_type);
188
189 if !status.is_client_error() && !status.is_server_error() {
190 let content = resp.text().await?;
191 match content_type {
192 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
193 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))),
194 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::AuthRequestResponseModel`")))),
195 }
196 } else {
197 let content = resp.text().await?;
198 let entity: Option<AuthRequestsIdGetError> = serde_json::from_str(&content).ok();
199 Err(Error::ResponseError(ResponseContent {
200 status,
201 content,
202 entity,
203 }))
204 }
205}
206
207pub async fn auth_requests_id_put(
208 configuration: &configuration::Configuration,
209 id: uuid::Uuid,
210 auth_request_update_request_model: Option<models::AuthRequestUpdateRequestModel>,
211) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsIdPutError>> {
212 let p_id = id;
214 let p_auth_request_update_request_model = auth_request_update_request_model;
215
216 let uri_str = format!(
217 "{}/auth-requests/{id}",
218 configuration.base_path,
219 id = crate::apis::urlencode(p_id.to_string())
220 );
221 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
222
223 if let Some(ref user_agent) = configuration.user_agent {
224 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
225 }
226 if let Some(ref token) = configuration.oauth_access_token {
227 req_builder = req_builder.bearer_auth(token.to_owned());
228 };
229 req_builder = req_builder.json(&p_auth_request_update_request_model);
230
231 let req = req_builder.build()?;
232 let resp = configuration.client.execute(req).await?;
233
234 let status = resp.status();
235 let content_type = resp
236 .headers()
237 .get("content-type")
238 .and_then(|v| v.to_str().ok())
239 .unwrap_or("application/octet-stream");
240 let content_type = super::ContentType::from(content_type);
241
242 if !status.is_client_error() && !status.is_server_error() {
243 let content = resp.text().await?;
244 match content_type {
245 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
246 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))),
247 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::AuthRequestResponseModel`")))),
248 }
249 } else {
250 let content = resp.text().await?;
251 let entity: Option<AuthRequestsIdPutError> = serde_json::from_str(&content).ok();
252 Err(Error::ResponseError(ResponseContent {
253 status,
254 content,
255 entity,
256 }))
257 }
258}
259
260pub async fn auth_requests_id_response_get(
261 configuration: &configuration::Configuration,
262 id: uuid::Uuid,
263 code: Option<&str>,
264) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsIdResponseGetError>> {
265 let p_id = id;
267 let p_code = code;
268
269 let uri_str = format!(
270 "{}/auth-requests/{id}/response",
271 configuration.base_path,
272 id = crate::apis::urlencode(p_id.to_string())
273 );
274 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
275
276 if let Some(ref param_value) = p_code {
277 req_builder = req_builder.query(&[("code", ¶m_value.to_string())]);
278 }
279 if let Some(ref user_agent) = configuration.user_agent {
280 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
281 }
282 if let Some(ref token) = configuration.oauth_access_token {
283 req_builder = req_builder.bearer_auth(token.to_owned());
284 };
285
286 let req = req_builder.build()?;
287 let resp = configuration.client.execute(req).await?;
288
289 let status = resp.status();
290 let content_type = resp
291 .headers()
292 .get("content-type")
293 .and_then(|v| v.to_str().ok())
294 .unwrap_or("application/octet-stream");
295 let content_type = super::ContentType::from(content_type);
296
297 if !status.is_client_error() && !status.is_server_error() {
298 let content = resp.text().await?;
299 match content_type {
300 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
301 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))),
302 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::AuthRequestResponseModel`")))),
303 }
304 } else {
305 let content = resp.text().await?;
306 let entity: Option<AuthRequestsIdResponseGetError> = serde_json::from_str(&content).ok();
307 Err(Error::ResponseError(ResponseContent {
308 status,
309 content,
310 entity,
311 }))
312 }
313}
314
315pub async fn auth_requests_pending_get(
316 configuration: &configuration::Configuration,
317) -> Result<
318 models::PendingAuthRequestResponseModelListResponseModel,
319 Error<AuthRequestsPendingGetError>,
320> {
321 let uri_str = format!("{}/auth-requests/pending", configuration.base_path);
322 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
323
324 if let Some(ref user_agent) = configuration.user_agent {
325 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
326 }
327 if let Some(ref token) = configuration.oauth_access_token {
328 req_builder = req_builder.bearer_auth(token.to_owned());
329 };
330
331 let req = req_builder.build()?;
332 let resp = configuration.client.execute(req).await?;
333
334 let status = resp.status();
335 let content_type = resp
336 .headers()
337 .get("content-type")
338 .and_then(|v| v.to_str().ok())
339 .unwrap_or("application/octet-stream");
340 let content_type = super::ContentType::from(content_type);
341
342 if !status.is_client_error() && !status.is_server_error() {
343 let content = resp.text().await?;
344 match content_type {
345 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
346 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PendingAuthRequestResponseModelListResponseModel`"))),
347 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::PendingAuthRequestResponseModelListResponseModel`")))),
348 }
349 } else {
350 let content = resp.text().await?;
351 let entity: Option<AuthRequestsPendingGetError> = serde_json::from_str(&content).ok();
352 Err(Error::ResponseError(ResponseContent {
353 status,
354 content,
355 entity,
356 }))
357 }
358}
359
360pub async fn auth_requests_post(
361 configuration: &configuration::Configuration,
362 auth_request_create_request_model: Option<models::AuthRequestCreateRequestModel>,
363) -> Result<models::AuthRequestResponseModel, Error<AuthRequestsPostError>> {
364 let p_auth_request_create_request_model = auth_request_create_request_model;
366
367 let uri_str = format!("{}/auth-requests", configuration.base_path);
368 let mut req_builder = configuration
369 .client
370 .request(reqwest::Method::POST, &uri_str);
371
372 if let Some(ref user_agent) = configuration.user_agent {
373 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
374 }
375 if let Some(ref token) = configuration.oauth_access_token {
376 req_builder = req_builder.bearer_auth(token.to_owned());
377 };
378 req_builder = req_builder.json(&p_auth_request_create_request_model);
379
380 let req = req_builder.build()?;
381 let resp = configuration.client.execute(req).await?;
382
383 let status = resp.status();
384 let content_type = resp
385 .headers()
386 .get("content-type")
387 .and_then(|v| v.to_str().ok())
388 .unwrap_or("application/octet-stream");
389 let content_type = super::ContentType::from(content_type);
390
391 if !status.is_client_error() && !status.is_server_error() {
392 let content = resp.text().await?;
393 match content_type {
394 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
395 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AuthRequestResponseModel`"))),
396 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::AuthRequestResponseModel`")))),
397 }
398 } else {
399 let content = resp.text().await?;
400 let entity: Option<AuthRequestsPostError> = serde_json::from_str(&content).ok();
401 Err(Error::ResponseError(ResponseContent {
402 status,
403 content,
404 entity,
405 }))
406 }
407}