Skip to main content

dtz_identity/apis/
default_api.rs

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