aws_sdk_ivschat/operation/create_chat_token/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_chat_token::_create_chat_token_output::CreateChatTokenOutputBuilder;
3
4pub use crate::operation::create_chat_token::_create_chat_token_input::CreateChatTokenInputBuilder;
5
6impl crate::operation::create_chat_token::builders::CreateChatTokenInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::create_chat_token::CreateChatTokenOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_chat_token::CreateChatTokenError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_chat_token();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreateChatToken`.
24///
25/// <p>Creates an encrypted token that is used by a chat participant to establish an individual WebSocket chat connection to a room. When the token is used to connect to chat, the connection is valid for the session duration specified in the request. The token becomes invalid at the token-expiration timestamp included in the response.</p>
26/// <p>Use the <code>capabilities</code> field to permit an end user to send messages or moderate a room.</p>
27/// <p>The <code>attributes</code> field securely attaches structured data to the chat session; the data is included within each message sent by the end user and received by other participants in the room. Common use cases for attributes include passing end-user profile data like an icon, display name, colors, badges, and other display features.</p>
28/// <p>Encryption keys are owned by Amazon IVS Chat and never used directly by your application.</p>
29#[derive(::std::clone::Clone, ::std::fmt::Debug)]
30pub struct CreateChatTokenFluentBuilder {
31    handle: ::std::sync::Arc<crate::client::Handle>,
32    inner: crate::operation::create_chat_token::builders::CreateChatTokenInputBuilder,
33    config_override: ::std::option::Option<crate::config::Builder>,
34}
35impl
36    crate::client::customize::internal::CustomizableSend<
37        crate::operation::create_chat_token::CreateChatTokenOutput,
38        crate::operation::create_chat_token::CreateChatTokenError,
39    > for CreateChatTokenFluentBuilder
40{
41    fn send(
42        self,
43        config_override: crate::config::Builder,
44    ) -> crate::client::customize::internal::BoxFuture<
45        crate::client::customize::internal::SendResult<
46            crate::operation::create_chat_token::CreateChatTokenOutput,
47            crate::operation::create_chat_token::CreateChatTokenError,
48        >,
49    > {
50        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
51    }
52}
53impl CreateChatTokenFluentBuilder {
54    /// Creates a new `CreateChatTokenFluentBuilder`.
55    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
56        Self {
57            handle,
58            inner: ::std::default::Default::default(),
59            config_override: ::std::option::Option::None,
60        }
61    }
62    /// Access the CreateChatToken as a reference.
63    pub fn as_input(&self) -> &crate::operation::create_chat_token::builders::CreateChatTokenInputBuilder {
64        &self.inner
65    }
66    /// Sends the request and returns the response.
67    ///
68    /// If an error occurs, an `SdkError` will be returned with additional details that
69    /// can be matched against.
70    ///
71    /// By default, any retryable failures will be retried twice. Retry behavior
72    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
73    /// set when configuring the client.
74    pub async fn send(
75        self,
76    ) -> ::std::result::Result<
77        crate::operation::create_chat_token::CreateChatTokenOutput,
78        ::aws_smithy_runtime_api::client::result::SdkError<
79            crate::operation::create_chat_token::CreateChatTokenError,
80            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
81        >,
82    > {
83        let input = self
84            .inner
85            .build()
86            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
87        let runtime_plugins = crate::operation::create_chat_token::CreateChatToken::operation_runtime_plugins(
88            self.handle.runtime_plugins.clone(),
89            &self.handle.conf,
90            self.config_override,
91        );
92        crate::operation::create_chat_token::CreateChatToken::orchestrate(&runtime_plugins, input).await
93    }
94
95    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
96    pub fn customize(
97        self,
98    ) -> crate::client::customize::CustomizableOperation<
99        crate::operation::create_chat_token::CreateChatTokenOutput,
100        crate::operation::create_chat_token::CreateChatTokenError,
101        Self,
102    > {
103        crate::client::customize::CustomizableOperation::new(self)
104    }
105    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
106        self.set_config_override(::std::option::Option::Some(config_override.into()));
107        self
108    }
109
110    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
111        self.config_override = config_override;
112        self
113    }
114    /// <p>Identifier of the room that the client is trying to access. Currently this must be an ARN.</p>
115    pub fn room_identifier(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
116        self.inner = self.inner.room_identifier(input.into());
117        self
118    }
119    /// <p>Identifier of the room that the client is trying to access. Currently this must be an ARN.</p>
120    pub fn set_room_identifier(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
121        self.inner = self.inner.set_room_identifier(input);
122        self
123    }
124    /// <p>Identifier of the room that the client is trying to access. Currently this must be an ARN.</p>
125    pub fn get_room_identifier(&self) -> &::std::option::Option<::std::string::String> {
126        self.inner.get_room_identifier()
127    }
128    /// <p>Application-provided ID that uniquely identifies the user associated with this token. This can be any UTF-8 encoded text.</p>
129    pub fn user_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
130        self.inner = self.inner.user_id(input.into());
131        self
132    }
133    /// <p>Application-provided ID that uniquely identifies the user associated with this token. This can be any UTF-8 encoded text.</p>
134    pub fn set_user_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
135        self.inner = self.inner.set_user_id(input);
136        self
137    }
138    /// <p>Application-provided ID that uniquely identifies the user associated with this token. This can be any UTF-8 encoded text.</p>
139    pub fn get_user_id(&self) -> &::std::option::Option<::std::string::String> {
140        self.inner.get_user_id()
141    }
142    ///
143    /// Appends an item to `capabilities`.
144    ///
145    /// To override the contents of this collection use [`set_capabilities`](Self::set_capabilities).
146    ///
147    /// <p>Set of capabilities that the user is allowed to perform in the room. Default: None (the capability to view messages is implicitly included in all requests).</p>
148    pub fn capabilities(mut self, input: crate::types::ChatTokenCapability) -> Self {
149        self.inner = self.inner.capabilities(input);
150        self
151    }
152    /// <p>Set of capabilities that the user is allowed to perform in the room. Default: None (the capability to view messages is implicitly included in all requests).</p>
153    pub fn set_capabilities(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::ChatTokenCapability>>) -> Self {
154        self.inner = self.inner.set_capabilities(input);
155        self
156    }
157    /// <p>Set of capabilities that the user is allowed to perform in the room. Default: None (the capability to view messages is implicitly included in all requests).</p>
158    pub fn get_capabilities(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::ChatTokenCapability>> {
159        self.inner.get_capabilities()
160    }
161    /// <p>Session duration (in minutes), after which the session expires. Default: 60 (1 hour).</p>
162    pub fn session_duration_in_minutes(mut self, input: i32) -> Self {
163        self.inner = self.inner.session_duration_in_minutes(input);
164        self
165    }
166    /// <p>Session duration (in minutes), after which the session expires. Default: 60 (1 hour).</p>
167    pub fn set_session_duration_in_minutes(mut self, input: ::std::option::Option<i32>) -> Self {
168        self.inner = self.inner.set_session_duration_in_minutes(input);
169        self
170    }
171    /// <p>Session duration (in minutes), after which the session expires. Default: 60 (1 hour).</p>
172    pub fn get_session_duration_in_minutes(&self) -> &::std::option::Option<i32> {
173        self.inner.get_session_duration_in_minutes()
174    }
175    ///
176    /// Adds a key-value pair to `attributes`.
177    ///
178    /// To override the contents of this collection use [`set_attributes`](Self::set_attributes).
179    ///
180    /// <p>Application-provided attributes to encode into the token and attach to a chat session. Map keys and values can contain UTF-8 encoded text. The maximum length of this field is 1 KB total.</p>
181    pub fn attributes(mut self, k: impl ::std::convert::Into<::std::string::String>, v: impl ::std::convert::Into<::std::string::String>) -> Self {
182        self.inner = self.inner.attributes(k.into(), v.into());
183        self
184    }
185    /// <p>Application-provided attributes to encode into the token and attach to a chat session. Map keys and values can contain UTF-8 encoded text. The maximum length of this field is 1 KB total.</p>
186    pub fn set_attributes(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>) -> Self {
187        self.inner = self.inner.set_attributes(input);
188        self
189    }
190    /// <p>Application-provided attributes to encode into the token and attach to a chat session. Map keys and values can contain UTF-8 encoded text. The maximum length of this field is 1 KB total.</p>
191    pub fn get_attributes(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
192        self.inner.get_attributes()
193    }
194}