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
// このファイルは codegen/generate.py が生成する。手で編集しない
#![allow(unused_imports)]
use crate::objects::*;
use crate::{
CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
};
use serde::{Deserialize, Serialize};
/// Arguments for the Slack Web API method [`agents.sessions.rename`](https://docs.slack.dev/reference/methods/agents.sessions.rename): Rename an agent session.
///
/// Send it with [`SlackClient::agents_sessions_rename`].
#[doc(alias = "agents.sessions.rename")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct AgentsSessionsRenameRequest {
/// New title for the agent session (1-200 characters). For a session channel, this also renames the channel.
pub title: String,
/// ID of the channel containing the agent session. Required for public channels.
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub thread_ts: Option<String>,
}
impl AgentsSessionsRenameRequest {
pub fn new(title: impl Into<String>) -> Self {
Self {
title: title.into(),
channel_id: None,
thread_ts: None,
}
}
pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
self.channel_id = Some(channel_id.into());
self
}
pub fn thread_ts(mut self, thread_ts: impl Into<String>) -> Self {
self.thread_ts = Some(thread_ts.into());
self
}
}
impl SlackApiMethod for AgentsSessionsRenameRequest {
const METHOD: &'static str = "agents.sessions.rename";
type Response = AgentsSessionsRenameResponse;
}
/// Successful response of the Slack Web API method [`agents.sessions.rename`](https://docs.slack.dev/reference/methods/agents.sessions.rename).
#[doc(alias = "agents.sessions.rename")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AgentsSessionsRenameResponse {
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub title: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub response_metadata: Option<ResponseMetadata>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub warning: Option<String>,
}
/// 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.
///
/// Send it with [`SlackClient::agents_sessions_set_status`].
#[doc(alias = "agents.sessions.setStatus")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct AgentsSessionsSetStatusRequest {
/// The lifecycle status to set.
pub status: String,
/// ID of the channel containing the agent session. Required for public channels.
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub thread_ts: Option<String>,
/// 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`.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub initiator_user_id: Option<String>,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_emoji: Option<String>,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_url: Option<String>,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
}
impl AgentsSessionsSetStatusRequest {
pub fn new(status: impl Into<String>) -> Self {
Self {
status: status.into(),
channel_id: None,
thread_ts: None,
title: None,
initiator_user_id: None,
icon_emoji: None,
icon_url: None,
username: None,
}
}
pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
self.channel_id = Some(channel_id.into());
self
}
pub fn thread_ts(mut self, thread_ts: impl Into<String>) -> Self {
self.thread_ts = Some(thread_ts.into());
self
}
pub fn title(mut self, title: impl Into<String>) -> Self {
self.title = Some(title.into());
self
}
pub fn initiator_user_id(mut self, initiator_user_id: impl Into<String>) -> Self {
self.initiator_user_id = Some(initiator_user_id.into());
self
}
pub fn icon_emoji(mut self, icon_emoji: impl Into<String>) -> Self {
self.icon_emoji = Some(icon_emoji.into());
self
}
pub fn icon_url(mut self, icon_url: impl Into<String>) -> Self {
self.icon_url = Some(icon_url.into());
self
}
pub fn username(mut self, username: impl Into<String>) -> Self {
self.username = Some(username.into());
self
}
}
impl SlackApiMethod for AgentsSessionsSetStatusRequest {
const METHOD: &'static str = "agents.sessions.setStatus";
type Response = AgentsSessionsSetStatusResponse;
}
/// Successful response of the Slack Web API method [`agents.sessions.setStatus`](https://docs.slack.dev/reference/methods/agents.sessions.setStatus).
#[doc(alias = "agents.sessions.setStatus")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AgentsSessionsSetStatusResponse {
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub status: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub agent_status: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub title: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub response_metadata: Option<ResponseMetadata>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub warning: Option<String>,
}
impl SlackClient {
/// Calls the Slack Web API method [`agents.sessions.rename`](https://docs.slack.dev/reference/methods/agents.sessions.rename): Rename an agent session.
///
/// Required scopes:
///
/// - bot token: `chat:write`
///
/// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
///
/// # Errors
///
/// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
#[doc(alias = "agents.sessions.rename")]
pub async fn agents_sessions_rename(
&self,
request: &AgentsSessionsRenameRequest,
) -> Result<AgentsSessionsRenameResponse, SlackError> {
self.call(request).await
}
/// 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.
///
/// Required scopes:
///
/// - bot token: `chat:write`
///
/// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
///
/// # Errors
///
/// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
#[doc(alias = "agents.sessions.setStatus")]
pub async fn agents_sessions_set_status(
&self,
request: &AgentsSessionsSetStatusRequest,
) -> Result<AgentsSessionsSetStatusResponse, SlackError> {
self.call(request).await
}
}