Skip to main content

slack_web_api/api/
agents.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 [`agents.sessions.rename`](https://docs.slack.dev/reference/methods/agents.sessions.rename): Rename an agent session.
12///
13/// Send it with [`SlackClient::agents_sessions_rename`].
14#[doc(alias = "agents.sessions.rename")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct AgentsSessionsRenameRequest {
18    /// New title for the agent session (1-200 characters). For a session channel, this also renames the channel.
19    pub title: String,
20    /// ID of the channel containing the agent session. Required for public channels.
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub channel_id: Option<String>,
23    /// Timestamp of the thread root message the session is scoped to. Required for thread-based sessions in regular channels and DMs. Must be omitted for session channels.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub thread_ts: Option<String>,
26}
27
28impl AgentsSessionsRenameRequest {
29    pub fn new(title: impl Into<String>) -> Self {
30        Self {
31            title: title.into(),
32            channel_id: None,
33            thread_ts: None,
34        }
35    }
36
37    pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
38        self.channel_id = Some(channel_id.into());
39        self
40    }
41
42    pub fn thread_ts(mut self, thread_ts: impl Into<String>) -> Self {
43        self.thread_ts = Some(thread_ts.into());
44        self
45    }
46}
47
48impl SlackApiMethod for AgentsSessionsRenameRequest {
49    const METHOD: &'static str = "agents.sessions.rename";
50    type Response = AgentsSessionsRenameResponse;
51}
52
53/// Successful response of the Slack Web API method [`agents.sessions.rename`](https://docs.slack.dev/reference/methods/agents.sessions.rename).
54#[doc(alias = "agents.sessions.rename")]
55#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
56pub struct AgentsSessionsRenameResponse {
57    #[serde(
58        default,
59        deserialize_with = "crate::de::opt_string",
60        skip_serializing_if = "Option::is_none"
61    )]
62    pub title: Option<String>,
63    #[serde(
64        default,
65        deserialize_with = "crate::de::opt_object",
66        skip_serializing_if = "Option::is_none"
67    )]
68    pub response_metadata: Option<ResponseMetadata>,
69    #[serde(
70        default,
71        deserialize_with = "crate::de::opt_string",
72        skip_serializing_if = "Option::is_none"
73    )]
74    pub warning: Option<String>,
75}
76
77/// Arguments for the Slack Web API method [`agents.sessions.setStatus`](https://docs.slack.dev/reference/methods/agents.sessions.setStatus): Set an agent session's lifecycle status, creating the session if needed.
78///
79/// Send it with [`SlackClient::agents_sessions_set_status`].
80#[doc(alias = "agents.sessions.setStatus")]
81#[derive(Debug, Clone, PartialEq, Serialize)]
82#[non_exhaustive]
83pub struct AgentsSessionsSetStatusRequest {
84    /// The lifecycle status to set.
85    pub status: String,
86    /// ID of the channel containing the agent session. Required for public channels.
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub channel_id: Option<String>,
89    /// Timestamp of the thread root message the session is scoped to. Required for thread-based sessions in regular channels and DMs. Must be omitted for session channels.
90    #[serde(skip_serializing_if = "Option::is_none")]
91    pub thread_ts: Option<String>,
92    /// Title for the agent session (max 200 characters). Only used when creating a new session; ignored if the session already exists. To rename an existing session, use `agents.sessions.rename`.
93    #[serde(skip_serializing_if = "Option::is_none")]
94    pub title: Option<String>,
95    /// The user who initiated the session. Only used when creating a new session; ignored if the session already exists. Must be a member of the channel.
96    #[serde(skip_serializing_if = "Option::is_none")]
97    pub initiator_user_id: Option<String>,
98    /// Emoji to use as the agent's icon. Takes priority over `icon_url`. Remains in effect until you clear it (pass `null`) or set a new value. Requires the `chat:write.customize` scope.
99    #[serde(skip_serializing_if = "Option::is_none")]
100    pub icon_emoji: Option<String>,
101    /// URL to an image to use as the agent's icon. Remains in effect until you clear it (pass `null`) or set a new value. Requires the `chat:write.customize` scope.
102    #[serde(skip_serializing_if = "Option::is_none")]
103    pub icon_url: Option<String>,
104    /// Display name override for the agent (max 200 characters). Remains in effect until you clear it (pass `null`) or set a new value. Requires the `chat:write.customize` scope.
105    #[serde(skip_serializing_if = "Option::is_none")]
106    pub username: Option<String>,
107}
108
109impl AgentsSessionsSetStatusRequest {
110    pub fn new(status: impl Into<String>) -> Self {
111        Self {
112            status: status.into(),
113            channel_id: None,
114            thread_ts: None,
115            title: None,
116            initiator_user_id: None,
117            icon_emoji: None,
118            icon_url: None,
119            username: None,
120        }
121    }
122
123    pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
124        self.channel_id = Some(channel_id.into());
125        self
126    }
127
128    pub fn thread_ts(mut self, thread_ts: impl Into<String>) -> Self {
129        self.thread_ts = Some(thread_ts.into());
130        self
131    }
132
133    pub fn title(mut self, title: impl Into<String>) -> Self {
134        self.title = Some(title.into());
135        self
136    }
137
138    pub fn initiator_user_id(mut self, initiator_user_id: impl Into<String>) -> Self {
139        self.initiator_user_id = Some(initiator_user_id.into());
140        self
141    }
142
143    pub fn icon_emoji(mut self, icon_emoji: impl Into<String>) -> Self {
144        self.icon_emoji = Some(icon_emoji.into());
145        self
146    }
147
148    pub fn icon_url(mut self, icon_url: impl Into<String>) -> Self {
149        self.icon_url = Some(icon_url.into());
150        self
151    }
152
153    pub fn username(mut self, username: impl Into<String>) -> Self {
154        self.username = Some(username.into());
155        self
156    }
157}
158
159impl SlackApiMethod for AgentsSessionsSetStatusRequest {
160    const METHOD: &'static str = "agents.sessions.setStatus";
161    type Response = AgentsSessionsSetStatusResponse;
162}
163
164/// Successful response of the Slack Web API method [`agents.sessions.setStatus`](https://docs.slack.dev/reference/methods/agents.sessions.setStatus).
165#[doc(alias = "agents.sessions.setStatus")]
166#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
167pub struct AgentsSessionsSetStatusResponse {
168    #[serde(
169        default,
170        deserialize_with = "crate::de::opt_string",
171        skip_serializing_if = "Option::is_none"
172    )]
173    pub status: Option<String>,
174    #[serde(
175        default,
176        deserialize_with = "crate::de::opt_string",
177        skip_serializing_if = "Option::is_none"
178    )]
179    pub agent_status: Option<String>,
180    #[serde(
181        default,
182        deserialize_with = "crate::de::opt_string",
183        skip_serializing_if = "Option::is_none"
184    )]
185    pub title: Option<String>,
186    #[serde(
187        default,
188        deserialize_with = "crate::de::opt_object",
189        skip_serializing_if = "Option::is_none"
190    )]
191    pub response_metadata: Option<ResponseMetadata>,
192    #[serde(
193        default,
194        deserialize_with = "crate::de::opt_string",
195        skip_serializing_if = "Option::is_none"
196    )]
197    pub warning: Option<String>,
198}
199
200impl SlackClient {
201    /// Calls the Slack Web API method [`agents.sessions.rename`](https://docs.slack.dev/reference/methods/agents.sessions.rename): Rename an agent session.
202    ///
203    /// Required scopes:
204    ///
205    /// - bot token: `chat:write`
206    ///
207    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
208    ///
209    /// # Errors
210    ///
211    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
212    #[doc(alias = "agents.sessions.rename")]
213    pub async fn agents_sessions_rename(
214        &self,
215        request: &AgentsSessionsRenameRequest,
216    ) -> Result<AgentsSessionsRenameResponse, SlackError> {
217        self.call(request).await
218    }
219
220    /// Calls the Slack Web API method [`agents.sessions.setStatus`](https://docs.slack.dev/reference/methods/agents.sessions.setStatus): Set an agent session's lifecycle status, creating the session if needed.
221    ///
222    /// Required scopes:
223    ///
224    /// - bot token: `chat:write`
225    ///
226    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
227    ///
228    /// # Errors
229    ///
230    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
231    #[doc(alias = "agents.sessions.setStatus")]
232    pub async fn agents_sessions_set_status(
233        &self,
234        request: &AgentsSessionsSetStatusRequest,
235    ) -> Result<AgentsSessionsSetStatusResponse, SlackError> {
236        self.call(request).await
237    }
238}