aws_sdk_iam/waiters/
policy_exists.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3///
4/// Fluent builder for the `policy_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 PolicyExistsFluentBuilder {
16    handle: ::std::sync::Arc<crate::client::Handle>,
17    inner: crate::operation::get_policy::builders::GetPolicyInputBuilder,
18}
19impl PolicyExistsFluentBuilder {
20    /// Creates a new `PolicyExistsFluentBuilder`.
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 GetPolicy as a reference.
28    pub fn as_input(&self) -> &crate::operation::get_policy::builders::GetPolicyInputBuilder {
29        &self.inner
30    }
31    /// Wait for `policy_exists`
32    pub async fn wait(
33        self,
34        max_wait: ::std::time::Duration,
35    ) -> ::std::result::Result<crate::waiters::policy_exists::PolicyExistsFinalPoll, crate::waiters::policy_exists::WaitUntilPolicyExistsError> {
36        let input = self
37            .inner
38            .build()
39            .map_err(::aws_smithy_runtime_api::client::waiters::error::WaiterError::construction_failure)?;
40        let runtime_plugins = crate::operation::get_policy::GetPolicy::operation_runtime_plugins(
41            self.handle.runtime_plugins.clone(),
42            &self.handle.conf,
43            ::std::option::Option::None,
44        )
45        .with_operation_plugin(crate::sdk_feature_tracker::waiter::WaiterFeatureTrackerRuntimePlugin::new());
46        let mut cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
47        let runtime_components_builder = runtime_plugins
48            .apply_client_configuration(&mut cfg)
49            .map_err(::aws_smithy_runtime_api::client::waiters::error::WaiterError::construction_failure)?;
50        let time_components = runtime_components_builder.into_time_components();
51        let sleep_impl = time_components.sleep_impl().expect("a sleep impl is required by waiters");
52        let time_source = time_components.time_source().expect("a time source is required by waiters");
53
54        let acceptor =
55            move |result: ::std::result::Result<&crate::operation::get_policy::GetPolicyOutput, &crate::operation::get_policy::GetPolicyError>| {
56                // Matches: {"success":true}
57                if crate::waiters::matchers::match_get_policy_c955e57777ec0d736(result) {
58                    return ::aws_smithy_runtime::client::waiters::AcceptorState::Success;
59                }
60                // Matches: {"errorType":"NoSuchEntity"}
61                if crate::waiters::matchers::match_get_policy_606386b4be9df73c9(result) {
62                    return ::aws_smithy_runtime::client::waiters::AcceptorState::Retry;
63                }
64                ::aws_smithy_runtime::client::waiters::AcceptorState::NoAcceptorsMatched
65            };
66        let operation = move || {
67            let input = input.clone();
68            let runtime_plugins = runtime_plugins.clone();
69            async move { crate::operation::get_policy::GetPolicy::orchestrate(&runtime_plugins, input).await }
70        };
71        let orchestrator = ::aws_smithy_runtime::client::waiters::WaiterOrchestrator::builder()
72            .min_delay(::std::time::Duration::from_secs(1))
73            .max_delay(::std::time::Duration::from_secs(120))
74            .max_wait(max_wait)
75            .time_source(time_source)
76            .sleep_impl(sleep_impl)
77            .acceptor(acceptor)
78            .operation(operation)
79            .build();
80        ::aws_smithy_runtime::client::waiters::attach_waiter_tracing_span(orchestrator.orchestrate()).await
81    }
82    /// <p>The Amazon Resource Name (ARN) of the managed policy that you want information about.</p>
83    /// <p>For more information about ARNs, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Names (ARNs)</a> in the <i>Amazon Web Services General Reference</i>.</p>
84    pub fn policy_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
85        self.inner = self.inner.policy_arn(input.into());
86        self
87    }
88    /// <p>The Amazon Resource Name (ARN) of the managed policy that you want information about.</p>
89    /// <p>For more information about ARNs, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Names (ARNs)</a> in the <i>Amazon Web Services General Reference</i>.</p>
90    pub fn set_policy_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
91        self.inner = self.inner.set_policy_arn(input);
92        self
93    }
94    /// <p>The Amazon Resource Name (ARN) of the managed policy that you want information about.</p>
95    /// <p>For more information about ARNs, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Names (ARNs)</a> in the <i>Amazon Web Services General Reference</i>.</p>
96    pub fn get_policy_arn(&self) -> &::std::option::Option<::std::string::String> {
97        self.inner.get_policy_arn()
98    }
99}
100
101/// Successful return type for the `policy_exists` waiter.
102pub type PolicyExistsFinalPoll = ::aws_smithy_runtime_api::client::waiters::FinalPoll<
103    crate::operation::get_policy::GetPolicyOutput,
104    ::aws_smithy_runtime_api::client::result::SdkError<
105        crate::operation::get_policy::GetPolicyError,
106        ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
107    >,
108>;
109
110/// Error type for the `policy_exists` waiter.
111pub type WaitUntilPolicyExistsError = ::aws_smithy_runtime_api::client::waiters::error::WaiterError<
112    crate::operation::get_policy::GetPolicyOutput,
113    crate::operation::get_policy::GetPolicyError,
114>;