slack_chat_api/admin_usergroups.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct AdminUsergroups {
5 pub client: Client,
6}
7
8impl AdminUsergroups {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 AdminUsergroups { client }
12 }
13
14 /**
15 * This function performs a `POST` to the `/admin.usergroups.addChannels` endpoint.
16 *
17 * Add one or more default channels to an IDP group.
18 *
19 * FROM: <https://api.slack.com/methods/admin.usergroups.addChannels>
20 *
21 * **Parameters:**
22 *
23 * * `token: &str` -- Authentication token. Requires scope: `admin.usergroups:write`.
24 */
25 pub async fn add_channels(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
26 let url = self.client.url("/admin.usergroups.addChannels", 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.usergroups.addTeams` endpoint.
39 *
40 * Associate one or more default workspaces with an organization-wide IDP group.
41 *
42 * FROM: <https://api.slack.com/methods/admin.usergroups.addTeams>
43 *
44 * **Parameters:**
45 *
46 * * `token: &str` -- Authentication token. Requires scope: `admin.teams:write`.
47 */
48 pub async fn add_teams(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
49 let url = self.client.url("/admin.usergroups.addTeams", 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.usergroups.listChannels` endpoint.
62 *
63 * List the channels linked to an org-level IDP group (user group).
64 *
65 * FROM: <https://api.slack.com/methods/admin.usergroups.listChannels>
66 *
67 * **Parameters:**
68 *
69 * * `token: &str` -- Authentication token. Requires scope: `admin.usergroups:read`.
70 * * `usergroup_id: &str` -- ID of the IDP group to list default channels for.
71 * * `team_id: &str` -- ID of the the workspace.
72 * * `include_num_members: bool` -- Flag to include or exclude the count of members per channel.
73 */
74 pub async fn list_channel(
75 &self,
76 usergroup_id: &str,
77 team_id: &str,
78 include_num_members: bool,
79 ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
80 let mut query_args: Vec<(String, String)> = Default::default();
81 if include_num_members {
82 query_args.push((
83 "include_num_members".to_string(),
84 include_num_members.to_string(),
85 ));
86 }
87 if !team_id.is_empty() {
88 query_args.push(("team_id".to_string(), team_id.to_string()));
89 }
90 if !usergroup_id.is_empty() {
91 query_args.push(("usergroup_id".to_string(), usergroup_id.to_string()));
92 }
93 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
94 let url = self
95 .client
96 .url(&format!("/admin.usergroups.listChannels?{}", query_), None);
97 self.client
98 .get(
99 &url,
100 crate::Message {
101 body: None,
102 content_type: None,
103 },
104 )
105 .await
106 }
107 /**
108 * This function performs a `POST` to the `/admin.usergroups.removeChannels` endpoint.
109 *
110 * Remove one or more default channels from an org-level IDP group (user group).
111 *
112 * FROM: <https://api.slack.com/methods/admin.usergroups.removeChannels>
113 *
114 * **Parameters:**
115 *
116 * * `token: &str` -- Authentication token. Requires scope: `admin.usergroups:write`.
117 */
118 pub async fn remove_channels(
119 &self,
120 ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
121 let url = self.client.url("/admin.usergroups.removeChannels", None);
122 self.client
123 .post(
124 &url,
125 crate::Message {
126 body: None,
127 content_type: Some("application/x-www-form-urlencoded".to_string()),
128 },
129 )
130 .await
131 }
132}