aws_sdk_iot/operation/create_thing/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_thing::_create_thing_output::CreateThingOutputBuilder;
3
4pub use crate::operation::create_thing::_create_thing_input::CreateThingInputBuilder;
5
6impl crate::operation::create_thing::builders::CreateThingInputBuilder {
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_thing::CreateThingOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_thing::CreateThingError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_thing();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreateThing`.
24///
25/// <p>Creates a thing record in the registry. If this call is made multiple times using the same thing name and configuration, the call will succeed. If this call is made with the same thing name but different configuration a <code>ResourceAlreadyExistsException</code> is thrown.</p><note>
26/// <p>This is a control plane operation. See <a href="https://docs.aws.amazon.com/iot/latest/developerguide/iot-authorization.html">Authorization</a> for information about authorizing control plane actions.</p>
27/// </note>
28/// <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">CreateThing</a> action.</p>
29#[derive(::std::clone::Clone, ::std::fmt::Debug)]
30pub struct CreateThingFluentBuilder {
31    handle: ::std::sync::Arc<crate::client::Handle>,
32    inner: crate::operation::create_thing::builders::CreateThingInputBuilder,
33    config_override: ::std::option::Option<crate::config::Builder>,
34}
35impl
36    crate::client::customize::internal::CustomizableSend<
37        crate::operation::create_thing::CreateThingOutput,
38        crate::operation::create_thing::CreateThingError,
39    > for CreateThingFluentBuilder
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_thing::CreateThingOutput,
47            crate::operation::create_thing::CreateThingError,
48        >,
49    > {
50        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
51    }
52}
53impl CreateThingFluentBuilder {
54    /// Creates a new `CreateThingFluentBuilder`.
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 CreateThing as a reference.
63    pub fn as_input(&self) -> &crate::operation::create_thing::builders::CreateThingInputBuilder {
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_thing::CreateThingOutput,
78        ::aws_smithy_runtime_api::client::result::SdkError<
79            crate::operation::create_thing::CreateThingError,
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_thing::CreateThing::operation_runtime_plugins(
88            self.handle.runtime_plugins.clone(),
89            &self.handle.conf,
90            self.config_override,
91        );
92        crate::operation::create_thing::CreateThing::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_thing::CreateThingOutput,
100        crate::operation::create_thing::CreateThingError,
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>The name of the thing to create.</p>
115    /// <p>You can't change a thing's name after you create it. To change a thing's name, you must create a new thing, give it the new name, and then delete the old thing.</p>
116    pub fn thing_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
117        self.inner = self.inner.thing_name(input.into());
118        self
119    }
120    /// <p>The name of the thing to create.</p>
121    /// <p>You can't change a thing's name after you create it. To change a thing's name, you must create a new thing, give it the new name, and then delete the old thing.</p>
122    pub fn set_thing_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
123        self.inner = self.inner.set_thing_name(input);
124        self
125    }
126    /// <p>The name of the thing to create.</p>
127    /// <p>You can't change a thing's name after you create it. To change a thing's name, you must create a new thing, give it the new name, and then delete the old thing.</p>
128    pub fn get_thing_name(&self) -> &::std::option::Option<::std::string::String> {
129        self.inner.get_thing_name()
130    }
131    /// <p>The name of the thing type associated with the new thing.</p>
132    pub fn thing_type_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
133        self.inner = self.inner.thing_type_name(input.into());
134        self
135    }
136    /// <p>The name of the thing type associated with the new thing.</p>
137    pub fn set_thing_type_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
138        self.inner = self.inner.set_thing_type_name(input);
139        self
140    }
141    /// <p>The name of the thing type associated with the new thing.</p>
142    pub fn get_thing_type_name(&self) -> &::std::option::Option<::std::string::String> {
143        self.inner.get_thing_type_name()
144    }
145    /// <p>The attribute payload, which consists of up to three name/value pairs in a JSON document. For example:</p>
146    /// <p><code>{\"attributes\":{\"string1\":\"string2\"}}</code></p>
147    pub fn attribute_payload(mut self, input: crate::types::AttributePayload) -> Self {
148        self.inner = self.inner.attribute_payload(input);
149        self
150    }
151    /// <p>The attribute payload, which consists of up to three name/value pairs in a JSON document. For example:</p>
152    /// <p><code>{\"attributes\":{\"string1\":\"string2\"}}</code></p>
153    pub fn set_attribute_payload(mut self, input: ::std::option::Option<crate::types::AttributePayload>) -> Self {
154        self.inner = self.inner.set_attribute_payload(input);
155        self
156    }
157    /// <p>The attribute payload, which consists of up to three name/value pairs in a JSON document. For example:</p>
158    /// <p><code>{\"attributes\":{\"string1\":\"string2\"}}</code></p>
159    pub fn get_attribute_payload(&self) -> &::std::option::Option<crate::types::AttributePayload> {
160        self.inner.get_attribute_payload()
161    }
162    /// <p>The name of the billing group the thing will be added to.</p>
163    pub fn billing_group_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
164        self.inner = self.inner.billing_group_name(input.into());
165        self
166    }
167    /// <p>The name of the billing group the thing will be added to.</p>
168    pub fn set_billing_group_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
169        self.inner = self.inner.set_billing_group_name(input);
170        self
171    }
172    /// <p>The name of the billing group the thing will be added to.</p>
173    pub fn get_billing_group_name(&self) -> &::std::option::Option<::std::string::String> {
174        self.inner.get_billing_group_name()
175    }
176}