Skip to main content

slack_web_api/api/
canvases.rs

1// このファイルは codegen/generate.py が生成する。手で編集しない
2
3#![allow(unused_imports)]
4
5use crate::objects::*;
6use crate::{
7    CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
8};
9use serde::{Deserialize, Serialize};
10
11/// Arguments for the Slack Web API method [`canvases.access.delete`](https://docs.slack.dev/reference/methods/canvases.access.delete): Remove access to a canvas for specified entities
12///
13/// Send it with [`SlackClient::canvases_access_delete`].
14#[doc(alias = "canvases.access.delete")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct CanvasesAccessDeleteRequest {
18    /// Encoded ID of the canvas
19    pub canvas_id: String,
20    /// List of channels you wish to update access for
21    #[serde(
22        skip_serializing_if = "Option::is_none",
23        serialize_with = "crate::form::as_json"
24    )]
25    pub channel_ids: Option<Vec<String>>,
26    /// List of users you wish to update access for
27    #[serde(
28        skip_serializing_if = "Option::is_none",
29        serialize_with = "crate::form::as_json"
30    )]
31    pub user_ids: Option<Vec<String>>,
32}
33
34impl CanvasesAccessDeleteRequest {
35    pub fn new(canvas_id: impl Into<String>) -> Self {
36        Self {
37            canvas_id: canvas_id.into(),
38            channel_ids: None,
39            user_ids: None,
40        }
41    }
42
43    pub fn channel_ids(mut self, channel_ids: Vec<String>) -> Self {
44        self.channel_ids = Some(channel_ids);
45        self
46    }
47
48    pub fn user_ids(mut self, user_ids: Vec<String>) -> Self {
49        self.user_ids = Some(user_ids);
50        self
51    }
52}
53
54impl SlackApiMethod for CanvasesAccessDeleteRequest {
55    const METHOD: &'static str = "canvases.access.delete";
56    type Response = CanvasesAccessDeleteResponse;
57}
58
59/// Successful response of the Slack Web API method [`canvases.access.delete`](https://docs.slack.dev/reference/methods/canvases.access.delete).
60#[doc(alias = "canvases.access.delete")]
61#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
62pub struct CanvasesAccessDeleteResponse {
63    /// Fields returned by Slack. This method has no documented response example.
64    #[serde(flatten)]
65    pub extra: serde_json::Map<String, serde_json::Value>,
66    #[serde(
67        default,
68        deserialize_with = "crate::de::opt_object",
69        skip_serializing_if = "Option::is_none"
70    )]
71    pub response_metadata: Option<ResponseMetadata>,
72    #[serde(
73        default,
74        deserialize_with = "crate::de::opt_string",
75        skip_serializing_if = "Option::is_none"
76    )]
77    pub warning: Option<String>,
78}
79
80/// Arguments for the Slack Web API method [`canvases.access.set`](https://docs.slack.dev/reference/methods/canvases.access.set): Sets the access level to a canvas for specified entities
81///
82/// Send it with [`SlackClient::canvases_access_set`].
83#[doc(alias = "canvases.access.set")]
84#[derive(Debug, Clone, PartialEq, Serialize)]
85#[non_exhaustive]
86pub struct CanvasesAccessSetRequest {
87    /// Encoded ID of the canvas
88    pub canvas_id: String,
89    /// Desired level of access
90    pub access_level: String,
91    /// List of channels you wish to update access for. Can only be used if user\_ids is not provided.
92    #[serde(
93        skip_serializing_if = "Option::is_none",
94        serialize_with = "crate::form::as_json"
95    )]
96    pub channel_ids: Option<Vec<String>>,
97    /// List of users you wish to update access for. Can only be used if channel\_ids is not provided.
98    #[serde(
99        skip_serializing_if = "Option::is_none",
100        serialize_with = "crate::form::as_json"
101    )]
102    pub user_ids: Option<Vec<String>>,
103}
104
105impl CanvasesAccessSetRequest {
106    pub fn new(canvas_id: impl Into<String>, access_level: impl Into<String>) -> Self {
107        Self {
108            canvas_id: canvas_id.into(),
109            access_level: access_level.into(),
110            channel_ids: None,
111            user_ids: None,
112        }
113    }
114
115    pub fn channel_ids(mut self, channel_ids: Vec<String>) -> Self {
116        self.channel_ids = Some(channel_ids);
117        self
118    }
119
120    pub fn user_ids(mut self, user_ids: Vec<String>) -> Self {
121        self.user_ids = Some(user_ids);
122        self
123    }
124}
125
126impl SlackApiMethod for CanvasesAccessSetRequest {
127    const METHOD: &'static str = "canvases.access.set";
128    type Response = CanvasesAccessSetResponse;
129}
130
131/// Successful response of the Slack Web API method [`canvases.access.set`](https://docs.slack.dev/reference/methods/canvases.access.set).
132#[doc(alias = "canvases.access.set")]
133#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
134pub struct CanvasesAccessSetResponse {
135    /// Fields returned by Slack. This method has no documented response example.
136    #[serde(flatten)]
137    pub extra: serde_json::Map<String, serde_json::Value>,
138    #[serde(
139        default,
140        deserialize_with = "crate::de::opt_object",
141        skip_serializing_if = "Option::is_none"
142    )]
143    pub response_metadata: Option<ResponseMetadata>,
144    #[serde(
145        default,
146        deserialize_with = "crate::de::opt_string",
147        skip_serializing_if = "Option::is_none"
148    )]
149    pub warning: Option<String>,
150}
151
152/// Arguments for the Slack Web API method [`canvases.create`](https://docs.slack.dev/reference/methods/canvases.create): Create canvas for a user
153///
154/// Send it with [`SlackClient::canvases_create`].
155#[doc(alias = "canvases.create")]
156#[derive(Debug, Clone, PartialEq, Serialize, Default)]
157#[non_exhaustive]
158pub struct CanvasesCreateRequest {
159    /// Title of the newly created canvas
160    #[serde(skip_serializing_if = "Option::is_none")]
161    pub title: Option<String>,
162    /// Structure describing the type and value of the content to create. The markdown content is limited to 1 MiB (1,048,576 characters).
163    #[serde(skip_serializing_if = "Option::is_none")]
164    pub document_content: Option<String>,
165    /// Channel ID of the channel the canvas will be tabbed in. This is a required field for free teams.
166    #[serde(skip_serializing_if = "Option::is_none")]
167    pub channel_id: Option<String>,
168}
169
170impl CanvasesCreateRequest {
171    pub fn new() -> Self {
172        Self {
173            title: None,
174            document_content: None,
175            channel_id: None,
176        }
177    }
178
179    pub fn title(mut self, title: impl Into<String>) -> Self {
180        self.title = Some(title.into());
181        self
182    }
183
184    pub fn document_content(mut self, document_content: impl Into<String>) -> Self {
185        self.document_content = Some(document_content.into());
186        self
187    }
188
189    pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
190        self.channel_id = Some(channel_id.into());
191        self
192    }
193}
194
195impl SlackApiMethod for CanvasesCreateRequest {
196    const METHOD: &'static str = "canvases.create";
197    type Response = CanvasesCreateResponse;
198}
199
200/// Successful response of the Slack Web API method [`canvases.create`](https://docs.slack.dev/reference/methods/canvases.create).
201#[doc(alias = "canvases.create")]
202#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
203pub struct CanvasesCreateResponse {
204    #[serde(
205        default,
206        deserialize_with = "crate::de::opt_string",
207        skip_serializing_if = "Option::is_none"
208    )]
209    pub canvas_id: Option<String>,
210    #[serde(
211        default,
212        deserialize_with = "crate::de::opt_object",
213        skip_serializing_if = "Option::is_none"
214    )]
215    pub response_metadata: Option<ResponseMetadata>,
216    #[serde(
217        default,
218        deserialize_with = "crate::de::opt_string",
219        skip_serializing_if = "Option::is_none"
220    )]
221    pub warning: Option<String>,
222}
223
224/// Arguments for the Slack Web API method [`canvases.delete`](https://docs.slack.dev/reference/methods/canvases.delete): Deletes a canvas
225///
226/// Send it with [`SlackClient::canvases_delete`].
227#[doc(alias = "canvases.delete")]
228#[derive(Debug, Clone, PartialEq, Serialize)]
229#[non_exhaustive]
230pub struct CanvasesDeleteRequest {
231    /// Encoded ID of the canvas
232    pub canvas_id: String,
233}
234
235impl CanvasesDeleteRequest {
236    pub fn new(canvas_id: impl Into<String>) -> Self {
237        Self {
238            canvas_id: canvas_id.into(),
239        }
240    }
241}
242
243impl SlackApiMethod for CanvasesDeleteRequest {
244    const METHOD: &'static str = "canvases.delete";
245    type Response = CanvasesDeleteResponse;
246}
247
248/// Successful response of the Slack Web API method [`canvases.delete`](https://docs.slack.dev/reference/methods/canvases.delete).
249#[doc(alias = "canvases.delete")]
250#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
251pub struct CanvasesDeleteResponse {
252    /// Fields returned by Slack. This method has no documented response example.
253    #[serde(flatten)]
254    pub extra: serde_json::Map<String, serde_json::Value>,
255    #[serde(
256        default,
257        deserialize_with = "crate::de::opt_object",
258        skip_serializing_if = "Option::is_none"
259    )]
260    pub response_metadata: Option<ResponseMetadata>,
261    #[serde(
262        default,
263        deserialize_with = "crate::de::opt_string",
264        skip_serializing_if = "Option::is_none"
265    )]
266    pub warning: Option<String>,
267}
268
269/// Arguments for the Slack Web API method [`canvases.edit`](https://docs.slack.dev/reference/methods/canvases.edit): Update an existing canvas
270///
271/// Send it with [`SlackClient::canvases_edit`].
272#[doc(alias = "canvases.edit")]
273#[derive(Debug, Clone, PartialEq, Serialize)]
274#[non_exhaustive]
275pub struct CanvasesEditRequest {
276    /// Encoded ID of the canvas
277    pub canvas_id: String,
278    /// List of changes to apply on the specified canvas. The markdown content of each change is limited to 1 MiB (1,048,576 characters).
279    #[serde(serialize_with = "crate::form::as_json")]
280    pub changes: Vec<serde_json::Value>,
281}
282
283impl CanvasesEditRequest {
284    pub fn new(canvas_id: impl Into<String>, changes: Vec<serde_json::Value>) -> Self {
285        Self {
286            canvas_id: canvas_id.into(),
287            changes,
288        }
289    }
290}
291
292impl SlackApiMethod for CanvasesEditRequest {
293    const METHOD: &'static str = "canvases.edit";
294    type Response = CanvasesEditResponse;
295}
296
297/// Successful response of the Slack Web API method [`canvases.edit`](https://docs.slack.dev/reference/methods/canvases.edit).
298#[doc(alias = "canvases.edit")]
299#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
300pub struct CanvasesEditResponse {
301    /// Fields returned by Slack. This method has no documented response example.
302    #[serde(flatten)]
303    pub extra: serde_json::Map<String, serde_json::Value>,
304    #[serde(
305        default,
306        deserialize_with = "crate::de::opt_object",
307        skip_serializing_if = "Option::is_none"
308    )]
309    pub response_metadata: Option<ResponseMetadata>,
310    #[serde(
311        default,
312        deserialize_with = "crate::de::opt_string",
313        skip_serializing_if = "Option::is_none"
314    )]
315    pub warning: Option<String>,
316}
317
318/// Arguments for the Slack Web API method [`canvases.getContent`](https://docs.slack.dev/reference/methods/canvases.getContent): Get the content of a canvas as markdown (default) or HTML.
319///
320/// Send it with [`SlackClient::canvases_get_content`].
321#[doc(alias = "canvases.getContent")]
322#[derive(Debug, Clone, PartialEq, Serialize)]
323#[non_exhaustive]
324pub struct CanvasesGetContentRequest {
325    /// Encoded ID of the canvas
326    pub canvas_id: String,
327    /// Format in which to return the canvas content. Defaults to markdown.
328    #[serde(skip_serializing_if = "Option::is_none")]
329    pub content_type: Option<String>,
330}
331
332impl CanvasesGetContentRequest {
333    pub fn new(canvas_id: impl Into<String>) -> Self {
334        Self {
335            canvas_id: canvas_id.into(),
336            content_type: None,
337        }
338    }
339
340    pub fn content_type(mut self, content_type: impl Into<String>) -> Self {
341        self.content_type = Some(content_type.into());
342        self
343    }
344}
345
346impl SlackApiMethod for CanvasesGetContentRequest {
347    const METHOD: &'static str = "canvases.getContent";
348    type Response = CanvasesGetContentResponse;
349}
350
351/// Successful response of the Slack Web API method [`canvases.getContent`](https://docs.slack.dev/reference/methods/canvases.getContent).
352#[doc(alias = "canvases.getContent")]
353#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
354pub struct CanvasesGetContentResponse {
355    #[serde(
356        default,
357        deserialize_with = "crate::de::opt_string",
358        skip_serializing_if = "Option::is_none"
359    )]
360    pub content: Option<String>,
361    #[serde(
362        default,
363        deserialize_with = "crate::de::opt_object",
364        skip_serializing_if = "Option::is_none"
365    )]
366    pub response_metadata: Option<ResponseMetadata>,
367    #[serde(
368        default,
369        deserialize_with = "crate::de::opt_string",
370        skip_serializing_if = "Option::is_none"
371    )]
372    pub warning: Option<String>,
373}
374
375/// Arguments for the Slack Web API method [`canvases.sections.lookup`](https://docs.slack.dev/reference/methods/canvases.sections.lookup): Find sections matching the provided criteria
376///
377/// Send it with [`SlackClient::canvases_sections_lookup`].
378#[doc(alias = "canvases.sections.lookup")]
379#[derive(Debug, Clone, PartialEq, Serialize)]
380#[non_exhaustive]
381pub struct CanvasesSectionsLookupRequest {
382    /// Encoded ID of the canvas
383    pub canvas_id: String,
384    /// Filtering criteria
385    pub criteria: String,
386}
387
388impl CanvasesSectionsLookupRequest {
389    pub fn new(canvas_id: impl Into<String>, criteria: impl Into<String>) -> Self {
390        Self {
391            canvas_id: canvas_id.into(),
392            criteria: criteria.into(),
393        }
394    }
395}
396
397impl SlackApiMethod for CanvasesSectionsLookupRequest {
398    const METHOD: &'static str = "canvases.sections.lookup";
399    type Response = CanvasesSectionsLookupResponse;
400}
401
402/// Successful response of the Slack Web API method [`canvases.sections.lookup`](https://docs.slack.dev/reference/methods/canvases.sections.lookup).
403#[doc(alias = "canvases.sections.lookup")]
404#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
405pub struct CanvasesSectionsLookupResponse {
406    #[serde(
407        default,
408        deserialize_with = "crate::de::vec",
409        skip_serializing_if = "Vec::is_empty"
410    )]
411    pub sections: Vec<CanvasesSectionsLookupResponseSections>,
412    #[serde(
413        default,
414        deserialize_with = "crate::de::opt_object",
415        skip_serializing_if = "Option::is_none"
416    )]
417    pub response_metadata: Option<ResponseMetadata>,
418    #[serde(
419        default,
420        deserialize_with = "crate::de::opt_string",
421        skip_serializing_if = "Option::is_none"
422    )]
423    pub warning: Option<String>,
424}
425
426#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
427pub struct CanvasesSectionsLookupResponseSections {
428    #[serde(
429        default,
430        deserialize_with = "crate::de::opt_string",
431        skip_serializing_if = "Option::is_none"
432    )]
433    pub id: Option<String>,
434}
435
436impl SlackClient {
437    /// Calls the Slack Web API method [`canvases.access.delete`](https://docs.slack.dev/reference/methods/canvases.access.delete): Remove access to a canvas for specified entities
438    ///
439    /// Required scopes:
440    ///
441    /// - bot token: `canvases:write`
442    /// - user token: `canvases:write`
443    ///
444    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
445    ///
446    /// # Errors
447    ///
448    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
449    #[doc(alias = "canvases.access.delete")]
450    pub async fn canvases_access_delete(
451        &self,
452        request: &CanvasesAccessDeleteRequest,
453    ) -> Result<CanvasesAccessDeleteResponse, SlackError> {
454        self.call(request).await
455    }
456
457    /// Calls the Slack Web API method [`canvases.access.set`](https://docs.slack.dev/reference/methods/canvases.access.set): Sets the access level to a canvas for specified entities
458    ///
459    /// Required scopes:
460    ///
461    /// - bot token: `canvases:write`
462    /// - user token: `canvases:write`
463    ///
464    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
465    ///
466    /// # Errors
467    ///
468    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
469    #[doc(alias = "canvases.access.set")]
470    pub async fn canvases_access_set(
471        &self,
472        request: &CanvasesAccessSetRequest,
473    ) -> Result<CanvasesAccessSetResponse, SlackError> {
474        self.call(request).await
475    }
476
477    /// Calls the Slack Web API method [`canvases.create`](https://docs.slack.dev/reference/methods/canvases.create): Create canvas for a user
478    ///
479    /// Required scopes:
480    ///
481    /// - bot token: `canvases:write`
482    /// - user token: `canvases:write`
483    ///
484    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
485    ///
486    /// # Errors
487    ///
488    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
489    #[doc(alias = "canvases.create")]
490    pub async fn canvases_create(
491        &self,
492        request: &CanvasesCreateRequest,
493    ) -> Result<CanvasesCreateResponse, SlackError> {
494        self.call(request).await
495    }
496
497    /// Calls the Slack Web API method [`canvases.delete`](https://docs.slack.dev/reference/methods/canvases.delete): Deletes a canvas
498    ///
499    /// Required scopes:
500    ///
501    /// - bot token: `canvases:write`
502    /// - user token: `canvases:write`
503    ///
504    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
505    ///
506    /// # Errors
507    ///
508    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
509    #[doc(alias = "canvases.delete")]
510    pub async fn canvases_delete(
511        &self,
512        request: &CanvasesDeleteRequest,
513    ) -> Result<CanvasesDeleteResponse, SlackError> {
514        self.call(request).await
515    }
516
517    /// Calls the Slack Web API method [`canvases.edit`](https://docs.slack.dev/reference/methods/canvases.edit): Update an existing canvas
518    ///
519    /// Required scopes:
520    ///
521    /// - bot token: `canvases:write`
522    /// - user token: `canvases:write`
523    ///
524    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
525    ///
526    /// # Errors
527    ///
528    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
529    #[doc(alias = "canvases.edit")]
530    pub async fn canvases_edit(
531        &self,
532        request: &CanvasesEditRequest,
533    ) -> Result<CanvasesEditResponse, SlackError> {
534        self.call(request).await
535    }
536
537    /// Calls the Slack Web API method [`canvases.getContent`](https://docs.slack.dev/reference/methods/canvases.getContent): Get the content of a canvas as markdown (default) or HTML.
538    ///
539    /// Required scopes:
540    ///
541    /// - bot token: `canvases:read`
542    /// - user token: `canvases:read`
543    ///
544    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
545    ///
546    /// # Errors
547    ///
548    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
549    #[doc(alias = "canvases.getContent")]
550    pub async fn canvases_get_content(
551        &self,
552        request: &CanvasesGetContentRequest,
553    ) -> Result<CanvasesGetContentResponse, SlackError> {
554        self.call(request).await
555    }
556
557    /// Calls the Slack Web API method [`canvases.sections.lookup`](https://docs.slack.dev/reference/methods/canvases.sections.lookup): Find sections matching the provided criteria
558    ///
559    /// Required scopes:
560    ///
561    /// - bot token: `canvases:read`
562    /// - user token: `canvases:read`
563    ///
564    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
565    ///
566    /// # Errors
567    ///
568    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
569    #[doc(alias = "canvases.sections.lookup")]
570    pub async fn canvases_sections_lookup(
571        &self,
572        request: &CanvasesSectionsLookupRequest,
573    ) -> Result<CanvasesSectionsLookupResponse, SlackError> {
574        self.call(request).await
575    }
576}