slack_chat_api/admin_users.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct AdminUsers {
5 pub client: Client,
6}
7
8impl AdminUsers {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 AdminUsers { client }
12 }
13
14 /**
15 * This function performs a `POST` to the `/admin.users.assign` endpoint.
16 *
17 * Add an Enterprise user to a workspace.
18 *
19 * FROM: <https://api.slack.com/methods/admin.users.assign>
20 *
21 * **Parameters:**
22 *
23 * * `token: &str` -- Authentication token. Requires scope: `admin.users:write`.
24 */
25 pub async fn assign(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
26 let url = self.client.url("/admin.users.assign", None);
27 self.client
28 .post(
29 &url,
30 crate::Message {
31 body: None,
32 content_type: Some("application/x-www-form-urlencoded".to_string()),
33 },
34 )
35 .await
36 }
37 /**
38 * This function performs a `POST` to the `/admin.users.invite` endpoint.
39 *
40 * Invite a user to a workspace.
41 *
42 * FROM: <https://api.slack.com/methods/admin.users.invite>
43 *
44 * **Parameters:**
45 *
46 * * `token: &str` -- Authentication token. Requires scope: `admin.users:write`.
47 */
48 pub async fn invite(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
49 let url = self.client.url("/admin.users.invite", None);
50 self.client
51 .post(
52 &url,
53 crate::Message {
54 body: None,
55 content_type: Some("application/x-www-form-urlencoded".to_string()),
56 },
57 )
58 .await
59 }
60 /**
61 * This function performs a `GET` to the `/admin.users.list` endpoint.
62 *
63 * List users on a workspace
64 *
65 * FROM: <https://api.slack.com/methods/admin.users.list>
66 *
67 * **Parameters:**
68 *
69 * * `token: &str` -- Authentication token. Requires scope: `admin.users:read`.
70 * * `team_id: &str` -- The ID (`T1234`) of the workspace.
71 * * `cursor: &str` -- Set `cursor` to `next_cursor` returned by the previous call to list items in the next page.
72 * * `limit: i64` -- Limit for how many users to be retrieved per page.
73 */
74 pub async fn list(
75 &self,
76 team_id: &str,
77 cursor: &str,
78 limit: i64,
79 ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
80 let mut query_args: Vec<(String, String)> = Default::default();
81 if !cursor.is_empty() {
82 query_args.push(("cursor".to_string(), cursor.to_string()));
83 }
84 if limit > 0 {
85 query_args.push(("limit".to_string(), limit.to_string()));
86 }
87 if !team_id.is_empty() {
88 query_args.push(("team_id".to_string(), team_id.to_string()));
89 }
90 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
91 let url = self
92 .client
93 .url(&format!("/admin.users.list?{}", query_), None);
94 self.client
95 .get(
96 &url,
97 crate::Message {
98 body: None,
99 content_type: None,
100 },
101 )
102 .await
103 }
104 /**
105 * This function performs a `POST` to the `/admin.users.remove` endpoint.
106 *
107 * Remove a user from a workspace.
108 *
109 * FROM: <https://api.slack.com/methods/admin.users.remove>
110 *
111 * **Parameters:**
112 *
113 * * `token: &str` -- Authentication token. Requires scope: `admin.users:write`.
114 */
115 pub async fn remove(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
116 let url = self.client.url("/admin.users.remove", None);
117 self.client
118 .post(
119 &url,
120 crate::Message {
121 body: None,
122 content_type: Some("application/x-www-form-urlencoded".to_string()),
123 },
124 )
125 .await
126 }
127 /**
128 * This function performs a `POST` to the `/admin.users.setAdmin` endpoint.
129 *
130 * Set an existing guest, regular user, or owner to be an admin user.
131 *
132 * FROM: <https://api.slack.com/methods/admin.users.setAdmin>
133 *
134 * **Parameters:**
135 *
136 * * `token: &str` -- Authentication token. Requires scope: `admin.users:write`.
137 */
138 pub async fn set(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
139 let url = self.client.url("/admin.users.setAdmin", None);
140 self.client
141 .post(
142 &url,
143 crate::Message {
144 body: None,
145 content_type: Some("application/x-www-form-urlencoded".to_string()),
146 },
147 )
148 .await
149 }
150 /**
151 * This function performs a `POST` to the `/admin.users.setExpiration` endpoint.
152 *
153 * Set an expiration for a guest user
154 *
155 * FROM: <https://api.slack.com/methods/admin.users.setExpiration>
156 *
157 * **Parameters:**
158 *
159 * * `token: &str` -- Authentication token. Requires scope: `admin.users:write`.
160 */
161 pub async fn set_expiration(
162 &self,
163 ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
164 let url = self.client.url("/admin.users.setExpiration", None);
165 self.client
166 .post(
167 &url,
168 crate::Message {
169 body: None,
170 content_type: Some("application/x-www-form-urlencoded".to_string()),
171 },
172 )
173 .await
174 }
175 /**
176 * This function performs a `POST` to the `/admin.users.setOwner` endpoint.
177 *
178 * Set an existing guest, regular user, or admin user to be a workspace owner.
179 *
180 * FROM: <https://api.slack.com/methods/admin.users.setOwner>
181 *
182 * **Parameters:**
183 *
184 * * `token: &str` -- Authentication token. Requires scope: `admin.users:write`.
185 */
186 pub async fn set_owner(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
187 let url = self.client.url("/admin.users.setOwner", None);
188 self.client
189 .post(
190 &url,
191 crate::Message {
192 body: None,
193 content_type: Some("application/x-www-form-urlencoded".to_string()),
194 },
195 )
196 .await
197 }
198 /**
199 * This function performs a `POST` to the `/admin.users.setRegular` endpoint.
200 *
201 * Set an existing guest user, admin user, or owner to be a regular user.
202 *
203 * FROM: <https://api.slack.com/methods/admin.users.setRegular>
204 *
205 * **Parameters:**
206 *
207 * * `token: &str` -- Authentication token. Requires scope: `admin.users:write`.
208 */
209 pub async fn set_regular(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
210 let url = self.client.url("/admin.users.setRegular", None);
211 self.client
212 .post(
213 &url,
214 crate::Message {
215 body: None,
216 content_type: Some("application/x-www-form-urlencoded".to_string()),
217 },
218 )
219 .await
220 }
221}