slack_chat_api/admin_conversations.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct AdminConversations {
5 pub client: Client,
6}
7
8impl AdminConversations {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 AdminConversations { client }
12 }
13
14 /**
15 * This function performs a `POST` to the `/admin.conversations.archive` endpoint.
16 *
17 * Archive a public or private channel.
18 *
19 * FROM: <https://api.slack.com/methods/admin.conversations.archive>
20 *
21 * **Parameters:**
22 *
23 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
24 */
25 pub async fn archive(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
26 let url = self.client.url("/admin.conversations.archive", 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.conversations.convertToPrivate` endpoint.
39 *
40 * Convert a public channel to a private channel.
41 *
42 * FROM: <https://api.slack.com/methods/admin.conversations.convertToPrivate>
43 *
44 * **Parameters:**
45 *
46 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
47 */
48 pub async fn convert_private(
49 &self,
50 ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
51 let url = self
52 .client
53 .url("/admin.conversations.convertToPrivate", None);
54 self.client
55 .post(
56 &url,
57 crate::Message {
58 body: None,
59 content_type: Some("application/x-www-form-urlencoded".to_string()),
60 },
61 )
62 .await
63 }
64 /**
65 * This function performs a `POST` to the `/admin.conversations.create` endpoint.
66 *
67 * Create a public or private channel-based conversation.
68 *
69 * FROM: <https://api.slack.com/methods/admin.conversations.create>
70 *
71 * **Parameters:**
72 *
73 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
74 */
75 pub async fn create(
76 &self,
77 ) -> ClientResult<crate::Response<crate::types::AdminConversationsCreateSchema>> {
78 let url = self.client.url("/admin.conversations.create", None);
79 self.client
80 .post(
81 &url,
82 crate::Message {
83 body: None,
84 content_type: Some("application/x-www-form-urlencoded".to_string()),
85 },
86 )
87 .await
88 }
89 /**
90 * This function performs a `POST` to the `/admin.conversations.delete` endpoint.
91 *
92 * Delete a public or private channel.
93 *
94 * FROM: <https://api.slack.com/methods/admin.conversations.delete>
95 *
96 * **Parameters:**
97 *
98 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
99 */
100 pub async fn delete(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
101 let url = self.client.url("/admin.conversations.delete", None);
102 self.client
103 .post(
104 &url,
105 crate::Message {
106 body: None,
107 content_type: Some("application/x-www-form-urlencoded".to_string()),
108 },
109 )
110 .await
111 }
112 /**
113 * This function performs a `POST` to the `/admin.conversations.disconnectShared` endpoint.
114 *
115 * Disconnect a connected channel from one or more workspaces.
116 *
117 * FROM: <https://api.slack.com/methods/admin.conversations.disconnectShared>
118 *
119 * **Parameters:**
120 *
121 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
122 */
123 pub async fn disconnect_shared(
124 &self,
125 ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
126 let url = self
127 .client
128 .url("/admin.conversations.disconnectShared", None);
129 self.client
130 .post(
131 &url,
132 crate::Message {
133 body: None,
134 content_type: Some("application/x-www-form-urlencoded".to_string()),
135 },
136 )
137 .await
138 }
139 /**
140 * This function performs a `GET` to the `/admin.conversations.getConversationPrefs` endpoint.
141 *
142 * Get conversation preferences for a public or private channel.
143 *
144 * FROM: <https://api.slack.com/methods/admin.conversations.getConversationPrefs>
145 *
146 * **Parameters:**
147 *
148 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:read`.
149 * * `channel_id: &str` -- The channel to get preferences for.
150 */
151 pub async fn get_conversation_pref(
152 &self,
153 channel_id: &str,
154 ) -> ClientResult<crate::Response<crate::types::AdminConversationsGetConversationPrefsSchemaData>>
155 {
156 let mut query_args: Vec<(String, String)> = Default::default();
157 if !channel_id.is_empty() {
158 query_args.push(("channel_id".to_string(), channel_id.to_string()));
159 }
160 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
161 let url = self.client.url(
162 &format!("/admin.conversations.getConversationPrefs?{}", query_),
163 None,
164 );
165 self.client
166 .get(
167 &url,
168 crate::Message {
169 body: None,
170 content_type: None,
171 },
172 )
173 .await
174 }
175 /**
176 * This function performs a `GET` to the `/admin.conversations.getTeams` endpoint.
177 *
178 * Get all the workspaces a given public or private channel is connected to within this Enterprise org.
179 *
180 * FROM: <https://api.slack.com/methods/admin.conversations.getTeams>
181 *
182 * **Parameters:**
183 *
184 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:read`.
185 * * `channel_id: &str` -- The channel to determine connected workspaces within the organization for.
186 * * `cursor: &str` -- Set `cursor` to `next_cursor` returned by the previous call to list items in the next page.
187 * * `limit: i64` -- The maximum number of items to return. Must be between 1 - 1000 both inclusive.
188 */
189 pub async fn get_team(
190 &self,
191 channel_id: &str,
192 cursor: &str,
193 limit: i64,
194 ) -> ClientResult<crate::Response<crate::types::AdminConversationsGetTeamsSchema>> {
195 let mut query_args: Vec<(String, String)> = Default::default();
196 if !channel_id.is_empty() {
197 query_args.push(("channel_id".to_string(), channel_id.to_string()));
198 }
199 if !cursor.is_empty() {
200 query_args.push(("cursor".to_string(), cursor.to_string()));
201 }
202 if limit > 0 {
203 query_args.push(("limit".to_string(), limit.to_string()));
204 }
205 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
206 let url = self
207 .client
208 .url(&format!("/admin.conversations.getTeams?{}", query_), None);
209 self.client
210 .get(
211 &url,
212 crate::Message {
213 body: None,
214 content_type: None,
215 },
216 )
217 .await
218 }
219 /**
220 * This function performs a `POST` to the `/admin.conversations.invite` endpoint.
221 *
222 * Invite a user to a public or private channel.
223 *
224 * FROM: <https://api.slack.com/methods/admin.conversations.invite>
225 *
226 * **Parameters:**
227 *
228 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
229 */
230 pub async fn invite(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
231 let url = self.client.url("/admin.conversations.invite", None);
232 self.client
233 .post(
234 &url,
235 crate::Message {
236 body: None,
237 content_type: Some("application/x-www-form-urlencoded".to_string()),
238 },
239 )
240 .await
241 }
242 /**
243 * This function performs a `POST` to the `/admin.conversations.rename` endpoint.
244 *
245 * Rename a public or private channel.
246 *
247 * FROM: <https://api.slack.com/methods/admin.conversations.rename>
248 *
249 * **Parameters:**
250 *
251 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
252 */
253 pub async fn rename(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
254 let url = self.client.url("/admin.conversations.rename", None);
255 self.client
256 .post(
257 &url,
258 crate::Message {
259 body: None,
260 content_type: Some("application/x-www-form-urlencoded".to_string()),
261 },
262 )
263 .await
264 }
265 /**
266 * This function performs a `GET` to the `/admin.conversations.search` endpoint.
267 *
268 * Search for public or private channels in an Enterprise organization.
269 *
270 * FROM: <https://api.slack.com/methods/admin.conversations.search>
271 *
272 * **Parameters:**
273 *
274 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:read`.
275 * * `team_ids: &str` -- Comma separated string of team IDs, signifying the workspaces to search through.
276 * * `query: &str` -- Name of the the channel to query by.
277 * * `limit: i64` -- Maximum number of items to be returned. Must be between 1 - 20 both inclusive. Default is 10.
278 * * `cursor: &str` -- Set `cursor` to `next_cursor` returned by the previous call to list items in the next page.
279 * * `search_channel_types: &str` -- The type of channel to include or exclude in the search. For example `private` will search private channels, while `private_exclude` will exclude them. For a full list of types, check the [Types section](#types).
280 * * `sort: &str` -- Possible values are `relevant` (search ranking based on what we think is closest), `name` (alphabetical), `member_count` (number of users in the channel), and `created` (date channel was created). You can optionally pair this with the `sort_dir` arg to change how it is sorted .
281 * * `sort_dir: &str` -- Sort direction. Possible values are `asc` for ascending order like (1, 2, 3) or (a, b, c), and `desc` for descending order like (3, 2, 1) or (c, b, a).
282 */
283 pub async fn search(
284 &self,
285 team_ids: &str,
286 query: &str,
287 limit: i64,
288 cursor: &str,
289 search_channel_types: &str,
290 sort: &str,
291 sort_dir: &str,
292 ) -> ClientResult<crate::Response<crate::types::AdminConversationsSearchSchema>> {
293 let mut query_args: Vec<(String, String)> = Default::default();
294 if !cursor.is_empty() {
295 query_args.push(("cursor".to_string(), cursor.to_string()));
296 }
297 if limit > 0 {
298 query_args.push(("limit".to_string(), limit.to_string()));
299 }
300 if !query.is_empty() {
301 query_args.push(("query".to_string(), query.to_string()));
302 }
303 if !search_channel_types.is_empty() {
304 query_args.push((
305 "search_channel_types".to_string(),
306 search_channel_types.to_string(),
307 ));
308 }
309 if !sort.is_empty() {
310 query_args.push(("sort".to_string(), sort.to_string()));
311 }
312 if !sort_dir.is_empty() {
313 query_args.push(("sort_dir".to_string(), sort_dir.to_string()));
314 }
315 if !team_ids.is_empty() {
316 query_args.push(("team_ids".to_string(), team_ids.to_string()));
317 }
318 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
319 let url = self
320 .client
321 .url(&format!("/admin.conversations.search?{}", query_), None);
322 self.client
323 .get(
324 &url,
325 crate::Message {
326 body: None,
327 content_type: None,
328 },
329 )
330 .await
331 }
332 /**
333 * This function performs a `POST` to the `/admin.conversations.setConversationPrefs` endpoint.
334 *
335 * Set the posting permissions for a public or private channel.
336 *
337 * FROM: <https://api.slack.com/methods/admin.conversations.setConversationPrefs>
338 *
339 * **Parameters:**
340 *
341 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
342 */
343 pub async fn set_conversation_prefs(
344 &self,
345 ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
346 let url = self
347 .client
348 .url("/admin.conversations.setConversationPrefs", None);
349 self.client
350 .post(
351 &url,
352 crate::Message {
353 body: None,
354 content_type: Some("application/x-www-form-urlencoded".to_string()),
355 },
356 )
357 .await
358 }
359 /**
360 * This function performs a `POST` to the `/admin.conversations.setTeams` endpoint.
361 *
362 * Set the workspaces in an Enterprise grid org that connect to a public or private channel.
363 *
364 * FROM: <https://api.slack.com/methods/admin.conversations.setTeams>
365 *
366 * **Parameters:**
367 *
368 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
369 */
370 pub async fn set_teams(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
371 let url = self.client.url("/admin.conversations.setTeams", None);
372 self.client
373 .post(
374 &url,
375 crate::Message {
376 body: None,
377 content_type: Some("application/x-www-form-urlencoded".to_string()),
378 },
379 )
380 .await
381 }
382 /**
383 * This function performs a `POST` to the `/admin.conversations.unarchive` endpoint.
384 *
385 * Unarchive a public or private channel.
386 *
387 * FROM: <https://api.slack.com/methods/admin.conversations.unarchive>
388 *
389 * **Parameters:**
390 *
391 * * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
392 */
393 pub async fn unarchive(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
394 let url = self.client.url("/admin.conversations.unarchive", None);
395 self.client
396 .post(
397 &url,
398 crate::Message {
399 body: None,
400 content_type: Some("application/x-www-form-urlencoded".to_string()),
401 },
402 )
403 .await
404 }
405}