1#![allow(unused_imports)]
4
5use crate::objects::*;
6use crate::{
7 CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
8};
9use serde::{Deserialize, Serialize};
10
11#[doc(alias = "admin.roles.addAssignments")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct AdminRolesAddAssignmentsRequest {
18 pub role_id: String,
20 #[serde(serialize_with = "crate::form::as_json")]
22 pub entity_ids: Vec<String>,
23 #[serde(serialize_with = "crate::form::as_json")]
25 pub user_ids: Vec<String>,
26}
27
28impl AdminRolesAddAssignmentsRequest {
29 pub fn new(role_id: impl Into<String>, entity_ids: Vec<String>, user_ids: Vec<String>) -> Self {
30 Self {
31 role_id: role_id.into(),
32 entity_ids,
33 user_ids,
34 }
35 }
36}
37
38impl SlackApiMethod for AdminRolesAddAssignmentsRequest {
39 const METHOD: &'static str = "admin.roles.addAssignments";
40 type Response = AdminRolesAddAssignmentsResponse;
41}
42
43#[doc(alias = "admin.roles.addAssignments")]
45#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
46pub struct AdminRolesAddAssignmentsResponse {
47 #[serde(flatten)]
49 pub extra: serde_json::Map<String, serde_json::Value>,
50 #[serde(
51 default,
52 deserialize_with = "crate::de::opt_object",
53 skip_serializing_if = "Option::is_none"
54 )]
55 pub response_metadata: Option<ResponseMetadata>,
56 #[serde(
57 default,
58 deserialize_with = "crate::de::opt_string",
59 skip_serializing_if = "Option::is_none"
60 )]
61 pub warning: Option<String>,
62}
63
64#[doc(alias = "admin.roles.listAssignments")]
68#[derive(Debug, Clone, PartialEq, Serialize, Default)]
69#[non_exhaustive]
70pub struct AdminRolesListAssignmentsRequest {
71 #[serde(skip_serializing_if = "Option::is_none")]
73 pub cursor: Option<String>,
74 #[serde(skip_serializing_if = "Option::is_none")]
76 pub limit: Option<i64>,
77 #[serde(
79 skip_serializing_if = "Option::is_none",
80 serialize_with = "crate::form::as_json"
81 )]
82 pub role_ids: Option<Vec<String>>,
83 #[serde(
85 skip_serializing_if = "Option::is_none",
86 serialize_with = "crate::form::as_json"
87 )]
88 pub entity_ids: Option<Vec<String>>,
89 #[serde(skip_serializing_if = "Option::is_none")]
91 pub sort_dir: Option<String>,
92}
93
94impl AdminRolesListAssignmentsRequest {
95 pub fn new() -> Self {
96 Self {
97 cursor: None,
98 limit: None,
99 role_ids: None,
100 entity_ids: None,
101 sort_dir: None,
102 }
103 }
104
105 pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
106 self.cursor = Some(cursor.into());
107 self
108 }
109
110 pub fn limit(mut self, limit: i64) -> Self {
111 self.limit = Some(limit);
112 self
113 }
114
115 pub fn role_ids(mut self, role_ids: Vec<String>) -> Self {
116 self.role_ids = Some(role_ids);
117 self
118 }
119
120 pub fn entity_ids(mut self, entity_ids: Vec<String>) -> Self {
121 self.entity_ids = Some(entity_ids);
122 self
123 }
124
125 pub fn sort_dir(mut self, sort_dir: impl Into<String>) -> Self {
126 self.sort_dir = Some(sort_dir.into());
127 self
128 }
129}
130
131impl SlackApiMethod for AdminRolesListAssignmentsRequest {
132 const METHOD: &'static str = "admin.roles.listAssignments";
133 type Response = AdminRolesListAssignmentsResponse;
134}
135
136impl CursorPaginated for AdminRolesListAssignmentsRequest {
137 fn set_cursor(&mut self, cursor: String) {
138 self.cursor = Some(cursor);
139 }
140}
141
142impl NextCursor for AdminRolesListAssignmentsResponse {
143 fn next_cursor(&self) -> Option<&str> {
144 self.response_metadata.as_ref()?.next_cursor.as_deref()
145 }
146}
147
148#[doc(alias = "admin.roles.listAssignments")]
150#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
151pub struct AdminRolesListAssignmentsResponse {
152 #[serde(
153 default,
154 deserialize_with = "crate::de::vec",
155 skip_serializing_if = "Vec::is_empty"
156 )]
157 pub role_assignments: Vec<AdminRolesListAssignmentsResponseRoleAssignments>,
158 #[serde(
159 default,
160 deserialize_with = "crate::de::opt_object",
161 skip_serializing_if = "Option::is_none"
162 )]
163 pub response_metadata: Option<ResponseMetadata>,
164 #[serde(
165 default,
166 deserialize_with = "crate::de::opt_string",
167 skip_serializing_if = "Option::is_none"
168 )]
169 pub warning: Option<String>,
170}
171
172#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
173pub struct AdminRolesListAssignmentsResponseRoleAssignments {
174 #[serde(
175 default,
176 deserialize_with = "crate::de::opt_string",
177 skip_serializing_if = "Option::is_none"
178 )]
179 pub role_id: Option<String>,
180 #[serde(
181 default,
182 deserialize_with = "crate::de::opt_string",
183 skip_serializing_if = "Option::is_none"
184 )]
185 pub entity_id: Option<String>,
186 #[serde(
187 default,
188 deserialize_with = "crate::de::opt_string",
189 skip_serializing_if = "Option::is_none"
190 )]
191 pub user_id: Option<String>,
192 #[serde(
193 default,
194 deserialize_with = "crate::de::opt_i64",
195 skip_serializing_if = "Option::is_none"
196 )]
197 pub date_create: Option<i64>,
198}
199
200#[doc(alias = "admin.roles.removeAssignments")]
204#[derive(Debug, Clone, PartialEq, Serialize)]
205#[non_exhaustive]
206pub struct AdminRolesRemoveAssignmentsRequest {
207 pub role_id: String,
209 #[serde(serialize_with = "crate::form::as_json")]
211 pub entity_ids: Vec<String>,
212 #[serde(serialize_with = "crate::form::as_json")]
214 pub user_ids: Vec<String>,
215}
216
217impl AdminRolesRemoveAssignmentsRequest {
218 pub fn new(role_id: impl Into<String>, entity_ids: Vec<String>, user_ids: Vec<String>) -> Self {
219 Self {
220 role_id: role_id.into(),
221 entity_ids,
222 user_ids,
223 }
224 }
225}
226
227impl SlackApiMethod for AdminRolesRemoveAssignmentsRequest {
228 const METHOD: &'static str = "admin.roles.removeAssignments";
229 type Response = AdminRolesRemoveAssignmentsResponse;
230}
231
232#[doc(alias = "admin.roles.removeAssignments")]
234#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
235pub struct AdminRolesRemoveAssignmentsResponse {
236 #[serde(flatten)]
238 pub extra: serde_json::Map<String, serde_json::Value>,
239 #[serde(
240 default,
241 deserialize_with = "crate::de::opt_object",
242 skip_serializing_if = "Option::is_none"
243 )]
244 pub response_metadata: Option<ResponseMetadata>,
245 #[serde(
246 default,
247 deserialize_with = "crate::de::opt_string",
248 skip_serializing_if = "Option::is_none"
249 )]
250 pub warning: Option<String>,
251}
252
253impl SlackClient {
254 #[doc(alias = "admin.roles.addAssignments")]
266 pub async fn admin_roles_add_assignments(
267 &self,
268 request: &AdminRolesAddAssignmentsRequest,
269 ) -> Result<AdminRolesAddAssignmentsResponse, SlackError> {
270 self.call(request).await
271 }
272
273 #[doc(alias = "admin.roles.listAssignments")]
285 pub async fn admin_roles_list_assignments(
286 &self,
287 request: &AdminRolesListAssignmentsRequest,
288 ) -> Result<AdminRolesListAssignmentsResponse, SlackError> {
289 self.call(request).await
290 }
291
292 #[doc(alias = "admin.roles.removeAssignments")]
304 pub async fn admin_roles_remove_assignments(
305 &self,
306 request: &AdminRolesRemoveAssignmentsRequest,
307 ) -> Result<AdminRolesRemoveAssignmentsResponse, SlackError> {
308 self.call(request).await
309 }
310}