mattermost_client/openapi/apis/
migrate_api.rs

1/*
2 * Mattermost API Reference
3 *
4 * There is also a work-in-progress [Postman API reference](https://documenter.getpostman.com/view/4508214/RW8FERUn).
5 *
6 * The version of the OpenAPI document: 4.0.0
7 * Contact: feedback@mattermost.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12
13use super::{configuration, Error};
14use super::ResponseContent;
15
16/// struct for passing parameters to the method [`migrate_auth_to_ldap`]
17#[derive(Clone, Debug, Default)]
18pub struct MigrateAuthToLdapParams {
19    pub migrate_auth_to_ldap_request: Option<crate::openapi::models::MigrateAuthToLdapRequest>,
20}
21
22/// struct for passing parameters to the method [`migrate_auth_to_saml`]
23#[derive(Clone, Debug, Default)]
24pub struct MigrateAuthToSamlParams {
25    pub migrate_auth_to_saml_request: Option<crate::openapi::models::MigrateAuthToSamlRequest>,
26}
27
28/// struct for typed errors of method [`migrate_auth_to_ldap`]
29#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
30#[serde(untagged)]
31pub enum MigrateAuthToLdapError {
32    Status400(crate::openapi::models::AppError),
33    Status401(crate::openapi::models::AppError),
34    Status403(crate::openapi::models::AppError),
35    Status501(crate::openapi::models::AppError),
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`migrate_auth_to_saml`]
40#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
41#[serde(untagged)]
42pub enum MigrateAuthToSamlError {
43    Status400(crate::openapi::models::AppError),
44    Status401(crate::openapi::models::AppError),
45    Status403(crate::openapi::models::AppError),
46    Status501(crate::openapi::models::AppError),
47    UnknownValue(serde_json::Value),
48}
49
50/// Migrates accounts from one authentication provider to another. For example, you can upgrade your authentication provider from email to LDAP. __Minimum server version__: 5.28 ##### Permissions Must have `manage_system` permission.
51pub async fn migrate_auth_to_ldap(
52    configuration: &configuration::Configuration,
53    params: MigrateAuthToLdapParams,
54) -> Result<(), Error<MigrateAuthToLdapError>> {
55    let local_var_configuration = configuration;
56
57    // unbox the parameters
58    let migrate_auth_to_ldap_request = params.migrate_auth_to_ldap_request;
59
60    let local_var_client = &local_var_configuration.client;
61
62    let local_var_uri_str = format!(
63        "{}/api/v4/users/migrate_auth/ldap",
64        local_var_configuration.base_path
65    );
66    let mut local_var_req_builder =
67        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
68
69    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
70        local_var_req_builder =
71            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
72    }
73    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
74        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
75    };
76    local_var_req_builder = local_var_req_builder.json(&migrate_auth_to_ldap_request);
77
78    let local_var_req = local_var_req_builder.build()?;
79    let local_var_resp = local_var_client.execute(local_var_req).await?;
80
81    let local_var_status = local_var_resp.status();
82    let local_var_content = local_var_resp.text().await?;
83
84    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
85        Ok(())
86    } else {
87        let local_var_entity: Option<MigrateAuthToLdapError> =
88            serde_json::from_str(&local_var_content).ok();
89        let local_var_error = ResponseContent {
90            status: local_var_status,
91            content: local_var_content,
92            entity: local_var_entity,
93        };
94        Err(Error::ResponseError(local_var_error))
95    }
96}
97
98/// Migrates accounts from one authentication provider to another. For example, you can upgrade your authentication provider from email to SAML. __Minimum server version__: 5.28 ##### Permissions Must have `manage_system` permission.
99pub async fn migrate_auth_to_saml(
100    configuration: &configuration::Configuration,
101    params: MigrateAuthToSamlParams,
102) -> Result<(), Error<MigrateAuthToSamlError>> {
103    let local_var_configuration = configuration;
104
105    // unbox the parameters
106    let migrate_auth_to_saml_request = params.migrate_auth_to_saml_request;
107
108    let local_var_client = &local_var_configuration.client;
109
110    let local_var_uri_str = format!(
111        "{}/api/v4/users/migrate_auth/saml",
112        local_var_configuration.base_path
113    );
114    let mut local_var_req_builder =
115        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
116
117    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
118        local_var_req_builder =
119            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
120    }
121    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
122        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
123    };
124    local_var_req_builder = local_var_req_builder.json(&migrate_auth_to_saml_request);
125
126    let local_var_req = local_var_req_builder.build()?;
127    let local_var_resp = local_var_client.execute(local_var_req).await?;
128
129    let local_var_status = local_var_resp.status();
130    let local_var_content = local_var_resp.text().await?;
131
132    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
133        Ok(())
134    } else {
135        let local_var_entity: Option<MigrateAuthToSamlError> =
136            serde_json::from_str(&local_var_content).ok();
137        let local_var_error = ResponseContent {
138            status: local_var_status,
139            content: local_var_content,
140            entity: local_var_entity,
141        };
142        Err(Error::ResponseError(local_var_error))
143    }
144}