aws_sdk_iotdataplane/operation/publish/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::publish::_publish_output::PublishOutputBuilder;
3
4pub use crate::operation::publish::_publish_input::PublishInputBuilder;
5
6impl crate::operation::publish::builders::PublishInputBuilder {
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::publish::PublishOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::publish::PublishError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.publish();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `Publish`.
24///
25/// <p>Publishes an MQTT message.</p>
26/// <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">Publish</a> action.</p>
27/// <p>For more information about MQTT messages, see <a href="http://docs.aws.amazon.com/iot/latest/developerguide/mqtt.html">MQTT Protocol</a> in the IoT Developer Guide.</p>
28/// <p>For more information about messaging costs, see <a href="http://aws.amazon.com/iot-core/pricing/#Messaging">Amazon Web Services IoT Core pricing - Messaging</a>.</p>
29#[derive(::std::clone::Clone, ::std::fmt::Debug)]
30pub struct PublishFluentBuilder {
31    handle: ::std::sync::Arc<crate::client::Handle>,
32    inner: crate::operation::publish::builders::PublishInputBuilder,
33    config_override: ::std::option::Option<crate::config::Builder>,
34}
35impl crate::client::customize::internal::CustomizableSend<crate::operation::publish::PublishOutput, crate::operation::publish::PublishError>
36    for PublishFluentBuilder
37{
38    fn send(
39        self,
40        config_override: crate::config::Builder,
41    ) -> crate::client::customize::internal::BoxFuture<
42        crate::client::customize::internal::SendResult<crate::operation::publish::PublishOutput, crate::operation::publish::PublishError>,
43    > {
44        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
45    }
46}
47impl PublishFluentBuilder {
48    /// Creates a new `PublishFluentBuilder`.
49    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
50        Self {
51            handle,
52            inner: ::std::default::Default::default(),
53            config_override: ::std::option::Option::None,
54        }
55    }
56    /// Access the Publish as a reference.
57    pub fn as_input(&self) -> &crate::operation::publish::builders::PublishInputBuilder {
58        &self.inner
59    }
60    /// Sends the request and returns the response.
61    ///
62    /// If an error occurs, an `SdkError` will be returned with additional details that
63    /// can be matched against.
64    ///
65    /// By default, any retryable failures will be retried twice. Retry behavior
66    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
67    /// set when configuring the client.
68    pub async fn send(
69        self,
70    ) -> ::std::result::Result<
71        crate::operation::publish::PublishOutput,
72        ::aws_smithy_runtime_api::client::result::SdkError<
73            crate::operation::publish::PublishError,
74            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
75        >,
76    > {
77        let input = self
78            .inner
79            .build()
80            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
81        let runtime_plugins = crate::operation::publish::Publish::operation_runtime_plugins(
82            self.handle.runtime_plugins.clone(),
83            &self.handle.conf,
84            self.config_override,
85        );
86        crate::operation::publish::Publish::orchestrate(&runtime_plugins, input).await
87    }
88
89    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
90    pub fn customize(
91        self,
92    ) -> crate::client::customize::CustomizableOperation<crate::operation::publish::PublishOutput, crate::operation::publish::PublishError, Self>
93    {
94        crate::client::customize::CustomizableOperation::new(self)
95    }
96    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
97        self.set_config_override(::std::option::Option::Some(config_override.into()));
98        self
99    }
100
101    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
102        self.config_override = config_override;
103        self
104    }
105    /// <p>The name of the MQTT topic.</p>
106    pub fn topic(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
107        self.inner = self.inner.topic(input.into());
108        self
109    }
110    /// <p>The name of the MQTT topic.</p>
111    pub fn set_topic(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
112        self.inner = self.inner.set_topic(input);
113        self
114    }
115    /// <p>The name of the MQTT topic.</p>
116    pub fn get_topic(&self) -> &::std::option::Option<::std::string::String> {
117        self.inner.get_topic()
118    }
119    /// <p>The Quality of Service (QoS) level. The default QoS level is 0.</p>
120    pub fn qos(mut self, input: i32) -> Self {
121        self.inner = self.inner.qos(input);
122        self
123    }
124    /// <p>The Quality of Service (QoS) level. The default QoS level is 0.</p>
125    pub fn set_qos(mut self, input: ::std::option::Option<i32>) -> Self {
126        self.inner = self.inner.set_qos(input);
127        self
128    }
129    /// <p>The Quality of Service (QoS) level. The default QoS level is 0.</p>
130    pub fn get_qos(&self) -> &::std::option::Option<i32> {
131        self.inner.get_qos()
132    }
133    /// <p>A Boolean value that determines whether to set the RETAIN flag when the message is published.</p>
134    /// <p>Setting the RETAIN flag causes the message to be retained and sent to new subscribers to the topic.</p>
135    /// <p>Valid values: <code>true</code> | <code>false</code></p>
136    /// <p>Default value: <code>false</code></p>
137    pub fn retain(mut self, input: bool) -> Self {
138        self.inner = self.inner.retain(input);
139        self
140    }
141    /// <p>A Boolean value that determines whether to set the RETAIN flag when the message is published.</p>
142    /// <p>Setting the RETAIN flag causes the message to be retained and sent to new subscribers to the topic.</p>
143    /// <p>Valid values: <code>true</code> | <code>false</code></p>
144    /// <p>Default value: <code>false</code></p>
145    pub fn set_retain(mut self, input: ::std::option::Option<bool>) -> Self {
146        self.inner = self.inner.set_retain(input);
147        self
148    }
149    /// <p>A Boolean value that determines whether to set the RETAIN flag when the message is published.</p>
150    /// <p>Setting the RETAIN flag causes the message to be retained and sent to new subscribers to the topic.</p>
151    /// <p>Valid values: <code>true</code> | <code>false</code></p>
152    /// <p>Default value: <code>false</code></p>
153    pub fn get_retain(&self) -> &::std::option::Option<bool> {
154        self.inner.get_retain()
155    }
156    /// <p>The message body. MQTT accepts text, binary, and empty (null) message payloads.</p>
157    /// <p>Publishing an empty (null) payload with <b>retain</b> = <code>true</code> deletes the retained message identified by <b>topic</b> from Amazon Web Services IoT Core.</p>
158    pub fn payload(mut self, input: ::aws_smithy_types::Blob) -> Self {
159        self.inner = self.inner.payload(input);
160        self
161    }
162    /// <p>The message body. MQTT accepts text, binary, and empty (null) message payloads.</p>
163    /// <p>Publishing an empty (null) payload with <b>retain</b> = <code>true</code> deletes the retained message identified by <b>topic</b> from Amazon Web Services IoT Core.</p>
164    pub fn set_payload(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
165        self.inner = self.inner.set_payload(input);
166        self
167    }
168    /// <p>The message body. MQTT accepts text, binary, and empty (null) message payloads.</p>
169    /// <p>Publishing an empty (null) payload with <b>retain</b> = <code>true</code> deletes the retained message identified by <b>topic</b> from Amazon Web Services IoT Core.</p>
170    pub fn get_payload(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
171        self.inner.get_payload()
172    }
173    /// <p>A JSON string that contains an array of JSON objects. If you don’t use Amazon Web Services SDK or CLI, you must encode the JSON string to base64 format before adding it to the HTTP header. <code>userProperties</code> is an HTTP header value in the API.</p>
174    /// <p>The following example <code>userProperties</code> parameter is a JSON string which represents two User Properties. Note that it needs to be base64-encoded:</p>
175    /// <p><code>\[{"deviceName": "alpha"}, {"deviceCnt": "45"}\]</code></p>
176    pub fn user_properties(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
177        self.inner = self.inner.user_properties(input.into());
178        self
179    }
180    /// <p>A JSON string that contains an array of JSON objects. If you don’t use Amazon Web Services SDK or CLI, you must encode the JSON string to base64 format before adding it to the HTTP header. <code>userProperties</code> is an HTTP header value in the API.</p>
181    /// <p>The following example <code>userProperties</code> parameter is a JSON string which represents two User Properties. Note that it needs to be base64-encoded:</p>
182    /// <p><code>\[{"deviceName": "alpha"}, {"deviceCnt": "45"}\]</code></p>
183    pub fn set_user_properties(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
184        self.inner = self.inner.set_user_properties(input);
185        self
186    }
187    /// <p>A JSON string that contains an array of JSON objects. If you don’t use Amazon Web Services SDK or CLI, you must encode the JSON string to base64 format before adding it to the HTTP header. <code>userProperties</code> is an HTTP header value in the API.</p>
188    /// <p>The following example <code>userProperties</code> parameter is a JSON string which represents two User Properties. Note that it needs to be base64-encoded:</p>
189    /// <p><code>\[{"deviceName": "alpha"}, {"deviceCnt": "45"}\]</code></p>
190    pub fn get_user_properties(&self) -> &::std::option::Option<::std::string::String> {
191        self.inner.get_user_properties()
192    }
193    /// <p>An <code>Enum</code> string value that indicates whether the payload is formatted as UTF-8. <code>payloadFormatIndicator</code> is an HTTP header value in the API.</p>
194    pub fn payload_format_indicator(mut self, input: crate::types::PayloadFormatIndicator) -> Self {
195        self.inner = self.inner.payload_format_indicator(input);
196        self
197    }
198    /// <p>An <code>Enum</code> string value that indicates whether the payload is formatted as UTF-8. <code>payloadFormatIndicator</code> is an HTTP header value in the API.</p>
199    pub fn set_payload_format_indicator(mut self, input: ::std::option::Option<crate::types::PayloadFormatIndicator>) -> Self {
200        self.inner = self.inner.set_payload_format_indicator(input);
201        self
202    }
203    /// <p>An <code>Enum</code> string value that indicates whether the payload is formatted as UTF-8. <code>payloadFormatIndicator</code> is an HTTP header value in the API.</p>
204    pub fn get_payload_format_indicator(&self) -> &::std::option::Option<crate::types::PayloadFormatIndicator> {
205        self.inner.get_payload_format_indicator()
206    }
207    /// <p>A UTF-8 encoded string that describes the content of the publishing message.</p>
208    pub fn content_type(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
209        self.inner = self.inner.content_type(input.into());
210        self
211    }
212    /// <p>A UTF-8 encoded string that describes the content of the publishing message.</p>
213    pub fn set_content_type(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
214        self.inner = self.inner.set_content_type(input);
215        self
216    }
217    /// <p>A UTF-8 encoded string that describes the content of the publishing message.</p>
218    pub fn get_content_type(&self) -> &::std::option::Option<::std::string::String> {
219        self.inner.get_content_type()
220    }
221    /// <p>A UTF-8 encoded string that's used as the topic name for a response message. The response topic is used to describe the topic which the receiver should publish to as part of the request-response flow. The topic must not contain wildcard characters.</p>
222    pub fn response_topic(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
223        self.inner = self.inner.response_topic(input.into());
224        self
225    }
226    /// <p>A UTF-8 encoded string that's used as the topic name for a response message. The response topic is used to describe the topic which the receiver should publish to as part of the request-response flow. The topic must not contain wildcard characters.</p>
227    pub fn set_response_topic(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
228        self.inner = self.inner.set_response_topic(input);
229        self
230    }
231    /// <p>A UTF-8 encoded string that's used as the topic name for a response message. The response topic is used to describe the topic which the receiver should publish to as part of the request-response flow. The topic must not contain wildcard characters.</p>
232    pub fn get_response_topic(&self) -> &::std::option::Option<::std::string::String> {
233        self.inner.get_response_topic()
234    }
235    /// <p>The base64-encoded binary data used by the sender of the request message to identify which request the response message is for when it's received. <code>correlationData</code> is an HTTP header value in the API.</p>
236    pub fn correlation_data(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
237        self.inner = self.inner.correlation_data(input.into());
238        self
239    }
240    /// <p>The base64-encoded binary data used by the sender of the request message to identify which request the response message is for when it's received. <code>correlationData</code> is an HTTP header value in the API.</p>
241    pub fn set_correlation_data(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
242        self.inner = self.inner.set_correlation_data(input);
243        self
244    }
245    /// <p>The base64-encoded binary data used by the sender of the request message to identify which request the response message is for when it's received. <code>correlationData</code> is an HTTP header value in the API.</p>
246    pub fn get_correlation_data(&self) -> &::std::option::Option<::std::string::String> {
247        self.inner.get_correlation_data()
248    }
249    /// <p>A user-defined integer value that represents the message expiry interval in seconds. If absent, the message doesn't expire. For more information about the limits of <code>messageExpiry</code>, see <a href="https://docs.aws.amazon.com/general/latest/gr/iot-core.html#message-broker-limits">Amazon Web Services IoT Core message broker and protocol limits and quotas </a> from the Amazon Web Services Reference Guide.</p>
250    pub fn message_expiry(mut self, input: i64) -> Self {
251        self.inner = self.inner.message_expiry(input);
252        self
253    }
254    /// <p>A user-defined integer value that represents the message expiry interval in seconds. If absent, the message doesn't expire. For more information about the limits of <code>messageExpiry</code>, see <a href="https://docs.aws.amazon.com/general/latest/gr/iot-core.html#message-broker-limits">Amazon Web Services IoT Core message broker and protocol limits and quotas </a> from the Amazon Web Services Reference Guide.</p>
255    pub fn set_message_expiry(mut self, input: ::std::option::Option<i64>) -> Self {
256        self.inner = self.inner.set_message_expiry(input);
257        self
258    }
259    /// <p>A user-defined integer value that represents the message expiry interval in seconds. If absent, the message doesn't expire. For more information about the limits of <code>messageExpiry</code>, see <a href="https://docs.aws.amazon.com/general/latest/gr/iot-core.html#message-broker-limits">Amazon Web Services IoT Core message broker and protocol limits and quotas </a> from the Amazon Web Services Reference Guide.</p>
260    pub fn get_message_expiry(&self) -> &::std::option::Option<i64> {
261        self.inner.get_message_expiry()
262    }
263}