aws_sdk_iot/operation/create_policy/
_create_policy_input.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>The input for the CreatePolicy operation.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct CreatePolicyInput {
7    /// <p>The policy name.</p>
8    pub policy_name: ::std::option::Option<::std::string::String>,
9    /// <p>The JSON document that describes the policy. <b>policyDocument</b> must have a minimum length of 1, with a maximum length of 2048, excluding whitespace.</p>
10    pub policy_document: ::std::option::Option<::std::string::String>,
11    /// <p>Metadata which can be used to manage the policy.</p><note>
12    /// <p>For URI Request parameters use format: ...key1=value1&amp;key2=value2...</p>
13    /// <p>For the CLI command-line parameter use format: &amp;&amp;tags "key1=value1&amp;key2=value2..."</p>
14    /// <p>For the cli-input-json file use format: "tags": "key1=value1&amp;key2=value2..."</p>
15    /// </note>
16    pub tags: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>,
17}
18impl CreatePolicyInput {
19    /// <p>The policy name.</p>
20    pub fn policy_name(&self) -> ::std::option::Option<&str> {
21        self.policy_name.as_deref()
22    }
23    /// <p>The JSON document that describes the policy. <b>policyDocument</b> must have a minimum length of 1, with a maximum length of 2048, excluding whitespace.</p>
24    pub fn policy_document(&self) -> ::std::option::Option<&str> {
25        self.policy_document.as_deref()
26    }
27    /// <p>Metadata which can be used to manage the policy.</p><note>
28    /// <p>For URI Request parameters use format: ...key1=value1&amp;key2=value2...</p>
29    /// <p>For the CLI command-line parameter use format: &amp;&amp;tags "key1=value1&amp;key2=value2..."</p>
30    /// <p>For the cli-input-json file use format: "tags": "key1=value1&amp;key2=value2..."</p>
31    /// </note>
32    ///
33    /// 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()`.
34    pub fn tags(&self) -> &[crate::types::Tag] {
35        self.tags.as_deref().unwrap_or_default()
36    }
37}
38impl CreatePolicyInput {
39    /// Creates a new builder-style object to manufacture [`CreatePolicyInput`](crate::operation::create_policy::CreatePolicyInput).
40    pub fn builder() -> crate::operation::create_policy::builders::CreatePolicyInputBuilder {
41        crate::operation::create_policy::builders::CreatePolicyInputBuilder::default()
42    }
43}
44
45/// A builder for [`CreatePolicyInput`](crate::operation::create_policy::CreatePolicyInput).
46#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
47#[non_exhaustive]
48pub struct CreatePolicyInputBuilder {
49    pub(crate) policy_name: ::std::option::Option<::std::string::String>,
50    pub(crate) policy_document: ::std::option::Option<::std::string::String>,
51    pub(crate) tags: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>,
52}
53impl CreatePolicyInputBuilder {
54    /// <p>The policy name.</p>
55    /// This field is required.
56    pub fn policy_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
57        self.policy_name = ::std::option::Option::Some(input.into());
58        self
59    }
60    /// <p>The policy name.</p>
61    pub fn set_policy_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
62        self.policy_name = input;
63        self
64    }
65    /// <p>The policy name.</p>
66    pub fn get_policy_name(&self) -> &::std::option::Option<::std::string::String> {
67        &self.policy_name
68    }
69    /// <p>The JSON document that describes the policy. <b>policyDocument</b> must have a minimum length of 1, with a maximum length of 2048, excluding whitespace.</p>
70    /// This field is required.
71    pub fn policy_document(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
72        self.policy_document = ::std::option::Option::Some(input.into());
73        self
74    }
75    /// <p>The JSON document that describes the policy. <b>policyDocument</b> must have a minimum length of 1, with a maximum length of 2048, excluding whitespace.</p>
76    pub fn set_policy_document(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
77        self.policy_document = input;
78        self
79    }
80    /// <p>The JSON document that describes the policy. <b>policyDocument</b> must have a minimum length of 1, with a maximum length of 2048, excluding whitespace.</p>
81    pub fn get_policy_document(&self) -> &::std::option::Option<::std::string::String> {
82        &self.policy_document
83    }
84    /// Appends an item to `tags`.
85    ///
86    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
87    ///
88    /// <p>Metadata which can be used to manage the policy.</p><note>
89    /// <p>For URI Request parameters use format: ...key1=value1&amp;key2=value2...</p>
90    /// <p>For the CLI command-line parameter use format: &amp;&amp;tags "key1=value1&amp;key2=value2..."</p>
91    /// <p>For the cli-input-json file use format: "tags": "key1=value1&amp;key2=value2..."</p>
92    /// </note>
93    pub fn tags(mut self, input: crate::types::Tag) -> Self {
94        let mut v = self.tags.unwrap_or_default();
95        v.push(input);
96        self.tags = ::std::option::Option::Some(v);
97        self
98    }
99    /// <p>Metadata which can be used to manage the policy.</p><note>
100    /// <p>For URI Request parameters use format: ...key1=value1&amp;key2=value2...</p>
101    /// <p>For the CLI command-line parameter use format: &amp;&amp;tags "key1=value1&amp;key2=value2..."</p>
102    /// <p>For the cli-input-json file use format: "tags": "key1=value1&amp;key2=value2..."</p>
103    /// </note>
104    pub fn set_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>) -> Self {
105        self.tags = input;
106        self
107    }
108    /// <p>Metadata which can be used to manage the policy.</p><note>
109    /// <p>For URI Request parameters use format: ...key1=value1&amp;key2=value2...</p>
110    /// <p>For the CLI command-line parameter use format: &amp;&amp;tags "key1=value1&amp;key2=value2..."</p>
111    /// <p>For the cli-input-json file use format: "tags": "key1=value1&amp;key2=value2..."</p>
112    /// </note>
113    pub fn get_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Tag>> {
114        &self.tags
115    }
116    /// Consumes the builder and constructs a [`CreatePolicyInput`](crate::operation::create_policy::CreatePolicyInput).
117    pub fn build(
118        self,
119    ) -> ::std::result::Result<crate::operation::create_policy::CreatePolicyInput, ::aws_smithy_types::error::operation::BuildError> {
120        ::std::result::Result::Ok(crate::operation::create_policy::CreatePolicyInput {
121            policy_name: self.policy_name,
122            policy_document: self.policy_document,
123            tags: self.tags,
124        })
125    }
126}