1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AcceptOAuth2ConsentRequestError {
22 DefaultResponse(models::ErrorOAuth2),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum AcceptOAuth2LoginRequestError {
30 DefaultResponse(models::ErrorOAuth2),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum AcceptOAuth2LogoutRequestError {
38 DefaultResponse(models::ErrorOAuth2),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum AcceptUserCodeRequestError {
46 DefaultResponse(models::ErrorOAuth2),
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum CreateOAuth2ClientError {
54 Status400(models::ErrorOAuth2),
55 DefaultResponse(models::ErrorOAuth2),
56 UnknownValue(serde_json::Value),
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum DeleteOAuth2ClientError {
63 DefaultResponse(models::GenericError),
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum DeleteOAuth2TokenError {
71 DefaultResponse(models::ErrorOAuth2),
72 UnknownValue(serde_json::Value),
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum DeleteTrustedOAuth2JwtGrantIssuerError {
79 DefaultResponse(models::GenericError),
80 UnknownValue(serde_json::Value),
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum GetOAuth2ClientError {
87 DefaultResponse(models::ErrorOAuth2),
88 UnknownValue(serde_json::Value),
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum GetOAuth2ConsentRequestError {
95 Status410(models::OAuth2RedirectTo),
96 DefaultResponse(models::ErrorOAuth2),
97 UnknownValue(serde_json::Value),
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum GetOAuth2LoginRequestError {
104 Status410(models::OAuth2RedirectTo),
105 DefaultResponse(models::ErrorOAuth2),
106 UnknownValue(serde_json::Value),
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum GetOAuth2LogoutRequestError {
113 Status410(models::OAuth2RedirectTo),
114 DefaultResponse(models::ErrorOAuth2),
115 UnknownValue(serde_json::Value),
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum GetTrustedOAuth2JwtGrantIssuerError {
122 DefaultResponse(models::GenericError),
123 UnknownValue(serde_json::Value),
124}
125
126#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum IntrospectOAuth2TokenError {
130 DefaultResponse(models::ErrorOAuth2),
131 UnknownValue(serde_json::Value),
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136#[serde(untagged)]
137pub enum ListOAuth2ClientsError {
138 DefaultResponse(models::ErrorOAuth2),
139 UnknownValue(serde_json::Value),
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize)]
144#[serde(untagged)]
145pub enum ListOAuth2ConsentSessionsError {
146 DefaultResponse(models::ErrorOAuth2),
147 UnknownValue(serde_json::Value),
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize)]
152#[serde(untagged)]
153pub enum ListTrustedOAuth2JwtGrantIssuersError {
154 DefaultResponse(models::GenericError),
155 UnknownValue(serde_json::Value),
156}
157
158#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum OAuth2AuthorizeError {
162 DefaultResponse(models::ErrorOAuth2),
163 UnknownValue(serde_json::Value),
164}
165
166#[derive(Debug, Clone, Serialize, Deserialize)]
168#[serde(untagged)]
169pub enum OAuth2DeviceFlowError {
170 DefaultResponse(models::ErrorOAuth2),
171 UnknownValue(serde_json::Value),
172}
173
174#[derive(Debug, Clone, Serialize, Deserialize)]
176#[serde(untagged)]
177pub enum Oauth2TokenExchangeError {
178 DefaultResponse(models::ErrorOAuth2),
179 UnknownValue(serde_json::Value),
180}
181
182#[derive(Debug, Clone, Serialize, Deserialize)]
184#[serde(untagged)]
185pub enum PatchOAuth2ClientError {
186 Status404(models::ErrorOAuth2),
187 DefaultResponse(models::ErrorOAuth2),
188 UnknownValue(serde_json::Value),
189}
190
191#[derive(Debug, Clone, Serialize, Deserialize)]
193#[serde(untagged)]
194pub enum PerformOAuth2DeviceVerificationFlowError {
195 DefaultResponse(models::ErrorOAuth2),
196 UnknownValue(serde_json::Value),
197}
198
199#[derive(Debug, Clone, Serialize, Deserialize)]
201#[serde(untagged)]
202pub enum RejectOAuth2ConsentRequestError {
203 DefaultResponse(models::ErrorOAuth2),
204 UnknownValue(serde_json::Value),
205}
206
207#[derive(Debug, Clone, Serialize, Deserialize)]
209#[serde(untagged)]
210pub enum RejectOAuth2LoginRequestError {
211 DefaultResponse(models::ErrorOAuth2),
212 UnknownValue(serde_json::Value),
213}
214
215#[derive(Debug, Clone, Serialize, Deserialize)]
217#[serde(untagged)]
218pub enum RejectOAuth2LogoutRequestError {
219 DefaultResponse(models::ErrorOAuth2),
220 UnknownValue(serde_json::Value),
221}
222
223#[derive(Debug, Clone, Serialize, Deserialize)]
225#[serde(untagged)]
226pub enum RevokeOAuth2ConsentSessionsError {
227 DefaultResponse(models::ErrorOAuth2),
228 UnknownValue(serde_json::Value),
229}
230
231#[derive(Debug, Clone, Serialize, Deserialize)]
233#[serde(untagged)]
234pub enum RevokeOAuth2LoginSessionsError {
235 DefaultResponse(models::ErrorOAuth2),
236 UnknownValue(serde_json::Value),
237}
238
239#[derive(Debug, Clone, Serialize, Deserialize)]
241#[serde(untagged)]
242pub enum RevokeOAuth2TokenError {
243 DefaultResponse(models::ErrorOAuth2),
244 UnknownValue(serde_json::Value),
245}
246
247#[derive(Debug, Clone, Serialize, Deserialize)]
249#[serde(untagged)]
250pub enum SetOAuth2ClientError {
251 Status400(models::ErrorOAuth2),
252 Status404(models::ErrorOAuth2),
253 DefaultResponse(models::ErrorOAuth2),
254 UnknownValue(serde_json::Value),
255}
256
257#[derive(Debug, Clone, Serialize, Deserialize)]
259#[serde(untagged)]
260pub enum SetOAuth2ClientLifespansError {
261 DefaultResponse(models::GenericError),
262 UnknownValue(serde_json::Value),
263}
264
265#[derive(Debug, Clone, Serialize, Deserialize)]
267#[serde(untagged)]
268pub enum TrustOAuth2JwtGrantIssuerError {
269 DefaultResponse(models::GenericError),
270 UnknownValue(serde_json::Value),
271}
272
273
274pub async fn accept_o_auth2_consent_request(configuration: &configuration::Configuration, consent_challenge: &str, accept_o_auth2_consent_request: Option<models::AcceptOAuth2ConsentRequest>) -> Result<models::OAuth2RedirectTo, Error<AcceptOAuth2ConsentRequestError>> {
276 let p_consent_challenge = consent_challenge;
278 let p_accept_o_auth2_consent_request = accept_o_auth2_consent_request;
279
280 let uri_str = format!("{}/admin/oauth2/auth/requests/consent/accept", configuration.base_path);
281 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
282
283 req_builder = req_builder.query(&[("consent_challenge", &p_consent_challenge.to_string())]);
284 if let Some(ref user_agent) = configuration.user_agent {
285 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
286 }
287 if let Some(ref token) = configuration.bearer_access_token {
288 req_builder = req_builder.bearer_auth(token.to_owned());
289 };
290 req_builder = req_builder.json(&p_accept_o_auth2_consent_request);
291
292 let req = req_builder.build()?;
293 let resp = configuration.client.execute(req).await?;
294
295 let status = resp.status();
296 let content_type = resp
297 .headers()
298 .get("content-type")
299 .and_then(|v| v.to_str().ok())
300 .unwrap_or("application/octet-stream");
301 let content_type = super::ContentType::from(content_type);
302
303 if !status.is_client_error() && !status.is_server_error() {
304 let content = resp.text().await?;
305 match content_type {
306 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
307 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2RedirectTo`"))),
308 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::OAuth2RedirectTo`")))),
309 }
310 } else {
311 let content = resp.text().await?;
312 let entity: Option<AcceptOAuth2ConsentRequestError> = serde_json::from_str(&content).ok();
313 Err(Error::ResponseError(ResponseContent { status, content, entity }))
314 }
315}
316
317pub async fn accept_o_auth2_login_request(configuration: &configuration::Configuration, login_challenge: &str, accept_o_auth2_login_request: Option<models::AcceptOAuth2LoginRequest>) -> Result<models::OAuth2RedirectTo, Error<AcceptOAuth2LoginRequestError>> {
319 let p_login_challenge = login_challenge;
321 let p_accept_o_auth2_login_request = accept_o_auth2_login_request;
322
323 let uri_str = format!("{}/admin/oauth2/auth/requests/login/accept", configuration.base_path);
324 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
325
326 req_builder = req_builder.query(&[("login_challenge", &p_login_challenge.to_string())]);
327 if let Some(ref user_agent) = configuration.user_agent {
328 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
329 }
330 if let Some(ref token) = configuration.bearer_access_token {
331 req_builder = req_builder.bearer_auth(token.to_owned());
332 };
333 req_builder = req_builder.json(&p_accept_o_auth2_login_request);
334
335 let req = req_builder.build()?;
336 let resp = configuration.client.execute(req).await?;
337
338 let status = resp.status();
339 let content_type = resp
340 .headers()
341 .get("content-type")
342 .and_then(|v| v.to_str().ok())
343 .unwrap_or("application/octet-stream");
344 let content_type = super::ContentType::from(content_type);
345
346 if !status.is_client_error() && !status.is_server_error() {
347 let content = resp.text().await?;
348 match content_type {
349 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
350 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2RedirectTo`"))),
351 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::OAuth2RedirectTo`")))),
352 }
353 } else {
354 let content = resp.text().await?;
355 let entity: Option<AcceptOAuth2LoginRequestError> = serde_json::from_str(&content).ok();
356 Err(Error::ResponseError(ResponseContent { status, content, entity }))
357 }
358}
359
360pub async fn accept_o_auth2_logout_request(configuration: &configuration::Configuration, logout_challenge: &str) -> Result<models::OAuth2RedirectTo, Error<AcceptOAuth2LogoutRequestError>> {
362 let p_logout_challenge = logout_challenge;
364
365 let uri_str = format!("{}/admin/oauth2/auth/requests/logout/accept", configuration.base_path);
366 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
367
368 req_builder = req_builder.query(&[("logout_challenge", &p_logout_challenge.to_string())]);
369 if let Some(ref user_agent) = configuration.user_agent {
370 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
371 }
372 if let Some(ref token) = configuration.bearer_access_token {
373 req_builder = req_builder.bearer_auth(token.to_owned());
374 };
375
376 let req = req_builder.build()?;
377 let resp = configuration.client.execute(req).await?;
378
379 let status = resp.status();
380 let content_type = resp
381 .headers()
382 .get("content-type")
383 .and_then(|v| v.to_str().ok())
384 .unwrap_or("application/octet-stream");
385 let content_type = super::ContentType::from(content_type);
386
387 if !status.is_client_error() && !status.is_server_error() {
388 let content = resp.text().await?;
389 match content_type {
390 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
391 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2RedirectTo`"))),
392 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::OAuth2RedirectTo`")))),
393 }
394 } else {
395 let content = resp.text().await?;
396 let entity: Option<AcceptOAuth2LogoutRequestError> = serde_json::from_str(&content).ok();
397 Err(Error::ResponseError(ResponseContent { status, content, entity }))
398 }
399}
400
401pub async fn accept_user_code_request(configuration: &configuration::Configuration, device_challenge: &str, accept_device_user_code_request: Option<models::AcceptDeviceUserCodeRequest>) -> Result<models::OAuth2RedirectTo, Error<AcceptUserCodeRequestError>> {
403 let p_device_challenge = device_challenge;
405 let p_accept_device_user_code_request = accept_device_user_code_request;
406
407 let uri_str = format!("{}/admin/oauth2/auth/requests/device/accept", configuration.base_path);
408 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
409
410 req_builder = req_builder.query(&[("device_challenge", &p_device_challenge.to_string())]);
411 if let Some(ref user_agent) = configuration.user_agent {
412 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
413 }
414 if let Some(ref token) = configuration.bearer_access_token {
415 req_builder = req_builder.bearer_auth(token.to_owned());
416 };
417 req_builder = req_builder.json(&p_accept_device_user_code_request);
418
419 let req = req_builder.build()?;
420 let resp = configuration.client.execute(req).await?;
421
422 let status = resp.status();
423 let content_type = resp
424 .headers()
425 .get("content-type")
426 .and_then(|v| v.to_str().ok())
427 .unwrap_or("application/octet-stream");
428 let content_type = super::ContentType::from(content_type);
429
430 if !status.is_client_error() && !status.is_server_error() {
431 let content = resp.text().await?;
432 match content_type {
433 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
434 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2RedirectTo`"))),
435 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::OAuth2RedirectTo`")))),
436 }
437 } else {
438 let content = resp.text().await?;
439 let entity: Option<AcceptUserCodeRequestError> = serde_json::from_str(&content).ok();
440 Err(Error::ResponseError(ResponseContent { status, content, entity }))
441 }
442}
443
444pub async fn create_o_auth2_client(configuration: &configuration::Configuration, o_auth2_client: models::OAuth2Client) -> Result<models::OAuth2Client, Error<CreateOAuth2ClientError>> {
446 let p_o_auth2_client = o_auth2_client;
448
449 let uri_str = format!("{}/admin/clients", configuration.base_path);
450 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
451
452 if let Some(ref user_agent) = configuration.user_agent {
453 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
454 }
455 if let Some(ref token) = configuration.bearer_access_token {
456 req_builder = req_builder.bearer_auth(token.to_owned());
457 };
458 req_builder = req_builder.json(&p_o_auth2_client);
459
460 let req = req_builder.build()?;
461 let resp = configuration.client.execute(req).await?;
462
463 let status = resp.status();
464 let content_type = resp
465 .headers()
466 .get("content-type")
467 .and_then(|v| v.to_str().ok())
468 .unwrap_or("application/octet-stream");
469 let content_type = super::ContentType::from(content_type);
470
471 if !status.is_client_error() && !status.is_server_error() {
472 let content = resp.text().await?;
473 match content_type {
474 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
475 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2Client`"))),
476 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::OAuth2Client`")))),
477 }
478 } else {
479 let content = resp.text().await?;
480 let entity: Option<CreateOAuth2ClientError> = serde_json::from_str(&content).ok();
481 Err(Error::ResponseError(ResponseContent { status, content, entity }))
482 }
483}
484
485pub async fn delete_o_auth2_client(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteOAuth2ClientError>> {
487 let p_id = id;
489
490 let uri_str = format!("{}/admin/clients/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
491 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
492
493 if let Some(ref user_agent) = configuration.user_agent {
494 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
495 }
496 if let Some(ref token) = configuration.bearer_access_token {
497 req_builder = req_builder.bearer_auth(token.to_owned());
498 };
499
500 let req = req_builder.build()?;
501 let resp = configuration.client.execute(req).await?;
502
503 let status = resp.status();
504
505 if !status.is_client_error() && !status.is_server_error() {
506 Ok(())
507 } else {
508 let content = resp.text().await?;
509 let entity: Option<DeleteOAuth2ClientError> = serde_json::from_str(&content).ok();
510 Err(Error::ResponseError(ResponseContent { status, content, entity }))
511 }
512}
513
514pub async fn delete_o_auth2_token(configuration: &configuration::Configuration, client_id: &str) -> Result<(), Error<DeleteOAuth2TokenError>> {
516 let p_client_id = client_id;
518
519 let uri_str = format!("{}/admin/oauth2/tokens", configuration.base_path);
520 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
521
522 req_builder = req_builder.query(&[("client_id", &p_client_id.to_string())]);
523 if let Some(ref user_agent) = configuration.user_agent {
524 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
525 }
526 if let Some(ref token) = configuration.bearer_access_token {
527 req_builder = req_builder.bearer_auth(token.to_owned());
528 };
529
530 let req = req_builder.build()?;
531 let resp = configuration.client.execute(req).await?;
532
533 let status = resp.status();
534
535 if !status.is_client_error() && !status.is_server_error() {
536 Ok(())
537 } else {
538 let content = resp.text().await?;
539 let entity: Option<DeleteOAuth2TokenError> = serde_json::from_str(&content).ok();
540 Err(Error::ResponseError(ResponseContent { status, content, entity }))
541 }
542}
543
544pub async fn delete_trusted_o_auth2_jwt_grant_issuer(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteTrustedOAuth2JwtGrantIssuerError>> {
546 let p_id = id;
548
549 let uri_str = format!("{}/admin/trust/grants/jwt-bearer/issuers/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
550 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
551
552 if let Some(ref user_agent) = configuration.user_agent {
553 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
554 }
555 if let Some(ref token) = configuration.bearer_access_token {
556 req_builder = req_builder.bearer_auth(token.to_owned());
557 };
558
559 let req = req_builder.build()?;
560 let resp = configuration.client.execute(req).await?;
561
562 let status = resp.status();
563
564 if !status.is_client_error() && !status.is_server_error() {
565 Ok(())
566 } else {
567 let content = resp.text().await?;
568 let entity: Option<DeleteTrustedOAuth2JwtGrantIssuerError> = serde_json::from_str(&content).ok();
569 Err(Error::ResponseError(ResponseContent { status, content, entity }))
570 }
571}
572
573pub async fn get_o_auth2_client(configuration: &configuration::Configuration, id: &str) -> Result<models::OAuth2Client, Error<GetOAuth2ClientError>> {
575 let p_id = id;
577
578 let uri_str = format!("{}/admin/clients/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
579 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
580
581 if let Some(ref user_agent) = configuration.user_agent {
582 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
583 }
584 if let Some(ref token) = configuration.bearer_access_token {
585 req_builder = req_builder.bearer_auth(token.to_owned());
586 };
587
588 let req = req_builder.build()?;
589 let resp = configuration.client.execute(req).await?;
590
591 let status = resp.status();
592 let content_type = resp
593 .headers()
594 .get("content-type")
595 .and_then(|v| v.to_str().ok())
596 .unwrap_or("application/octet-stream");
597 let content_type = super::ContentType::from(content_type);
598
599 if !status.is_client_error() && !status.is_server_error() {
600 let content = resp.text().await?;
601 match content_type {
602 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
603 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2Client`"))),
604 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::OAuth2Client`")))),
605 }
606 } else {
607 let content = resp.text().await?;
608 let entity: Option<GetOAuth2ClientError> = serde_json::from_str(&content).ok();
609 Err(Error::ResponseError(ResponseContent { status, content, entity }))
610 }
611}
612
613pub async fn get_o_auth2_consent_request(configuration: &configuration::Configuration, consent_challenge: &str) -> Result<models::OAuth2ConsentRequest, Error<GetOAuth2ConsentRequestError>> {
615 let p_consent_challenge = consent_challenge;
617
618 let uri_str = format!("{}/admin/oauth2/auth/requests/consent", configuration.base_path);
619 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
620
621 req_builder = req_builder.query(&[("consent_challenge", &p_consent_challenge.to_string())]);
622 if let Some(ref user_agent) = configuration.user_agent {
623 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
624 }
625 if let Some(ref token) = configuration.bearer_access_token {
626 req_builder = req_builder.bearer_auth(token.to_owned());
627 };
628
629 let req = req_builder.build()?;
630 let resp = configuration.client.execute(req).await?;
631
632 let status = resp.status();
633 let content_type = resp
634 .headers()
635 .get("content-type")
636 .and_then(|v| v.to_str().ok())
637 .unwrap_or("application/octet-stream");
638 let content_type = super::ContentType::from(content_type);
639
640 if !status.is_client_error() && !status.is_server_error() {
641 let content = resp.text().await?;
642 match content_type {
643 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
644 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2ConsentRequest`"))),
645 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::OAuth2ConsentRequest`")))),
646 }
647 } else {
648 let content = resp.text().await?;
649 let entity: Option<GetOAuth2ConsentRequestError> = serde_json::from_str(&content).ok();
650 Err(Error::ResponseError(ResponseContent { status, content, entity }))
651 }
652}
653
654pub async fn get_o_auth2_login_request(configuration: &configuration::Configuration, login_challenge: &str) -> Result<models::OAuth2LoginRequest, Error<GetOAuth2LoginRequestError>> {
656 let p_login_challenge = login_challenge;
658
659 let uri_str = format!("{}/admin/oauth2/auth/requests/login", configuration.base_path);
660 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
661
662 req_builder = req_builder.query(&[("login_challenge", &p_login_challenge.to_string())]);
663 if let Some(ref user_agent) = configuration.user_agent {
664 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
665 }
666 if let Some(ref token) = configuration.bearer_access_token {
667 req_builder = req_builder.bearer_auth(token.to_owned());
668 };
669
670 let req = req_builder.build()?;
671 let resp = configuration.client.execute(req).await?;
672
673 let status = resp.status();
674 let content_type = resp
675 .headers()
676 .get("content-type")
677 .and_then(|v| v.to_str().ok())
678 .unwrap_or("application/octet-stream");
679 let content_type = super::ContentType::from(content_type);
680
681 if !status.is_client_error() && !status.is_server_error() {
682 let content = resp.text().await?;
683 match content_type {
684 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
685 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2LoginRequest`"))),
686 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::OAuth2LoginRequest`")))),
687 }
688 } else {
689 let content = resp.text().await?;
690 let entity: Option<GetOAuth2LoginRequestError> = serde_json::from_str(&content).ok();
691 Err(Error::ResponseError(ResponseContent { status, content, entity }))
692 }
693}
694
695pub async fn get_o_auth2_logout_request(configuration: &configuration::Configuration, logout_challenge: &str) -> Result<models::OAuth2LogoutRequest, Error<GetOAuth2LogoutRequestError>> {
697 let p_logout_challenge = logout_challenge;
699
700 let uri_str = format!("{}/admin/oauth2/auth/requests/logout", configuration.base_path);
701 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
702
703 req_builder = req_builder.query(&[("logout_challenge", &p_logout_challenge.to_string())]);
704 if let Some(ref user_agent) = configuration.user_agent {
705 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
706 }
707 if let Some(ref token) = configuration.bearer_access_token {
708 req_builder = req_builder.bearer_auth(token.to_owned());
709 };
710
711 let req = req_builder.build()?;
712 let resp = configuration.client.execute(req).await?;
713
714 let status = resp.status();
715 let content_type = resp
716 .headers()
717 .get("content-type")
718 .and_then(|v| v.to_str().ok())
719 .unwrap_or("application/octet-stream");
720 let content_type = super::ContentType::from(content_type);
721
722 if !status.is_client_error() && !status.is_server_error() {
723 let content = resp.text().await?;
724 match content_type {
725 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
726 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2LogoutRequest`"))),
727 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::OAuth2LogoutRequest`")))),
728 }
729 } else {
730 let content = resp.text().await?;
731 let entity: Option<GetOAuth2LogoutRequestError> = serde_json::from_str(&content).ok();
732 Err(Error::ResponseError(ResponseContent { status, content, entity }))
733 }
734}
735
736pub async fn get_trusted_o_auth2_jwt_grant_issuer(configuration: &configuration::Configuration, id: &str) -> Result<models::TrustedOAuth2JwtGrantIssuer, Error<GetTrustedOAuth2JwtGrantIssuerError>> {
738 let p_id = id;
740
741 let uri_str = format!("{}/admin/trust/grants/jwt-bearer/issuers/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
742 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
743
744 if let Some(ref user_agent) = configuration.user_agent {
745 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
746 }
747 if let Some(ref token) = configuration.bearer_access_token {
748 req_builder = req_builder.bearer_auth(token.to_owned());
749 };
750
751 let req = req_builder.build()?;
752 let resp = configuration.client.execute(req).await?;
753
754 let status = resp.status();
755 let content_type = resp
756 .headers()
757 .get("content-type")
758 .and_then(|v| v.to_str().ok())
759 .unwrap_or("application/octet-stream");
760 let content_type = super::ContentType::from(content_type);
761
762 if !status.is_client_error() && !status.is_server_error() {
763 let content = resp.text().await?;
764 match content_type {
765 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
766 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TrustedOAuth2JwtGrantIssuer`"))),
767 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::TrustedOAuth2JwtGrantIssuer`")))),
768 }
769 } else {
770 let content = resp.text().await?;
771 let entity: Option<GetTrustedOAuth2JwtGrantIssuerError> = serde_json::from_str(&content).ok();
772 Err(Error::ResponseError(ResponseContent { status, content, entity }))
773 }
774}
775
776pub async fn introspect_o_auth2_token(configuration: &configuration::Configuration, token: &str, scope: Option<&str>) -> Result<models::IntrospectedOAuth2Token, Error<IntrospectOAuth2TokenError>> {
778 let p_token = token;
780 let p_scope = scope;
781
782 let uri_str = format!("{}/admin/oauth2/introspect", configuration.base_path);
783 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
784
785 if let Some(ref user_agent) = configuration.user_agent {
786 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
787 }
788 if let Some(ref token) = configuration.bearer_access_token {
789 req_builder = req_builder.bearer_auth(token.to_owned());
790 };
791 let mut multipart_form_params = std::collections::HashMap::new();
792 if let Some(param_value) = p_scope {
793 multipart_form_params.insert("scope", param_value.to_string());
794 }
795 multipart_form_params.insert("token", p_token.to_string());
796 req_builder = req_builder.form(&multipart_form_params);
797
798 let req = req_builder.build()?;
799 let resp = configuration.client.execute(req).await?;
800
801 let status = resp.status();
802 let content_type = resp
803 .headers()
804 .get("content-type")
805 .and_then(|v| v.to_str().ok())
806 .unwrap_or("application/octet-stream");
807 let content_type = super::ContentType::from(content_type);
808
809 if !status.is_client_error() && !status.is_server_error() {
810 let content = resp.text().await?;
811 match content_type {
812 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
813 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IntrospectedOAuth2Token`"))),
814 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::IntrospectedOAuth2Token`")))),
815 }
816 } else {
817 let content = resp.text().await?;
818 let entity: Option<IntrospectOAuth2TokenError> = serde_json::from_str(&content).ok();
819 Err(Error::ResponseError(ResponseContent { status, content, entity }))
820 }
821}
822
823pub async fn list_o_auth2_clients(configuration: &configuration::Configuration, page_size: Option<i64>, page_token: Option<&str>, client_name: Option<&str>, owner: Option<&str>) -> Result<Vec<models::OAuth2Client>, Error<ListOAuth2ClientsError>> {
825 let p_page_size = page_size;
827 let p_page_token = page_token;
828 let p_client_name = client_name;
829 let p_owner = owner;
830
831 let uri_str = format!("{}/admin/clients", configuration.base_path);
832 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
833
834 if let Some(ref param_value) = p_page_size {
835 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
836 }
837 if let Some(ref param_value) = p_page_token {
838 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
839 }
840 if let Some(ref param_value) = p_client_name {
841 req_builder = req_builder.query(&[("client_name", ¶m_value.to_string())]);
842 }
843 if let Some(ref param_value) = p_owner {
844 req_builder = req_builder.query(&[("owner", ¶m_value.to_string())]);
845 }
846 if let Some(ref user_agent) = configuration.user_agent {
847 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
848 }
849 if let Some(ref token) = configuration.bearer_access_token {
850 req_builder = req_builder.bearer_auth(token.to_owned());
851 };
852
853 let req = req_builder.build()?;
854 let resp = configuration.client.execute(req).await?;
855
856 let status = resp.status();
857 let content_type = resp
858 .headers()
859 .get("content-type")
860 .and_then(|v| v.to_str().ok())
861 .unwrap_or("application/octet-stream");
862 let content_type = super::ContentType::from(content_type);
863
864 if !status.is_client_error() && !status.is_server_error() {
865 let content = resp.text().await?;
866 match content_type {
867 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
868 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OAuth2Client>`"))),
869 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::OAuth2Client>`")))),
870 }
871 } else {
872 let content = resp.text().await?;
873 let entity: Option<ListOAuth2ClientsError> = serde_json::from_str(&content).ok();
874 Err(Error::ResponseError(ResponseContent { status, content, entity }))
875 }
876}
877
878pub async fn list_o_auth2_consent_sessions(configuration: &configuration::Configuration, subject: &str, page_size: Option<i64>, page_token: Option<&str>, login_session_id: Option<&str>) -> Result<Vec<models::OAuth2ConsentSession>, Error<ListOAuth2ConsentSessionsError>> {
880 let p_subject = subject;
882 let p_page_size = page_size;
883 let p_page_token = page_token;
884 let p_login_session_id = login_session_id;
885
886 let uri_str = format!("{}/admin/oauth2/auth/sessions/consent", configuration.base_path);
887 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
888
889 if let Some(ref param_value) = p_page_size {
890 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
891 }
892 if let Some(ref param_value) = p_page_token {
893 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
894 }
895 req_builder = req_builder.query(&[("subject", &p_subject.to_string())]);
896 if let Some(ref param_value) = p_login_session_id {
897 req_builder = req_builder.query(&[("login_session_id", ¶m_value.to_string())]);
898 }
899 if let Some(ref user_agent) = configuration.user_agent {
900 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
901 }
902 if let Some(ref token) = configuration.bearer_access_token {
903 req_builder = req_builder.bearer_auth(token.to_owned());
904 };
905
906 let req = req_builder.build()?;
907 let resp = configuration.client.execute(req).await?;
908
909 let status = resp.status();
910 let content_type = resp
911 .headers()
912 .get("content-type")
913 .and_then(|v| v.to_str().ok())
914 .unwrap_or("application/octet-stream");
915 let content_type = super::ContentType::from(content_type);
916
917 if !status.is_client_error() && !status.is_server_error() {
918 let content = resp.text().await?;
919 match content_type {
920 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
921 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OAuth2ConsentSession>`"))),
922 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::OAuth2ConsentSession>`")))),
923 }
924 } else {
925 let content = resp.text().await?;
926 let entity: Option<ListOAuth2ConsentSessionsError> = serde_json::from_str(&content).ok();
927 Err(Error::ResponseError(ResponseContent { status, content, entity }))
928 }
929}
930
931pub async fn list_trusted_o_auth2_jwt_grant_issuers(configuration: &configuration::Configuration, page_size: Option<i64>, page_token: Option<&str>, issuer: Option<&str>) -> Result<Vec<models::TrustedOAuth2JwtGrantIssuer>, Error<ListTrustedOAuth2JwtGrantIssuersError>> {
933 let p_page_size = page_size;
935 let p_page_token = page_token;
936 let p_issuer = issuer;
937
938 let uri_str = format!("{}/admin/trust/grants/jwt-bearer/issuers", configuration.base_path);
939 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
940
941 if let Some(ref param_value) = p_page_size {
942 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
943 }
944 if let Some(ref param_value) = p_page_token {
945 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
946 }
947 if let Some(ref param_value) = p_issuer {
948 req_builder = req_builder.query(&[("issuer", ¶m_value.to_string())]);
949 }
950 if let Some(ref user_agent) = configuration.user_agent {
951 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
952 }
953 if let Some(ref token) = configuration.bearer_access_token {
954 req_builder = req_builder.bearer_auth(token.to_owned());
955 };
956
957 let req = req_builder.build()?;
958 let resp = configuration.client.execute(req).await?;
959
960 let status = resp.status();
961 let content_type = resp
962 .headers()
963 .get("content-type")
964 .and_then(|v| v.to_str().ok())
965 .unwrap_or("application/octet-stream");
966 let content_type = super::ContentType::from(content_type);
967
968 if !status.is_client_error() && !status.is_server_error() {
969 let content = resp.text().await?;
970 match content_type {
971 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
972 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::TrustedOAuth2JwtGrantIssuer>`"))),
973 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::TrustedOAuth2JwtGrantIssuer>`")))),
974 }
975 } else {
976 let content = resp.text().await?;
977 let entity: Option<ListTrustedOAuth2JwtGrantIssuersError> = serde_json::from_str(&content).ok();
978 Err(Error::ResponseError(ResponseContent { status, content, entity }))
979 }
980}
981
982pub async fn o_auth2_authorize(configuration: &configuration::Configuration, ) -> Result<models::ErrorOAuth2, Error<OAuth2AuthorizeError>> {
984
985 let uri_str = format!("{}/oauth2/auth", configuration.base_path);
986 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
987
988 if let Some(ref user_agent) = configuration.user_agent {
989 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
990 }
991
992 let req = req_builder.build()?;
993 let resp = configuration.client.execute(req).await?;
994
995 let status = resp.status();
996 let content_type = resp
997 .headers()
998 .get("content-type")
999 .and_then(|v| v.to_str().ok())
1000 .unwrap_or("application/octet-stream");
1001 let content_type = super::ContentType::from(content_type);
1002
1003 if !status.is_client_error() && !status.is_server_error() {
1004 let content = resp.text().await?;
1005 match content_type {
1006 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1007 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ErrorOAuth2`"))),
1008 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::ErrorOAuth2`")))),
1009 }
1010 } else {
1011 let content = resp.text().await?;
1012 let entity: Option<OAuth2AuthorizeError> = serde_json::from_str(&content).ok();
1013 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1014 }
1015}
1016
1017pub async fn o_auth2_device_flow(configuration: &configuration::Configuration, ) -> Result<models::DeviceAuthorization, Error<OAuth2DeviceFlowError>> {
1019
1020 let uri_str = format!("{}/oauth2/device/auth", configuration.base_path);
1021 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1022
1023 if let Some(ref user_agent) = configuration.user_agent {
1024 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1025 }
1026
1027 let req = req_builder.build()?;
1028 let resp = configuration.client.execute(req).await?;
1029
1030 let status = resp.status();
1031 let content_type = resp
1032 .headers()
1033 .get("content-type")
1034 .and_then(|v| v.to_str().ok())
1035 .unwrap_or("application/octet-stream");
1036 let content_type = super::ContentType::from(content_type);
1037
1038 if !status.is_client_error() && !status.is_server_error() {
1039 let content = resp.text().await?;
1040 match content_type {
1041 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1042 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceAuthorization`"))),
1043 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::DeviceAuthorization`")))),
1044 }
1045 } else {
1046 let content = resp.text().await?;
1047 let entity: Option<OAuth2DeviceFlowError> = serde_json::from_str(&content).ok();
1048 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1049 }
1050}
1051
1052pub async fn oauth2_token_exchange(configuration: &configuration::Configuration, grant_type: &str, client_id: Option<&str>, code: Option<&str>, redirect_uri: Option<&str>, refresh_token: Option<&str>) -> Result<models::OAuth2TokenExchange, Error<Oauth2TokenExchangeError>> {
1054 let p_grant_type = grant_type;
1056 let p_client_id = client_id;
1057 let p_code = code;
1058 let p_redirect_uri = redirect_uri;
1059 let p_refresh_token = refresh_token;
1060
1061 let uri_str = format!("{}/oauth2/token", configuration.base_path);
1062 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1063
1064 if let Some(ref user_agent) = configuration.user_agent {
1065 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1066 }
1067 if let Some(ref auth_conf) = configuration.basic_auth {
1068 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1069 };
1070 if let Some(ref token) = configuration.oauth_access_token {
1071 req_builder = req_builder.bearer_auth(token.to_owned());
1072 };
1073 let mut multipart_form_params = std::collections::HashMap::new();
1074 if let Some(param_value) = p_client_id {
1075 multipart_form_params.insert("client_id", param_value.to_string());
1076 }
1077 if let Some(param_value) = p_code {
1078 multipart_form_params.insert("code", param_value.to_string());
1079 }
1080 multipart_form_params.insert("grant_type", p_grant_type.to_string());
1081 if let Some(param_value) = p_redirect_uri {
1082 multipart_form_params.insert("redirect_uri", param_value.to_string());
1083 }
1084 if let Some(param_value) = p_refresh_token {
1085 multipart_form_params.insert("refresh_token", param_value.to_string());
1086 }
1087 req_builder = req_builder.form(&multipart_form_params);
1088
1089 let req = req_builder.build()?;
1090 let resp = configuration.client.execute(req).await?;
1091
1092 let status = resp.status();
1093 let content_type = resp
1094 .headers()
1095 .get("content-type")
1096 .and_then(|v| v.to_str().ok())
1097 .unwrap_or("application/octet-stream");
1098 let content_type = super::ContentType::from(content_type);
1099
1100 if !status.is_client_error() && !status.is_server_error() {
1101 let content = resp.text().await?;
1102 match content_type {
1103 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1104 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2TokenExchange`"))),
1105 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::OAuth2TokenExchange`")))),
1106 }
1107 } else {
1108 let content = resp.text().await?;
1109 let entity: Option<Oauth2TokenExchangeError> = serde_json::from_str(&content).ok();
1110 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1111 }
1112}
1113
1114pub async fn patch_o_auth2_client(configuration: &configuration::Configuration, id: &str, json_patch: Vec<models::JsonPatch>) -> Result<models::OAuth2Client, Error<PatchOAuth2ClientError>> {
1116 let p_id = id;
1118 let p_json_patch = json_patch;
1119
1120 let uri_str = format!("{}/admin/clients/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
1121 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1122
1123 if let Some(ref user_agent) = configuration.user_agent {
1124 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1125 }
1126 if let Some(ref token) = configuration.bearer_access_token {
1127 req_builder = req_builder.bearer_auth(token.to_owned());
1128 };
1129 req_builder = req_builder.json(&p_json_patch);
1130
1131 let req = req_builder.build()?;
1132 let resp = configuration.client.execute(req).await?;
1133
1134 let status = resp.status();
1135 let content_type = resp
1136 .headers()
1137 .get("content-type")
1138 .and_then(|v| v.to_str().ok())
1139 .unwrap_or("application/octet-stream");
1140 let content_type = super::ContentType::from(content_type);
1141
1142 if !status.is_client_error() && !status.is_server_error() {
1143 let content = resp.text().await?;
1144 match content_type {
1145 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1146 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2Client`"))),
1147 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::OAuth2Client`")))),
1148 }
1149 } else {
1150 let content = resp.text().await?;
1151 let entity: Option<PatchOAuth2ClientError> = serde_json::from_str(&content).ok();
1152 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1153 }
1154}
1155
1156pub async fn perform_o_auth2_device_verification_flow(configuration: &configuration::Configuration, ) -> Result<models::ErrorOAuth2, Error<PerformOAuth2DeviceVerificationFlowError>> {
1158
1159 let uri_str = format!("{}/oauth2/device/verify", configuration.base_path);
1160 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1161
1162 if let Some(ref user_agent) = configuration.user_agent {
1163 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1164 }
1165
1166 let req = req_builder.build()?;
1167 let resp = configuration.client.execute(req).await?;
1168
1169 let status = resp.status();
1170 let content_type = resp
1171 .headers()
1172 .get("content-type")
1173 .and_then(|v| v.to_str().ok())
1174 .unwrap_or("application/octet-stream");
1175 let content_type = super::ContentType::from(content_type);
1176
1177 if !status.is_client_error() && !status.is_server_error() {
1178 let content = resp.text().await?;
1179 match content_type {
1180 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1181 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ErrorOAuth2`"))),
1182 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::ErrorOAuth2`")))),
1183 }
1184 } else {
1185 let content = resp.text().await?;
1186 let entity: Option<PerformOAuth2DeviceVerificationFlowError> = serde_json::from_str(&content).ok();
1187 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1188 }
1189}
1190
1191pub async fn reject_o_auth2_consent_request(configuration: &configuration::Configuration, consent_challenge: &str, reject_o_auth2_request: Option<models::RejectOAuth2Request>) -> Result<models::OAuth2RedirectTo, Error<RejectOAuth2ConsentRequestError>> {
1193 let p_consent_challenge = consent_challenge;
1195 let p_reject_o_auth2_request = reject_o_auth2_request;
1196
1197 let uri_str = format!("{}/admin/oauth2/auth/requests/consent/reject", configuration.base_path);
1198 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1199
1200 req_builder = req_builder.query(&[("consent_challenge", &p_consent_challenge.to_string())]);
1201 if let Some(ref user_agent) = configuration.user_agent {
1202 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1203 }
1204 if let Some(ref token) = configuration.bearer_access_token {
1205 req_builder = req_builder.bearer_auth(token.to_owned());
1206 };
1207 req_builder = req_builder.json(&p_reject_o_auth2_request);
1208
1209 let req = req_builder.build()?;
1210 let resp = configuration.client.execute(req).await?;
1211
1212 let status = resp.status();
1213 let content_type = resp
1214 .headers()
1215 .get("content-type")
1216 .and_then(|v| v.to_str().ok())
1217 .unwrap_or("application/octet-stream");
1218 let content_type = super::ContentType::from(content_type);
1219
1220 if !status.is_client_error() && !status.is_server_error() {
1221 let content = resp.text().await?;
1222 match content_type {
1223 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1224 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2RedirectTo`"))),
1225 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::OAuth2RedirectTo`")))),
1226 }
1227 } else {
1228 let content = resp.text().await?;
1229 let entity: Option<RejectOAuth2ConsentRequestError> = serde_json::from_str(&content).ok();
1230 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1231 }
1232}
1233
1234pub async fn reject_o_auth2_login_request(configuration: &configuration::Configuration, login_challenge: &str, reject_o_auth2_request: Option<models::RejectOAuth2Request>) -> Result<models::OAuth2RedirectTo, Error<RejectOAuth2LoginRequestError>> {
1236 let p_login_challenge = login_challenge;
1238 let p_reject_o_auth2_request = reject_o_auth2_request;
1239
1240 let uri_str = format!("{}/admin/oauth2/auth/requests/login/reject", configuration.base_path);
1241 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1242
1243 req_builder = req_builder.query(&[("login_challenge", &p_login_challenge.to_string())]);
1244 if let Some(ref user_agent) = configuration.user_agent {
1245 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1246 }
1247 if let Some(ref token) = configuration.bearer_access_token {
1248 req_builder = req_builder.bearer_auth(token.to_owned());
1249 };
1250 req_builder = req_builder.json(&p_reject_o_auth2_request);
1251
1252 let req = req_builder.build()?;
1253 let resp = configuration.client.execute(req).await?;
1254
1255 let status = resp.status();
1256 let content_type = resp
1257 .headers()
1258 .get("content-type")
1259 .and_then(|v| v.to_str().ok())
1260 .unwrap_or("application/octet-stream");
1261 let content_type = super::ContentType::from(content_type);
1262
1263 if !status.is_client_error() && !status.is_server_error() {
1264 let content = resp.text().await?;
1265 match content_type {
1266 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1267 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2RedirectTo`"))),
1268 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::OAuth2RedirectTo`")))),
1269 }
1270 } else {
1271 let content = resp.text().await?;
1272 let entity: Option<RejectOAuth2LoginRequestError> = serde_json::from_str(&content).ok();
1273 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1274 }
1275}
1276
1277pub async fn reject_o_auth2_logout_request(configuration: &configuration::Configuration, logout_challenge: &str) -> Result<(), Error<RejectOAuth2LogoutRequestError>> {
1279 let p_logout_challenge = logout_challenge;
1281
1282 let uri_str = format!("{}/admin/oauth2/auth/requests/logout/reject", configuration.base_path);
1283 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1284
1285 req_builder = req_builder.query(&[("logout_challenge", &p_logout_challenge.to_string())]);
1286 if let Some(ref user_agent) = configuration.user_agent {
1287 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1288 }
1289 if let Some(ref token) = configuration.bearer_access_token {
1290 req_builder = req_builder.bearer_auth(token.to_owned());
1291 };
1292
1293 let req = req_builder.build()?;
1294 let resp = configuration.client.execute(req).await?;
1295
1296 let status = resp.status();
1297
1298 if !status.is_client_error() && !status.is_server_error() {
1299 Ok(())
1300 } else {
1301 let content = resp.text().await?;
1302 let entity: Option<RejectOAuth2LogoutRequestError> = serde_json::from_str(&content).ok();
1303 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1304 }
1305}
1306
1307pub async fn revoke_o_auth2_consent_sessions(configuration: &configuration::Configuration, subject: Option<&str>, client: Option<&str>, consent_request_id: Option<&str>, all: Option<bool>) -> Result<(), Error<RevokeOAuth2ConsentSessionsError>> {
1309 let p_subject = subject;
1311 let p_client = client;
1312 let p_consent_request_id = consent_request_id;
1313 let p_all = all;
1314
1315 let uri_str = format!("{}/admin/oauth2/auth/sessions/consent", configuration.base_path);
1316 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1317
1318 if let Some(ref param_value) = p_subject {
1319 req_builder = req_builder.query(&[("subject", ¶m_value.to_string())]);
1320 }
1321 if let Some(ref param_value) = p_client {
1322 req_builder = req_builder.query(&[("client", ¶m_value.to_string())]);
1323 }
1324 if let Some(ref param_value) = p_consent_request_id {
1325 req_builder = req_builder.query(&[("consent_request_id", ¶m_value.to_string())]);
1326 }
1327 if let Some(ref param_value) = p_all {
1328 req_builder = req_builder.query(&[("all", ¶m_value.to_string())]);
1329 }
1330 if let Some(ref user_agent) = configuration.user_agent {
1331 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1332 }
1333 if let Some(ref token) = configuration.bearer_access_token {
1334 req_builder = req_builder.bearer_auth(token.to_owned());
1335 };
1336
1337 let req = req_builder.build()?;
1338 let resp = configuration.client.execute(req).await?;
1339
1340 let status = resp.status();
1341
1342 if !status.is_client_error() && !status.is_server_error() {
1343 Ok(())
1344 } else {
1345 let content = resp.text().await?;
1346 let entity: Option<RevokeOAuth2ConsentSessionsError> = serde_json::from_str(&content).ok();
1347 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1348 }
1349}
1350
1351pub async fn revoke_o_auth2_login_sessions(configuration: &configuration::Configuration, subject: Option<&str>, sid: Option<&str>) -> Result<(), Error<RevokeOAuth2LoginSessionsError>> {
1353 let p_subject = subject;
1355 let p_sid = sid;
1356
1357 let uri_str = format!("{}/admin/oauth2/auth/sessions/login", configuration.base_path);
1358 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1359
1360 if let Some(ref param_value) = p_subject {
1361 req_builder = req_builder.query(&[("subject", ¶m_value.to_string())]);
1362 }
1363 if let Some(ref param_value) = p_sid {
1364 req_builder = req_builder.query(&[("sid", ¶m_value.to_string())]);
1365 }
1366 if let Some(ref user_agent) = configuration.user_agent {
1367 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1368 }
1369 if let Some(ref token) = configuration.bearer_access_token {
1370 req_builder = req_builder.bearer_auth(token.to_owned());
1371 };
1372
1373 let req = req_builder.build()?;
1374 let resp = configuration.client.execute(req).await?;
1375
1376 let status = resp.status();
1377
1378 if !status.is_client_error() && !status.is_server_error() {
1379 Ok(())
1380 } else {
1381 let content = resp.text().await?;
1382 let entity: Option<RevokeOAuth2LoginSessionsError> = serde_json::from_str(&content).ok();
1383 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1384 }
1385}
1386
1387pub async fn revoke_o_auth2_token(configuration: &configuration::Configuration, token: &str, client_id: Option<&str>, client_secret: Option<&str>) -> Result<(), Error<RevokeOAuth2TokenError>> {
1389 let p_token = token;
1391 let p_client_id = client_id;
1392 let p_client_secret = client_secret;
1393
1394 let uri_str = format!("{}/oauth2/revoke", configuration.base_path);
1395 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1396
1397 if let Some(ref user_agent) = configuration.user_agent {
1398 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1399 }
1400 if let Some(ref auth_conf) = configuration.basic_auth {
1401 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
1402 };
1403 if let Some(ref token) = configuration.oauth_access_token {
1404 req_builder = req_builder.bearer_auth(token.to_owned());
1405 };
1406 let mut multipart_form_params = std::collections::HashMap::new();
1407 if let Some(param_value) = p_client_id {
1408 multipart_form_params.insert("client_id", param_value.to_string());
1409 }
1410 if let Some(param_value) = p_client_secret {
1411 multipart_form_params.insert("client_secret", param_value.to_string());
1412 }
1413 multipart_form_params.insert("token", p_token.to_string());
1414 req_builder = req_builder.form(&multipart_form_params);
1415
1416 let req = req_builder.build()?;
1417 let resp = configuration.client.execute(req).await?;
1418
1419 let status = resp.status();
1420
1421 if !status.is_client_error() && !status.is_server_error() {
1422 Ok(())
1423 } else {
1424 let content = resp.text().await?;
1425 let entity: Option<RevokeOAuth2TokenError> = serde_json::from_str(&content).ok();
1426 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1427 }
1428}
1429
1430pub async fn set_o_auth2_client(configuration: &configuration::Configuration, id: &str, o_auth2_client: models::OAuth2Client) -> Result<models::OAuth2Client, Error<SetOAuth2ClientError>> {
1432 let p_id = id;
1434 let p_o_auth2_client = o_auth2_client;
1435
1436 let uri_str = format!("{}/admin/clients/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
1437 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1438
1439 if let Some(ref user_agent) = configuration.user_agent {
1440 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1441 }
1442 if let Some(ref token) = configuration.bearer_access_token {
1443 req_builder = req_builder.bearer_auth(token.to_owned());
1444 };
1445 req_builder = req_builder.json(&p_o_auth2_client);
1446
1447 let req = req_builder.build()?;
1448 let resp = configuration.client.execute(req).await?;
1449
1450 let status = resp.status();
1451 let content_type = resp
1452 .headers()
1453 .get("content-type")
1454 .and_then(|v| v.to_str().ok())
1455 .unwrap_or("application/octet-stream");
1456 let content_type = super::ContentType::from(content_type);
1457
1458 if !status.is_client_error() && !status.is_server_error() {
1459 let content = resp.text().await?;
1460 match content_type {
1461 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1462 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2Client`"))),
1463 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::OAuth2Client`")))),
1464 }
1465 } else {
1466 let content = resp.text().await?;
1467 let entity: Option<SetOAuth2ClientError> = serde_json::from_str(&content).ok();
1468 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1469 }
1470}
1471
1472pub async fn set_o_auth2_client_lifespans(configuration: &configuration::Configuration, id: &str, o_auth2_client_token_lifespans: Option<models::OAuth2ClientTokenLifespans>) -> Result<models::OAuth2Client, Error<SetOAuth2ClientLifespansError>> {
1474 let p_id = id;
1476 let p_o_auth2_client_token_lifespans = o_auth2_client_token_lifespans;
1477
1478 let uri_str = format!("{}/admin/clients/{id}/lifespans", configuration.base_path, id=crate::apis::urlencode(p_id));
1479 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1480
1481 if let Some(ref user_agent) = configuration.user_agent {
1482 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1483 }
1484 if let Some(ref token) = configuration.bearer_access_token {
1485 req_builder = req_builder.bearer_auth(token.to_owned());
1486 };
1487 req_builder = req_builder.json(&p_o_auth2_client_token_lifespans);
1488
1489 let req = req_builder.build()?;
1490 let resp = configuration.client.execute(req).await?;
1491
1492 let status = resp.status();
1493 let content_type = resp
1494 .headers()
1495 .get("content-type")
1496 .and_then(|v| v.to_str().ok())
1497 .unwrap_or("application/octet-stream");
1498 let content_type = super::ContentType::from(content_type);
1499
1500 if !status.is_client_error() && !status.is_server_error() {
1501 let content = resp.text().await?;
1502 match content_type {
1503 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1504 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OAuth2Client`"))),
1505 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::OAuth2Client`")))),
1506 }
1507 } else {
1508 let content = resp.text().await?;
1509 let entity: Option<SetOAuth2ClientLifespansError> = serde_json::from_str(&content).ok();
1510 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1511 }
1512}
1513
1514pub async fn trust_o_auth2_jwt_grant_issuer(configuration: &configuration::Configuration, trust_o_auth2_jwt_grant_issuer: Option<models::TrustOAuth2JwtGrantIssuer>) -> Result<models::TrustedOAuth2JwtGrantIssuer, Error<TrustOAuth2JwtGrantIssuerError>> {
1516 let p_trust_o_auth2_jwt_grant_issuer = trust_o_auth2_jwt_grant_issuer;
1518
1519 let uri_str = format!("{}/admin/trust/grants/jwt-bearer/issuers", configuration.base_path);
1520 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1521
1522 if let Some(ref user_agent) = configuration.user_agent {
1523 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1524 }
1525 if let Some(ref token) = configuration.bearer_access_token {
1526 req_builder = req_builder.bearer_auth(token.to_owned());
1527 };
1528 req_builder = req_builder.json(&p_trust_o_auth2_jwt_grant_issuer);
1529
1530 let req = req_builder.build()?;
1531 let resp = configuration.client.execute(req).await?;
1532
1533 let status = resp.status();
1534 let content_type = resp
1535 .headers()
1536 .get("content-type")
1537 .and_then(|v| v.to_str().ok())
1538 .unwrap_or("application/octet-stream");
1539 let content_type = super::ContentType::from(content_type);
1540
1541 if !status.is_client_error() && !status.is_server_error() {
1542 let content = resp.text().await?;
1543 match content_type {
1544 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1545 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TrustedOAuth2JwtGrantIssuer`"))),
1546 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::TrustedOAuth2JwtGrantIssuer`")))),
1547 }
1548 } else {
1549 let content = resp.text().await?;
1550 let entity: Option<TrustOAuth2JwtGrantIssuerError> = serde_json::from_str(&content).ok();
1551 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1552 }
1553}
1554