1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum Oauth2AccessTokensDestroyError {
20 Status400(models::ValidationError),
21 Status403(models::GenericError),
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum Oauth2AccessTokensListError {
29 Status400(models::ValidationError),
30 Status403(models::GenericError),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum Oauth2AccessTokensRetrieveError {
38 Status400(models::ValidationError),
39 Status403(models::GenericError),
40 UnknownValue(serde_json::Value),
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum Oauth2AccessTokensUsedByListError {
47 Status400(models::ValidationError),
48 Status403(models::GenericError),
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum Oauth2AuthorizationCodesDestroyError {
56 Status400(models::ValidationError),
57 Status403(models::GenericError),
58 UnknownValue(serde_json::Value),
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum Oauth2AuthorizationCodesListError {
65 Status400(models::ValidationError),
66 Status403(models::GenericError),
67 UnknownValue(serde_json::Value),
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum Oauth2AuthorizationCodesRetrieveError {
74 Status400(models::ValidationError),
75 Status403(models::GenericError),
76 UnknownValue(serde_json::Value),
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum Oauth2AuthorizationCodesUsedByListError {
83 Status400(models::ValidationError),
84 Status403(models::GenericError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum Oauth2RefreshTokensDestroyError {
92 Status400(models::ValidationError),
93 Status403(models::GenericError),
94 UnknownValue(serde_json::Value),
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum Oauth2RefreshTokensListError {
101 Status400(models::ValidationError),
102 Status403(models::GenericError),
103 UnknownValue(serde_json::Value),
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum Oauth2RefreshTokensRetrieveError {
110 Status400(models::ValidationError),
111 Status403(models::GenericError),
112 UnknownValue(serde_json::Value),
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum Oauth2RefreshTokensUsedByListError {
119 Status400(models::ValidationError),
120 Status403(models::GenericError),
121 UnknownValue(serde_json::Value),
122}
123
124pub async fn oauth2_access_tokens_destroy(
126 configuration: &configuration::Configuration,
127 id: i32,
128) -> Result<(), Error<Oauth2AccessTokensDestroyError>> {
129 let p_path_id = id;
131
132 let uri_str = format!("{}/oauth2/access_tokens/{id}/", configuration.base_path, id = p_path_id);
133 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
134
135 if let Some(ref user_agent) = configuration.user_agent {
136 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
137 }
138 if let Some(ref token) = configuration.bearer_access_token {
139 req_builder = req_builder.bearer_auth(token.to_owned());
140 };
141
142 let req = req_builder.build()?;
143 let resp = configuration.client.execute(req).await?;
144
145 let status = resp.status();
146
147 if !status.is_client_error() && !status.is_server_error() {
148 Ok(())
149 } else {
150 let content = resp.text().await?;
151 let entity: Option<Oauth2AccessTokensDestroyError> = serde_json::from_str(&content).ok();
152 Err(Error::ResponseError(ResponseContent {
153 status,
154 content,
155 entity,
156 }))
157 }
158}
159
160pub async fn oauth2_access_tokens_list(
162 configuration: &configuration::Configuration,
163 ordering: Option<&str>,
164 page: Option<i32>,
165 page_size: Option<i32>,
166 provider: Option<i32>,
167 search: Option<&str>,
168 user: Option<i32>,
169) -> Result<models::PaginatedTokenModelList, Error<Oauth2AccessTokensListError>> {
170 let p_query_ordering = ordering;
172 let p_query_page = page;
173 let p_query_page_size = page_size;
174 let p_query_provider = provider;
175 let p_query_search = search;
176 let p_query_user = user;
177
178 let uri_str = format!("{}/oauth2/access_tokens/", configuration.base_path);
179 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
180
181 if let Some(ref param_value) = p_query_ordering {
182 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
183 }
184 if let Some(ref param_value) = p_query_page {
185 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
186 }
187 if let Some(ref param_value) = p_query_page_size {
188 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
189 }
190 if let Some(ref param_value) = p_query_provider {
191 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
192 }
193 if let Some(ref param_value) = p_query_search {
194 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
195 }
196 if let Some(ref param_value) = p_query_user {
197 req_builder = req_builder.query(&[("user", ¶m_value.to_string())]);
198 }
199 if let Some(ref user_agent) = configuration.user_agent {
200 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
201 }
202 if let Some(ref token) = configuration.bearer_access_token {
203 req_builder = req_builder.bearer_auth(token.to_owned());
204 };
205
206 let req = req_builder.build()?;
207 let resp = configuration.client.execute(req).await?;
208
209 let status = resp.status();
210 let content_type = resp
211 .headers()
212 .get("content-type")
213 .and_then(|v| v.to_str().ok())
214 .unwrap_or("application/octet-stream");
215 let content_type = super::ContentType::from(content_type);
216
217 if !status.is_client_error() && !status.is_server_error() {
218 let content = resp.text().await?;
219 match content_type {
220 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
221 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedTokenModelList`"))),
222 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::PaginatedTokenModelList`")))),
223 }
224 } else {
225 let content = resp.text().await?;
226 let entity: Option<Oauth2AccessTokensListError> = serde_json::from_str(&content).ok();
227 Err(Error::ResponseError(ResponseContent {
228 status,
229 content,
230 entity,
231 }))
232 }
233}
234
235pub async fn oauth2_access_tokens_retrieve(
237 configuration: &configuration::Configuration,
238 id: i32,
239) -> Result<models::TokenModel, Error<Oauth2AccessTokensRetrieveError>> {
240 let p_path_id = id;
242
243 let uri_str = format!("{}/oauth2/access_tokens/{id}/", configuration.base_path, id = p_path_id);
244 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
245
246 if let Some(ref user_agent) = configuration.user_agent {
247 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
248 }
249 if let Some(ref token) = configuration.bearer_access_token {
250 req_builder = req_builder.bearer_auth(token.to_owned());
251 };
252
253 let req = req_builder.build()?;
254 let resp = configuration.client.execute(req).await?;
255
256 let status = resp.status();
257 let content_type = resp
258 .headers()
259 .get("content-type")
260 .and_then(|v| v.to_str().ok())
261 .unwrap_or("application/octet-stream");
262 let content_type = super::ContentType::from(content_type);
263
264 if !status.is_client_error() && !status.is_server_error() {
265 let content = resp.text().await?;
266 match content_type {
267 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
268 ContentType::Text => {
269 return Err(Error::from(serde_json::Error::custom(
270 "Received `text/plain` content type response that cannot be converted to `models::TokenModel`",
271 )))
272 }
273 ContentType::Unsupported(unknown_type) => {
274 return Err(Error::from(serde_json::Error::custom(format!(
275 "Received `{unknown_type}` content type response that cannot be converted to `models::TokenModel`"
276 ))))
277 }
278 }
279 } else {
280 let content = resp.text().await?;
281 let entity: Option<Oauth2AccessTokensRetrieveError> = serde_json::from_str(&content).ok();
282 Err(Error::ResponseError(ResponseContent {
283 status,
284 content,
285 entity,
286 }))
287 }
288}
289
290pub async fn oauth2_access_tokens_used_by_list(
292 configuration: &configuration::Configuration,
293 id: i32,
294) -> Result<Vec<models::UsedBy>, Error<Oauth2AccessTokensUsedByListError>> {
295 let p_path_id = id;
297
298 let uri_str = format!(
299 "{}/oauth2/access_tokens/{id}/used_by/",
300 configuration.base_path,
301 id = p_path_id
302 );
303 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
304
305 if let Some(ref user_agent) = configuration.user_agent {
306 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
307 }
308 if let Some(ref token) = configuration.bearer_access_token {
309 req_builder = req_builder.bearer_auth(token.to_owned());
310 };
311
312 let req = req_builder.build()?;
313 let resp = configuration.client.execute(req).await?;
314
315 let status = resp.status();
316 let content_type = resp
317 .headers()
318 .get("content-type")
319 .and_then(|v| v.to_str().ok())
320 .unwrap_or("application/octet-stream");
321 let content_type = super::ContentType::from(content_type);
322
323 if !status.is_client_error() && !status.is_server_error() {
324 let content = resp.text().await?;
325 match content_type {
326 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
327 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UsedBy>`"))),
328 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::UsedBy>`")))),
329 }
330 } else {
331 let content = resp.text().await?;
332 let entity: Option<Oauth2AccessTokensUsedByListError> = serde_json::from_str(&content).ok();
333 Err(Error::ResponseError(ResponseContent {
334 status,
335 content,
336 entity,
337 }))
338 }
339}
340
341pub async fn oauth2_authorization_codes_destroy(
343 configuration: &configuration::Configuration,
344 id: i32,
345) -> Result<(), Error<Oauth2AuthorizationCodesDestroyError>> {
346 let p_path_id = id;
348
349 let uri_str = format!(
350 "{}/oauth2/authorization_codes/{id}/",
351 configuration.base_path,
352 id = p_path_id
353 );
354 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
355
356 if let Some(ref user_agent) = configuration.user_agent {
357 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
358 }
359 if let Some(ref token) = configuration.bearer_access_token {
360 req_builder = req_builder.bearer_auth(token.to_owned());
361 };
362
363 let req = req_builder.build()?;
364 let resp = configuration.client.execute(req).await?;
365
366 let status = resp.status();
367
368 if !status.is_client_error() && !status.is_server_error() {
369 Ok(())
370 } else {
371 let content = resp.text().await?;
372 let entity: Option<Oauth2AuthorizationCodesDestroyError> = serde_json::from_str(&content).ok();
373 Err(Error::ResponseError(ResponseContent {
374 status,
375 content,
376 entity,
377 }))
378 }
379}
380
381pub async fn oauth2_authorization_codes_list(
383 configuration: &configuration::Configuration,
384 ordering: Option<&str>,
385 page: Option<i32>,
386 page_size: Option<i32>,
387 provider: Option<i32>,
388 search: Option<&str>,
389 user: Option<i32>,
390) -> Result<models::PaginatedExpiringBaseGrantModelList, Error<Oauth2AuthorizationCodesListError>> {
391 let p_query_ordering = ordering;
393 let p_query_page = page;
394 let p_query_page_size = page_size;
395 let p_query_provider = provider;
396 let p_query_search = search;
397 let p_query_user = user;
398
399 let uri_str = format!("{}/oauth2/authorization_codes/", configuration.base_path);
400 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
401
402 if let Some(ref param_value) = p_query_ordering {
403 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
404 }
405 if let Some(ref param_value) = p_query_page {
406 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
407 }
408 if let Some(ref param_value) = p_query_page_size {
409 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
410 }
411 if let Some(ref param_value) = p_query_provider {
412 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
413 }
414 if let Some(ref param_value) = p_query_search {
415 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
416 }
417 if let Some(ref param_value) = p_query_user {
418 req_builder = req_builder.query(&[("user", ¶m_value.to_string())]);
419 }
420 if let Some(ref user_agent) = configuration.user_agent {
421 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
422 }
423 if let Some(ref token) = configuration.bearer_access_token {
424 req_builder = req_builder.bearer_auth(token.to_owned());
425 };
426
427 let req = req_builder.build()?;
428 let resp = configuration.client.execute(req).await?;
429
430 let status = resp.status();
431 let content_type = resp
432 .headers()
433 .get("content-type")
434 .and_then(|v| v.to_str().ok())
435 .unwrap_or("application/octet-stream");
436 let content_type = super::ContentType::from(content_type);
437
438 if !status.is_client_error() && !status.is_server_error() {
439 let content = resp.text().await?;
440 match content_type {
441 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
442 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedExpiringBaseGrantModelList`"))),
443 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::PaginatedExpiringBaseGrantModelList`")))),
444 }
445 } else {
446 let content = resp.text().await?;
447 let entity: Option<Oauth2AuthorizationCodesListError> = serde_json::from_str(&content).ok();
448 Err(Error::ResponseError(ResponseContent {
449 status,
450 content,
451 entity,
452 }))
453 }
454}
455
456pub async fn oauth2_authorization_codes_retrieve(
458 configuration: &configuration::Configuration,
459 id: i32,
460) -> Result<models::ExpiringBaseGrantModel, Error<Oauth2AuthorizationCodesRetrieveError>> {
461 let p_path_id = id;
463
464 let uri_str = format!(
465 "{}/oauth2/authorization_codes/{id}/",
466 configuration.base_path,
467 id = p_path_id
468 );
469 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
470
471 if let Some(ref user_agent) = configuration.user_agent {
472 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
473 }
474 if let Some(ref token) = configuration.bearer_access_token {
475 req_builder = req_builder.bearer_auth(token.to_owned());
476 };
477
478 let req = req_builder.build()?;
479 let resp = configuration.client.execute(req).await?;
480
481 let status = resp.status();
482 let content_type = resp
483 .headers()
484 .get("content-type")
485 .and_then(|v| v.to_str().ok())
486 .unwrap_or("application/octet-stream");
487 let content_type = super::ContentType::from(content_type);
488
489 if !status.is_client_error() && !status.is_server_error() {
490 let content = resp.text().await?;
491 match content_type {
492 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
493 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExpiringBaseGrantModel`"))),
494 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::ExpiringBaseGrantModel`")))),
495 }
496 } else {
497 let content = resp.text().await?;
498 let entity: Option<Oauth2AuthorizationCodesRetrieveError> = serde_json::from_str(&content).ok();
499 Err(Error::ResponseError(ResponseContent {
500 status,
501 content,
502 entity,
503 }))
504 }
505}
506
507pub async fn oauth2_authorization_codes_used_by_list(
509 configuration: &configuration::Configuration,
510 id: i32,
511) -> Result<Vec<models::UsedBy>, Error<Oauth2AuthorizationCodesUsedByListError>> {
512 let p_path_id = id;
514
515 let uri_str = format!(
516 "{}/oauth2/authorization_codes/{id}/used_by/",
517 configuration.base_path,
518 id = p_path_id
519 );
520 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
521
522 if let Some(ref user_agent) = configuration.user_agent {
523 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
524 }
525 if let Some(ref token) = configuration.bearer_access_token {
526 req_builder = req_builder.bearer_auth(token.to_owned());
527 };
528
529 let req = req_builder.build()?;
530 let resp = configuration.client.execute(req).await?;
531
532 let status = resp.status();
533 let content_type = resp
534 .headers()
535 .get("content-type")
536 .and_then(|v| v.to_str().ok())
537 .unwrap_or("application/octet-stream");
538 let content_type = super::ContentType::from(content_type);
539
540 if !status.is_client_error() && !status.is_server_error() {
541 let content = resp.text().await?;
542 match content_type {
543 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
544 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UsedBy>`"))),
545 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::UsedBy>`")))),
546 }
547 } else {
548 let content = resp.text().await?;
549 let entity: Option<Oauth2AuthorizationCodesUsedByListError> = serde_json::from_str(&content).ok();
550 Err(Error::ResponseError(ResponseContent {
551 status,
552 content,
553 entity,
554 }))
555 }
556}
557
558pub async fn oauth2_refresh_tokens_destroy(
560 configuration: &configuration::Configuration,
561 id: i32,
562) -> Result<(), Error<Oauth2RefreshTokensDestroyError>> {
563 let p_path_id = id;
565
566 let uri_str = format!(
567 "{}/oauth2/refresh_tokens/{id}/",
568 configuration.base_path,
569 id = p_path_id
570 );
571 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
572
573 if let Some(ref user_agent) = configuration.user_agent {
574 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
575 }
576 if let Some(ref token) = configuration.bearer_access_token {
577 req_builder = req_builder.bearer_auth(token.to_owned());
578 };
579
580 let req = req_builder.build()?;
581 let resp = configuration.client.execute(req).await?;
582
583 let status = resp.status();
584
585 if !status.is_client_error() && !status.is_server_error() {
586 Ok(())
587 } else {
588 let content = resp.text().await?;
589 let entity: Option<Oauth2RefreshTokensDestroyError> = serde_json::from_str(&content).ok();
590 Err(Error::ResponseError(ResponseContent {
591 status,
592 content,
593 entity,
594 }))
595 }
596}
597
598pub async fn oauth2_refresh_tokens_list(
600 configuration: &configuration::Configuration,
601 ordering: Option<&str>,
602 page: Option<i32>,
603 page_size: Option<i32>,
604 provider: Option<i32>,
605 search: Option<&str>,
606 user: Option<i32>,
607) -> Result<models::PaginatedTokenModelList, Error<Oauth2RefreshTokensListError>> {
608 let p_query_ordering = ordering;
610 let p_query_page = page;
611 let p_query_page_size = page_size;
612 let p_query_provider = provider;
613 let p_query_search = search;
614 let p_query_user = user;
615
616 let uri_str = format!("{}/oauth2/refresh_tokens/", configuration.base_path);
617 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
618
619 if let Some(ref param_value) = p_query_ordering {
620 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
621 }
622 if let Some(ref param_value) = p_query_page {
623 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
624 }
625 if let Some(ref param_value) = p_query_page_size {
626 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
627 }
628 if let Some(ref param_value) = p_query_provider {
629 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
630 }
631 if let Some(ref param_value) = p_query_search {
632 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
633 }
634 if let Some(ref param_value) = p_query_user {
635 req_builder = req_builder.query(&[("user", ¶m_value.to_string())]);
636 }
637 if let Some(ref user_agent) = configuration.user_agent {
638 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
639 }
640 if let Some(ref token) = configuration.bearer_access_token {
641 req_builder = req_builder.bearer_auth(token.to_owned());
642 };
643
644 let req = req_builder.build()?;
645 let resp = configuration.client.execute(req).await?;
646
647 let status = resp.status();
648 let content_type = resp
649 .headers()
650 .get("content-type")
651 .and_then(|v| v.to_str().ok())
652 .unwrap_or("application/octet-stream");
653 let content_type = super::ContentType::from(content_type);
654
655 if !status.is_client_error() && !status.is_server_error() {
656 let content = resp.text().await?;
657 match content_type {
658 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
659 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedTokenModelList`"))),
660 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::PaginatedTokenModelList`")))),
661 }
662 } else {
663 let content = resp.text().await?;
664 let entity: Option<Oauth2RefreshTokensListError> = serde_json::from_str(&content).ok();
665 Err(Error::ResponseError(ResponseContent {
666 status,
667 content,
668 entity,
669 }))
670 }
671}
672
673pub async fn oauth2_refresh_tokens_retrieve(
675 configuration: &configuration::Configuration,
676 id: i32,
677) -> Result<models::TokenModel, Error<Oauth2RefreshTokensRetrieveError>> {
678 let p_path_id = id;
680
681 let uri_str = format!(
682 "{}/oauth2/refresh_tokens/{id}/",
683 configuration.base_path,
684 id = p_path_id
685 );
686 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
687
688 if let Some(ref user_agent) = configuration.user_agent {
689 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
690 }
691 if let Some(ref token) = configuration.bearer_access_token {
692 req_builder = req_builder.bearer_auth(token.to_owned());
693 };
694
695 let req = req_builder.build()?;
696 let resp = configuration.client.execute(req).await?;
697
698 let status = resp.status();
699 let content_type = resp
700 .headers()
701 .get("content-type")
702 .and_then(|v| v.to_str().ok())
703 .unwrap_or("application/octet-stream");
704 let content_type = super::ContentType::from(content_type);
705
706 if !status.is_client_error() && !status.is_server_error() {
707 let content = resp.text().await?;
708 match content_type {
709 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
710 ContentType::Text => {
711 return Err(Error::from(serde_json::Error::custom(
712 "Received `text/plain` content type response that cannot be converted to `models::TokenModel`",
713 )))
714 }
715 ContentType::Unsupported(unknown_type) => {
716 return Err(Error::from(serde_json::Error::custom(format!(
717 "Received `{unknown_type}` content type response that cannot be converted to `models::TokenModel`"
718 ))))
719 }
720 }
721 } else {
722 let content = resp.text().await?;
723 let entity: Option<Oauth2RefreshTokensRetrieveError> = serde_json::from_str(&content).ok();
724 Err(Error::ResponseError(ResponseContent {
725 status,
726 content,
727 entity,
728 }))
729 }
730}
731
732pub async fn oauth2_refresh_tokens_used_by_list(
734 configuration: &configuration::Configuration,
735 id: i32,
736) -> Result<Vec<models::UsedBy>, Error<Oauth2RefreshTokensUsedByListError>> {
737 let p_path_id = id;
739
740 let uri_str = format!(
741 "{}/oauth2/refresh_tokens/{id}/used_by/",
742 configuration.base_path,
743 id = p_path_id
744 );
745 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
746
747 if let Some(ref user_agent) = configuration.user_agent {
748 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
749 }
750 if let Some(ref token) = configuration.bearer_access_token {
751 req_builder = req_builder.bearer_auth(token.to_owned());
752 };
753
754 let req = req_builder.build()?;
755 let resp = configuration.client.execute(req).await?;
756
757 let status = resp.status();
758 let content_type = resp
759 .headers()
760 .get("content-type")
761 .and_then(|v| v.to_str().ok())
762 .unwrap_or("application/octet-stream");
763 let content_type = super::ContentType::from(content_type);
764
765 if !status.is_client_error() && !status.is_server_error() {
766 let content = resp.text().await?;
767 match content_type {
768 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
769 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UsedBy>`"))),
770 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::UsedBy>`")))),
771 }
772 } else {
773 let content = resp.text().await?;
774 let entity: Option<Oauth2RefreshTokensUsedByListError> = serde_json::from_str(&content).ok();
775 Err(Error::ResponseError(ResponseContent {
776 status,
777 content,
778 entity,
779 }))
780 }
781}