aws_sdk_iam/operation/create_policy/
_create_policy_input.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(missing_docs)] // documentation missing in model
3#[non_exhaustive]
4#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
5pub struct CreatePolicyInput {
6    /// <p>The friendly name of the policy.</p>
7    /// <p>IAM user, group, role, and policy names must be unique within the account. Names are not distinguished by case. For example, you cannot create resources named both "MyResource" and "myresource".</p>
8    pub policy_name: ::std::option::Option<::std::string::String>,
9    /// <p>The path for the policy.</p>
10    /// <p>For more information about paths, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
11    /// <p>This parameter is optional. If it is not included, it defaults to a slash (/).</p>
12    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! (<code>\u0021</code>) through the DEL character (<code>\u007F</code>), including most punctuation characters, digits, and upper and lowercased letters.</p><note>
13    /// <p>You cannot use an asterisk (*) in the path name.</p>
14    /// </note>
15    pub path: ::std::option::Option<::std::string::String>,
16    /// <p>The JSON policy document that you want to use as the content for the new policy.</p>
17    /// <p>You must provide policies in JSON format in IAM. However, for CloudFormation templates formatted in YAML, you can provide the policy in JSON or YAML format. CloudFormation always converts a YAML policy to JSON format before submitting it to IAM.</p>
18    /// <p>The maximum length of the policy document that you can pass in this operation, including whitespace, is listed below. To view the maximum character counts of a managed policy with no whitespaces, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entity-length">IAM and STS character quotas</a>.</p>
19    /// <p>To learn more about JSON policy grammar, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_grammar.html">Grammar of the IAM JSON policy language</a> in the <i>IAM User Guide</i>.</p>
20    /// <p>The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a string of characters consisting of the following:</p>
21    /// <ul>
22    /// <li>
23    /// <p>Any printable ASCII character ranging from the space character (<code>\u0020</code>) through the end of the ASCII character range</p></li>
24    /// <li>
25    /// <p>The printable characters in the Basic Latin and Latin-1 Supplement character set (through <code>\u00FF</code>)</p></li>
26    /// <li>
27    /// <p>The special characters tab (<code>\u0009</code>), line feed (<code>\u000A</code>), and carriage return (<code>\u000D</code>)</p></li>
28    /// </ul>
29    pub policy_document: ::std::option::Option<::std::string::String>,
30    /// <p>A friendly description of the policy.</p>
31    /// <p>Typically used to store information about the permissions defined in the policy. For example, "Grants access to production DynamoDB tables."</p>
32    /// <p>The policy description is immutable. After a value is assigned, it cannot be changed.</p>
33    pub description: ::std::option::Option<::std::string::String>,
34    /// <p>A list of tags that you want to attach to the new IAM customer managed policy. Each tag consists of a key name and an associated value. 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><note>
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.</p>
36    /// </note>
37    pub tags: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>,
38}
39impl CreatePolicyInput {
40    /// <p>The friendly name of the policy.</p>
41    /// <p>IAM user, group, role, and policy names must be unique within the account. Names are not distinguished by case. For example, you cannot create resources named both "MyResource" and "myresource".</p>
42    pub fn policy_name(&self) -> ::std::option::Option<&str> {
43        self.policy_name.as_deref()
44    }
45    /// <p>The path for the policy.</p>
46    /// <p>For more information about paths, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
47    /// <p>This parameter is optional. If it is not included, it defaults to a slash (/).</p>
48    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! (<code>\u0021</code>) through the DEL character (<code>\u007F</code>), including most punctuation characters, digits, and upper and lowercased letters.</p><note>
49    /// <p>You cannot use an asterisk (*) in the path name.</p>
50    /// </note>
51    pub fn path(&self) -> ::std::option::Option<&str> {
52        self.path.as_deref()
53    }
54    /// <p>The JSON policy document that you want to use as the content for the new policy.</p>
55    /// <p>You must provide policies in JSON format in IAM. However, for CloudFormation templates formatted in YAML, you can provide the policy in JSON or YAML format. CloudFormation always converts a YAML policy to JSON format before submitting it to IAM.</p>
56    /// <p>The maximum length of the policy document that you can pass in this operation, including whitespace, is listed below. To view the maximum character counts of a managed policy with no whitespaces, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entity-length">IAM and STS character quotas</a>.</p>
57    /// <p>To learn more about JSON policy grammar, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_grammar.html">Grammar of the IAM JSON policy language</a> in the <i>IAM User Guide</i>.</p>
58    /// <p>The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a string of characters consisting of the following:</p>
59    /// <ul>
60    /// <li>
61    /// <p>Any printable ASCII character ranging from the space character (<code>\u0020</code>) through the end of the ASCII character range</p></li>
62    /// <li>
63    /// <p>The printable characters in the Basic Latin and Latin-1 Supplement character set (through <code>\u00FF</code>)</p></li>
64    /// <li>
65    /// <p>The special characters tab (<code>\u0009</code>), line feed (<code>\u000A</code>), and carriage return (<code>\u000D</code>)</p></li>
66    /// </ul>
67    pub fn policy_document(&self) -> ::std::option::Option<&str> {
68        self.policy_document.as_deref()
69    }
70    /// <p>A friendly description of the policy.</p>
71    /// <p>Typically used to store information about the permissions defined in the policy. For example, "Grants access to production DynamoDB tables."</p>
72    /// <p>The policy description is immutable. After a value is assigned, it cannot be changed.</p>
73    pub fn description(&self) -> ::std::option::Option<&str> {
74        self.description.as_deref()
75    }
76    /// <p>A list of tags that you want to attach to the new IAM customer managed policy. Each tag consists of a key name and an associated value. 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><note>
77    /// <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.</p>
78    /// </note>
79    ///
80    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.tags.is_none()`.
81    pub fn tags(&self) -> &[crate::types::Tag] {
82        self.tags.as_deref().unwrap_or_default()
83    }
84}
85impl CreatePolicyInput {
86    /// Creates a new builder-style object to manufacture [`CreatePolicyInput`](crate::operation::create_policy::CreatePolicyInput).
87    pub fn builder() -> crate::operation::create_policy::builders::CreatePolicyInputBuilder {
88        crate::operation::create_policy::builders::CreatePolicyInputBuilder::default()
89    }
90}
91
92/// A builder for [`CreatePolicyInput`](crate::operation::create_policy::CreatePolicyInput).
93#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
94#[non_exhaustive]
95pub struct CreatePolicyInputBuilder {
96    pub(crate) policy_name: ::std::option::Option<::std::string::String>,
97    pub(crate) path: ::std::option::Option<::std::string::String>,
98    pub(crate) policy_document: ::std::option::Option<::std::string::String>,
99    pub(crate) description: ::std::option::Option<::std::string::String>,
100    pub(crate) tags: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>,
101}
102impl CreatePolicyInputBuilder {
103    /// <p>The friendly name of the policy.</p>
104    /// <p>IAM user, group, role, and policy names must be unique within the account. Names are not distinguished by case. For example, you cannot create resources named both "MyResource" and "myresource".</p>
105    /// This field is required.
106    pub fn policy_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
107        self.policy_name = ::std::option::Option::Some(input.into());
108        self
109    }
110    /// <p>The friendly name of the policy.</p>
111    /// <p>IAM user, group, role, and policy names must be unique within the account. Names are not distinguished by case. For example, you cannot create resources named both "MyResource" and "myresource".</p>
112    pub fn set_policy_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
113        self.policy_name = input;
114        self
115    }
116    /// <p>The friendly name of the policy.</p>
117    /// <p>IAM user, group, role, and policy names must be unique within the account. Names are not distinguished by case. For example, you cannot create resources named both "MyResource" and "myresource".</p>
118    pub fn get_policy_name(&self) -> &::std::option::Option<::std::string::String> {
119        &self.policy_name
120    }
121    /// <p>The path for the policy.</p>
122    /// <p>For more information about paths, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
123    /// <p>This parameter is optional. If it is not included, it defaults to a slash (/).</p>
124    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! (<code>\u0021</code>) through the DEL character (<code>\u007F</code>), including most punctuation characters, digits, and upper and lowercased letters.</p><note>
125    /// <p>You cannot use an asterisk (*) in the path name.</p>
126    /// </note>
127    pub fn path(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
128        self.path = ::std::option::Option::Some(input.into());
129        self
130    }
131    /// <p>The path for the policy.</p>
132    /// <p>For more information about paths, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
133    /// <p>This parameter is optional. If it is not included, it defaults to a slash (/).</p>
134    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! (<code>\u0021</code>) through the DEL character (<code>\u007F</code>), including most punctuation characters, digits, and upper and lowercased letters.</p><note>
135    /// <p>You cannot use an asterisk (*) in the path name.</p>
136    /// </note>
137    pub fn set_path(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
138        self.path = input;
139        self
140    }
141    /// <p>The path for the policy.</p>
142    /// <p>For more information about paths, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
143    /// <p>This parameter is optional. If it is not included, it defaults to a slash (/).</p>
144    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! (<code>\u0021</code>) through the DEL character (<code>\u007F</code>), including most punctuation characters, digits, and upper and lowercased letters.</p><note>
145    /// <p>You cannot use an asterisk (*) in the path name.</p>
146    /// </note>
147    pub fn get_path(&self) -> &::std::option::Option<::std::string::String> {
148        &self.path
149    }
150    /// <p>The JSON policy document that you want to use as the content for the new policy.</p>
151    /// <p>You must provide policies in JSON format in IAM. However, for CloudFormation templates formatted in YAML, you can provide the policy in JSON or YAML format. CloudFormation always converts a YAML policy to JSON format before submitting it to IAM.</p>
152    /// <p>The maximum length of the policy document that you can pass in this operation, including whitespace, is listed below. To view the maximum character counts of a managed policy with no whitespaces, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entity-length">IAM and STS character quotas</a>.</p>
153    /// <p>To learn more about JSON policy grammar, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_grammar.html">Grammar of the IAM JSON policy language</a> in the <i>IAM User Guide</i>.</p>
154    /// <p>The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a string of characters consisting of the following:</p>
155    /// <ul>
156    /// <li>
157    /// <p>Any printable ASCII character ranging from the space character (<code>\u0020</code>) through the end of the ASCII character range</p></li>
158    /// <li>
159    /// <p>The printable characters in the Basic Latin and Latin-1 Supplement character set (through <code>\u00FF</code>)</p></li>
160    /// <li>
161    /// <p>The special characters tab (<code>\u0009</code>), line feed (<code>\u000A</code>), and carriage return (<code>\u000D</code>)</p></li>
162    /// </ul>
163    /// This field is required.
164    pub fn policy_document(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
165        self.policy_document = ::std::option::Option::Some(input.into());
166        self
167    }
168    /// <p>The JSON policy document that you want to use as the content for the new policy.</p>
169    /// <p>You must provide policies in JSON format in IAM. However, for CloudFormation templates formatted in YAML, you can provide the policy in JSON or YAML format. CloudFormation always converts a YAML policy to JSON format before submitting it to IAM.</p>
170    /// <p>The maximum length of the policy document that you can pass in this operation, including whitespace, is listed below. To view the maximum character counts of a managed policy with no whitespaces, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entity-length">IAM and STS character quotas</a>.</p>
171    /// <p>To learn more about JSON policy grammar, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_grammar.html">Grammar of the IAM JSON policy language</a> in the <i>IAM User Guide</i>.</p>
172    /// <p>The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a string of characters consisting of the following:</p>
173    /// <ul>
174    /// <li>
175    /// <p>Any printable ASCII character ranging from the space character (<code>\u0020</code>) through the end of the ASCII character range</p></li>
176    /// <li>
177    /// <p>The printable characters in the Basic Latin and Latin-1 Supplement character set (through <code>\u00FF</code>)</p></li>
178    /// <li>
179    /// <p>The special characters tab (<code>\u0009</code>), line feed (<code>\u000A</code>), and carriage return (<code>\u000D</code>)</p></li>
180    /// </ul>
181    pub fn set_policy_document(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
182        self.policy_document = input;
183        self
184    }
185    /// <p>The JSON policy document that you want to use as the content for the new policy.</p>
186    /// <p>You must provide policies in JSON format in IAM. However, for CloudFormation templates formatted in YAML, you can provide the policy in JSON or YAML format. CloudFormation always converts a YAML policy to JSON format before submitting it to IAM.</p>
187    /// <p>The maximum length of the policy document that you can pass in this operation, including whitespace, is listed below. To view the maximum character counts of a managed policy with no whitespaces, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entity-length">IAM and STS character quotas</a>.</p>
188    /// <p>To learn more about JSON policy grammar, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_grammar.html">Grammar of the IAM JSON policy language</a> in the <i>IAM User Guide</i>.</p>
189    /// <p>The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a string of characters consisting of the following:</p>
190    /// <ul>
191    /// <li>
192    /// <p>Any printable ASCII character ranging from the space character (<code>\u0020</code>) through the end of the ASCII character range</p></li>
193    /// <li>
194    /// <p>The printable characters in the Basic Latin and Latin-1 Supplement character set (through <code>\u00FF</code>)</p></li>
195    /// <li>
196    /// <p>The special characters tab (<code>\u0009</code>), line feed (<code>\u000A</code>), and carriage return (<code>\u000D</code>)</p></li>
197    /// </ul>
198    pub fn get_policy_document(&self) -> &::std::option::Option<::std::string::String> {
199        &self.policy_document
200    }
201    /// <p>A friendly description of the policy.</p>
202    /// <p>Typically used to store information about the permissions defined in the policy. For example, "Grants access to production DynamoDB tables."</p>
203    /// <p>The policy description is immutable. After a value is assigned, it cannot be changed.</p>
204    pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
205        self.description = ::std::option::Option::Some(input.into());
206        self
207    }
208    /// <p>A friendly description of the policy.</p>
209    /// <p>Typically used to store information about the permissions defined in the policy. For example, "Grants access to production DynamoDB tables."</p>
210    /// <p>The policy description is immutable. After a value is assigned, it cannot be changed.</p>
211    pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
212        self.description = input;
213        self
214    }
215    /// <p>A friendly description of the policy.</p>
216    /// <p>Typically used to store information about the permissions defined in the policy. For example, "Grants access to production DynamoDB tables."</p>
217    /// <p>The policy description is immutable. After a value is assigned, it cannot be changed.</p>
218    pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
219        &self.description
220    }
221    /// Appends an item to `tags`.
222    ///
223    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
224    ///
225    /// <p>A list of tags that you want to attach to the new IAM customer managed policy. Each tag consists of a key name and an associated value. 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><note>
226    /// <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.</p>
227    /// </note>
228    pub fn tags(mut self, input: crate::types::Tag) -> Self {
229        let mut v = self.tags.unwrap_or_default();
230        v.push(input);
231        self.tags = ::std::option::Option::Some(v);
232        self
233    }
234    /// <p>A list of tags that you want to attach to the new IAM customer managed policy. Each tag consists of a key name and an associated value. 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><note>
235    /// <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.</p>
236    /// </note>
237    pub fn set_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>) -> Self {
238        self.tags = input;
239        self
240    }
241    /// <p>A list of tags that you want to attach to the new IAM customer managed policy. Each tag consists of a key name and an associated value. 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><note>
242    /// <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.</p>
243    /// </note>
244    pub fn get_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Tag>> {
245        &self.tags
246    }
247    /// Consumes the builder and constructs a [`CreatePolicyInput`](crate::operation::create_policy::CreatePolicyInput).
248    pub fn build(
249        self,
250    ) -> ::std::result::Result<crate::operation::create_policy::CreatePolicyInput, ::aws_smithy_types::error::operation::BuildError> {
251        ::std::result::Result::Ok(crate::operation::create_policy::CreatePolicyInput {
252            policy_name: self.policy_name,
253            path: self.path,
254            policy_document: self.policy_document,
255            description: self.description,
256            tags: self.tags,
257        })
258    }
259}