propelauth/apis/
user_service_api.rs

1/*
2 * propelauth
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 0.1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12
13use super::{configuration, Error, UserFacingError};
14use crate::models::{FetchUsersOrderBy, ResendEmailConfirmationRequest};
15use crate::propelauth::auth::AUTH_HOSTNAME_HEADER;
16use crate::{apis::ResponseContent, models::InviteUserToOrgRequest};
17
18/// struct for passing parameters to the method [`create_magic_link`]
19#[derive(Clone, Debug, Default)]
20pub struct CreateMagicLinkParams {
21    pub create_magic_link_request: crate::models::CreateMagicLinkRequest,
22}
23
24/// struct for passing parameters to the method [`create_user`]
25#[derive(Clone, Debug, Default)]
26pub struct CreateUserParams {
27    pub create_user_request: crate::models::CreateUserRequest,
28}
29
30/// struct for passing parameters to the method [`delete_user`]
31#[derive(Clone, Debug, Default)]
32pub struct DeleteUserParams {
33    pub user_id: String,
34}
35
36/// struct for passing parameters to the method [`disable_user`]
37#[derive(Clone, Debug, Default)]
38pub struct DisableUserParams {
39    pub user_id: String,
40}
41
42/// struct for passing parameters to the method [`disable_user2fa`]
43#[derive(Clone, Debug, Default)]
44pub struct DisableUser2faParams {
45    pub user_id: String,
46}
47
48/// struct for passing parameters to the method [`enable_user`]
49#[derive(Clone, Debug, Default)]
50pub struct EnableUserParams {
51    pub user_id: String,
52}
53
54/// struct for passing parameters to the method [`fetch_user_by_email`]
55#[derive(Clone, Debug, Default)]
56pub struct FetchUserByEmailParams {
57    pub email: String,
58    /// Defaults to false
59    pub include_orgs: Option<bool>,
60}
61
62/// struct for passing parameters to the method [`fetch_user_by_id`]
63#[derive(Clone, Debug, Default)]
64pub struct FetchUserByIdParams {
65    pub user_id: String,
66    /// Defaults to false
67    pub include_orgs: Option<bool>,
68}
69
70/// struct for passing parameters to the method [`fetch_user_by_username`]
71#[derive(Clone, Debug, Default)]
72pub struct FetchUserByUsernameParams {
73    pub username: String,
74    /// Defaults to false
75    pub include_orgs: Option<bool>,
76}
77
78/// struct for passing parameters to the method [`fetch_users_by_emails`]
79#[derive(Clone, Debug, Default)]
80pub struct FetchUsersByEmailsParams {
81    pub emails_query: crate::models::EmailsQuery,
82    /// Defaults to false
83    pub include_orgs: Option<bool>,
84}
85
86/// struct for passing parameters to the method [`fetch_users_by_ids`]
87#[derive(Clone, Debug, Default)]
88pub struct FetchUsersByIdsParams {
89    pub user_ids_query: crate::models::UserIdsQuery,
90    /// Defaults to false
91    pub include_orgs: Option<bool>,
92}
93
94/// struct for passing parameters to the method [`fetch_users_by_query`]
95#[derive(Clone, Debug, Default)]
96pub struct FetchUsersByQueryParams {
97    pub page_size: Option<i64>,
98    pub page_number: Option<i64>,
99    pub order_by: Option<FetchUsersOrderBy>,
100    pub email_or_username: Option<String>,
101    pub include_orgs: Option<bool>,
102    pub legacy_user_id: Option<String>,
103}
104
105/// struct for passing parameters to the method [`fetch_users_by_usernames`]
106#[derive(Clone, Debug, Default)]
107pub struct FetchUsersByUsernamesParams {
108    pub usernames_query: crate::models::UsernamesQuery,
109    /// Defaults to false
110    pub include_orgs: Option<bool>,
111}
112
113/// struct for passing parameters to the method [`migrate_user`]
114#[derive(Clone, Debug, Default)]
115pub struct MigrateUserParams {
116    pub migrate_user_request: crate::models::MigrateUserRequest,
117}
118
119/// struct for passing parameters to the method [`migrate_user_password`]
120#[derive(Clone, Debug, Default)]
121pub struct MigrateUserPasswordParams {
122    pub migrate_user_password_request: crate::models::MigrateUserPasswordRequest,
123}
124
125/// struct for passing parameters to the method [`update_user_email`]
126#[derive(Clone, Debug, Default)]
127pub struct UpdateUserEmailParams {
128    pub user_id: String,
129    pub update_email_request: crate::models::UpdateEmailRequest,
130}
131
132/// struct for passing parameters to the method [`update_user_metadata`]
133#[derive(Clone, Debug, Default)]
134pub struct UpdateUserMetadataParams {
135    pub user_id: String,
136    pub update_metadata_request: crate::models::UpdateMetadataRequest,
137}
138
139/// struct for passing parameters to the method [`update_user_password`]
140#[derive(Clone, Debug, Default)]
141pub struct UpdateUserPasswordParams {
142    pub user_id: String,
143    pub update_password_request: crate::models::UpdatePasswordRequest,
144}
145
146/// struct for typed errors of method [`create_magic_link`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum CreateMagicLinkError {
150    Status400(crate::models::BadCreateMagicLinkRequest),
151    Status401(serde_json::Value),
152    UnknownValue(serde_json::Value),
153}
154
155/// struct for typed errors of method [`create_user`]
156#[derive(Debug, Clone, Serialize, Deserialize)]
157#[serde(untagged)]
158pub enum CreateUserError {
159    Status400(crate::models::BadCreateUserRequest),
160    Status401(serde_json::Value),
161    UnknownValue(serde_json::Value),
162}
163
164/// struct for typed errors of method [`delete_user`]
165#[derive(Debug, Clone, Serialize, Deserialize)]
166#[serde(untagged)]
167pub enum DeleteUserError {
168    Status401(serde_json::Value),
169    Status404(serde_json::Value),
170    UnknownValue(serde_json::Value),
171}
172
173/// struct for typed errors of method [`disable_user`]
174#[derive(Debug, Clone, Serialize, Deserialize)]
175#[serde(untagged)]
176pub enum DisableUserError {
177    Status401(serde_json::Value),
178    Status404(serde_json::Value),
179    UnknownValue(serde_json::Value),
180}
181
182/// struct for typed errors of method [`logout_all_user_sessions`]
183#[derive(Debug, Clone, Serialize, Deserialize)]
184#[serde(untagged)]
185pub enum LogoutAllUserSessionsError {
186    Status401(serde_json::Value),
187    Status404(serde_json::Value),
188    UnknownValue(serde_json::Value),
189}
190
191// struct for typed errors of method [`resend_email_confirmation`]
192#[derive(Debug, Clone, Serialize, Deserialize)]
193#[serde(untagged)]
194pub enum ResendEmailConfirmationError {
195    Status400(UserFacingError),
196    Status401(UserFacingError),
197    Status404(UserFacingError),
198    Status429(UserFacingError),
199    UnknownValue(serde_json::Value),
200}
201
202/// struct for typed errors of method [`disable_user2fa`]
203#[derive(Debug, Clone, Serialize, Deserialize)]
204#[serde(untagged)]
205pub enum DisableUser2faError {
206    Status401(serde_json::Value),
207    Status404(serde_json::Value),
208    UnknownValue(serde_json::Value),
209}
210
211/// struct for typed errors of method [`enable_user`]
212#[derive(Debug, Clone, Serialize, Deserialize)]
213#[serde(untagged)]
214pub enum EnableUserError {
215    Status401(serde_json::Value),
216    Status404(serde_json::Value),
217    UnknownValue(serde_json::Value),
218}
219
220/// struct for typed errors of method [`fetch_user_by_email`]
221#[derive(Debug, Clone, Serialize, Deserialize)]
222#[serde(untagged)]
223pub enum FetchUserByEmailError {
224    Status401(serde_json::Value),
225    Status404(serde_json::Value),
226    UnknownValue(serde_json::Value),
227}
228
229/// struct for typed errors of method [`fetch_user_by_id`]
230#[derive(Debug, Clone, Serialize, Deserialize)]
231#[serde(untagged)]
232pub enum FetchUserByIdError {
233    Status401(serde_json::Value),
234    Status404(serde_json::Value),
235    UnknownValue(serde_json::Value),
236}
237
238/// struct for typed errors of method [`fetch_user_by_username`]
239#[derive(Debug, Clone, Serialize, Deserialize)]
240#[serde(untagged)]
241pub enum FetchUserByUsernameError {
242    Status401(serde_json::Value),
243    Status404(serde_json::Value),
244    UnknownValue(serde_json::Value),
245}
246
247/// struct for typed errors of method [`fetch_users_by_emails`]
248#[derive(Debug, Clone, Serialize, Deserialize)]
249#[serde(untagged)]
250pub enum FetchUsersByEmailsError {
251    Status400(crate::models::BadFetchUsersByEmailsQuery),
252    Status401(serde_json::Value),
253    UnknownValue(serde_json::Value),
254}
255
256/// struct for typed errors of method [`fetch_users_by_ids`]
257#[derive(Debug, Clone, Serialize, Deserialize)]
258#[serde(untagged)]
259pub enum FetchUsersByIdsError {
260    Status400(crate::models::BadFetchUsersByIdsQuery),
261    Status401(serde_json::Value),
262    UnknownValue(serde_json::Value),
263}
264
265/// struct for typed errors of method [`fetch_users_by_query`]
266#[derive(Debug, Clone, Serialize, Deserialize)]
267#[serde(untagged)]
268pub enum FetchUsersByQueryError {
269    Status400(crate::models::BadFetchUsersByQuery),
270    Status401(serde_json::Value),
271    UnknownValue(serde_json::Value),
272}
273
274/// struct for typed errors of method [`fetch_users_by_usernames`]
275#[derive(Debug, Clone, Serialize, Deserialize)]
276#[serde(untagged)]
277pub enum FetchUsersByUsernamesError {
278    Status400(crate::models::BadFetchUsersByUsernamesQuery),
279    Status401(serde_json::Value),
280    UnknownValue(serde_json::Value),
281}
282
283/// struct for typed errors of method [`migrate_user`]
284#[derive(Debug, Clone, Serialize, Deserialize)]
285#[serde(untagged)]
286pub enum MigrateUserError {
287    Status400(crate::models::BadMigrateUserRequest),
288    Status401(serde_json::Value),
289    UnknownValue(serde_json::Value),
290}
291
292/// struct for typed errors of method [`migrate_user_password`]
293#[derive(Debug, Clone, Serialize, Deserialize)]
294#[serde(untagged)]
295pub enum MigrateUserPasswordError {
296    Status400(crate::models::BadMigrateUserPasswordRequest),
297    Status401(serde_json::Value),
298    UnknownValue(serde_json::Value),
299}
300
301/// struct for typed errors of method [`update_user_email`]
302#[derive(Debug, Clone, Serialize, Deserialize)]
303#[serde(untagged)]
304pub enum UpdateUserEmailError {
305    Status400(crate::models::BadUpdateUserEmailRequest),
306    Status401(serde_json::Value),
307    Status404(serde_json::Value),
308    Status429(serde_json::Value),
309    UnknownValue(serde_json::Value),
310}
311
312/// struct for typed errors of method [`update_user_metadata`]
313#[derive(Debug, Clone, Serialize, Deserialize)]
314#[serde(untagged)]
315pub enum UpdateUserMetadataError {
316    Status400(crate::models::BadUpdateUserMetadataRequest),
317    Status401(serde_json::Value),
318    Status404(serde_json::Value),
319    UnknownValue(serde_json::Value),
320}
321
322/// struct for typed errors of method [`update_user_password`]
323#[derive(Debug, Clone, Serialize, Deserialize)]
324#[serde(untagged)]
325pub enum UpdateUserPasswordError {
326    Status400(crate::models::BadUpdatePasswordRequest),
327    Status401(serde_json::Value),
328    Status404(serde_json::Value),
329    UnknownValue(serde_json::Value),
330}
331
332/// struct for typed errors of method [`clear_user_password`]
333#[derive(Debug, Clone, Serialize, Deserialize)]
334#[serde(untagged)]
335pub enum ClearUserPasswordError {
336    Status401(serde_json::Value),
337    Status404(serde_json::Value),
338    UnknownValue(serde_json::Value),
339}
340
341/// struct for typed errors of method [`invite_user_to_org`]
342#[derive(Debug, Clone, Serialize, Deserialize)]
343#[serde(untagged)]
344pub enum InviteUserToOrgError {
345    Status400(serde_json::Value),
346    Status401(serde_json::Value),
347    Status404(serde_json::Value),
348    UnknownValue(serde_json::Value),
349}
350
351pub async fn create_magic_link(
352    configuration: &configuration::Configuration,
353    params: CreateMagicLinkParams,
354) -> Result<crate::models::MagicLink, Error<CreateMagicLinkError>> {
355    let local_var_configuration = configuration;
356
357    // unbox the parameters
358    let create_magic_link_request = params.create_magic_link_request;
359
360    let local_var_client = &local_var_configuration.client;
361
362    let local_var_uri_str = format!(
363        "{}/api/backend/v1/magic_link",
364        local_var_configuration.base_path
365    );
366    let mut local_var_req_builder =
367        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
368
369    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
370        local_var_req_builder =
371            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
372    }
373    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
374        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
375    };
376    local_var_req_builder = local_var_req_builder.header(
377        AUTH_HOSTNAME_HEADER,
378        local_var_configuration.auth_hostname.to_owned(),
379    );
380
381    local_var_req_builder = local_var_req_builder.json(&create_magic_link_request);
382
383    let local_var_req = local_var_req_builder.build()?;
384    let local_var_resp = local_var_client.execute(local_var_req).await?;
385
386    let local_var_status = local_var_resp.status();
387    let local_var_content = local_var_resp.text().await?;
388
389    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
390        serde_json::from_str(&local_var_content).map_err(Error::from)
391    } else {
392        let local_var_entity: Option<CreateMagicLinkError> =
393            serde_json::from_str(&local_var_content).ok();
394        let local_var_error = ResponseContent {
395            status: local_var_status,
396            content: local_var_content,
397            entity: local_var_entity,
398        };
399        Err(Error::ResponseError(local_var_error))
400    }
401}
402
403pub async fn create_user(
404    configuration: &configuration::Configuration,
405    params: CreateUserParams,
406) -> Result<crate::models::CreatedUserResponse, Error<CreateUserError>> {
407    let local_var_configuration = configuration;
408
409    // unbox the parameters
410    let create_user_request = params.create_user_request;
411
412    let local_var_client = &local_var_configuration.client;
413
414    let local_var_uri_str = format!("{}/api/backend/v1/user/", local_var_configuration.base_path);
415    let mut local_var_req_builder =
416        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
417
418    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
419        local_var_req_builder =
420            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
421    }
422    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
423        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
424    };
425    local_var_req_builder = local_var_req_builder.header(
426        AUTH_HOSTNAME_HEADER,
427        local_var_configuration.auth_hostname.to_owned(),
428    );
429
430    local_var_req_builder = local_var_req_builder.json(&create_user_request);
431
432    let local_var_req = local_var_req_builder.build()?;
433    let local_var_resp = local_var_client.execute(local_var_req).await?;
434
435    let local_var_status = local_var_resp.status();
436    let local_var_content = local_var_resp.text().await?;
437
438    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
439        serde_json::from_str(&local_var_content).map_err(Error::from)
440    } else {
441        let local_var_entity: Option<CreateUserError> =
442            serde_json::from_str(&local_var_content).ok();
443        let local_var_error = ResponseContent {
444            status: local_var_status,
445            content: local_var_content,
446            entity: local_var_entity,
447        };
448        Err(Error::ResponseError(local_var_error))
449    }
450}
451
452pub async fn delete_user(
453    configuration: &configuration::Configuration,
454    params: DeleteUserParams,
455) -> Result<crate::models::SuccessfulResponse, Error<DeleteUserError>> {
456    let local_var_configuration = configuration;
457
458    // unbox the parameters
459    let user_id = params.user_id;
460
461    let local_var_client = &local_var_configuration.client;
462
463    let local_var_uri_str = format!(
464        "{}/api/backend/v1/user/{user_id}",
465        local_var_configuration.base_path,
466        user_id = crate::apis::urlencode(user_id)
467    );
468    let mut local_var_req_builder =
469        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
470
471    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
472        local_var_req_builder =
473            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
474    }
475    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
476        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
477    };
478    local_var_req_builder = local_var_req_builder.header(
479        AUTH_HOSTNAME_HEADER,
480        local_var_configuration.auth_hostname.to_owned(),
481    );
482
483    let local_var_req = local_var_req_builder.build()?;
484    let local_var_resp = local_var_client.execute(local_var_req).await?;
485
486    let local_var_status = local_var_resp.status();
487    let local_var_content = local_var_resp.text().await?;
488
489    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
490        serde_json::from_str(&local_var_content).map_err(Error::from)
491    } else {
492        let local_var_entity: Option<DeleteUserError> =
493            serde_json::from_str(&local_var_content).ok();
494        let local_var_error = ResponseContent {
495            status: local_var_status,
496            content: local_var_content,
497            entity: local_var_entity,
498        };
499        Err(Error::ResponseError(local_var_error))
500    }
501}
502
503pub async fn disable_user(
504    configuration: &configuration::Configuration,
505    params: DisableUserParams,
506) -> Result<crate::models::SuccessfulResponse, Error<DisableUserError>> {
507    let local_var_configuration = configuration;
508
509    // unbox the parameters
510    let user_id = params.user_id;
511
512    let local_var_client = &local_var_configuration.client;
513
514    let local_var_uri_str = format!(
515        "{}/api/backend/v1/user/{user_id}/disable",
516        local_var_configuration.base_path,
517        user_id = crate::apis::urlencode(user_id)
518    );
519    let mut local_var_req_builder =
520        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
521
522    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
523        local_var_req_builder =
524            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
525    }
526    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
527        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
528    };
529    local_var_req_builder = local_var_req_builder.header(
530        AUTH_HOSTNAME_HEADER,
531        local_var_configuration.auth_hostname.to_owned(),
532    );
533
534    let local_var_req = local_var_req_builder.build()?;
535    let local_var_resp = local_var_client.execute(local_var_req).await?;
536
537    let local_var_status = local_var_resp.status();
538    let local_var_content = local_var_resp.text().await?;
539
540    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
541        serde_json::from_str(&local_var_content).map_err(Error::from)
542    } else {
543        let local_var_entity: Option<DisableUserError> =
544            serde_json::from_str(&local_var_content).ok();
545        let local_var_error = ResponseContent {
546            status: local_var_status,
547            content: local_var_content,
548            entity: local_var_entity,
549        };
550        Err(Error::ResponseError(local_var_error))
551    }
552}
553
554pub async fn resend_email_confirmation(
555    configuration: &configuration::Configuration,
556    user_id: String,
557) -> Result<crate::models::SuccessfulResponse, Error<ResendEmailConfirmationError>> {
558    let local_var_configuration = configuration;
559
560    let local_var_client = &local_var_configuration.client;
561
562    let request = ResendEmailConfirmationRequest { user_id };
563
564    let local_var_uri_str = format!(
565        "{}/api/backend/v1/resend_email_confirmation",
566        local_var_configuration.base_path,
567    );
568    let mut local_var_req_builder =
569        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
570
571    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
572        local_var_req_builder =
573            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
574    }
575    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
576        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
577    };
578    local_var_req_builder = local_var_req_builder.header(
579        AUTH_HOSTNAME_HEADER,
580        local_var_configuration.auth_hostname.to_owned(),
581    );
582
583    local_var_req_builder = local_var_req_builder.json(&request);
584
585    let local_var_req = local_var_req_builder.build()?;
586    let local_var_resp = local_var_client.execute(local_var_req).await?;
587
588    let local_var_status = local_var_resp.status();
589    let local_var_content = local_var_resp.text().await?;
590
591    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
592        serde_json::from_str(&local_var_content).map_err(Error::from)
593    } else {
594        let local_var_entity: Option<ResendEmailConfirmationError> =
595            serde_json::from_str(&local_var_content).ok();
596        let local_var_error = ResponseContent {
597            status: local_var_status,
598            content: local_var_content,
599            entity: local_var_entity,
600        };
601        Err(Error::ResponseError(local_var_error))
602    }
603}
604
605pub async fn logout_all_user_sessions(
606    configuration: &configuration::Configuration,
607    user_id: String,
608) -> Result<crate::models::SuccessfulResponse, Error<LogoutAllUserSessionsError>> {
609    let local_var_configuration = configuration;
610
611    let local_var_client = &local_var_configuration.client;
612
613    let local_var_uri_str = format!(
614        "{}/api/backend/v1/user/{user_id}/logout_all_sessions",
615        local_var_configuration.base_path,
616        user_id = crate::apis::urlencode(user_id)
617    );
618    let mut local_var_req_builder =
619        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
620
621    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
622        local_var_req_builder =
623            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
624    }
625    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
626        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
627    };
628    local_var_req_builder = local_var_req_builder.header(
629        AUTH_HOSTNAME_HEADER,
630        local_var_configuration.auth_hostname.to_owned(),
631    );
632
633    let local_var_req = local_var_req_builder.build()?;
634    let local_var_resp = local_var_client.execute(local_var_req).await?;
635
636    let local_var_status = local_var_resp.status();
637    let local_var_content = local_var_resp.text().await?;
638
639    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
640        serde_json::from_str(&local_var_content).map_err(Error::from)
641    } else {
642        let local_var_entity: Option<LogoutAllUserSessionsError> =
643            serde_json::from_str(&local_var_content).ok();
644        let local_var_error = ResponseContent {
645            status: local_var_status,
646            content: local_var_content,
647            entity: local_var_entity,
648        };
649        Err(Error::ResponseError(local_var_error))
650    }
651}
652
653pub async fn disable_user2fa(
654    configuration: &configuration::Configuration,
655    params: DisableUser2faParams,
656) -> Result<crate::models::SuccessfulResponse, Error<DisableUser2faError>> {
657    let local_var_configuration = configuration;
658
659    // unbox the parameters
660    let user_id = params.user_id;
661
662    let local_var_client = &local_var_configuration.client;
663
664    let local_var_uri_str = format!(
665        "{}/api/backend/v1/user/{user_id}/disable_2fa",
666        local_var_configuration.base_path,
667        user_id = crate::apis::urlencode(user_id)
668    );
669    let mut local_var_req_builder =
670        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
671
672    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
673        local_var_req_builder =
674            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
675    }
676    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
677        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
678    };
679    local_var_req_builder = local_var_req_builder.header(
680        AUTH_HOSTNAME_HEADER,
681        local_var_configuration.auth_hostname.to_owned(),
682    );
683
684    let local_var_req = local_var_req_builder.build()?;
685    let local_var_resp = local_var_client.execute(local_var_req).await?;
686
687    let local_var_status = local_var_resp.status();
688    let local_var_content = local_var_resp.text().await?;
689
690    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
691        serde_json::from_str(&local_var_content).map_err(Error::from)
692    } else {
693        let local_var_entity: Option<DisableUser2faError> =
694            serde_json::from_str(&local_var_content).ok();
695        let local_var_error = ResponseContent {
696            status: local_var_status,
697            content: local_var_content,
698            entity: local_var_entity,
699        };
700        Err(Error::ResponseError(local_var_error))
701    }
702}
703
704pub async fn enable_user(
705    configuration: &configuration::Configuration,
706    params: EnableUserParams,
707) -> Result<crate::models::SuccessfulResponse, Error<EnableUserError>> {
708    let local_var_configuration = configuration;
709
710    // unbox the parameters
711    let user_id = params.user_id;
712
713    let local_var_client = &local_var_configuration.client;
714
715    let local_var_uri_str = format!(
716        "{}/api/backend/v1/user/{user_id}/enable",
717        local_var_configuration.base_path,
718        user_id = crate::apis::urlencode(user_id)
719    );
720    let mut local_var_req_builder =
721        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
722
723    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
724        local_var_req_builder =
725            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
726    }
727    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
728        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
729    };
730    local_var_req_builder = local_var_req_builder.header(
731        AUTH_HOSTNAME_HEADER,
732        local_var_configuration.auth_hostname.to_owned(),
733    );
734
735    let local_var_req = local_var_req_builder.build()?;
736    let local_var_resp = local_var_client.execute(local_var_req).await?;
737
738    let local_var_status = local_var_resp.status();
739    let local_var_content = local_var_resp.text().await?;
740
741    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
742        serde_json::from_str(&local_var_content).map_err(Error::from)
743    } else {
744        let local_var_entity: Option<EnableUserError> =
745            serde_json::from_str(&local_var_content).ok();
746        let local_var_error = ResponseContent {
747            status: local_var_status,
748            content: local_var_content,
749            entity: local_var_entity,
750        };
751        Err(Error::ResponseError(local_var_error))
752    }
753}
754
755pub async fn fetch_user_by_email(
756    configuration: &configuration::Configuration,
757    params: FetchUserByEmailParams,
758) -> Result<crate::models::UserMetadata, Error<FetchUserByEmailError>> {
759    let local_var_configuration = configuration;
760
761    // unbox the parameters
762    let email = params.email;
763    let include_orgs = params.include_orgs;
764
765    let local_var_client = &local_var_configuration.client;
766
767    let local_var_uri_str = format!(
768        "{}/api/backend/v1/user/email",
769        local_var_configuration.base_path
770    );
771    let mut local_var_req_builder =
772        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
773
774    local_var_req_builder = local_var_req_builder.query(&[("email", &email.to_string())]);
775    if let Some(ref local_var_str) = include_orgs {
776        local_var_req_builder =
777            local_var_req_builder.query(&[("include_orgs", &local_var_str.to_string())]);
778    }
779    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
780        local_var_req_builder =
781            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
782    }
783    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
784        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
785    };
786    local_var_req_builder = local_var_req_builder.header(
787        AUTH_HOSTNAME_HEADER,
788        local_var_configuration.auth_hostname.to_owned(),
789    );
790
791    let local_var_req = local_var_req_builder.build()?;
792    let local_var_resp = local_var_client.execute(local_var_req).await?;
793
794    let local_var_status = local_var_resp.status();
795    let local_var_content = local_var_resp.text().await?;
796
797    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
798        serde_json::from_str(&local_var_content).map_err(Error::from)
799    } else {
800        let local_var_entity: Option<FetchUserByEmailError> =
801            serde_json::from_str(&local_var_content).ok();
802        let local_var_error = ResponseContent {
803            status: local_var_status,
804            content: local_var_content,
805            entity: local_var_entity,
806        };
807        Err(Error::ResponseError(local_var_error))
808    }
809}
810
811pub async fn fetch_user_by_id(
812    configuration: &configuration::Configuration,
813    params: FetchUserByIdParams,
814) -> Result<crate::models::UserMetadata, Error<FetchUserByIdError>> {
815    let local_var_configuration = configuration;
816
817    // unbox the parameters
818    let user_id = params.user_id;
819    let include_orgs = params.include_orgs;
820
821    let local_var_client = &local_var_configuration.client;
822
823    let local_var_uri_str = format!(
824        "{}/api/backend/v1/user/{user_id}",
825        local_var_configuration.base_path,
826        user_id = crate::apis::urlencode(user_id)
827    );
828    let mut local_var_req_builder =
829        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
830
831    if let Some(ref local_var_str) = include_orgs {
832        local_var_req_builder =
833            local_var_req_builder.query(&[("include_orgs", &local_var_str.to_string())]);
834    }
835    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
836        local_var_req_builder =
837            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
838    }
839    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
840        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
841    };
842    local_var_req_builder = local_var_req_builder.header(
843        AUTH_HOSTNAME_HEADER,
844        local_var_configuration.auth_hostname.to_owned(),
845    );
846
847    let local_var_req = local_var_req_builder.build()?;
848    let local_var_resp = local_var_client.execute(local_var_req).await?;
849
850    let local_var_status = local_var_resp.status();
851    let local_var_content = local_var_resp.text().await?;
852
853    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
854        serde_json::from_str(&local_var_content).map_err(Error::from)
855    } else {
856        let local_var_entity: Option<FetchUserByIdError> =
857            serde_json::from_str(&local_var_content).ok();
858        let local_var_error = ResponseContent {
859            status: local_var_status,
860            content: local_var_content,
861            entity: local_var_entity,
862        };
863        Err(Error::ResponseError(local_var_error))
864    }
865}
866
867pub async fn fetch_user_by_username(
868    configuration: &configuration::Configuration,
869    params: FetchUserByUsernameParams,
870) -> Result<crate::models::UserMetadata, Error<FetchUserByUsernameError>> {
871    let local_var_configuration = configuration;
872
873    // unbox the parameters
874    let username = params.username;
875    let include_orgs = params.include_orgs;
876
877    let local_var_client = &local_var_configuration.client;
878
879    let local_var_uri_str = format!(
880        "{}/api/backend/v1/user/username",
881        local_var_configuration.base_path
882    );
883    let mut local_var_req_builder =
884        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
885
886    if let Some(ref local_var_str) = include_orgs {
887        local_var_req_builder =
888            local_var_req_builder.query(&[("include_orgs", &local_var_str.to_string())]);
889    }
890    local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]);
891    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
892        local_var_req_builder =
893            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
894    }
895    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
896        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
897    };
898    local_var_req_builder = local_var_req_builder.header(
899        AUTH_HOSTNAME_HEADER,
900        local_var_configuration.auth_hostname.to_owned(),
901    );
902
903    let local_var_req = local_var_req_builder.build()?;
904    let local_var_resp = local_var_client.execute(local_var_req).await?;
905
906    let local_var_status = local_var_resp.status();
907    let local_var_content = local_var_resp.text().await?;
908
909    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
910        serde_json::from_str(&local_var_content).map_err(Error::from)
911    } else {
912        let local_var_entity: Option<FetchUserByUsernameError> =
913            serde_json::from_str(&local_var_content).ok();
914        let local_var_error = ResponseContent {
915            status: local_var_status,
916            content: local_var_content,
917            entity: local_var_entity,
918        };
919        Err(Error::ResponseError(local_var_error))
920    }
921}
922
923pub async fn fetch_users_by_emails(
924    configuration: &configuration::Configuration,
925    params: FetchUsersByEmailsParams,
926) -> Result<Vec<crate::models::UserMetadata>, Error<FetchUsersByEmailsError>> {
927    let local_var_configuration = configuration;
928
929    // unbox the parameters
930    let emails_query = params.emails_query;
931    let include_orgs = params.include_orgs;
932
933    let local_var_client = &local_var_configuration.client;
934
935    let local_var_uri_str = format!(
936        "{}/api/backend/v1/user/emails",
937        local_var_configuration.base_path
938    );
939    let mut local_var_req_builder =
940        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
941
942    if let Some(ref local_var_str) = include_orgs {
943        local_var_req_builder =
944            local_var_req_builder.query(&[("include_orgs", &local_var_str.to_string())]);
945    }
946    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
947        local_var_req_builder =
948            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
949    }
950    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
951        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
952    };
953    local_var_req_builder = local_var_req_builder.header(
954        AUTH_HOSTNAME_HEADER,
955        local_var_configuration.auth_hostname.to_owned(),
956    );
957
958    local_var_req_builder = local_var_req_builder.json(&emails_query);
959
960    let local_var_req = local_var_req_builder.build()?;
961    let local_var_resp = local_var_client.execute(local_var_req).await?;
962
963    let local_var_status = local_var_resp.status();
964    let local_var_content = local_var_resp.text().await?;
965
966    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
967        serde_json::from_str(&local_var_content).map_err(Error::from)
968    } else {
969        let local_var_entity: Option<FetchUsersByEmailsError> =
970            serde_json::from_str(&local_var_content).ok();
971        let local_var_error = ResponseContent {
972            status: local_var_status,
973            content: local_var_content,
974            entity: local_var_entity,
975        };
976        Err(Error::ResponseError(local_var_error))
977    }
978}
979
980pub async fn fetch_users_by_ids(
981    configuration: &configuration::Configuration,
982    params: FetchUsersByIdsParams,
983) -> Result<Vec<crate::models::UserMetadata>, Error<FetchUsersByIdsError>> {
984    let local_var_configuration = configuration;
985
986    // unbox the parameters
987    let user_ids_query = params.user_ids_query;
988    let include_orgs = params.include_orgs;
989
990    let local_var_client = &local_var_configuration.client;
991
992    let local_var_uri_str = format!(
993        "{}/api/backend/v1/user/user_ids",
994        local_var_configuration.base_path
995    );
996    let mut local_var_req_builder =
997        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
998
999    if let Some(ref local_var_str) = include_orgs {
1000        local_var_req_builder =
1001            local_var_req_builder.query(&[("include_orgs", &local_var_str.to_string())]);
1002    }
1003    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1004        local_var_req_builder =
1005            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1006    }
1007    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1008        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1009    };
1010    local_var_req_builder = local_var_req_builder.header(
1011        AUTH_HOSTNAME_HEADER,
1012        local_var_configuration.auth_hostname.to_owned(),
1013    );
1014
1015    local_var_req_builder = local_var_req_builder.json(&user_ids_query);
1016
1017    let local_var_req = local_var_req_builder.build()?;
1018    let local_var_resp = local_var_client.execute(local_var_req).await?;
1019
1020    let local_var_status = local_var_resp.status();
1021    let local_var_content = local_var_resp.text().await?;
1022
1023    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1024        serde_json::from_str(&local_var_content).map_err(Error::from)
1025    } else {
1026        let local_var_entity: Option<FetchUsersByIdsError> =
1027            serde_json::from_str(&local_var_content).ok();
1028        let local_var_error = ResponseContent {
1029            status: local_var_status,
1030            content: local_var_content,
1031            entity: local_var_entity,
1032        };
1033        Err(Error::ResponseError(local_var_error))
1034    }
1035}
1036
1037pub async fn fetch_users_by_query(
1038    configuration: &configuration::Configuration,
1039    params: FetchUsersByQueryParams,
1040) -> Result<crate::models::UserPagedResponse, Error<FetchUsersByQueryError>> {
1041    let local_var_configuration = configuration;
1042
1043    // unbox the parameters
1044    let page_size = params.page_size;
1045    let page_number = params.page_number;
1046    let order_by = params.order_by;
1047    let email_or_username = params.email_or_username;
1048    let include_orgs = params.include_orgs;
1049    let legacy_user_id = params.legacy_user_id;
1050
1051    let local_var_client = &local_var_configuration.client;
1052
1053    let local_var_uri_str = format!(
1054        "{}/api/backend/v1/user/query",
1055        local_var_configuration.base_path
1056    );
1057    let mut local_var_req_builder =
1058        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1059
1060    if let Some(ref local_var_str) = page_size {
1061        local_var_req_builder =
1062            local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]);
1063    }
1064    if let Some(ref local_var_str) = page_number {
1065        local_var_req_builder =
1066            local_var_req_builder.query(&[("page_number", &local_var_str.to_string())]);
1067    }
1068    if let Some(ref local_var_str) = order_by {
1069        local_var_req_builder =
1070            local_var_req_builder.query(&[("order_by", &local_var_str.to_string())]);
1071    }
1072    if let Some(ref local_var_str) = email_or_username {
1073        local_var_req_builder =
1074            local_var_req_builder.query(&[("email_or_username", &local_var_str.to_string())]);
1075    }
1076    if let Some(ref local_var_str) = include_orgs {
1077        local_var_req_builder =
1078            local_var_req_builder.query(&[("include_orgs", &local_var_str.to_string())]);
1079    }
1080    if let Some(ref local_var_str) = legacy_user_id {
1081        local_var_req_builder =
1082            local_var_req_builder.query(&[("legacy_user_id", &local_var_str.to_string())]);
1083    }
1084    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1085        local_var_req_builder =
1086            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1087    }
1088    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1089        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1090    };
1091    local_var_req_builder = local_var_req_builder.header(
1092        AUTH_HOSTNAME_HEADER,
1093        local_var_configuration.auth_hostname.to_owned(),
1094    );
1095
1096    let local_var_req = local_var_req_builder.build()?;
1097    let local_var_resp = local_var_client.execute(local_var_req).await?;
1098
1099    let local_var_status = local_var_resp.status();
1100    let local_var_content = local_var_resp.text().await?;
1101
1102    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1103        serde_json::from_str(&local_var_content).map_err(Error::from)
1104    } else {
1105        let local_var_entity: Option<FetchUsersByQueryError> =
1106            serde_json::from_str(&local_var_content).ok();
1107        let local_var_error = ResponseContent {
1108            status: local_var_status,
1109            content: local_var_content,
1110            entity: local_var_entity,
1111        };
1112        Err(Error::ResponseError(local_var_error))
1113    }
1114}
1115
1116pub async fn fetch_users_by_usernames(
1117    configuration: &configuration::Configuration,
1118    params: FetchUsersByUsernamesParams,
1119) -> Result<Vec<crate::models::UserMetadata>, Error<FetchUsersByUsernamesError>> {
1120    let local_var_configuration = configuration;
1121
1122    // unbox the parameters
1123    let usernames_query = params.usernames_query;
1124    let include_orgs = params.include_orgs;
1125
1126    let local_var_client = &local_var_configuration.client;
1127
1128    let local_var_uri_str = format!(
1129        "{}/api/backend/v1/user/usernames",
1130        local_var_configuration.base_path
1131    );
1132    let mut local_var_req_builder =
1133        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1134
1135    if let Some(ref local_var_str) = include_orgs {
1136        local_var_req_builder =
1137            local_var_req_builder.query(&[("include_orgs", &local_var_str.to_string())]);
1138    }
1139    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1140        local_var_req_builder =
1141            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1142    }
1143    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1144        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1145    };
1146    local_var_req_builder = local_var_req_builder.header(
1147        AUTH_HOSTNAME_HEADER,
1148        local_var_configuration.auth_hostname.to_owned(),
1149    );
1150
1151    local_var_req_builder = local_var_req_builder.json(&usernames_query);
1152
1153    let local_var_req = local_var_req_builder.build()?;
1154    let local_var_resp = local_var_client.execute(local_var_req).await?;
1155
1156    let local_var_status = local_var_resp.status();
1157    let local_var_content = local_var_resp.text().await?;
1158
1159    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1160        serde_json::from_str(&local_var_content).map_err(Error::from)
1161    } else {
1162        let local_var_entity: Option<FetchUsersByUsernamesError> =
1163            serde_json::from_str(&local_var_content).ok();
1164        let local_var_error = ResponseContent {
1165            status: local_var_status,
1166            content: local_var_content,
1167            entity: local_var_entity,
1168        };
1169        Err(Error::ResponseError(local_var_error))
1170    }
1171}
1172
1173pub async fn migrate_user(
1174    configuration: &configuration::Configuration,
1175    params: MigrateUserParams,
1176) -> Result<crate::models::CreatedUserResponse, Error<MigrateUserError>> {
1177    let local_var_configuration = configuration;
1178
1179    // unbox the parameters
1180    let migrate_user_request = params.migrate_user_request;
1181
1182    let local_var_client = &local_var_configuration.client;
1183
1184    let local_var_uri_str = format!(
1185        "{}/api/backend/v1/migrate_user/",
1186        local_var_configuration.base_path
1187    );
1188    let mut local_var_req_builder =
1189        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1190
1191    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1192        local_var_req_builder =
1193            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1194    }
1195    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1196        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1197    };
1198    local_var_req_builder = local_var_req_builder.header(
1199        AUTH_HOSTNAME_HEADER,
1200        local_var_configuration.auth_hostname.to_owned(),
1201    );
1202
1203    local_var_req_builder = local_var_req_builder.json(&migrate_user_request);
1204
1205    let local_var_req = local_var_req_builder.build()?;
1206    let local_var_resp = local_var_client.execute(local_var_req).await?;
1207
1208    let local_var_status = local_var_resp.status();
1209    let local_var_content = local_var_resp.text().await?;
1210
1211    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1212        serde_json::from_str(&local_var_content).map_err(Error::from)
1213    } else {
1214        let local_var_entity: Option<MigrateUserError> =
1215            serde_json::from_str(&local_var_content).ok();
1216        let local_var_error = ResponseContent {
1217            status: local_var_status,
1218            content: local_var_content,
1219            entity: local_var_entity,
1220        };
1221        Err(Error::ResponseError(local_var_error))
1222    }
1223}
1224
1225pub async fn migrate_user_password(
1226    configuration: &configuration::Configuration,
1227    params: MigrateUserPasswordParams,
1228) -> Result<crate::models::SuccessfulResponse, Error<MigrateUserPasswordError>> {
1229    let local_var_configuration = configuration;
1230
1231    // unbox the parameters
1232    let migrate_user_password_request = params.migrate_user_password_request;
1233
1234    let local_var_client = &local_var_configuration.client;
1235
1236    let local_var_uri_str = format!(
1237        "{}/api/backend/v1/migrate_user/password",
1238        local_var_configuration.base_path
1239    );
1240    let mut local_var_req_builder =
1241        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1242
1243    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1244        local_var_req_builder =
1245            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1246    }
1247    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1248        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1249    };
1250    local_var_req_builder = local_var_req_builder.header(
1251        AUTH_HOSTNAME_HEADER,
1252        local_var_configuration.auth_hostname.to_owned(),
1253    );
1254
1255    local_var_req_builder = local_var_req_builder.json(&migrate_user_password_request);
1256
1257    let local_var_req = local_var_req_builder.build()?;
1258    let local_var_resp = local_var_client.execute(local_var_req).await?;
1259
1260    let local_var_status = local_var_resp.status();
1261    let local_var_content = local_var_resp.text().await?;
1262
1263    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1264        serde_json::from_str(&local_var_content).map_err(Error::from)
1265    } else {
1266        let local_var_entity: Option<MigrateUserPasswordError> =
1267            serde_json::from_str(&local_var_content).ok();
1268        let local_var_error = ResponseContent {
1269            status: local_var_status,
1270            content: local_var_content,
1271            entity: local_var_entity,
1272        };
1273        Err(Error::ResponseError(local_var_error))
1274    }
1275}
1276
1277pub async fn update_user_email(
1278    configuration: &configuration::Configuration,
1279    params: UpdateUserEmailParams,
1280) -> Result<crate::models::SuccessfulResponse, Error<UpdateUserEmailError>> {
1281    let local_var_configuration = configuration;
1282
1283    // unbox the parameters
1284    let user_id = params.user_id;
1285    let update_email_request = params.update_email_request;
1286
1287    let local_var_client = &local_var_configuration.client;
1288
1289    let local_var_uri_str = format!(
1290        "{}/api/backend/v1/user/{user_id}/email",
1291        local_var_configuration.base_path,
1292        user_id = crate::apis::urlencode(user_id)
1293    );
1294    let mut local_var_req_builder =
1295        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1296
1297    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1298        local_var_req_builder =
1299            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1300    }
1301    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1302        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1303    };
1304    local_var_req_builder = local_var_req_builder.header(
1305        AUTH_HOSTNAME_HEADER,
1306        local_var_configuration.auth_hostname.to_owned(),
1307    );
1308
1309    local_var_req_builder = local_var_req_builder.json(&update_email_request);
1310
1311    let local_var_req = local_var_req_builder.build()?;
1312    let local_var_resp = local_var_client.execute(local_var_req).await?;
1313
1314    let local_var_status = local_var_resp.status();
1315    let local_var_content = local_var_resp.text().await?;
1316
1317    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1318        serde_json::from_str(&local_var_content).map_err(Error::from)
1319    } else {
1320        let local_var_entity: Option<UpdateUserEmailError> =
1321            serde_json::from_str(&local_var_content).ok();
1322        let local_var_error = ResponseContent {
1323            status: local_var_status,
1324            content: local_var_content,
1325            entity: local_var_entity,
1326        };
1327        Err(Error::ResponseError(local_var_error))
1328    }
1329}
1330
1331pub async fn update_user_metadata(
1332    configuration: &configuration::Configuration,
1333    params: UpdateUserMetadataParams,
1334) -> Result<crate::models::SuccessfulResponse, Error<UpdateUserMetadataError>> {
1335    let local_var_configuration = configuration;
1336
1337    // unbox the parameters
1338    let user_id = params.user_id;
1339    let update_metadata_request = params.update_metadata_request;
1340
1341    let local_var_client = &local_var_configuration.client;
1342
1343    let local_var_uri_str = format!(
1344        "{}/api/backend/v1/user/{user_id}",
1345        local_var_configuration.base_path,
1346        user_id = crate::apis::urlencode(user_id)
1347    );
1348    let mut local_var_req_builder =
1349        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1350
1351    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1352        local_var_req_builder =
1353            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1354    }
1355    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1356        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1357    };
1358    local_var_req_builder = local_var_req_builder.header(
1359        AUTH_HOSTNAME_HEADER,
1360        local_var_configuration.auth_hostname.to_owned(),
1361    );
1362
1363    local_var_req_builder = local_var_req_builder.json(&update_metadata_request);
1364
1365    let local_var_req = local_var_req_builder.build()?;
1366    let local_var_resp = local_var_client.execute(local_var_req).await?;
1367
1368    let local_var_status = local_var_resp.status();
1369    let local_var_content = local_var_resp.text().await?;
1370
1371    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1372        serde_json::from_str(&local_var_content).map_err(Error::from)
1373    } else {
1374        let local_var_entity: Option<UpdateUserMetadataError> =
1375            serde_json::from_str(&local_var_content).ok();
1376        let local_var_error = ResponseContent {
1377            status: local_var_status,
1378            content: local_var_content,
1379            entity: local_var_entity,
1380        };
1381        Err(Error::ResponseError(local_var_error))
1382    }
1383}
1384
1385pub async fn update_user_password(
1386    configuration: &configuration::Configuration,
1387    params: UpdateUserPasswordParams,
1388) -> Result<crate::models::SuccessfulResponse, Error<UpdateUserPasswordError>> {
1389    let local_var_configuration = configuration;
1390
1391    // unbox the parameters
1392    let user_id = params.user_id;
1393    let update_password_request = params.update_password_request;
1394
1395    let local_var_client = &local_var_configuration.client;
1396
1397    let local_var_uri_str = format!(
1398        "{}/api/backend/v1/user/{user_id}/password",
1399        local_var_configuration.base_path,
1400        user_id = crate::apis::urlencode(user_id)
1401    );
1402    let mut local_var_req_builder =
1403        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1404
1405    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1406        local_var_req_builder =
1407            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1408    }
1409    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1410        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1411    };
1412    local_var_req_builder = local_var_req_builder.header(
1413        AUTH_HOSTNAME_HEADER,
1414        local_var_configuration.auth_hostname.to_owned(),
1415    );
1416
1417    local_var_req_builder = local_var_req_builder.json(&update_password_request);
1418
1419    let local_var_req = local_var_req_builder.build()?;
1420    let local_var_resp = local_var_client.execute(local_var_req).await?;
1421
1422    let local_var_status = local_var_resp.status();
1423    let local_var_content = local_var_resp.text().await?;
1424
1425    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1426        serde_json::from_str(&local_var_content).map_err(Error::from)
1427    } else {
1428        let local_var_entity: Option<UpdateUserPasswordError> =
1429            serde_json::from_str(&local_var_content).ok();
1430        let local_var_error = ResponseContent {
1431            status: local_var_status,
1432            content: local_var_content,
1433            entity: local_var_entity,
1434        };
1435        Err(Error::ResponseError(local_var_error))
1436    }
1437}
1438
1439pub async fn clear_user_password(
1440    configuration: &configuration::Configuration,
1441    user_id: String,
1442) -> Result<crate::models::SuccessfulResponse, Error<ClearUserPasswordError>> {
1443    let local_var_configuration = configuration;
1444
1445    let local_var_client = &local_var_configuration.client;
1446
1447    let local_var_uri_str = format!(
1448        "{}/api/backend/v1/user/{user_id}/clear_password",
1449        local_var_configuration.base_path,
1450        user_id = crate::apis::urlencode(user_id)
1451    );
1452    let mut local_var_req_builder =
1453        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1454
1455    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1456        local_var_req_builder =
1457            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1458    }
1459    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1460        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1461    };
1462    local_var_req_builder = local_var_req_builder.header(
1463        AUTH_HOSTNAME_HEADER,
1464        local_var_configuration.auth_hostname.to_owned(),
1465    );
1466
1467    let local_var_req = local_var_req_builder.build()?;
1468    let local_var_resp = local_var_client.execute(local_var_req).await?;
1469
1470    let local_var_status = local_var_resp.status();
1471    let local_var_content = local_var_resp.text().await?;
1472
1473    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1474        serde_json::from_str(&local_var_content).map_err(Error::from)
1475    } else {
1476        let local_var_entity: Option<ClearUserPasswordError> =
1477            serde_json::from_str(&local_var_content).ok();
1478        let local_var_error = ResponseContent {
1479            status: local_var_status,
1480            content: local_var_content,
1481            entity: local_var_entity,
1482        };
1483        Err(Error::ResponseError(local_var_error))
1484    }
1485}
1486
1487pub async fn enable_user_can_create_orgs(
1488    configuration: &configuration::Configuration,
1489    user_id: String,
1490) -> Result<crate::models::SuccessfulResponse, Error<DisableUser2faError>> {
1491    let local_var_configuration = configuration;
1492
1493    let local_var_client = &local_var_configuration.client;
1494
1495    let local_var_uri_str = format!(
1496        "{}/api/backend/v1/user/{user_id}/can_create_orgs/enable",
1497        local_var_configuration.base_path,
1498        user_id = crate::apis::urlencode(user_id)
1499    );
1500    let mut local_var_req_builder =
1501        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1502
1503    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1504        local_var_req_builder =
1505            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1506    }
1507    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1508        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1509    };
1510    local_var_req_builder = local_var_req_builder.header(
1511        AUTH_HOSTNAME_HEADER,
1512        local_var_configuration.auth_hostname.to_owned(),
1513    );
1514
1515    let local_var_req = local_var_req_builder.build()?;
1516    let local_var_resp = local_var_client.execute(local_var_req).await?;
1517
1518    let local_var_status = local_var_resp.status();
1519    let local_var_content = local_var_resp.text().await?;
1520
1521    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1522        serde_json::from_str(&local_var_content).map_err(Error::from)
1523    } else {
1524        let local_var_entity: Option<DisableUser2faError> =
1525            serde_json::from_str(&local_var_content).ok();
1526        let local_var_error = ResponseContent {
1527            status: local_var_status,
1528            content: local_var_content,
1529            entity: local_var_entity,
1530        };
1531        Err(Error::ResponseError(local_var_error))
1532    }
1533}
1534
1535pub async fn disable_user_can_create_orgs(
1536    configuration: &configuration::Configuration,
1537    user_id: String,
1538) -> Result<crate::models::SuccessfulResponse, Error<DisableUser2faError>> {
1539    let local_var_configuration = configuration;
1540
1541    let local_var_client = &local_var_configuration.client;
1542
1543    let local_var_uri_str = format!(
1544        "{}/api/backend/v1/user/{user_id}/can_create_orgs/disable",
1545        local_var_configuration.base_path,
1546        user_id = crate::apis::urlencode(user_id)
1547    );
1548    let mut local_var_req_builder =
1549        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1550
1551    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1552        local_var_req_builder =
1553            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1554    }
1555    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1556        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1557    };
1558    local_var_req_builder = local_var_req_builder.header(
1559        AUTH_HOSTNAME_HEADER,
1560        local_var_configuration.auth_hostname.to_owned(),
1561    );
1562
1563    let local_var_req = local_var_req_builder.build()?;
1564    let local_var_resp = local_var_client.execute(local_var_req).await?;
1565
1566    let local_var_status = local_var_resp.status();
1567    let local_var_content = local_var_resp.text().await?;
1568
1569    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1570        serde_json::from_str(&local_var_content).map_err(Error::from)
1571    } else {
1572        let local_var_entity: Option<DisableUser2faError> =
1573            serde_json::from_str(&local_var_content).ok();
1574        let local_var_error = ResponseContent {
1575            status: local_var_status,
1576            content: local_var_content,
1577            entity: local_var_entity,
1578        };
1579        Err(Error::ResponseError(local_var_error))
1580    }
1581}
1582
1583pub async fn invite_user_to_org(
1584    configuration: &configuration::Configuration,
1585    params: InviteUserToOrgRequest,
1586) -> Result<String, Error<InviteUserToOrgError>> {
1587    let local_var_configuration = configuration;
1588
1589    // unbox the parameters
1590    let invite_user_to_org_request = params;
1591
1592    let local_var_client = &local_var_configuration.client;
1593
1594    let local_var_uri_str = format!(
1595        "{}/api/backend/v1/invite_user",
1596        local_var_configuration.base_path
1597    );
1598    let mut local_var_req_builder =
1599        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1600
1601    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1602        local_var_req_builder =
1603            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1604    }
1605    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1606        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1607    };
1608    local_var_req_builder = local_var_req_builder.header(
1609        AUTH_HOSTNAME_HEADER,
1610        local_var_configuration.auth_hostname.to_owned(),
1611    );
1612
1613    local_var_req_builder = local_var_req_builder.json(&invite_user_to_org_request);
1614
1615    let local_var_req = local_var_req_builder.build()?;
1616    let local_var_resp = local_var_client.execute(local_var_req).await?;
1617
1618    let local_var_status = local_var_resp.status();
1619    let local_var_content = local_var_resp.text().await?;
1620
1621    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1622        Ok(local_var_content)
1623    } else {
1624        let local_var_entity: Option<InviteUserToOrgError> =
1625            serde_json::from_str(&local_var_content).ok();
1626        let local_var_error = ResponseContent {
1627            status: local_var_status,
1628            content: local_var_content,
1629            entity: local_var_entity,
1630        };
1631        Err(Error::ResponseError(local_var_error))
1632    }
1633}