Skip to main content

slack_web_api/api/
migration.rs

1// このファイルは codegen/generate.py が生成する。手で編集しない
2
3#![allow(unused_imports)]
4
5use crate::objects::*;
6use crate::{
7    CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
8};
9use serde::{Deserialize, Serialize};
10
11/// Arguments for the Slack Web API method [`migration.exchange`](https://docs.slack.dev/reference/methods/migration.exchange): For Enterprise organization workspaces, map local user IDs to global user IDs
12///
13/// Send it with [`SlackClient::migration_exchange`].
14#[doc(alias = "migration.exchange")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct MigrationExchangeRequest {
18    /// A comma-separated list of user ids, up to 400 per request
19    #[serde(serialize_with = "crate::form::as_json")]
20    pub users: Vec<serde_json::Value>,
21    /// Specify team\_id starts with `T` in case of Org Token
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub team_id: Option<String>,
24    /// Specify `true` to convert `W` global user IDs to workspace-specific `U` IDs. Defaults to `false`.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub to_old: Option<bool>,
27}
28
29impl MigrationExchangeRequest {
30    pub fn new(users: Vec<serde_json::Value>) -> Self {
31        Self {
32            users,
33            team_id: None,
34            to_old: None,
35        }
36    }
37
38    pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
39        self.team_id = Some(team_id.into());
40        self
41    }
42
43    pub fn to_old(mut self, to_old: bool) -> Self {
44        self.to_old = Some(to_old);
45        self
46    }
47}
48
49impl SlackApiMethod for MigrationExchangeRequest {
50    const METHOD: &'static str = "migration.exchange";
51    type Response = MigrationExchangeResponse;
52}
53
54/// Successful response of the Slack Web API method [`migration.exchange`](https://docs.slack.dev/reference/methods/migration.exchange).
55#[doc(alias = "migration.exchange")]
56#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
57pub struct MigrationExchangeResponse {
58    #[serde(
59        default,
60        deserialize_with = "crate::de::opt_string",
61        skip_serializing_if = "Option::is_none"
62    )]
63    pub team_id: Option<String>,
64    #[serde(
65        default,
66        deserialize_with = "crate::de::opt_string",
67        skip_serializing_if = "Option::is_none"
68    )]
69    pub enterprise_id: Option<String>,
70    #[serde(
71        default,
72        deserialize_with = "crate::de::opt_object",
73        skip_serializing_if = "Option::is_none"
74    )]
75    pub user_id_map: Option<std::collections::HashMap<String, String>>,
76    #[serde(
77        default,
78        deserialize_with = "crate::de::vec",
79        skip_serializing_if = "Vec::is_empty"
80    )]
81    pub invalid_user_ids: Vec<String>,
82    #[serde(
83        default,
84        deserialize_with = "crate::de::opt_object",
85        skip_serializing_if = "Option::is_none"
86    )]
87    pub response_metadata: Option<ResponseMetadata>,
88    #[serde(
89        default,
90        deserialize_with = "crate::de::opt_string",
91        skip_serializing_if = "Option::is_none"
92    )]
93    pub warning: Option<String>,
94}
95
96impl SlackClient {
97    /// Calls the Slack Web API method [`migration.exchange`](https://docs.slack.dev/reference/methods/migration.exchange): For Enterprise organization workspaces, map local user IDs to global user IDs
98    ///
99    /// Required scopes:
100    ///
101    /// - bot token: `tokens.basic`
102    /// - user token: `tokens.basic`
103    ///
104    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
105    ///
106    /// # Errors
107    ///
108    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
109    #[doc(alias = "migration.exchange")]
110    pub async fn migration_exchange(
111        &self,
112        request: &MigrationExchangeRequest,
113    ) -> Result<MigrationExchangeResponse, SlackError> {
114        self.call(request).await
115    }
116}