1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
use anyhow::Result;
use crate::Client;
pub struct AdminConversations {
pub client: Client,
}
impl AdminConversations {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
AdminConversations { client }
}
/**
* This function performs a `POST` to the `/admin.conversations.archive` endpoint.
*
* Archive a public or private channel.
*
* FROM: <https://api.slack.com/methods/admin.conversations.archive>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
*/
pub async fn archive(&self) -> Result<crate::types::DndEndSchema> {
let url = "/admin.conversations.archive".to_string();
self.client.post(&url, None).await
}
/**
* This function performs a `POST` to the `/admin.conversations.convertToPrivate` endpoint.
*
* Convert a public channel to a private channel.
*
* FROM: <https://api.slack.com/methods/admin.conversations.convertToPrivate>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
*/
pub async fn convert_private(&self) -> Result<crate::types::DndEndSchema> {
let url = "/admin.conversations.convertToPrivate".to_string();
self.client.post(&url, None).await
}
/**
* This function performs a `POST` to the `/admin.conversations.create` endpoint.
*
* Create a public or private channel-based conversation.
*
* FROM: <https://api.slack.com/methods/admin.conversations.create>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
*/
pub async fn create(&self) -> Result<crate::types::AdminConversationsCreateSchema> {
let url = "/admin.conversations.create".to_string();
self.client.post(&url, None).await
}
/**
* This function performs a `POST` to the `/admin.conversations.delete` endpoint.
*
* Delete a public or private channel.
*
* FROM: <https://api.slack.com/methods/admin.conversations.delete>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
*/
pub async fn delete(&self) -> Result<crate::types::DndEndSchema> {
let url = "/admin.conversations.delete".to_string();
self.client.post(&url, None).await
}
/**
* This function performs a `POST` to the `/admin.conversations.disconnectShared` endpoint.
*
* Disconnect a connected channel from one or more workspaces.
*
* FROM: <https://api.slack.com/methods/admin.conversations.disconnectShared>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
*/
pub async fn disconnect_shared(&self) -> Result<crate::types::DndEndSchema> {
let url = "/admin.conversations.disconnectShared".to_string();
self.client.post(&url, None).await
}
/**
* This function performs a `GET` to the `/admin.conversations.getConversationPrefs` endpoint.
*
* Get conversation preferences for a public or private channel.
*
* FROM: <https://api.slack.com/methods/admin.conversations.getConversationPrefs>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:read`.
* * `channel_id: &str` -- The channel to get preferences for.
*/
pub async fn get_conversation_pref(
&self,
channel_id: &str,
) -> Result<crate::types::AdminConversationsGetConversationPrefsSchemaData> {
let mut query_args: Vec<(String, String)> = Default::default();
if !channel_id.is_empty() {
query_args.push(("channel_id".to_string(), channel_id.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!("/admin.conversations.getConversationPrefs?{}", query_);
self.client.get(&url, None).await
}
/**
* This function performs a `GET` to the `/admin.conversations.getTeams` endpoint.
*
* Get all the workspaces a given public or private channel is connected to within this Enterprise org.
*
* FROM: <https://api.slack.com/methods/admin.conversations.getTeams>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:read`.
* * `channel_id: &str` -- The channel to determine connected workspaces within the organization for.
* * `cursor: &str` -- Set `cursor` to `next_cursor` returned by the previous call to list items in the next page.
* * `limit: i64` -- The maximum number of items to return. Must be between 1 - 1000 both inclusive.
*/
pub async fn get_team(
&self,
channel_id: &str,
cursor: &str,
limit: i64,
) -> Result<crate::types::AdminConversationsGetTeamsSchema> {
let mut query_args: Vec<(String, String)> = Default::default();
if !channel_id.is_empty() {
query_args.push(("channel_id".to_string(), channel_id.to_string()));
}
if !cursor.is_empty() {
query_args.push(("cursor".to_string(), cursor.to_string()));
}
if limit > 0 {
query_args.push(("limit".to_string(), limit.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!("/admin.conversations.getTeams?{}", query_);
self.client.get(&url, None).await
}
/**
* This function performs a `POST` to the `/admin.conversations.invite` endpoint.
*
* Invite a user to a public or private channel.
*
* FROM: <https://api.slack.com/methods/admin.conversations.invite>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
*/
pub async fn invite(&self) -> Result<crate::types::DndEndSchema> {
let url = "/admin.conversations.invite".to_string();
self.client.post(&url, None).await
}
/**
* This function performs a `POST` to the `/admin.conversations.rename` endpoint.
*
* Rename a public or private channel.
*
* FROM: <https://api.slack.com/methods/admin.conversations.rename>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
*/
pub async fn rename(&self) -> Result<crate::types::DndEndSchema> {
let url = "/admin.conversations.rename".to_string();
self.client.post(&url, None).await
}
/**
* This function performs a `GET` to the `/admin.conversations.search` endpoint.
*
* Search for public or private channels in an Enterprise organization.
*
* FROM: <https://api.slack.com/methods/admin.conversations.search>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:read`.
* * `team_ids: &str` -- Comma separated string of team IDs, signifying the workspaces to search through.
* * `query: &str` -- Name of the the channel to query by.
* * `limit: i64` -- Maximum number of items to be returned. Must be between 1 - 20 both inclusive. Default is 10.
* * `cursor: &str` -- Set `cursor` to `next_cursor` returned by the previous call to list items in the next page.
* * `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).
* * `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 .
* * `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).
*/
pub async fn search(
&self,
team_ids: &str,
query: &str,
limit: i64,
cursor: &str,
search_channel_types: &str,
sort: &str,
sort_dir: &str,
) -> Result<crate::types::AdminConversationsSearchSchema> {
let mut query_args: Vec<(String, String)> = Default::default();
if !cursor.is_empty() {
query_args.push(("cursor".to_string(), cursor.to_string()));
}
if limit > 0 {
query_args.push(("limit".to_string(), limit.to_string()));
}
if !query.is_empty() {
query_args.push(("query".to_string(), query.to_string()));
}
if !search_channel_types.is_empty() {
query_args.push((
"search_channel_types".to_string(),
search_channel_types.to_string(),
));
}
if !sort.is_empty() {
query_args.push(("sort".to_string(), sort.to_string()));
}
if !sort_dir.is_empty() {
query_args.push(("sort_dir".to_string(), sort_dir.to_string()));
}
if !team_ids.is_empty() {
query_args.push(("team_ids".to_string(), team_ids.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!("/admin.conversations.search?{}", query_);
self.client.get(&url, None).await
}
/**
* This function performs a `POST` to the `/admin.conversations.setConversationPrefs` endpoint.
*
* Set the posting permissions for a public or private channel.
*
* FROM: <https://api.slack.com/methods/admin.conversations.setConversationPrefs>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
*/
pub async fn set_conversation_prefs(&self) -> Result<crate::types::DndEndSchema> {
let url = "/admin.conversations.setConversationPrefs".to_string();
self.client.post(&url, None).await
}
/**
* This function performs a `POST` to the `/admin.conversations.setTeams` endpoint.
*
* Set the workspaces in an Enterprise grid org that connect to a public or private channel.
*
* FROM: <https://api.slack.com/methods/admin.conversations.setTeams>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
*/
pub async fn set_teams(&self) -> Result<crate::types::DndEndSchema> {
let url = "/admin.conversations.setTeams".to_string();
self.client.post(&url, None).await
}
/**
* This function performs a `POST` to the `/admin.conversations.unarchive` endpoint.
*
* Unarchive a public or private channel.
*
* FROM: <https://api.slack.com/methods/admin.conversations.unarchive>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.conversations:write`.
*/
pub async fn unarchive(&self) -> Result<crate::types::DndEndSchema> {
let url = "/admin.conversations.unarchive".to_string();
self.client.post(&url, None).await
}
}