slack_morphism/api/
assistant.rs

1use crate::ratectl::{
2    SlackApiMethodRateControlConfig, SlackApiRateControlLimit, SlackApiRateControlSpecialLimit,
3    SLACK_TIER4_METHOD_CONFIG,
4};
5use crate::{
6    ClientResult, SlackAssistantPrompt, SlackChannelId, SlackClientHttpConnector,
7    SlackClientSession, SlackTs,
8};
9use lazy_static::lazy_static;
10use rsb_derive::Builder;
11use serde::{Deserialize, Serialize};
12use serde_with::skip_serializing_none;
13
14impl<'a, SCHC> SlackClientSession<'a, SCHC>
15where
16    SCHC: SlackClientHttpConnector + Send,
17{
18    /// https://api.slack.com/methods/assistant.threads.setStatus
19    pub async fn assistant_threads_set_status(
20        &self,
21        req: &SlackApiAssistantThreadsSetStatusRequest,
22    ) -> ClientResult<SlackApiAssistantThreadsSetStatusResponse> {
23        self.http_session_api
24            .http_post(
25                "assistant.threads.setStatus",
26                req,
27                Some(&ASSISTANT_THREAD_SET_STATUS_SPECIAL_LIMIT_RATE_CTL),
28            )
29            .await
30    }
31
32    /// https://api.slack.com/methods/assistant.threads.setSuggestedPrompts
33    pub async fn assistant_threads_set_suggested_prompts(
34        &self,
35        req: &SlackApiAssistantThreadsSetSuggestedPromptsRequest,
36    ) -> ClientResult<SlackApiAssistantThreadsSetSuggestedPromptsResponse> {
37        self.http_session_api
38            .http_post(
39                "assistant.threads.setSuggestedPrompts",
40                req,
41                Some(&SLACK_TIER4_METHOD_CONFIG),
42            )
43            .await
44    }
45
46    /// https://api.slack.com/methods/assistant.threads.setTitle
47    pub async fn assistant_threads_set_title(
48        &self,
49        req: &SlackApiAssistantThreadSetTitleRequest,
50    ) -> ClientResult<SlackApiAssistantThreadSetTitleResponse> {
51        self.http_session_api
52            .http_post(
53                "assistant.threads.setTitle",
54                req,
55                Some(&SLACK_TIER4_METHOD_CONFIG),
56            )
57            .await
58    }
59}
60
61#[skip_serializing_none]
62#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
63pub struct SlackApiAssistantThreadsSetStatusRequest {
64    pub channel_id: SlackChannelId,
65    pub status: String,
66    pub thread_ts: SlackTs,
67}
68
69#[skip_serializing_none]
70#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
71pub struct SlackApiAssistantThreadsSetStatusResponse {}
72
73#[skip_serializing_none]
74#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
75pub struct SlackApiAssistantThreadsSetSuggestedPromptsRequest {
76    pub channel_id: SlackChannelId,
77    pub thread_ts: SlackTs,
78    pub prompts: Vec<SlackAssistantPrompt>,
79    pub title: Option<String>,
80}
81#[skip_serializing_none]
82#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
83pub struct SlackApiAssistantThreadsSetSuggestedPromptsResponse {}
84
85#[skip_serializing_none]
86#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
87pub struct SlackApiAssistantThreadSetTitleRequest {
88    pub channel_id: SlackChannelId,
89    pub thread_ts: SlackTs,
90    pub title: String,
91}
92
93#[skip_serializing_none]
94#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
95pub struct SlackApiAssistantThreadSetTitleResponse {}
96
97lazy_static! {
98    pub static ref ASSISTANT_THREAD_SET_STATUS_SPECIAL_LIMIT_RATE_CTL: SlackApiMethodRateControlConfig =
99        SlackApiMethodRateControlConfig::new().with_special_rate_limit(
100            SlackApiRateControlSpecialLimit::new(
101                "assistant.threads.setStatus".into(),
102                SlackApiRateControlLimit::new(1, std::time::Duration::from_secs(1))
103            )
104        );
105}