mattermost_rust_client/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
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`migrate_auth_to_ldap`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum MigrateAuthToLdapError {
22    Status400(crate::models::AppError),
23    Status401(crate::models::AppError),
24    Status403(crate::models::AppError),
25    Status501(crate::models::AppError),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`migrate_auth_to_saml`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum MigrateAuthToSamlError {
33    Status400(crate::models::AppError),
34    Status401(crate::models::AppError),
35    Status403(crate::models::AppError),
36    Status501(crate::models::AppError),
37    UnknownValue(serde_json::Value),
38}
39
40
41/// 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. 
42pub async fn migrate_auth_to_ldap(configuration: &configuration::Configuration, migrate_auth_to_ldap_request: Option<crate::models::MigrateAuthToLdapRequest>) -> Result<(), Error<MigrateAuthToLdapError>> {
43    let local_var_configuration = configuration;
44
45    let local_var_client = &local_var_configuration.client;
46
47    let local_var_uri_str = format!("{}/users/migrate_auth/ldap", local_var_configuration.base_path);
48    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
49
50    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
51        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
52    }
53    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
54        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
55    };
56    local_var_req_builder = local_var_req_builder.json(&migrate_auth_to_ldap_request);
57
58    let local_var_req = local_var_req_builder.build()?;
59    let local_var_resp = local_var_client.execute(local_var_req).await?;
60
61    let local_var_status = local_var_resp.status();
62    let local_var_content = local_var_resp.text().await?;
63
64    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
65        Ok(())
66    } else {
67        let local_var_entity: Option<MigrateAuthToLdapError> = serde_json::from_str(&local_var_content).ok();
68        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
69        Err(Error::ResponseError(local_var_error))
70    }
71}
72
73/// 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. 
74pub async fn migrate_auth_to_saml(configuration: &configuration::Configuration, migrate_auth_to_saml_request: Option<crate::models::MigrateAuthToSamlRequest>) -> Result<(), Error<MigrateAuthToSamlError>> {
75    let local_var_configuration = configuration;
76
77    let local_var_client = &local_var_configuration.client;
78
79    let local_var_uri_str = format!("{}/users/migrate_auth/saml", local_var_configuration.base_path);
80    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
81
82    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
83        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
84    }
85    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
86        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
87    };
88    local_var_req_builder = local_var_req_builder.json(&migrate_auth_to_saml_request);
89
90    let local_var_req = local_var_req_builder.build()?;
91    let local_var_resp = local_var_client.execute(local_var_req).await?;
92
93    let local_var_status = local_var_resp.status();
94    let local_var_content = local_var_resp.text().await?;
95
96    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
97        Ok(())
98    } else {
99        let local_var_entity: Option<MigrateAuthToSamlError> = serde_json::from_str(&local_var_content).ok();
100        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
101        Err(Error::ResponseError(local_var_error))
102    }
103}
104