aws_sdk_ec2/waiters/
key_pair_exists.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3///
4/// Fluent builder for the `key_pair_exists` waiter.
5///
6/// This builder is intended to be used similar to the other fluent builders for
7/// normal operations on the client. However, instead of a `send` method, it has
8/// a `wait` method that takes a maximum amount of time to wait.
9///
10/// Construct this fluent builder using the client by importing the
11/// [`Waiters`](crate::client::Waiters) trait and calling the methods
12/// prefixed with `wait_until`.
13///
14#[derive(::std::clone::Clone, ::std::fmt::Debug)]
15pub struct KeyPairExistsFluentBuilder {
16    handle: ::std::sync::Arc<crate::client::Handle>,
17    inner: crate::operation::describe_key_pairs::builders::DescribeKeyPairsInputBuilder,
18}
19impl KeyPairExistsFluentBuilder {
20    /// Creates a new `KeyPairExistsFluentBuilder`.
21    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
22        Self {
23            handle,
24            inner: ::std::default::Default::default(),
25        }
26    }
27    /// Access the DescribeKeyPairs as a reference.
28    pub fn as_input(&self) -> &crate::operation::describe_key_pairs::builders::DescribeKeyPairsInputBuilder {
29        &self.inner
30    }
31    /// Wait for `key_pair_exists`
32    pub async fn wait(
33        self,
34        max_wait: ::std::time::Duration,
35    ) -> ::std::result::Result<crate::waiters::key_pair_exists::KeyPairExistsFinalPoll, crate::waiters::key_pair_exists::WaitUntilKeyPairExistsError>
36    {
37        let input = self
38            .inner
39            .build()
40            .map_err(::aws_smithy_runtime_api::client::waiters::error::WaiterError::construction_failure)?;
41        let runtime_plugins = crate::operation::describe_key_pairs::DescribeKeyPairs::operation_runtime_plugins(
42            self.handle.runtime_plugins.clone(),
43            &self.handle.conf,
44            ::std::option::Option::None,
45        )
46        .with_operation_plugin(crate::sdk_feature_tracker::waiter::WaiterFeatureTrackerRuntimePlugin::new());
47        let mut cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
48        let runtime_components_builder = runtime_plugins
49            .apply_client_configuration(&mut cfg)
50            .map_err(::aws_smithy_runtime_api::client::waiters::error::WaiterError::construction_failure)?;
51        let time_components = runtime_components_builder.into_time_components();
52        let sleep_impl = time_components.sleep_impl().expect("a sleep impl is required by waiters");
53        let time_source = time_components.time_source().expect("a time source is required by waiters");
54
55        let acceptor = move |result: ::std::result::Result<
56            &crate::operation::describe_key_pairs::DescribeKeyPairsOutput,
57            &crate::operation::describe_key_pairs::DescribeKeyPairsError,
58        >| {
59            // Matches: {"output":{"path":"length(KeyPairs[].KeyName) > `0`","expected":"true","comparator":"booleanEquals"}}
60            if crate::waiters::matchers::match_describe_key_pairs_0e2929c8dde53894b(result) {
61                return ::aws_smithy_runtime::client::waiters::AcceptorState::Success;
62            }
63            // Matches: {"errorType":"InvalidKeyPair.NotFound"}
64            if crate::waiters::matchers::match_describe_key_pairs_8c790177499d2da21(result) {
65                return ::aws_smithy_runtime::client::waiters::AcceptorState::Retry;
66            }
67            ::aws_smithy_runtime::client::waiters::AcceptorState::NoAcceptorsMatched
68        };
69        let operation = move || {
70            let input = input.clone();
71            let runtime_plugins = runtime_plugins.clone();
72            async move { crate::operation::describe_key_pairs::DescribeKeyPairs::orchestrate(&runtime_plugins, input).await }
73        };
74        let orchestrator = ::aws_smithy_runtime::client::waiters::WaiterOrchestrator::builder()
75            .min_delay(::std::time::Duration::from_secs(5))
76            .max_delay(::std::time::Duration::from_secs(120))
77            .max_wait(max_wait)
78            .time_source(time_source)
79            .sleep_impl(sleep_impl)
80            .acceptor(acceptor)
81            .operation(operation)
82            .build();
83        ::aws_smithy_runtime::client::waiters::attach_waiter_tracing_span(orchestrator.orchestrate()).await
84    }
85    ///
86    /// Appends an item to `KeyNames`.
87    ///
88    /// To override the contents of this collection use [`set_key_names`](Self::set_key_names).
89    ///
90    /// <p>The key pair names.</p>
91    /// <p>Default: Describes all of your key pairs.</p>
92    pub fn key_names(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
93        self.inner = self.inner.key_names(input.into());
94        self
95    }
96    /// <p>The key pair names.</p>
97    /// <p>Default: Describes all of your key pairs.</p>
98    pub fn set_key_names(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
99        self.inner = self.inner.set_key_names(input);
100        self
101    }
102    /// <p>The key pair names.</p>
103    /// <p>Default: Describes all of your key pairs.</p>
104    pub fn get_key_names(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
105        self.inner.get_key_names()
106    }
107    ///
108    /// Appends an item to `KeyPairIds`.
109    ///
110    /// To override the contents of this collection use [`set_key_pair_ids`](Self::set_key_pair_ids).
111    ///
112    /// <p>The IDs of the key pairs.</p>
113    pub fn key_pair_ids(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
114        self.inner = self.inner.key_pair_ids(input.into());
115        self
116    }
117    /// <p>The IDs of the key pairs.</p>
118    pub fn set_key_pair_ids(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
119        self.inner = self.inner.set_key_pair_ids(input);
120        self
121    }
122    /// <p>The IDs of the key pairs.</p>
123    pub fn get_key_pair_ids(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
124        self.inner.get_key_pair_ids()
125    }
126    /// <p>If <code>true</code>, the public key material is included in the response.</p>
127    /// <p>Default: <code>false</code></p>
128    pub fn include_public_key(mut self, input: bool) -> Self {
129        self.inner = self.inner.include_public_key(input);
130        self
131    }
132    /// <p>If <code>true</code>, the public key material is included in the response.</p>
133    /// <p>Default: <code>false</code></p>
134    pub fn set_include_public_key(mut self, input: ::std::option::Option<bool>) -> Self {
135        self.inner = self.inner.set_include_public_key(input);
136        self
137    }
138    /// <p>If <code>true</code>, the public key material is included in the response.</p>
139    /// <p>Default: <code>false</code></p>
140    pub fn get_include_public_key(&self) -> &::std::option::Option<bool> {
141        self.inner.get_include_public_key()
142    }
143    /// <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
144    pub fn dry_run(mut self, input: bool) -> Self {
145        self.inner = self.inner.dry_run(input);
146        self
147    }
148    /// <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
149    pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
150        self.inner = self.inner.set_dry_run(input);
151        self
152    }
153    /// <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
154    pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
155        self.inner.get_dry_run()
156    }
157    ///
158    /// Appends an item to `Filters`.
159    ///
160    /// To override the contents of this collection use [`set_filters`](Self::set_filters).
161    ///
162    /// <p>The filters.</p>
163    /// <ul>
164    /// <li>
165    /// <p><code>key-pair-id</code> - The ID of the key pair.</p></li>
166    /// <li>
167    /// <p><code>fingerprint</code> - The fingerprint of the key pair.</p></li>
168    /// <li>
169    /// <p><code>key-name</code> - The name of the key pair.</p></li>
170    /// <li>
171    /// <p><code>tag-key</code> - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.</p></li>
172    /// <li>
173    /// <p><code>tag</code>:<key>
174    /// - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key
175    /// <code>Owner</code> and the value
176    /// <code>TeamA</code>, specify
177    /// <code>tag:Owner</code> for the filter name and
178    /// <code>TeamA</code> for the filter value.
179    /// </key></p></li>
180    /// </ul>
181    pub fn filters(mut self, input: crate::types::Filter) -> Self {
182        self.inner = self.inner.filters(input);
183        self
184    }
185    /// <p>The filters.</p>
186    /// <ul>
187    /// <li>
188    /// <p><code>key-pair-id</code> - The ID of the key pair.</p></li>
189    /// <li>
190    /// <p><code>fingerprint</code> - The fingerprint of the key pair.</p></li>
191    /// <li>
192    /// <p><code>key-name</code> - The name of the key pair.</p></li>
193    /// <li>
194    /// <p><code>tag-key</code> - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.</p></li>
195    /// <li>
196    /// <p><code>tag</code>:<key>
197    /// - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key
198    /// <code>Owner</code> and the value
199    /// <code>TeamA</code>, specify
200    /// <code>tag:Owner</code> for the filter name and
201    /// <code>TeamA</code> for the filter value.
202    /// </key></p></li>
203    /// </ul>
204    pub fn set_filters(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Filter>>) -> Self {
205        self.inner = self.inner.set_filters(input);
206        self
207    }
208    /// <p>The filters.</p>
209    /// <ul>
210    /// <li>
211    /// <p><code>key-pair-id</code> - The ID of the key pair.</p></li>
212    /// <li>
213    /// <p><code>fingerprint</code> - The fingerprint of the key pair.</p></li>
214    /// <li>
215    /// <p><code>key-name</code> - The name of the key pair.</p></li>
216    /// <li>
217    /// <p><code>tag-key</code> - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.</p></li>
218    /// <li>
219    /// <p><code>tag</code>:<key>
220    /// - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key
221    /// <code>Owner</code> and the value
222    /// <code>TeamA</code>, specify
223    /// <code>tag:Owner</code> for the filter name and
224    /// <code>TeamA</code> for the filter value.
225    /// </key></p></li>
226    /// </ul>
227    pub fn get_filters(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Filter>> {
228        self.inner.get_filters()
229    }
230}
231
232/// Successful return type for the `key_pair_exists` waiter.
233pub type KeyPairExistsFinalPoll = ::aws_smithy_runtime_api::client::waiters::FinalPoll<
234    crate::operation::describe_key_pairs::DescribeKeyPairsOutput,
235    ::aws_smithy_runtime_api::client::result::SdkError<
236        crate::operation::describe_key_pairs::DescribeKeyPairsError,
237        ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
238    >,
239>;
240
241/// Error type for the `key_pair_exists` waiter.
242pub type WaitUntilKeyPairExistsError = ::aws_smithy_runtime_api::client::waiters::error::WaiterError<
243    crate::operation::describe_key_pairs::DescribeKeyPairsOutput,
244    crate::operation::describe_key_pairs::DescribeKeyPairsError,
245>;