aws_sdk_iotdataplane/operation/publish/
_publish_input.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>The input for the Publish operation.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct PublishInput {
7    /// <p>The name of the MQTT topic.</p>
8    pub topic: ::std::option::Option<::std::string::String>,
9    /// <p>The Quality of Service (QoS) level. The default QoS level is 0.</p>
10    pub qos: ::std::option::Option<i32>,
11    /// <p>A Boolean value that determines whether to set the RETAIN flag when the message is published.</p>
12    /// <p>Setting the RETAIN flag causes the message to be retained and sent to new subscribers to the topic.</p>
13    /// <p>Valid values: <code>true</code> | <code>false</code></p>
14    /// <p>Default value: <code>false</code></p>
15    pub retain: ::std::option::Option<bool>,
16    /// <p>The message body. MQTT accepts text, binary, and empty (null) message payloads.</p>
17    /// <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>
18    pub payload: ::std::option::Option<::aws_smithy_types::Blob>,
19    /// <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>
20    /// <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>
21    /// <p><code>\[{"deviceName": "alpha"}, {"deviceCnt": "45"}\]</code></p>
22    pub user_properties: ::std::option::Option<::std::string::String>,
23    /// <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>
24    pub payload_format_indicator: ::std::option::Option<crate::types::PayloadFormatIndicator>,
25    /// <p>A UTF-8 encoded string that describes the content of the publishing message.</p>
26    pub content_type: ::std::option::Option<::std::string::String>,
27    /// <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>
28    pub response_topic: ::std::option::Option<::std::string::String>,
29    /// <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>
30    pub correlation_data: ::std::option::Option<::std::string::String>,
31    /// <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>
32    pub message_expiry: ::std::option::Option<i64>,
33}
34impl PublishInput {
35    /// <p>The name of the MQTT topic.</p>
36    pub fn topic(&self) -> ::std::option::Option<&str> {
37        self.topic.as_deref()
38    }
39    /// <p>The Quality of Service (QoS) level. The default QoS level is 0.</p>
40    pub fn qos(&self) -> ::std::option::Option<i32> {
41        self.qos
42    }
43    /// <p>A Boolean value that determines whether to set the RETAIN flag when the message is published.</p>
44    /// <p>Setting the RETAIN flag causes the message to be retained and sent to new subscribers to the topic.</p>
45    /// <p>Valid values: <code>true</code> | <code>false</code></p>
46    /// <p>Default value: <code>false</code></p>
47    pub fn retain(&self) -> ::std::option::Option<bool> {
48        self.retain
49    }
50    /// <p>The message body. MQTT accepts text, binary, and empty (null) message payloads.</p>
51    /// <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>
52    pub fn payload(&self) -> ::std::option::Option<&::aws_smithy_types::Blob> {
53        self.payload.as_ref()
54    }
55    /// <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>
56    /// <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>
57    /// <p><code>\[{"deviceName": "alpha"}, {"deviceCnt": "45"}\]</code></p>
58    pub fn user_properties(&self) -> ::std::option::Option<&str> {
59        self.user_properties.as_deref()
60    }
61    /// <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>
62    pub fn payload_format_indicator(&self) -> ::std::option::Option<&crate::types::PayloadFormatIndicator> {
63        self.payload_format_indicator.as_ref()
64    }
65    /// <p>A UTF-8 encoded string that describes the content of the publishing message.</p>
66    pub fn content_type(&self) -> ::std::option::Option<&str> {
67        self.content_type.as_deref()
68    }
69    /// <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>
70    pub fn response_topic(&self) -> ::std::option::Option<&str> {
71        self.response_topic.as_deref()
72    }
73    /// <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>
74    pub fn correlation_data(&self) -> ::std::option::Option<&str> {
75        self.correlation_data.as_deref()
76    }
77    /// <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>
78    pub fn message_expiry(&self) -> ::std::option::Option<i64> {
79        self.message_expiry
80    }
81}
82impl PublishInput {
83    /// Creates a new builder-style object to manufacture [`PublishInput`](crate::operation::publish::PublishInput).
84    pub fn builder() -> crate::operation::publish::builders::PublishInputBuilder {
85        crate::operation::publish::builders::PublishInputBuilder::default()
86    }
87}
88
89/// A builder for [`PublishInput`](crate::operation::publish::PublishInput).
90#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
91#[non_exhaustive]
92pub struct PublishInputBuilder {
93    pub(crate) topic: ::std::option::Option<::std::string::String>,
94    pub(crate) qos: ::std::option::Option<i32>,
95    pub(crate) retain: ::std::option::Option<bool>,
96    pub(crate) payload: ::std::option::Option<::aws_smithy_types::Blob>,
97    pub(crate) user_properties: ::std::option::Option<::std::string::String>,
98    pub(crate) payload_format_indicator: ::std::option::Option<crate::types::PayloadFormatIndicator>,
99    pub(crate) content_type: ::std::option::Option<::std::string::String>,
100    pub(crate) response_topic: ::std::option::Option<::std::string::String>,
101    pub(crate) correlation_data: ::std::option::Option<::std::string::String>,
102    pub(crate) message_expiry: ::std::option::Option<i64>,
103}
104impl PublishInputBuilder {
105    /// <p>The name of the MQTT topic.</p>
106    /// This field is required.
107    pub fn topic(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
108        self.topic = ::std::option::Option::Some(input.into());
109        self
110    }
111    /// <p>The name of the MQTT topic.</p>
112    pub fn set_topic(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
113        self.topic = input;
114        self
115    }
116    /// <p>The name of the MQTT topic.</p>
117    pub fn get_topic(&self) -> &::std::option::Option<::std::string::String> {
118        &self.topic
119    }
120    /// <p>The Quality of Service (QoS) level. The default QoS level is 0.</p>
121    pub fn qos(mut self, input: i32) -> Self {
122        self.qos = ::std::option::Option::Some(input);
123        self
124    }
125    /// <p>The Quality of Service (QoS) level. The default QoS level is 0.</p>
126    pub fn set_qos(mut self, input: ::std::option::Option<i32>) -> Self {
127        self.qos = input;
128        self
129    }
130    /// <p>The Quality of Service (QoS) level. The default QoS level is 0.</p>
131    pub fn get_qos(&self) -> &::std::option::Option<i32> {
132        &self.qos
133    }
134    /// <p>A Boolean value that determines whether to set the RETAIN flag when the message is published.</p>
135    /// <p>Setting the RETAIN flag causes the message to be retained and sent to new subscribers to the topic.</p>
136    /// <p>Valid values: <code>true</code> | <code>false</code></p>
137    /// <p>Default value: <code>false</code></p>
138    pub fn retain(mut self, input: bool) -> Self {
139        self.retain = ::std::option::Option::Some(input);
140        self
141    }
142    /// <p>A Boolean value that determines whether to set the RETAIN flag when the message is published.</p>
143    /// <p>Setting the RETAIN flag causes the message to be retained and sent to new subscribers to the topic.</p>
144    /// <p>Valid values: <code>true</code> | <code>false</code></p>
145    /// <p>Default value: <code>false</code></p>
146    pub fn set_retain(mut self, input: ::std::option::Option<bool>) -> Self {
147        self.retain = input;
148        self
149    }
150    /// <p>A Boolean value that determines whether to set the RETAIN flag when the message is published.</p>
151    /// <p>Setting the RETAIN flag causes the message to be retained and sent to new subscribers to the topic.</p>
152    /// <p>Valid values: <code>true</code> | <code>false</code></p>
153    /// <p>Default value: <code>false</code></p>
154    pub fn get_retain(&self) -> &::std::option::Option<bool> {
155        &self.retain
156    }
157    /// <p>The message body. MQTT accepts text, binary, and empty (null) message payloads.</p>
158    /// <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>
159    pub fn payload(mut self, input: ::aws_smithy_types::Blob) -> Self {
160        self.payload = ::std::option::Option::Some(input);
161        self
162    }
163    /// <p>The message body. MQTT accepts text, binary, and empty (null) message payloads.</p>
164    /// <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>
165    pub fn set_payload(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
166        self.payload = input;
167        self
168    }
169    /// <p>The message body. MQTT accepts text, binary, and empty (null) message payloads.</p>
170    /// <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>
171    pub fn get_payload(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
172        &self.payload
173    }
174    /// <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>
175    /// <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>
176    /// <p><code>\[{"deviceName": "alpha"}, {"deviceCnt": "45"}\]</code></p>
177    pub fn user_properties(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
178        self.user_properties = ::std::option::Option::Some(input.into());
179        self
180    }
181    /// <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>
182    /// <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>
183    /// <p><code>\[{"deviceName": "alpha"}, {"deviceCnt": "45"}\]</code></p>
184    pub fn set_user_properties(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
185        self.user_properties = input;
186        self
187    }
188    /// <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>
189    /// <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>
190    /// <p><code>\[{"deviceName": "alpha"}, {"deviceCnt": "45"}\]</code></p>
191    pub fn get_user_properties(&self) -> &::std::option::Option<::std::string::String> {
192        &self.user_properties
193    }
194    /// <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>
195    pub fn payload_format_indicator(mut self, input: crate::types::PayloadFormatIndicator) -> Self {
196        self.payload_format_indicator = ::std::option::Option::Some(input);
197        self
198    }
199    /// <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>
200    pub fn set_payload_format_indicator(mut self, input: ::std::option::Option<crate::types::PayloadFormatIndicator>) -> Self {
201        self.payload_format_indicator = input;
202        self
203    }
204    /// <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>
205    pub fn get_payload_format_indicator(&self) -> &::std::option::Option<crate::types::PayloadFormatIndicator> {
206        &self.payload_format_indicator
207    }
208    /// <p>A UTF-8 encoded string that describes the content of the publishing message.</p>
209    pub fn content_type(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
210        self.content_type = ::std::option::Option::Some(input.into());
211        self
212    }
213    /// <p>A UTF-8 encoded string that describes the content of the publishing message.</p>
214    pub fn set_content_type(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
215        self.content_type = input;
216        self
217    }
218    /// <p>A UTF-8 encoded string that describes the content of the publishing message.</p>
219    pub fn get_content_type(&self) -> &::std::option::Option<::std::string::String> {
220        &self.content_type
221    }
222    /// <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>
223    pub fn response_topic(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
224        self.response_topic = ::std::option::Option::Some(input.into());
225        self
226    }
227    /// <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>
228    pub fn set_response_topic(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
229        self.response_topic = input;
230        self
231    }
232    /// <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>
233    pub fn get_response_topic(&self) -> &::std::option::Option<::std::string::String> {
234        &self.response_topic
235    }
236    /// <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>
237    pub fn correlation_data(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
238        self.correlation_data = ::std::option::Option::Some(input.into());
239        self
240    }
241    /// <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>
242    pub fn set_correlation_data(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
243        self.correlation_data = input;
244        self
245    }
246    /// <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>
247    pub fn get_correlation_data(&self) -> &::std::option::Option<::std::string::String> {
248        &self.correlation_data
249    }
250    /// <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>
251    pub fn message_expiry(mut self, input: i64) -> Self {
252        self.message_expiry = ::std::option::Option::Some(input);
253        self
254    }
255    /// <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>
256    pub fn set_message_expiry(mut self, input: ::std::option::Option<i64>) -> Self {
257        self.message_expiry = input;
258        self
259    }
260    /// <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>
261    pub fn get_message_expiry(&self) -> &::std::option::Option<i64> {
262        &self.message_expiry
263    }
264    /// Consumes the builder and constructs a [`PublishInput`](crate::operation::publish::PublishInput).
265    pub fn build(self) -> ::std::result::Result<crate::operation::publish::PublishInput, ::aws_smithy_types::error::operation::BuildError> {
266        ::std::result::Result::Ok(crate::operation::publish::PublishInput {
267            topic: self.topic,
268            qos: self.qos,
269            retain: self.retain,
270            payload: self.payload,
271            user_properties: self.user_properties,
272            payload_format_indicator: self.payload_format_indicator,
273            content_type: self.content_type,
274            response_topic: self.response_topic,
275            correlation_data: self.correlation_data,
276            message_expiry: self.message_expiry,
277        })
278    }
279}