1use reqwest;
12#[allow(unused_imports)]
13use serde::{de::Error as _};
14use crate::{apis::ResponseContent, models};
15#[allow(unused_imports)]
16use super::{Error, ContentType};
17use dtz_config::Configuration;
18
19fn build_url(config: &Configuration) -> String {
20 if let Some(base_path) = &config.base_path {
21 let base = url::Url::parse(base_path).unwrap();
22 let mut target_url = url::Url::parse(crate::apis::SVC_URL).unwrap();
23 let _ = target_url.set_scheme(base.scheme());
24 let _ = target_url.set_port(base.port());
25 let _ = target_url.set_host(Some(base.host_str().unwrap()));
26 format!("{target_url}")
27 } else {
28 crate::apis::SVC_URL.to_string()
29 }
30}
31
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum AssignConcreteRoleError {
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum AssumeIdentityError {
44 Status401(models::ErrorResponse),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum AuthenticateApikeyError {
52 Status401(models::ErrorResponse),
53 UnknownValue(serde_json::Value),
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum ChangeAuthenticationError {
60 UnknownValue(serde_json::Value),
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum CheckIdentityError {
67 Status401(models::ErrorResponse),
68 UnknownValue(serde_json::Value),
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum CreateApiKeyError {
75 UnknownValue(serde_json::Value),
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum CreateConcreteRoleForContextError {
82 UnknownValue(serde_json::Value),
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum DeleteApiKeyError {
89 UnknownValue(serde_json::Value),
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
94#[serde(untagged)]
95pub enum DeleteContextRolesError {
96 UnknownValue(serde_json::Value),
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum DeleteIdentityError {
103 UnknownValue(serde_json::Value),
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum GetAbstractRolesError {
110 UnknownValue(serde_json::Value),
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize)]
115#[serde(untagged)]
116pub enum GetAccountEmailError {
117 Status404(models::ErrorResponse),
118 UnknownValue(serde_json::Value),
119}
120
121#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum GetAccountStatsError {
125 UnknownValue(serde_json::Value),
126}
127
128#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum GetConcreteRolesForContextError {
132 UnknownValue(serde_json::Value),
133}
134
135#[derive(Debug, Clone, Serialize, Deserialize)]
137#[serde(untagged)]
138pub enum GetConcreteRolesForIdentityError {
139 UnknownValue(serde_json::Value),
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize)]
144#[serde(untagged)]
145pub enum GetRoleAssignmentError {
146 Status401(models::ErrorResponse),
147 Status500(models::ErrorResponse),
148 UnknownValue(serde_json::Value),
149}
150
151#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum ListAuthenticationError {
155 UnknownValue(serde_json::Value),
156}
157
158#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum ListAvailableContextsError {
162 UnknownValue(serde_json::Value),
163}
164
165#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum ListIdentityError {
169 UnknownValue(serde_json::Value),
170}
171
172#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum NewContextError {
176 UnknownValue(serde_json::Value),
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize)]
181#[serde(untagged)]
182pub enum NewIdentityError {
183 UnknownValue(serde_json::Value),
184}
185
186#[derive(Debug, Clone, Serialize, Deserialize)]
188#[serde(untagged)]
189pub enum OauthAuthorizeError {
190 Status401(),
191 UnknownValue(serde_json::Value),
192}
193
194#[derive(Debug, Clone, Serialize, Deserialize)]
196#[serde(untagged)]
197pub enum OauthAuthorizePostError {
198 Status401(),
199 UnknownValue(serde_json::Value),
200}
201
202#[derive(Debug, Clone, Serialize, Deserialize)]
204#[serde(untagged)]
205pub enum OauthRegisterError {
206 UnknownValue(serde_json::Value),
207}
208
209#[derive(Debug, Clone, Serialize, Deserialize)]
211#[serde(untagged)]
212pub enum OauthTokenError {
213 Status400(models::ErrorResponse),
214 Status401(models::ErrorResponse),
215 Status500(models::ErrorResponse),
216 UnknownValue(serde_json::Value),
217}
218
219#[derive(Debug, Clone, Serialize, Deserialize)]
221#[serde(untagged)]
222pub enum OauthUserinfoError {
223 Status401(models::ErrorResponse),
224 UnknownValue(serde_json::Value),
225}
226
227#[derive(Debug, Clone, Serialize, Deserialize)]
229#[serde(untagged)]
230pub enum RevokeRoleAssignmentError {
231 Status401(models::ErrorResponse),
232 Status404(models::ErrorResponse),
233 Status500(models::ErrorResponse),
234 UnknownValue(serde_json::Value),
235}
236
237#[derive(Debug, Clone, Serialize, Deserialize)]
239#[serde(untagged)]
240pub enum ShareConcreteRoleError {
241 Status401(),
242 Status400(models::ErrorResponse),
243 UnknownValue(serde_json::Value),
244}
245
246#[derive(Debug, Clone, Serialize, Deserialize)]
248#[serde(untagged)]
249pub enum TokenRefreshError {
250 Status400(models::ErrorResponse),
251 UnknownValue(serde_json::Value),
252}
253
254#[derive(Debug, Clone, Serialize, Deserialize)]
256#[serde(untagged)]
257pub enum UnassignConcreteRoleError {
258 Status404(models::ErrorResponse),
259 UnknownValue(serde_json::Value),
260}
261
262#[derive(Debug, Clone, Serialize, Deserialize)]
264#[serde(untagged)]
265pub enum UpdateApiKeyAliasError {
266 UnknownValue(serde_json::Value),
267}
268
269#[derive(Debug, Clone, Serialize, Deserialize)]
271#[serde(untagged)]
272pub enum UserLoginError {
273 Status401(models::ErrorResponse),
274 UnknownValue(serde_json::Value),
275}
276
277#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum UserSignupError {
281 Status409(models::ErrorResponse),
282 Status400(models::ErrorResponse),
283 Status500(models::ErrorResponse),
284 UnknownValue(serde_json::Value),
285}
286
287#[derive(Debug, Clone, Serialize, Deserialize)]
289#[serde(untagged)]
290pub enum UserSignupWithRedirectError {
291 Status409(models::ErrorResponse),
292 Status400(models::ErrorResponse),
293 Status500(models::ErrorResponse),
294 UnknownValue(serde_json::Value),
295}
296
297
298pub async fn assign_concrete_role(configuration: &Configuration, role_id: &str) -> Result<(), Error<AssignConcreteRoleError>> {
299 let p_path_role_id = role_id;
301
302 let uri_str = format!("{}/me/roles/{roleId}", build_url(configuration), roleId=crate::apis::urlencode(p_path_role_id));
303 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
304
305
306 if let Some(ref token) = configuration.oauth_access_token {
307 req_builder = req_builder.bearer_auth(token.to_owned());
308 };
309 if let Some(ref value) = configuration.api_key {
310 req_builder = req_builder.header("X-API-KEY", value);
311 };
312
313 let req = req_builder.build()?;
314 let resp = configuration.client.execute(req).await?;
315
316 let status = resp.status();
317
318 if !status.is_client_error() && !status.is_server_error() {
319 Ok(())
320 } else {
321 let content = resp.text().await?;
322 let entity: Option<AssignConcreteRoleError> = serde_json::from_str(&content).ok();
323 Err(Error::ResponseError(ResponseContent { status, content, entity }))
324 }
325}
326
327pub async fn assume_identity(configuration: &Configuration, assume_identity_request: Option<models::AssumeIdentityRequest>) -> Result<models::TokenResponse, Error<AssumeIdentityError>> {
328 let p_body_assume_identity_request = assume_identity_request;
330
331 let uri_str = format!("{}/identity/assume", build_url(configuration));
332 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
333
334
335 if let Some(ref token) = configuration.oauth_access_token {
336 req_builder = req_builder.bearer_auth(token.to_owned());
337 };
338 if let Some(ref value) = configuration.api_key {
339 req_builder = req_builder.header("X-API-KEY", value);
340 };
341 req_builder = req_builder.json(&p_body_assume_identity_request);
342
343 let req = req_builder.build()?;
344 let resp = configuration.client.execute(req).await?;
345
346 let status = resp.status();
347 let content_type = resp
348 .headers()
349 .get("content-type")
350 .and_then(|v| v.to_str().ok())
351 .unwrap_or("application/octet-stream");
352 let content_type = super::ContentType::from(content_type);
353
354 if !status.is_client_error() && !status.is_server_error() {
355 let content = resp.text().await?;
356 match content_type {
357 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
358 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TokenResponse`"))),
359 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::TokenResponse`")))),
360 }
361 } else {
362 let content = resp.text().await?;
363 let entity: Option<AssumeIdentityError> = serde_json::from_str(&content).ok();
364 Err(Error::ResponseError(ResponseContent { status, content, entity }))
365 }
366}
367
368pub async fn authenticate_apikey(configuration: &Configuration, apikey_request: Option<models::ApikeyRequest>) -> Result<models::TokenResponse, Error<AuthenticateApikeyError>> {
369 let p_body_apikey_request = apikey_request;
371
372 let uri_str = format!("{}/auth/apikey", build_url(configuration));
373 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
374
375
376 if let Some(ref token) = configuration.oauth_access_token {
377 req_builder = req_builder.bearer_auth(token.to_owned());
378 };
379 if let Some(ref value) = configuration.api_key {
380 req_builder = req_builder.header("X-API-KEY", value);
381 };
382 req_builder = req_builder.json(&p_body_apikey_request);
383
384 let req = req_builder.build()?;
385 let resp = configuration.client.execute(req).await?;
386
387 let status = resp.status();
388 let content_type = resp
389 .headers()
390 .get("content-type")
391 .and_then(|v| v.to_str().ok())
392 .unwrap_or("application/octet-stream");
393 let content_type = super::ContentType::from(content_type);
394
395 if !status.is_client_error() && !status.is_server_error() {
396 let content = resp.text().await?;
397 match content_type {
398 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
399 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TokenResponse`"))),
400 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::TokenResponse`")))),
401 }
402 } else {
403 let content = resp.text().await?;
404 let entity: Option<AuthenticateApikeyError> = serde_json::from_str(&content).ok();
405 Err(Error::ResponseError(ResponseContent { status, content, entity }))
406 }
407}
408
409pub async fn change_authentication(configuration: &Configuration, change_authentication_request: Option<models::ChangeAuthenticationRequest>) -> Result<(), Error<ChangeAuthenticationError>> {
410 let p_body_change_authentication_request = change_authentication_request;
412
413 let uri_str = format!("{}/authentication", build_url(configuration));
414 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
415
416
417 if let Some(ref token) = configuration.oauth_access_token {
418 req_builder = req_builder.bearer_auth(token.to_owned());
419 };
420 if let Some(ref value) = configuration.api_key {
421 req_builder = req_builder.header("X-API-KEY", value);
422 };
423 req_builder = req_builder.json(&p_body_change_authentication_request);
424
425 let req = req_builder.build()?;
426 let resp = configuration.client.execute(req).await?;
427
428 let status = resp.status();
429
430 if !status.is_client_error() && !status.is_server_error() {
431 Ok(())
432 } else {
433 let content = resp.text().await?;
434 let entity: Option<ChangeAuthenticationError> = serde_json::from_str(&content).ok();
435 Err(Error::ResponseError(ResponseContent { status, content, entity }))
436 }
437}
438
439pub async fn check_identity(configuration: &Configuration, check_identity_request: Option<models::CheckIdentityRequest>) -> Result<models::CheckIdentity200Response, Error<CheckIdentityError>> {
440 let p_body_check_identity_request = check_identity_request;
442
443 let uri_str = format!("{}/identity/check", build_url(configuration));
444 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
445
446
447 if let Some(ref token) = configuration.oauth_access_token {
448 req_builder = req_builder.bearer_auth(token.to_owned());
449 };
450 if let Some(ref value) = configuration.api_key {
451 req_builder = req_builder.header("X-API-KEY", value);
452 };
453 req_builder = req_builder.json(&p_body_check_identity_request);
454
455 let req = req_builder.build()?;
456 let resp = configuration.client.execute(req).await?;
457
458 let status = resp.status();
459 let content_type = resp
460 .headers()
461 .get("content-type")
462 .and_then(|v| v.to_str().ok())
463 .unwrap_or("application/octet-stream");
464 let content_type = super::ContentType::from(content_type);
465
466 if !status.is_client_error() && !status.is_server_error() {
467 let content = resp.text().await?;
468 match content_type {
469 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
470 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CheckIdentity200Response`"))),
471 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::CheckIdentity200Response`")))),
472 }
473 } else {
474 let content = resp.text().await?;
475 let entity: Option<CheckIdentityError> = serde_json::from_str(&content).ok();
476 Err(Error::ResponseError(ResponseContent { status, content, entity }))
477 }
478}
479
480pub async fn create_api_key(configuration: &Configuration, create_api_key_request: models::CreateApiKeyRequest) -> Result<String, Error<CreateApiKeyError>> {
481 let p_body_create_api_key_request = create_api_key_request;
483
484 let uri_str = format!("{}/me/identity/apikey", build_url(configuration));
485 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
486
487
488 if let Some(ref token) = configuration.oauth_access_token {
489 req_builder = req_builder.bearer_auth(token.to_owned());
490 };
491 if let Some(ref value) = configuration.api_key {
492 req_builder = req_builder.header("X-API-KEY", value);
493 };
494 req_builder = req_builder.json(&p_body_create_api_key_request);
495
496 let req = req_builder.build()?;
497 let resp = configuration.client.execute(req).await?;
498
499 let status = resp.status();
500 let content_type = resp
501 .headers()
502 .get("content-type")
503 .and_then(|v| v.to_str().ok())
504 .unwrap_or("application/octet-stream");
505 let content_type = super::ContentType::from(content_type);
506
507 if !status.is_client_error() && !status.is_server_error() {
508 let content = resp.text().await?;
509 match content_type {
510 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
511 ContentType::Text => return Ok(content),
512 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
513 }
514 } else {
515 let content = resp.text().await?;
516 let entity: Option<CreateApiKeyError> = serde_json::from_str(&content).ok();
517 Err(Error::ResponseError(ResponseContent { status, content, entity }))
518 }
519}
520
521pub async fn create_concrete_role_for_context(configuration: &Configuration, context_id: &str, create_concrete_role_for_context_request: Option<models::CreateConcreteRoleForContextRequest>) -> Result<models::ContextRole, Error<CreateConcreteRoleForContextError>> {
522 let p_path_context_id = context_id;
524 let p_body_create_concrete_role_for_context_request = create_concrete_role_for_context_request;
525
526 let uri_str = format!("{}/roles/context/{contextId}", build_url(configuration), contextId=crate::apis::urlencode(p_path_context_id));
527 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
528
529
530 if let Some(ref token) = configuration.oauth_access_token {
531 req_builder = req_builder.bearer_auth(token.to_owned());
532 };
533 if let Some(ref value) = configuration.api_key {
534 req_builder = req_builder.header("X-API-KEY", value);
535 };
536 req_builder = req_builder.json(&p_body_create_concrete_role_for_context_request);
537
538 let req = req_builder.build()?;
539 let resp = configuration.client.execute(req).await?;
540
541 let status = resp.status();
542 let content_type = resp
543 .headers()
544 .get("content-type")
545 .and_then(|v| v.to_str().ok())
546 .unwrap_or("application/octet-stream");
547 let content_type = super::ContentType::from(content_type);
548
549 if !status.is_client_error() && !status.is_server_error() {
550 let content = resp.text().await?;
551 match content_type {
552 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
553 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContextRole`"))),
554 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::ContextRole`")))),
555 }
556 } else {
557 let content = resp.text().await?;
558 let entity: Option<CreateConcreteRoleForContextError> = serde_json::from_str(&content).ok();
559 Err(Error::ResponseError(ResponseContent { status, content, entity }))
560 }
561}
562
563pub async fn delete_api_key(configuration: &Configuration, apikey: &str) -> Result<(), Error<DeleteApiKeyError>> {
564 let p_path_apikey = apikey;
566
567 let uri_str = format!("{}/me/identity/apikey/{apikey}", build_url(configuration), apikey=crate::apis::urlencode(p_path_apikey));
568 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
569
570
571 if let Some(ref token) = configuration.oauth_access_token {
572 req_builder = req_builder.bearer_auth(token.to_owned());
573 };
574 if let Some(ref value) = configuration.api_key {
575 req_builder = req_builder.header("X-API-KEY", value);
576 };
577
578 let req = req_builder.build()?;
579 let resp = configuration.client.execute(req).await?;
580
581 let status = resp.status();
582
583 if !status.is_client_error() && !status.is_server_error() {
584 Ok(())
585 } else {
586 let content = resp.text().await?;
587 let entity: Option<DeleteApiKeyError> = serde_json::from_str(&content).ok();
588 Err(Error::ResponseError(ResponseContent { status, content, entity }))
589 }
590}
591
592pub async fn delete_context_roles(configuration: &Configuration, context_id: &str) -> Result<(), Error<DeleteContextRolesError>> {
593 let p_path_context_id = context_id;
595
596 let uri_str = format!("{}/context/{context_id}", build_url(configuration), context_id=crate::apis::urlencode(p_path_context_id));
597 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
598
599
600 if let Some(ref token) = configuration.oauth_access_token {
601 req_builder = req_builder.bearer_auth(token.to_owned());
602 };
603 if let Some(ref value) = configuration.api_key {
604 req_builder = req_builder.header("X-API-KEY", value);
605 };
606
607 let req = req_builder.build()?;
608 let resp = configuration.client.execute(req).await?;
609
610 let status = resp.status();
611
612 if !status.is_client_error() && !status.is_server_error() {
613 Ok(())
614 } else {
615 let content = resp.text().await?;
616 let entity: Option<DeleteContextRolesError> = serde_json::from_str(&content).ok();
617 Err(Error::ResponseError(ResponseContent { status, content, entity }))
618 }
619}
620
621pub async fn delete_identity(configuration: &Configuration) -> Result<(), Error<DeleteIdentityError>> {
622
623 let uri_str = format!("{}/me/identity", build_url(configuration));
624 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
625
626
627 if let Some(ref token) = configuration.oauth_access_token {
628 req_builder = req_builder.bearer_auth(token.to_owned());
629 };
630 if let Some(ref value) = configuration.api_key {
631 req_builder = req_builder.header("X-API-KEY", value);
632 };
633
634 let req = req_builder.build()?;
635 let resp = configuration.client.execute(req).await?;
636
637 let status = resp.status();
638
639 if !status.is_client_error() && !status.is_server_error() {
640 Ok(())
641 } else {
642 let content = resp.text().await?;
643 let entity: Option<DeleteIdentityError> = serde_json::from_str(&content).ok();
644 Err(Error::ResponseError(ResponseContent { status, content, entity }))
645 }
646}
647
648pub async fn get_abstract_roles(configuration: &Configuration) -> Result<models::GetAbstractRoles200Response, Error<GetAbstractRolesError>> {
649
650 let uri_str = format!("{}/roles", build_url(configuration));
651 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
652
653
654 if let Some(ref token) = configuration.oauth_access_token {
655 req_builder = req_builder.bearer_auth(token.to_owned());
656 };
657 if let Some(ref value) = configuration.api_key {
658 req_builder = req_builder.header("X-API-KEY", value);
659 };
660
661 let req = req_builder.build()?;
662 let resp = configuration.client.execute(req).await?;
663
664 let status = resp.status();
665 let content_type = resp
666 .headers()
667 .get("content-type")
668 .and_then(|v| v.to_str().ok())
669 .unwrap_or("application/octet-stream");
670 let content_type = super::ContentType::from(content_type);
671
672 if !status.is_client_error() && !status.is_server_error() {
673 let content = resp.text().await?;
674 match content_type {
675 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
676 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAbstractRoles200Response`"))),
677 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::GetAbstractRoles200Response`")))),
678 }
679 } else {
680 let content = resp.text().await?;
681 let entity: Option<GetAbstractRolesError> = serde_json::from_str(&content).ok();
682 Err(Error::ResponseError(ResponseContent { status, content, entity }))
683 }
684}
685
686pub async fn get_account_email(configuration: &Configuration) -> Result<models::GetAccountEmail200Response, Error<GetAccountEmailError>> {
687
688 let uri_str = format!("{}/me/email", build_url(configuration));
689 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
690
691
692 if let Some(ref token) = configuration.oauth_access_token {
693 req_builder = req_builder.bearer_auth(token.to_owned());
694 };
695 if let Some(ref value) = configuration.api_key {
696 req_builder = req_builder.header("X-API-KEY", value);
697 };
698
699 let req = req_builder.build()?;
700 let resp = configuration.client.execute(req).await?;
701
702 let status = resp.status();
703 let content_type = resp
704 .headers()
705 .get("content-type")
706 .and_then(|v| v.to_str().ok())
707 .unwrap_or("application/octet-stream");
708 let content_type = super::ContentType::from(content_type);
709
710 if !status.is_client_error() && !status.is_server_error() {
711 let content = resp.text().await?;
712 match content_type {
713 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
714 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAccountEmail200Response`"))),
715 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::GetAccountEmail200Response`")))),
716 }
717 } else {
718 let content = resp.text().await?;
719 let entity: Option<GetAccountEmailError> = serde_json::from_str(&content).ok();
720 Err(Error::ResponseError(ResponseContent { status, content, entity }))
721 }
722}
723
724pub async fn get_account_stats(configuration: &Configuration) -> Result<models::GetAccountStats200Response, Error<GetAccountStatsError>> {
725
726 let uri_str = format!("{}/me", build_url(configuration));
727 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
728
729
730 if let Some(ref token) = configuration.oauth_access_token {
731 req_builder = req_builder.bearer_auth(token.to_owned());
732 };
733 if let Some(ref value) = configuration.api_key {
734 req_builder = req_builder.header("X-API-KEY", value);
735 };
736
737 let req = req_builder.build()?;
738 let resp = configuration.client.execute(req).await?;
739
740 let status = resp.status();
741 let content_type = resp
742 .headers()
743 .get("content-type")
744 .and_then(|v| v.to_str().ok())
745 .unwrap_or("application/octet-stream");
746 let content_type = super::ContentType::from(content_type);
747
748 if !status.is_client_error() && !status.is_server_error() {
749 let content = resp.text().await?;
750 match content_type {
751 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
752 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAccountStats200Response`"))),
753 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::GetAccountStats200Response`")))),
754 }
755 } else {
756 let content = resp.text().await?;
757 let entity: Option<GetAccountStatsError> = serde_json::from_str(&content).ok();
758 Err(Error::ResponseError(ResponseContent { status, content, entity }))
759 }
760}
761
762pub async fn get_concrete_roles_for_context(configuration: &Configuration, context_id: &str) -> Result<models::GetConcreteRolesForContext200Response, Error<GetConcreteRolesForContextError>> {
763 let p_path_context_id = context_id;
765
766 let uri_str = format!("{}/roles/context/{contextId}", build_url(configuration), contextId=crate::apis::urlencode(p_path_context_id));
767 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
768
769
770 if let Some(ref token) = configuration.oauth_access_token {
771 req_builder = req_builder.bearer_auth(token.to_owned());
772 };
773 if let Some(ref value) = configuration.api_key {
774 req_builder = req_builder.header("X-API-KEY", value);
775 };
776
777 let req = req_builder.build()?;
778 let resp = configuration.client.execute(req).await?;
779
780 let status = resp.status();
781 let content_type = resp
782 .headers()
783 .get("content-type")
784 .and_then(|v| v.to_str().ok())
785 .unwrap_or("application/octet-stream");
786 let content_type = super::ContentType::from(content_type);
787
788 if !status.is_client_error() && !status.is_server_error() {
789 let content = resp.text().await?;
790 match content_type {
791 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
792 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetConcreteRolesForContext200Response`"))),
793 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::GetConcreteRolesForContext200Response`")))),
794 }
795 } else {
796 let content = resp.text().await?;
797 let entity: Option<GetConcreteRolesForContextError> = serde_json::from_str(&content).ok();
798 Err(Error::ResponseError(ResponseContent { status, content, entity }))
799 }
800}
801
802pub async fn get_concrete_roles_for_identity(configuration: &Configuration, identity_id: &str) -> Result<models::GetConcreteRolesForIdentity200Response, Error<GetConcreteRolesForIdentityError>> {
803 let p_path_identity_id = identity_id;
805
806 let uri_str = format!("{}/roles/identity/{identityId}", build_url(configuration), identityId=crate::apis::urlencode(p_path_identity_id));
807 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
808
809
810 if let Some(ref token) = configuration.oauth_access_token {
811 req_builder = req_builder.bearer_auth(token.to_owned());
812 };
813 if let Some(ref value) = configuration.api_key {
814 req_builder = req_builder.header("X-API-KEY", value);
815 };
816
817 let req = req_builder.build()?;
818 let resp = configuration.client.execute(req).await?;
819
820 let status = resp.status();
821 let content_type = resp
822 .headers()
823 .get("content-type")
824 .and_then(|v| v.to_str().ok())
825 .unwrap_or("application/octet-stream");
826 let content_type = super::ContentType::from(content_type);
827
828 if !status.is_client_error() && !status.is_server_error() {
829 let content = resp.text().await?;
830 match content_type {
831 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
832 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetConcreteRolesForIdentity200Response`"))),
833 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::GetConcreteRolesForIdentity200Response`")))),
834 }
835 } else {
836 let content = resp.text().await?;
837 let entity: Option<GetConcreteRolesForIdentityError> = serde_json::from_str(&content).ok();
838 Err(Error::ResponseError(ResponseContent { status, content, entity }))
839 }
840}
841
842pub async fn get_role_assignment(configuration: &Configuration, role_id: &str) -> Result<Vec<models::RoleAssignmentEntry>, Error<GetRoleAssignmentError>> {
843 let p_path_role_id = role_id;
845
846 let uri_str = format!("{}/roles/{roleId}/identity", build_url(configuration), roleId=crate::apis::urlencode(p_path_role_id));
847 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
848
849
850 if let Some(ref token) = configuration.oauth_access_token {
851 req_builder = req_builder.bearer_auth(token.to_owned());
852 };
853 if let Some(ref value) = configuration.api_key {
854 req_builder = req_builder.header("X-API-KEY", value);
855 };
856
857 let req = req_builder.build()?;
858 let resp = configuration.client.execute(req).await?;
859
860 let status = resp.status();
861 let content_type = resp
862 .headers()
863 .get("content-type")
864 .and_then(|v| v.to_str().ok())
865 .unwrap_or("application/octet-stream");
866 let content_type = super::ContentType::from(content_type);
867
868 if !status.is_client_error() && !status.is_server_error() {
869 let content = resp.text().await?;
870 match content_type {
871 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
872 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::RoleAssignmentEntry>`"))),
873 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::RoleAssignmentEntry>`")))),
874 }
875 } else {
876 let content = resp.text().await?;
877 let entity: Option<GetRoleAssignmentError> = serde_json::from_str(&content).ok();
878 Err(Error::ResponseError(ResponseContent { status, content, entity }))
879 }
880}
881
882pub async fn list_authentication(configuration: &Configuration) -> Result<models::ListAuthentication200Response, Error<ListAuthenticationError>> {
883
884 let uri_str = format!("{}/authentication", build_url(configuration));
885 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
886
887
888 if let Some(ref token) = configuration.oauth_access_token {
889 req_builder = req_builder.bearer_auth(token.to_owned());
890 };
891 if let Some(ref value) = configuration.api_key {
892 req_builder = req_builder.header("X-API-KEY", value);
893 };
894
895 let req = req_builder.build()?;
896 let resp = configuration.client.execute(req).await?;
897
898 let status = resp.status();
899 let content_type = resp
900 .headers()
901 .get("content-type")
902 .and_then(|v| v.to_str().ok())
903 .unwrap_or("application/octet-stream");
904 let content_type = super::ContentType::from(content_type);
905
906 if !status.is_client_error() && !status.is_server_error() {
907 let content = resp.text().await?;
908 match content_type {
909 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
910 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAuthentication200Response`"))),
911 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::ListAuthentication200Response`")))),
912 }
913 } else {
914 let content = resp.text().await?;
915 let entity: Option<ListAuthenticationError> = serde_json::from_str(&content).ok();
916 Err(Error::ResponseError(ResponseContent { status, content, entity }))
917 }
918}
919
920pub async fn list_available_contexts(configuration: &Configuration) -> Result<Vec<models::ListAvailableContexts200ResponseInner>, Error<ListAvailableContextsError>> {
921
922 let uri_str = format!("{}/context", build_url(configuration));
923 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
924
925
926 if let Some(ref token) = configuration.oauth_access_token {
927 req_builder = req_builder.bearer_auth(token.to_owned());
928 };
929 if let Some(ref value) = configuration.api_key {
930 req_builder = req_builder.header("X-API-KEY", value);
931 };
932
933 let req = req_builder.build()?;
934 let resp = configuration.client.execute(req).await?;
935
936 let status = resp.status();
937 let content_type = resp
938 .headers()
939 .get("content-type")
940 .and_then(|v| v.to_str().ok())
941 .unwrap_or("application/octet-stream");
942 let content_type = super::ContentType::from(content_type);
943
944 if !status.is_client_error() && !status.is_server_error() {
945 let content = resp.text().await?;
946 match content_type {
947 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
948 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ListAvailableContexts200ResponseInner>`"))),
949 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::ListAvailableContexts200ResponseInner>`")))),
950 }
951 } else {
952 let content = resp.text().await?;
953 let entity: Option<ListAvailableContextsError> = serde_json::from_str(&content).ok();
954 Err(Error::ResponseError(ResponseContent { status, content, entity }))
955 }
956}
957
958pub async fn list_identity(configuration: &Configuration) -> Result<models::ListIdentity200Response, Error<ListIdentityError>> {
959
960 let uri_str = format!("{}/identity", build_url(configuration));
961 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
962
963
964 if let Some(ref token) = configuration.oauth_access_token {
965 req_builder = req_builder.bearer_auth(token.to_owned());
966 };
967 if let Some(ref value) = configuration.api_key {
968 req_builder = req_builder.header("X-API-KEY", value);
969 };
970
971 let req = req_builder.build()?;
972 let resp = configuration.client.execute(req).await?;
973
974 let status = resp.status();
975 let content_type = resp
976 .headers()
977 .get("content-type")
978 .and_then(|v| v.to_str().ok())
979 .unwrap_or("application/octet-stream");
980 let content_type = super::ContentType::from(content_type);
981
982 if !status.is_client_error() && !status.is_server_error() {
983 let content = resp.text().await?;
984 match content_type {
985 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
986 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListIdentity200Response`"))),
987 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::ListIdentity200Response`")))),
988 }
989 } else {
990 let content = resp.text().await?;
991 let entity: Option<ListIdentityError> = serde_json::from_str(&content).ok();
992 Err(Error::ResponseError(ResponseContent { status, content, entity }))
993 }
994}
995
996pub async fn new_context(configuration: &Configuration, context_id: &str, new_context_request: Option<models::NewContextRequest>) -> Result<(), Error<NewContextError>> {
997 let p_path_context_id = context_id;
999 let p_body_new_context_request = new_context_request;
1000
1001 let uri_str = format!("{}/context/{context_id}/new", build_url(configuration), context_id=crate::apis::urlencode(p_path_context_id));
1002 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1003
1004
1005 if let Some(ref token) = configuration.oauth_access_token {
1006 req_builder = req_builder.bearer_auth(token.to_owned());
1007 };
1008 if let Some(ref value) = configuration.api_key {
1009 req_builder = req_builder.header("X-API-KEY", value);
1010 };
1011 req_builder = req_builder.json(&p_body_new_context_request);
1012
1013 let req = req_builder.build()?;
1014 let resp = configuration.client.execute(req).await?;
1015
1016 let status = resp.status();
1017
1018 if !status.is_client_error() && !status.is_server_error() {
1019 Ok(())
1020 } else {
1021 let content = resp.text().await?;
1022 let entity: Option<NewContextError> = serde_json::from_str(&content).ok();
1023 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1024 }
1025}
1026
1027pub async fn new_identity(configuration: &Configuration, new_identity_request: Option<models::NewIdentityRequest>) -> Result<models::ListIdentity200ResponseIdentitiesInner, Error<NewIdentityError>> {
1028 let p_body_new_identity_request = new_identity_request;
1030
1031 let uri_str = format!("{}/identity", build_url(configuration));
1032 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1033
1034
1035 if let Some(ref token) = configuration.oauth_access_token {
1036 req_builder = req_builder.bearer_auth(token.to_owned());
1037 };
1038 if let Some(ref value) = configuration.api_key {
1039 req_builder = req_builder.header("X-API-KEY", value);
1040 };
1041 req_builder = req_builder.json(&p_body_new_identity_request);
1042
1043 let req = req_builder.build()?;
1044 let resp = configuration.client.execute(req).await?;
1045
1046 let status = resp.status();
1047 let content_type = resp
1048 .headers()
1049 .get("content-type")
1050 .and_then(|v| v.to_str().ok())
1051 .unwrap_or("application/octet-stream");
1052 let content_type = super::ContentType::from(content_type);
1053
1054 if !status.is_client_error() && !status.is_server_error() {
1055 let content = resp.text().await?;
1056 match content_type {
1057 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1058 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListIdentity200ResponseIdentitiesInner`"))),
1059 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::ListIdentity200ResponseIdentitiesInner`")))),
1060 }
1061 } else {
1062 let content = resp.text().await?;
1063 let entity: Option<NewIdentityError> = serde_json::from_str(&content).ok();
1064 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1065 }
1066}
1067
1068pub async fn oauth_authorize(configuration: &Configuration, response_type: &str, client_id: &str, redirect_uri: &str, scope: &str, state: Option<&str>, nonce: Option<&str>) -> Result<reqwest::header::HeaderMap, Error<OauthAuthorizeError>> {
1069 let p_query_response_type = response_type;
1071 let p_query_client_id = client_id;
1072 let p_query_redirect_uri = redirect_uri;
1073 let p_query_scope = scope;
1074 let p_query_state = state;
1075 let p_query_nonce = nonce;
1076
1077 let uri_str = format!("{}/oauth/authorize", build_url(configuration));
1078 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1079
1080
1081 req_builder = req_builder.query(&[("response_type", &p_query_response_type.to_string())]);
1082 req_builder = req_builder.query(&[("client_id", &p_query_client_id.to_string())]);
1083 req_builder = req_builder.query(&[("redirect_uri", &p_query_redirect_uri.to_string())]);
1084 req_builder = req_builder.query(&[("scope", &p_query_scope.to_string())]);
1085 if let Some(ref param_value) = p_query_state {
1086 req_builder = req_builder.query(&[("state", ¶m_value.to_string())]);
1087 }
1088 if let Some(ref param_value) = p_query_nonce {
1089 req_builder = req_builder.query(&[("nonce", ¶m_value.to_string())]);
1090 }
1091 if let Some(ref token) = configuration.oauth_access_token {
1092 req_builder = req_builder.bearer_auth(token.to_owned());
1093 };
1094 if let Some(ref value) = configuration.api_key {
1095 req_builder = req_builder.header("X-API-KEY", value);
1096 };
1097
1098 let req = req_builder.build()?;
1099 let resp = configuration.client.execute(req).await?;
1100
1101 let status = resp.status();
1102 let headers = resp.headers().clone();
1103
1104 if !status.is_client_error() && !status.is_server_error() {
1105 Ok(headers)
1106 } else {
1107 let content = resp.text().await?;
1108 let entity: Option<OauthAuthorizeError> = serde_json::from_str(&content).ok();
1109 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1110 }
1111}
1112
1113pub async fn oauth_authorize_post(configuration: &Configuration, response_type: &str, client_id: &str, redirect_uri: &str, scope: &str, state: Option<&str>, nonce: Option<&str>) -> Result<reqwest::header::HeaderMap, Error<OauthAuthorizePostError>> {
1114 let p_query_response_type = response_type;
1116 let p_query_client_id = client_id;
1117 let p_query_redirect_uri = redirect_uri;
1118 let p_query_scope = scope;
1119 let p_query_state = state;
1120 let p_query_nonce = nonce;
1121
1122 let uri_str = format!("{}/oauth/authorize", build_url(configuration));
1123 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1124
1125
1126 req_builder = req_builder.query(&[("response_type", &p_query_response_type.to_string())]);
1127 req_builder = req_builder.query(&[("client_id", &p_query_client_id.to_string())]);
1128 req_builder = req_builder.query(&[("redirect_uri", &p_query_redirect_uri.to_string())]);
1129 req_builder = req_builder.query(&[("scope", &p_query_scope.to_string())]);
1130 if let Some(ref param_value) = p_query_state {
1131 req_builder = req_builder.query(&[("state", ¶m_value.to_string())]);
1132 }
1133 if let Some(ref param_value) = p_query_nonce {
1134 req_builder = req_builder.query(&[("nonce", ¶m_value.to_string())]);
1135 }
1136 if let Some(ref token) = configuration.oauth_access_token {
1137 req_builder = req_builder.bearer_auth(token.to_owned());
1138 };
1139 if let Some(ref value) = configuration.api_key {
1140 req_builder = req_builder.header("X-API-KEY", value);
1141 };
1142
1143 let req = req_builder.build()?;
1144 let resp = configuration.client.execute(req).await?;
1145
1146 let status = resp.status();
1147 let headers = resp.headers().clone();
1148
1149 if !status.is_client_error() && !status.is_server_error() {
1150 Ok(headers)
1151 } else {
1152 let content = resp.text().await?;
1153 let entity: Option<OauthAuthorizePostError> = serde_json::from_str(&content).ok();
1154 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1155 }
1156}
1157
1158pub async fn oauth_register(configuration: &Configuration, oauth_register_request: models::OauthRegisterRequest) -> Result<models::OauthRegister200Response, Error<OauthRegisterError>> {
1160 let p_body_oauth_register_request = oauth_register_request;
1162
1163 let uri_str = format!("{}/oauth/register", build_url(configuration));
1164 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1165
1166
1167 if let Some(ref token) = configuration.oauth_access_token {
1168 req_builder = req_builder.bearer_auth(token.to_owned());
1169 };
1170 if let Some(ref value) = configuration.api_key {
1171 req_builder = req_builder.header("X-API-KEY", value);
1172 };
1173 req_builder = req_builder.json(&p_body_oauth_register_request);
1174
1175 let req = req_builder.build()?;
1176 let resp = configuration.client.execute(req).await?;
1177
1178 let status = resp.status();
1179 let content_type = resp
1180 .headers()
1181 .get("content-type")
1182 .and_then(|v| v.to_str().ok())
1183 .unwrap_or("application/octet-stream");
1184 let content_type = super::ContentType::from(content_type);
1185
1186 if !status.is_client_error() && !status.is_server_error() {
1187 let content = resp.text().await?;
1188 match content_type {
1189 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1190 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OauthRegister200Response`"))),
1191 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::OauthRegister200Response`")))),
1192 }
1193 } else {
1194 let content = resp.text().await?;
1195 let entity: Option<OauthRegisterError> = serde_json::from_str(&content).ok();
1196 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1197 }
1198}
1199
1200pub async fn oauth_token(configuration: &Configuration, grant_type: &str, client_id: &str, client_secret: &str, redirect_uri: &str, code: &str) -> Result<models::TokenResponse, Error<OauthTokenError>> {
1202 let p_form_grant_type = grant_type;
1204 let p_form_client_id = client_id;
1205 let p_form_client_secret = client_secret;
1206 let p_form_redirect_uri = redirect_uri;
1207 let p_form_code = code;
1208
1209 let uri_str = format!("{}/oauth/token", build_url(configuration));
1210 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1211
1212
1213 let mut multipart_form_params = std::collections::HashMap::new();
1214 multipart_form_params.insert("grant_type", p_form_grant_type.to_string());
1215 multipart_form_params.insert("client_id", p_form_client_id.to_string());
1216 multipart_form_params.insert("client_secret", p_form_client_secret.to_string());
1217 multipart_form_params.insert("redirect_uri", p_form_redirect_uri.to_string());
1218 multipart_form_params.insert("code", p_form_code.to_string());
1219 req_builder = req_builder.form(&multipart_form_params);
1220
1221 let req = req_builder.build()?;
1222 let resp = configuration.client.execute(req).await?;
1223
1224 let status = resp.status();
1225 let content_type = resp
1226 .headers()
1227 .get("content-type")
1228 .and_then(|v| v.to_str().ok())
1229 .unwrap_or("application/octet-stream");
1230 let content_type = super::ContentType::from(content_type);
1231
1232 if !status.is_client_error() && !status.is_server_error() {
1233 let content = resp.text().await?;
1234 match content_type {
1235 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1236 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TokenResponse`"))),
1237 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::TokenResponse`")))),
1238 }
1239 } else {
1240 let content = resp.text().await?;
1241 let entity: Option<OauthTokenError> = serde_json::from_str(&content).ok();
1242 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1243 }
1244}
1245
1246pub async fn oauth_userinfo(configuration: &Configuration) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<OauthUserinfoError>> {
1248
1249 let uri_str = format!("{}/oauth/userinfo", build_url(configuration));
1250 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1251
1252
1253 if let Some(ref token) = configuration.oauth_access_token {
1254 req_builder = req_builder.bearer_auth(token.to_owned());
1255 };
1256 if let Some(ref value) = configuration.api_key {
1257 req_builder = req_builder.header("X-API-KEY", value);
1258 };
1259
1260 let req = req_builder.build()?;
1261 let resp = configuration.client.execute(req).await?;
1262
1263 let status = resp.status();
1264 let content_type = resp
1265 .headers()
1266 .get("content-type")
1267 .and_then(|v| v.to_str().ok())
1268 .unwrap_or("application/octet-stream");
1269 let content_type = super::ContentType::from(content_type);
1270
1271 if !status.is_client_error() && !status.is_server_error() {
1272 let content = resp.text().await?;
1273 match content_type {
1274 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1275 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1276 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1277 }
1278 } else {
1279 let content = resp.text().await?;
1280 let entity: Option<OauthUserinfoError> = serde_json::from_str(&content).ok();
1281 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1282 }
1283}
1284
1285pub async fn revoke_role_assignment(configuration: &Configuration, role_id: &str, identity_id: &str) -> Result<(), Error<RevokeRoleAssignmentError>> {
1286 let p_path_role_id = role_id;
1288 let p_path_identity_id = identity_id;
1289
1290 let uri_str = format!("{}/roles/{roleId}/identity/{identityId}", build_url(configuration), roleId=crate::apis::urlencode(p_path_role_id), identityId=crate::apis::urlencode(p_path_identity_id));
1291 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1292
1293
1294 if let Some(ref token) = configuration.oauth_access_token {
1295 req_builder = req_builder.bearer_auth(token.to_owned());
1296 };
1297 if let Some(ref value) = configuration.api_key {
1298 req_builder = req_builder.header("X-API-KEY", value);
1299 };
1300
1301 let req = req_builder.build()?;
1302 let resp = configuration.client.execute(req).await?;
1303
1304 let status = resp.status();
1305
1306 if !status.is_client_error() && !status.is_server_error() {
1307 Ok(())
1308 } else {
1309 let content = resp.text().await?;
1310 let entity: Option<RevokeRoleAssignmentError> = serde_json::from_str(&content).ok();
1311 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1312 }
1313}
1314
1315pub async fn share_concrete_role(configuration: &Configuration, role_id: &str, check_identity_request: models::CheckIdentityRequest) -> Result<(), Error<ShareConcreteRoleError>> {
1316 let p_path_role_id = role_id;
1318 let p_body_check_identity_request = check_identity_request;
1319
1320 let uri_str = format!("{}/roles/{roleId}/share", build_url(configuration), roleId=crate::apis::urlencode(p_path_role_id));
1321 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1322
1323
1324 if let Some(ref token) = configuration.oauth_access_token {
1325 req_builder = req_builder.bearer_auth(token.to_owned());
1326 };
1327 if let Some(ref value) = configuration.api_key {
1328 req_builder = req_builder.header("X-API-KEY", value);
1329 };
1330 req_builder = req_builder.json(&p_body_check_identity_request);
1331
1332 let req = req_builder.build()?;
1333 let resp = configuration.client.execute(req).await?;
1334
1335 let status = resp.status();
1336
1337 if !status.is_client_error() && !status.is_server_error() {
1338 Ok(())
1339 } else {
1340 let content = resp.text().await?;
1341 let entity: Option<ShareConcreteRoleError> = serde_json::from_str(&content).ok();
1342 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1343 }
1344}
1345
1346pub async fn token_refresh(configuration: &Configuration, change_context_request: models::ChangeContextRequest) -> Result<models::TokenResponse, Error<TokenRefreshError>> {
1348 let p_body_change_context_request = change_context_request;
1350
1351 let uri_str = format!("{}/token/refresh", build_url(configuration));
1352 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1353
1354
1355 if let Some(ref token) = configuration.oauth_access_token {
1356 req_builder = req_builder.bearer_auth(token.to_owned());
1357 };
1358 if let Some(ref value) = configuration.api_key {
1359 req_builder = req_builder.header("X-API-KEY", value);
1360 };
1361 req_builder = req_builder.json(&p_body_change_context_request);
1362
1363 let req = req_builder.build()?;
1364 let resp = configuration.client.execute(req).await?;
1365
1366 let status = resp.status();
1367 let content_type = resp
1368 .headers()
1369 .get("content-type")
1370 .and_then(|v| v.to_str().ok())
1371 .unwrap_or("application/octet-stream");
1372 let content_type = super::ContentType::from(content_type);
1373
1374 if !status.is_client_error() && !status.is_server_error() {
1375 let content = resp.text().await?;
1376 match content_type {
1377 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1378 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TokenResponse`"))),
1379 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::TokenResponse`")))),
1380 }
1381 } else {
1382 let content = resp.text().await?;
1383 let entity: Option<TokenRefreshError> = serde_json::from_str(&content).ok();
1384 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1385 }
1386}
1387
1388pub async fn unassign_concrete_role(configuration: &Configuration, role_id: &str) -> Result<(), Error<UnassignConcreteRoleError>> {
1389 let p_path_role_id = role_id;
1391
1392 let uri_str = format!("{}/me/roles/{roleId}", build_url(configuration), roleId=crate::apis::urlencode(p_path_role_id));
1393 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1394
1395
1396 if let Some(ref token) = configuration.oauth_access_token {
1397 req_builder = req_builder.bearer_auth(token.to_owned());
1398 };
1399 if let Some(ref value) = configuration.api_key {
1400 req_builder = req_builder.header("X-API-KEY", value);
1401 };
1402
1403 let req = req_builder.build()?;
1404 let resp = configuration.client.execute(req).await?;
1405
1406 let status = resp.status();
1407
1408 if !status.is_client_error() && !status.is_server_error() {
1409 Ok(())
1410 } else {
1411 let content = resp.text().await?;
1412 let entity: Option<UnassignConcreteRoleError> = serde_json::from_str(&content).ok();
1413 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1414 }
1415}
1416
1417pub async fn update_api_key_alias(configuration: &Configuration, apikey: &str, update_api_key_alias_request: Option<models::UpdateApiKeyAliasRequest>) -> Result<(), Error<UpdateApiKeyAliasError>> {
1418 let p_path_apikey = apikey;
1420 let p_body_update_api_key_alias_request = update_api_key_alias_request;
1421
1422 let uri_str = format!("{}/me/identity/apikey/{apikey}", build_url(configuration), apikey=crate::apis::urlencode(p_path_apikey));
1423 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1424
1425
1426 if let Some(ref token) = configuration.oauth_access_token {
1427 req_builder = req_builder.bearer_auth(token.to_owned());
1428 };
1429 if let Some(ref value) = configuration.api_key {
1430 req_builder = req_builder.header("X-API-KEY", value);
1431 };
1432 req_builder = req_builder.json(&p_body_update_api_key_alias_request);
1433
1434 let req = req_builder.build()?;
1435 let resp = configuration.client.execute(req).await?;
1436
1437 let status = resp.status();
1438
1439 if !status.is_client_error() && !status.is_server_error() {
1440 Ok(())
1441 } else {
1442 let content = resp.text().await?;
1443 let entity: Option<UpdateApiKeyAliasError> = serde_json::from_str(&content).ok();
1444 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1445 }
1446}
1447
1448pub async fn user_login(configuration: &Configuration, auth_request: models::AuthRequest) -> Result<models::TokenResponse, Error<UserLoginError>> {
1449 let p_body_auth_request = auth_request;
1451
1452 let uri_str = format!("{}/token/auth", build_url(configuration));
1453 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1454
1455
1456 req_builder = req_builder.json(&p_body_auth_request);
1457
1458 let req = req_builder.build()?;
1459 let resp = configuration.client.execute(req).await?;
1460
1461 let status = resp.status();
1462 let content_type = resp
1463 .headers()
1464 .get("content-type")
1465 .and_then(|v| v.to_str().ok())
1466 .unwrap_or("application/octet-stream");
1467 let content_type = super::ContentType::from(content_type);
1468
1469 if !status.is_client_error() && !status.is_server_error() {
1470 let content = resp.text().await?;
1471 match content_type {
1472 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1473 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TokenResponse`"))),
1474 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::TokenResponse`")))),
1475 }
1476 } else {
1477 let content = resp.text().await?;
1478 let entity: Option<UserLoginError> = serde_json::from_str(&content).ok();
1479 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1480 }
1481}
1482
1483pub async fn user_signup(configuration: &Configuration, signup_request: models::SignupRequest) -> Result<models::TokenResponse, Error<UserSignupError>> {
1484 let p_body_signup_request = signup_request;
1486
1487 let uri_str = format!("{}/signup", build_url(configuration));
1488 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1489
1490
1491 req_builder = req_builder.json(&p_body_signup_request);
1492
1493 let req = req_builder.build()?;
1494 let resp = configuration.client.execute(req).await?;
1495
1496 let status = resp.status();
1497 let content_type = resp
1498 .headers()
1499 .get("content-type")
1500 .and_then(|v| v.to_str().ok())
1501 .unwrap_or("application/octet-stream");
1502 let content_type = super::ContentType::from(content_type);
1503
1504 if !status.is_client_error() && !status.is_server_error() {
1505 let content = resp.text().await?;
1506 match content_type {
1507 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1508 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TokenResponse`"))),
1509 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::TokenResponse`")))),
1510 }
1511 } else {
1512 let content = resp.text().await?;
1513 let entity: Option<UserSignupError> = serde_json::from_str(&content).ok();
1514 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1515 }
1516}
1517
1518pub async fn user_signup_with_redirect(configuration: &Configuration, signup_request: models::SignupRequest) -> Result<models::OauthCodeResponse, Error<UserSignupWithRedirectError>> {
1520 let p_body_signup_request = signup_request;
1522
1523 let uri_str = format!("{}/signup_with_redirect", build_url(configuration));
1524 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1525
1526
1527 req_builder = req_builder.json(&p_body_signup_request);
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::OauthCodeResponse`"))),
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::OauthCodeResponse`")))),
1546 }
1547 } else {
1548 let content = resp.text().await?;
1549 let entity: Option<UserSignupWithRedirectError> = serde_json::from_str(&content).ok();
1550 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1551 }
1552}
1553