Skip to main content

aws_sdk_iam/operation/tag_policy/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::tag_policy::_tag_policy_input::TagPolicyInputBuilder;
3
4pub use crate::operation::tag_policy::_tag_policy_output::TagPolicyOutputBuilder;
5
6impl crate::operation::tag_policy::builders::TagPolicyInputBuilder {
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::tag_policy::TagPolicyOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::tag_policy::TagPolicyError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.tag_policy();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `TagPolicy`.
24///
25/// <p>Adds one or more tags to an IAM customer managed policy. If a tag with the same key name already exists, then that tag is overwritten with the new value.</p>
26/// <p>A tag consists of a key name and an associated value. By assigning tags to your resources, you can do the following:</p>
27/// <ul>
28/// <li>
29/// <p><b>Administrative grouping and discovery</b> - Attach tags to resources to aid in organization and search. For example, you could search for all resources with the key name <i>Project</i> and the value <i>MyImportantProject</i>. Or search for all resources with the key name <i>Cost Center</i> and the value <i>41200</i>.</p></li>
30/// <li>
31/// <p><b>Access control</b> - Include tags in IAM user-based and resource-based policies. You can use tags to restrict access to only an IAM customer managed policy that has a specified tag attached. For examples of policies that show how to use tags to control access, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html">Control access using IAM tags</a> in the <i>IAM User Guide</i>.</p></li>
32/// </ul><note>
33/// <ul>
34/// <li>
35/// <p>If any one of the tags is invalid or if you exceed the allowed maximum number of tags, then the entire request fails and the resource is not created. For more information about tagging, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html">Tagging IAM resources</a> in the <i>IAM User Guide</i>.</p></li>
36/// <li>
37/// <p>Amazon Web Services always interprets the tag <code>Value</code> as a single string. If you need to store an array, you can store comma-separated values in the string. However, you must interpret the value in your code.</p></li>
38/// </ul>
39/// </note>
40#[derive(::std::clone::Clone, ::std::fmt::Debug)]
41pub struct TagPolicyFluentBuilder {
42    handle: ::std::sync::Arc<crate::client::Handle>,
43    inner: crate::operation::tag_policy::builders::TagPolicyInputBuilder,
44    config_override: ::std::option::Option<crate::config::Builder>,
45}
46impl crate::client::customize::internal::CustomizableSend<crate::operation::tag_policy::TagPolicyOutput, crate::operation::tag_policy::TagPolicyError>
47    for TagPolicyFluentBuilder
48{
49    fn send(
50        self,
51        config_override: crate::config::Builder,
52    ) -> crate::client::customize::internal::BoxFuture<
53        crate::client::customize::internal::SendResult<crate::operation::tag_policy::TagPolicyOutput, crate::operation::tag_policy::TagPolicyError>,
54    > {
55        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
56    }
57}
58impl TagPolicyFluentBuilder {
59    /// Creates a new `TagPolicyFluentBuilder`.
60    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
61        Self {
62            handle,
63            inner: ::std::default::Default::default(),
64            config_override: ::std::option::Option::None,
65        }
66    }
67    /// Access the TagPolicy as a reference.
68    pub fn as_input(&self) -> &crate::operation::tag_policy::builders::TagPolicyInputBuilder {
69        &self.inner
70    }
71    /// Sends the request and returns the response.
72    ///
73    /// If an error occurs, an `SdkError` will be returned with additional details that
74    /// can be matched against.
75    ///
76    /// By default, any retryable failures will be retried twice. Retry behavior
77    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
78    /// set when configuring the client.
79    pub async fn send(
80        self,
81    ) -> ::std::result::Result<
82        crate::operation::tag_policy::TagPolicyOutput,
83        ::aws_smithy_runtime_api::client::result::SdkError<
84            crate::operation::tag_policy::TagPolicyError,
85            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
86        >,
87    > {
88        let input = self
89            .inner
90            .build()
91            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
92        let runtime_plugins = crate::operation::tag_policy::TagPolicy::operation_runtime_plugins(
93            self.handle.runtime_plugins.clone(),
94            &self.handle.conf,
95            self.config_override,
96        );
97        crate::operation::tag_policy::TagPolicy::orchestrate(&runtime_plugins, input).await
98    }
99
100    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
101    pub fn customize(
102        self,
103    ) -> crate::client::customize::CustomizableOperation<
104        crate::operation::tag_policy::TagPolicyOutput,
105        crate::operation::tag_policy::TagPolicyError,
106        Self,
107    > {
108        crate::client::customize::CustomizableOperation::new(self)
109    }
110    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
111        self.set_config_override(::std::option::Option::Some(config_override.into()));
112        self
113    }
114
115    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
116        self.config_override = config_override;
117        self
118    }
119    /// <p>The ARN of the IAM customer managed policy to which you want to add tags.</p>
120    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
121    pub fn policy_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
122        self.inner = self.inner.policy_arn(input.into());
123        self
124    }
125    /// <p>The ARN of the IAM customer managed policy to which you want to add tags.</p>
126    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
127    pub fn set_policy_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
128        self.inner = self.inner.set_policy_arn(input);
129        self
130    }
131    /// <p>The ARN of the IAM customer managed policy to which you want to add tags.</p>
132    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
133    pub fn get_policy_arn(&self) -> &::std::option::Option<::std::string::String> {
134        self.inner.get_policy_arn()
135    }
136    ///
137    /// Appends an item to `Tags`.
138    ///
139    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
140    ///
141    /// <p>The list of tags that you want to attach to the IAM customer managed policy. Each tag consists of a key name and an associated value.</p>
142    pub fn tags(mut self, input: crate::types::Tag) -> Self {
143        self.inner = self.inner.tags(input);
144        self
145    }
146    /// <p>The list of tags that you want to attach to the IAM customer managed policy. Each tag consists of a key name and an associated value.</p>
147    pub fn set_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>) -> Self {
148        self.inner = self.inner.set_tags(input);
149        self
150    }
151    /// <p>The list of tags that you want to attach to the IAM customer managed policy. Each tag consists of a key name and an associated value.</p>
152    pub fn get_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Tag>> {
153        self.inner.get_tags()
154    }
155}