slack_api/mod_types/
usergroups_types.rs

1//=============================================================================
2//
3//                    WARNING: This file is AUTO-GENERATED
4//
5// Do not make changes directly to this file.
6//
7// If you would like to make a change to the library, please update the schema
8// definitions at https://github.com/slack-rs/slack-api-schemas
9//
10// If you would like to make a change how the library was generated,
11// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen
12//
13//=============================================================================
14
15//! Get info on your team's User Groups.
16
17#[allow(unused_imports)]
18use std::collections::HashMap;
19use std::convert::From;
20use std::error::Error;
21use std::fmt;
22
23#[derive(Clone, Default, Debug)]
24pub struct CreateRequest<'a> {
25    /// A name for the User Group. Must be unique among User Groups.
26    pub name: &'a str,
27    /// A mention handle. Must be unique among channels, users and User Groups.
28    pub handle: Option<&'a str>,
29    /// A short description of the User Group.
30    pub description: Option<&'a str>,
31    /// A comma separated string of encoded channel IDs for which the User Group uses as a default.
32    pub channels: Option<&'a str>,
33    /// Include the number of users in each User Group.
34    pub include_count: Option<bool>,
35}
36
37#[derive(Clone, Debug, Deserialize)]
38pub struct CreateResponse {
39    error: Option<String>,
40    #[serde(default)]
41    ok: bool,
42    pub usergroup: Option<crate::Usergroup>,
43}
44
45impl<E: Error> Into<Result<CreateResponse, CreateError<E>>> for CreateResponse {
46    fn into(self) -> Result<CreateResponse, CreateError<E>> {
47        if self.ok {
48            Ok(self)
49        } else {
50            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
51        }
52    }
53}
54#[derive(Debug)]
55pub enum CreateError<E: Error> {
56    /// No authentication token provided.
57    NotAuthed,
58    /// Invalid authentication token.
59    InvalidAuth,
60    /// Authentication token is for a deleted user or team.
61    AccountInactive,
62    /// This method cannot be called by a bot user.
63    UserIsBot,
64    /// This method cannot be called by a restricted user or single channel guest.
65    UserIsRestricted,
66    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
67    InvalidArgName,
68    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
69    InvalidArrayArg,
70    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
71    InvalidCharset,
72    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
73    InvalidFormData,
74    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
75    InvalidPostType,
76    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
77    MissingPostType,
78    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
79    TeamAddedToOrg,
80    /// The method was called via a POST request, but the POST data was either missing or truncated.
81    RequestTimeout,
82    /// The response was not parseable as the expected object
83    MalformedResponse(String, serde_json::error::Error),
84    /// The response returned an error that was unknown to the library
85    Unknown(String),
86    /// The client had an error sending the request to Slack
87    Client(E),
88}
89
90impl<'a, E: Error> From<&'a str> for CreateError<E> {
91    fn from(s: &'a str) -> Self {
92        match s {
93            "not_authed" => CreateError::NotAuthed,
94            "invalid_auth" => CreateError::InvalidAuth,
95            "account_inactive" => CreateError::AccountInactive,
96            "user_is_bot" => CreateError::UserIsBot,
97            "user_is_restricted" => CreateError::UserIsRestricted,
98            "invalid_arg_name" => CreateError::InvalidArgName,
99            "invalid_array_arg" => CreateError::InvalidArrayArg,
100            "invalid_charset" => CreateError::InvalidCharset,
101            "invalid_form_data" => CreateError::InvalidFormData,
102            "invalid_post_type" => CreateError::InvalidPostType,
103            "missing_post_type" => CreateError::MissingPostType,
104            "team_added_to_org" => CreateError::TeamAddedToOrg,
105            "request_timeout" => CreateError::RequestTimeout,
106            _ => CreateError::Unknown(s.to_owned()),
107        }
108    }
109}
110
111impl<E: Error> fmt::Display for CreateError<E> {
112    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
113        let d = match *self {
114                        CreateError::NotAuthed => "not_authed: No authentication token provided.",
115CreateError::InvalidAuth => "invalid_auth: Invalid authentication token.",
116CreateError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
117CreateError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
118CreateError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.",
119CreateError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
120CreateError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
121CreateError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
122CreateError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
123CreateError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
124CreateError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
125CreateError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
126CreateError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
127                        CreateError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
128                        CreateError::Unknown(ref s) => return write!(f, "{}", s),
129                        CreateError::Client(ref inner) => return write!(f, "{}", inner),
130                    };
131        write!(f, "{}", d)
132    }
133}
134
135impl<E: Error + 'static> Error for CreateError<E> {
136    fn source(&self) -> Option<&(dyn Error + 'static)> {
137        match *self {
138            CreateError::MalformedResponse(_, ref e) => Some(e),
139            CreateError::Client(ref inner) => Some(inner),
140            _ => None,
141        }
142    }
143}
144
145#[derive(Clone, Default, Debug)]
146pub struct DisableRequest<'a> {
147    /// The encoded ID of the User Group to disable.
148    pub usergroup: &'a str,
149    /// Include the number of users in the User Group.
150    pub include_count: Option<bool>,
151}
152
153#[derive(Clone, Debug, Deserialize)]
154pub struct DisableResponse {
155    error: Option<String>,
156    #[serde(default)]
157    ok: bool,
158    pub usergroup: Option<crate::Usergroup>,
159}
160
161impl<E: Error> Into<Result<DisableResponse, DisableError<E>>> for DisableResponse {
162    fn into(self) -> Result<DisableResponse, DisableError<E>> {
163        if self.ok {
164            Ok(self)
165        } else {
166            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
167        }
168    }
169}
170#[derive(Debug)]
171pub enum DisableError<E: Error> {
172    /// No authentication token provided.
173    NotAuthed,
174    /// Invalid authentication token.
175    InvalidAuth,
176    /// Authentication token is for a deleted user or team.
177    AccountInactive,
178    /// This method cannot be called by a bot user.
179    UserIsBot,
180    /// This method cannot be called by a restricted user or single channel guest.
181    UserIsRestricted,
182    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
183    InvalidArgName,
184    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
185    InvalidArrayArg,
186    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
187    InvalidCharset,
188    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
189    InvalidFormData,
190    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
191    InvalidPostType,
192    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
193    MissingPostType,
194    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
195    TeamAddedToOrg,
196    /// The method was called via a POST request, but the POST data was either missing or truncated.
197    RequestTimeout,
198    /// The response was not parseable as the expected object
199    MalformedResponse(String, serde_json::error::Error),
200    /// The response returned an error that was unknown to the library
201    Unknown(String),
202    /// The client had an error sending the request to Slack
203    Client(E),
204}
205
206impl<'a, E: Error> From<&'a str> for DisableError<E> {
207    fn from(s: &'a str) -> Self {
208        match s {
209            "not_authed" => DisableError::NotAuthed,
210            "invalid_auth" => DisableError::InvalidAuth,
211            "account_inactive" => DisableError::AccountInactive,
212            "user_is_bot" => DisableError::UserIsBot,
213            "user_is_restricted" => DisableError::UserIsRestricted,
214            "invalid_arg_name" => DisableError::InvalidArgName,
215            "invalid_array_arg" => DisableError::InvalidArrayArg,
216            "invalid_charset" => DisableError::InvalidCharset,
217            "invalid_form_data" => DisableError::InvalidFormData,
218            "invalid_post_type" => DisableError::InvalidPostType,
219            "missing_post_type" => DisableError::MissingPostType,
220            "team_added_to_org" => DisableError::TeamAddedToOrg,
221            "request_timeout" => DisableError::RequestTimeout,
222            _ => DisableError::Unknown(s.to_owned()),
223        }
224    }
225}
226
227impl<E: Error> fmt::Display for DisableError<E> {
228    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
229        let d = match *self {
230                        DisableError::NotAuthed => "not_authed: No authentication token provided.",
231DisableError::InvalidAuth => "invalid_auth: Invalid authentication token.",
232DisableError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
233DisableError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
234DisableError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.",
235DisableError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
236DisableError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
237DisableError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
238DisableError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
239DisableError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
240DisableError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
241DisableError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
242DisableError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
243                        DisableError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
244                        DisableError::Unknown(ref s) => return write!(f, "{}", s),
245                        DisableError::Client(ref inner) => return write!(f, "{}", inner),
246                    };
247        write!(f, "{}", d)
248    }
249}
250
251impl<E: Error + 'static> Error for DisableError<E> {
252    fn source(&self) -> Option<&(dyn Error + 'static)> {
253        match *self {
254            DisableError::MalformedResponse(_, ref e) => Some(e),
255            DisableError::Client(ref inner) => Some(inner),
256            _ => None,
257        }
258    }
259}
260
261#[derive(Clone, Default, Debug)]
262pub struct EnableRequest<'a> {
263    /// The encoded ID of the User Group to enable.
264    pub usergroup: &'a str,
265    /// Include the number of users in the User Group.
266    pub include_count: Option<bool>,
267}
268
269#[derive(Clone, Debug, Deserialize)]
270pub struct EnableResponse {
271    error: Option<String>,
272    #[serde(default)]
273    ok: bool,
274    pub usergroup: Option<crate::Usergroup>,
275}
276
277impl<E: Error> Into<Result<EnableResponse, EnableError<E>>> for EnableResponse {
278    fn into(self) -> Result<EnableResponse, EnableError<E>> {
279        if self.ok {
280            Ok(self)
281        } else {
282            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
283        }
284    }
285}
286#[derive(Debug)]
287pub enum EnableError<E: Error> {
288    /// No authentication token provided.
289    NotAuthed,
290    /// Invalid authentication token.
291    InvalidAuth,
292    /// Authentication token is for a deleted user or team.
293    AccountInactive,
294    /// This method cannot be called by a bot user.
295    UserIsBot,
296    /// This method cannot be called by a restricted user or single channel guest.
297    UserIsRestricted,
298    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
299    InvalidArgName,
300    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
301    InvalidArrayArg,
302    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
303    InvalidCharset,
304    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
305    InvalidFormData,
306    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
307    InvalidPostType,
308    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
309    MissingPostType,
310    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
311    TeamAddedToOrg,
312    /// The method was called via a POST request, but the POST data was either missing or truncated.
313    RequestTimeout,
314    /// The response was not parseable as the expected object
315    MalformedResponse(String, serde_json::error::Error),
316    /// The response returned an error that was unknown to the library
317    Unknown(String),
318    /// The client had an error sending the request to Slack
319    Client(E),
320}
321
322impl<'a, E: Error> From<&'a str> for EnableError<E> {
323    fn from(s: &'a str) -> Self {
324        match s {
325            "not_authed" => EnableError::NotAuthed,
326            "invalid_auth" => EnableError::InvalidAuth,
327            "account_inactive" => EnableError::AccountInactive,
328            "user_is_bot" => EnableError::UserIsBot,
329            "user_is_restricted" => EnableError::UserIsRestricted,
330            "invalid_arg_name" => EnableError::InvalidArgName,
331            "invalid_array_arg" => EnableError::InvalidArrayArg,
332            "invalid_charset" => EnableError::InvalidCharset,
333            "invalid_form_data" => EnableError::InvalidFormData,
334            "invalid_post_type" => EnableError::InvalidPostType,
335            "missing_post_type" => EnableError::MissingPostType,
336            "team_added_to_org" => EnableError::TeamAddedToOrg,
337            "request_timeout" => EnableError::RequestTimeout,
338            _ => EnableError::Unknown(s.to_owned()),
339        }
340    }
341}
342
343impl<E: Error> fmt::Display for EnableError<E> {
344    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
345        let d = match *self {
346                        EnableError::NotAuthed => "not_authed: No authentication token provided.",
347EnableError::InvalidAuth => "invalid_auth: Invalid authentication token.",
348EnableError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
349EnableError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
350EnableError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.",
351EnableError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
352EnableError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
353EnableError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
354EnableError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
355EnableError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
356EnableError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
357EnableError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
358EnableError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
359                        EnableError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
360                        EnableError::Unknown(ref s) => return write!(f, "{}", s),
361                        EnableError::Client(ref inner) => return write!(f, "{}", inner),
362                    };
363        write!(f, "{}", d)
364    }
365}
366
367impl<E: Error + 'static> Error for EnableError<E> {
368    fn source(&self) -> Option<&(dyn Error + 'static)> {
369        match *self {
370            EnableError::MalformedResponse(_, ref e) => Some(e),
371            EnableError::Client(ref inner) => Some(inner),
372            _ => None,
373        }
374    }
375}
376
377#[derive(Clone, Default, Debug)]
378pub struct ListRequest {
379    /// Include disabled User Groups.
380    pub include_disabled: Option<bool>,
381    /// Include the number of users in each User Group.
382    pub include_count: Option<bool>,
383    /// Include the list of users for each User Group.
384    pub include_users: Option<bool>,
385}
386
387#[derive(Clone, Debug, Deserialize)]
388pub struct ListResponse {
389    error: Option<String>,
390    #[serde(default)]
391    ok: bool,
392    pub usergroups: Option<Vec<crate::Usergroup>>,
393}
394
395impl<E: Error> Into<Result<ListResponse, ListError<E>>> for ListResponse {
396    fn into(self) -> Result<ListResponse, ListError<E>> {
397        if self.ok {
398            Ok(self)
399        } else {
400            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
401        }
402    }
403}
404#[derive(Debug)]
405pub enum ListError<E: Error> {
406    /// No authentication token provided.
407    NotAuthed,
408    /// Invalid authentication token.
409    InvalidAuth,
410    /// Authentication token is for a deleted user or team.
411    AccountInactive,
412    /// This method cannot be called by a bot user.
413    UserIsBot,
414    /// This method cannot be called by a restricted user or single channel guest.
415    UserIsRestricted,
416    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
417    InvalidArgName,
418    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
419    InvalidArrayArg,
420    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
421    InvalidCharset,
422    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
423    InvalidFormData,
424    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
425    InvalidPostType,
426    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
427    MissingPostType,
428    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
429    TeamAddedToOrg,
430    /// The method was called via a POST request, but the POST data was either missing or truncated.
431    RequestTimeout,
432    /// The response was not parseable as the expected object
433    MalformedResponse(String, serde_json::error::Error),
434    /// The response returned an error that was unknown to the library
435    Unknown(String),
436    /// The client had an error sending the request to Slack
437    Client(E),
438}
439
440impl<'a, E: Error> From<&'a str> for ListError<E> {
441    fn from(s: &'a str) -> Self {
442        match s {
443            "not_authed" => ListError::NotAuthed,
444            "invalid_auth" => ListError::InvalidAuth,
445            "account_inactive" => ListError::AccountInactive,
446            "user_is_bot" => ListError::UserIsBot,
447            "user_is_restricted" => ListError::UserIsRestricted,
448            "invalid_arg_name" => ListError::InvalidArgName,
449            "invalid_array_arg" => ListError::InvalidArrayArg,
450            "invalid_charset" => ListError::InvalidCharset,
451            "invalid_form_data" => ListError::InvalidFormData,
452            "invalid_post_type" => ListError::InvalidPostType,
453            "missing_post_type" => ListError::MissingPostType,
454            "team_added_to_org" => ListError::TeamAddedToOrg,
455            "request_timeout" => ListError::RequestTimeout,
456            _ => ListError::Unknown(s.to_owned()),
457        }
458    }
459}
460
461impl<E: Error> fmt::Display for ListError<E> {
462    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
463        let d = match *self {
464                        ListError::NotAuthed => "not_authed: No authentication token provided.",
465ListError::InvalidAuth => "invalid_auth: Invalid authentication token.",
466ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
467ListError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
468ListError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.",
469ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
470ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
471ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
472ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
473ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
474ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
475ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
476ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
477                        ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
478                        ListError::Unknown(ref s) => return write!(f, "{}", s),
479                        ListError::Client(ref inner) => return write!(f, "{}", inner),
480                    };
481        write!(f, "{}", d)
482    }
483}
484
485impl<E: Error + 'static> Error for ListError<E> {
486    fn source(&self) -> Option<&(dyn Error + 'static)> {
487        match *self {
488            ListError::MalformedResponse(_, ref e) => Some(e),
489            ListError::Client(ref inner) => Some(inner),
490            _ => None,
491        }
492    }
493}
494
495#[derive(Clone, Default, Debug)]
496pub struct UpdateRequest<'a> {
497    /// The encoded ID of the User Group to update.
498    pub usergroup: &'a str,
499    /// A name for the User Group. Must be unique among User Groups.
500    pub name: Option<&'a str>,
501    /// A mention handle. Must be unique among channels, users and User Groups.
502    pub handle: Option<&'a str>,
503    /// A short description of the User Group.
504    pub description: Option<&'a str>,
505    /// A comma separated string of encoded channel IDs for which the User Group uses as a default.
506    pub channels: Option<&'a str>,
507    /// Include the number of users in the User Group.
508    pub include_count: Option<bool>,
509}
510
511#[derive(Clone, Debug, Deserialize)]
512pub struct UpdateResponse {
513    error: Option<String>,
514    #[serde(default)]
515    ok: bool,
516    pub usergroup: Option<crate::Usergroup>,
517}
518
519impl<E: Error> Into<Result<UpdateResponse, UpdateError<E>>> for UpdateResponse {
520    fn into(self) -> Result<UpdateResponse, UpdateError<E>> {
521        if self.ok {
522            Ok(self)
523        } else {
524            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
525        }
526    }
527}
528#[derive(Debug)]
529pub enum UpdateError<E: Error> {
530    /// No authentication token provided.
531    NotAuthed,
532    /// Invalid authentication token.
533    InvalidAuth,
534    /// Authentication token is for a deleted user or team.
535    AccountInactive,
536    /// This method cannot be called by a bot user.
537    UserIsBot,
538    /// This method cannot be called by a restricted user or single channel guest.
539    UserIsRestricted,
540    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
541    InvalidArgName,
542    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
543    InvalidArrayArg,
544    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
545    InvalidCharset,
546    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
547    InvalidFormData,
548    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
549    InvalidPostType,
550    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
551    MissingPostType,
552    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
553    TeamAddedToOrg,
554    /// The method was called via a POST request, but the POST data was either missing or truncated.
555    RequestTimeout,
556    /// The response was not parseable as the expected object
557    MalformedResponse(String, serde_json::error::Error),
558    /// The response returned an error that was unknown to the library
559    Unknown(String),
560    /// The client had an error sending the request to Slack
561    Client(E),
562}
563
564impl<'a, E: Error> From<&'a str> for UpdateError<E> {
565    fn from(s: &'a str) -> Self {
566        match s {
567            "not_authed" => UpdateError::NotAuthed,
568            "invalid_auth" => UpdateError::InvalidAuth,
569            "account_inactive" => UpdateError::AccountInactive,
570            "user_is_bot" => UpdateError::UserIsBot,
571            "user_is_restricted" => UpdateError::UserIsRestricted,
572            "invalid_arg_name" => UpdateError::InvalidArgName,
573            "invalid_array_arg" => UpdateError::InvalidArrayArg,
574            "invalid_charset" => UpdateError::InvalidCharset,
575            "invalid_form_data" => UpdateError::InvalidFormData,
576            "invalid_post_type" => UpdateError::InvalidPostType,
577            "missing_post_type" => UpdateError::MissingPostType,
578            "team_added_to_org" => UpdateError::TeamAddedToOrg,
579            "request_timeout" => UpdateError::RequestTimeout,
580            _ => UpdateError::Unknown(s.to_owned()),
581        }
582    }
583}
584
585impl<E: Error> fmt::Display for UpdateError<E> {
586    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
587        let d = match *self {
588                        UpdateError::NotAuthed => "not_authed: No authentication token provided.",
589UpdateError::InvalidAuth => "invalid_auth: Invalid authentication token.",
590UpdateError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
591UpdateError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
592UpdateError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.",
593UpdateError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
594UpdateError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
595UpdateError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
596UpdateError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
597UpdateError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
598UpdateError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
599UpdateError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
600UpdateError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
601                        UpdateError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
602                        UpdateError::Unknown(ref s) => return write!(f, "{}", s),
603                        UpdateError::Client(ref inner) => return write!(f, "{}", inner),
604                    };
605        write!(f, "{}", d)
606    }
607}
608
609impl<E: Error + 'static> Error for UpdateError<E> {
610    fn source(&self) -> Option<&(dyn Error + 'static)> {
611        match *self {
612            UpdateError::MalformedResponse(_, ref e) => Some(e),
613            UpdateError::Client(ref inner) => Some(inner),
614            _ => None,
615        }
616    }
617}