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