aws_sdk_kinesis/operation/merge_shards/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::merge_shards::_merge_shards_output::MergeShardsOutputBuilder;
3
4pub use crate::operation::merge_shards::_merge_shards_input::MergeShardsInputBuilder;
5
6impl crate::operation::merge_shards::builders::MergeShardsInputBuilder {
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::merge_shards::MergeShardsOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::merge_shards::MergeShardsError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.merge_shards();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `MergeShards`.
24///
25/// <p>Merges two adjacent shards in a Kinesis data stream and combines them into a single shard to reduce the stream's capacity to ingest and transport data. This API is only supported for the data streams with the provisioned capacity mode. Two shards are considered adjacent if the union of the hash key ranges for the two shards form a contiguous set with no gaps. For example, if you have two shards, one with a hash key range of 276...381 and the other with a hash key range of 382...454, then you could merge these two shards into a single shard that would have a hash key range of 276...454. After the merge, the single child shard receives data for all hash key values covered by the two parent shards.</p><note>
26/// <p>When invoking this API, you must use either the <code>StreamARN</code> or the <code>StreamName</code> parameter, or both. It is recommended that you use the <code>StreamARN</code> input parameter when you invoke this API.</p>
27/// </note>
28/// <p><code>MergeShards</code> is called when there is a need to reduce the overall capacity of a stream because of excess capacity that is not being used. You must specify the shard to be merged and the adjacent shard for a stream. For more information about merging shards, see <a href="https://docs.aws.amazon.com/kinesis/latest/dev/kinesis-using-sdk-java-resharding-merge.html">Merge Two Shards</a> in the <i>Amazon Kinesis Data Streams Developer Guide</i>.</p>
29/// <p>If the stream is in the <code>ACTIVE</code> state, you can call <code>MergeShards</code>. If a stream is in the <code>CREATING</code>, <code>UPDATING</code>, or <code>DELETING</code> state, <code>MergeShards</code> returns a <code>ResourceInUseException</code>. If the specified stream does not exist, <code>MergeShards</code> returns a <code>ResourceNotFoundException</code>.</p>
30/// <p>You can use <code>DescribeStreamSummary</code> to check the state of the stream, which is returned in <code>StreamStatus</code>.</p>
31/// <p><code>MergeShards</code> is an asynchronous operation. Upon receiving a <code>MergeShards</code> request, Amazon Kinesis Data Streams immediately returns a response and sets the <code>StreamStatus</code> to <code>UPDATING</code>. After the operation is completed, Kinesis Data Streams sets the <code>StreamStatus</code> to <code>ACTIVE</code>. Read and write operations continue to work while the stream is in the <code>UPDATING</code> state.</p>
32/// <p>You use <code>DescribeStreamSummary</code> and the <code>ListShards</code> APIs to determine the shard IDs that are specified in the <code>MergeShards</code> request.</p>
33/// <p>If you try to operate on too many streams in parallel using <code>CreateStream</code>, <code>DeleteStream</code>, <code>MergeShards</code>, or <code>SplitShard</code>, you receive a <code>LimitExceededException</code>.</p>
34/// <p><code>MergeShards</code> has a limit of five transactions per second per account.</p>
35#[derive(::std::clone::Clone, ::std::fmt::Debug)]
36pub struct MergeShardsFluentBuilder {
37    handle: ::std::sync::Arc<crate::client::Handle>,
38    inner: crate::operation::merge_shards::builders::MergeShardsInputBuilder,
39    config_override: ::std::option::Option<crate::config::Builder>,
40}
41impl
42    crate::client::customize::internal::CustomizableSend<
43        crate::operation::merge_shards::MergeShardsOutput,
44        crate::operation::merge_shards::MergeShardsError,
45    > for MergeShardsFluentBuilder
46{
47    fn send(
48        self,
49        config_override: crate::config::Builder,
50    ) -> crate::client::customize::internal::BoxFuture<
51        crate::client::customize::internal::SendResult<
52            crate::operation::merge_shards::MergeShardsOutput,
53            crate::operation::merge_shards::MergeShardsError,
54        >,
55    > {
56        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
57    }
58}
59impl MergeShardsFluentBuilder {
60    /// Creates a new `MergeShardsFluentBuilder`.
61    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
62        Self {
63            handle,
64            inner: ::std::default::Default::default(),
65            config_override: ::std::option::Option::None,
66        }
67    }
68    /// Access the MergeShards as a reference.
69    pub fn as_input(&self) -> &crate::operation::merge_shards::builders::MergeShardsInputBuilder {
70        &self.inner
71    }
72    /// Sends the request and returns the response.
73    ///
74    /// If an error occurs, an `SdkError` will be returned with additional details that
75    /// can be matched against.
76    ///
77    /// By default, any retryable failures will be retried twice. Retry behavior
78    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
79    /// set when configuring the client.
80    pub async fn send(
81        self,
82    ) -> ::std::result::Result<
83        crate::operation::merge_shards::MergeShardsOutput,
84        ::aws_smithy_runtime_api::client::result::SdkError<
85            crate::operation::merge_shards::MergeShardsError,
86            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
87        >,
88    > {
89        let input = self
90            .inner
91            .build()
92            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
93        let runtime_plugins = crate::operation::merge_shards::MergeShards::operation_runtime_plugins(
94            self.handle.runtime_plugins.clone(),
95            &self.handle.conf,
96            self.config_override,
97        );
98        crate::operation::merge_shards::MergeShards::orchestrate(&runtime_plugins, input).await
99    }
100
101    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
102    pub fn customize(
103        self,
104    ) -> crate::client::customize::CustomizableOperation<
105        crate::operation::merge_shards::MergeShardsOutput,
106        crate::operation::merge_shards::MergeShardsError,
107        Self,
108    > {
109        crate::client::customize::CustomizableOperation::new(self)
110    }
111    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
112        self.set_config_override(::std::option::Option::Some(config_override.into()));
113        self
114    }
115
116    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
117        self.config_override = config_override;
118        self
119    }
120    /// <p>The name of the stream for the merge.</p>
121    pub fn stream_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
122        self.inner = self.inner.stream_name(input.into());
123        self
124    }
125    /// <p>The name of the stream for the merge.</p>
126    pub fn set_stream_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
127        self.inner = self.inner.set_stream_name(input);
128        self
129    }
130    /// <p>The name of the stream for the merge.</p>
131    pub fn get_stream_name(&self) -> &::std::option::Option<::std::string::String> {
132        self.inner.get_stream_name()
133    }
134    /// <p>The shard ID of the shard to combine with the adjacent shard for the merge.</p>
135    pub fn shard_to_merge(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
136        self.inner = self.inner.shard_to_merge(input.into());
137        self
138    }
139    /// <p>The shard ID of the shard to combine with the adjacent shard for the merge.</p>
140    pub fn set_shard_to_merge(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
141        self.inner = self.inner.set_shard_to_merge(input);
142        self
143    }
144    /// <p>The shard ID of the shard to combine with the adjacent shard for the merge.</p>
145    pub fn get_shard_to_merge(&self) -> &::std::option::Option<::std::string::String> {
146        self.inner.get_shard_to_merge()
147    }
148    /// <p>The shard ID of the adjacent shard for the merge.</p>
149    pub fn adjacent_shard_to_merge(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
150        self.inner = self.inner.adjacent_shard_to_merge(input.into());
151        self
152    }
153    /// <p>The shard ID of the adjacent shard for the merge.</p>
154    pub fn set_adjacent_shard_to_merge(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
155        self.inner = self.inner.set_adjacent_shard_to_merge(input);
156        self
157    }
158    /// <p>The shard ID of the adjacent shard for the merge.</p>
159    pub fn get_adjacent_shard_to_merge(&self) -> &::std::option::Option<::std::string::String> {
160        self.inner.get_adjacent_shard_to_merge()
161    }
162    /// <p>The ARN of the stream.</p>
163    pub fn stream_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
164        self.inner = self.inner.stream_arn(input.into());
165        self
166    }
167    /// <p>The ARN of the stream.</p>
168    pub fn set_stream_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
169        self.inner = self.inner.set_stream_arn(input);
170        self
171    }
172    /// <p>The ARN of the stream.</p>
173    pub fn get_stream_arn(&self) -> &::std::option::Option<::std::string::String> {
174        self.inner.get_stream_arn()
175    }
176}