aws_sdk_verifiedpermissions/operation/get_policy/
_get_policy_output.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 GetPolicyOutput {
6    /// <p>The ID of the policy store that contains the policy that you want information about.</p>
7    pub policy_store_id: ::std::string::String,
8    /// <p>The unique ID of the policy that you want information about.</p>
9    pub policy_id: ::std::string::String,
10    /// <p>The type of the policy.</p>
11    pub policy_type: crate::types::PolicyType,
12    /// <p>The principal specified in the policy's scope. This element isn't included in the response when <code>Principal</code> isn't present in the policy content.</p>
13    pub principal: ::std::option::Option<crate::types::EntityIdentifier>,
14    /// <p>The resource specified in the policy's scope. This element isn't included in the response when <code>Resource</code> isn't present in the policy content.</p>
15    pub resource: ::std::option::Option<crate::types::EntityIdentifier>,
16    /// <p>The action that a policy permits or forbids. For example, <code>{"actions": \[{"actionId": "ViewPhoto", "actionType": "PhotoFlash::Action"}, {"entityID": "SharePhoto", "entityType": "PhotoFlash::Action"}\]}</code>.</p>
17    pub actions: ::std::option::Option<::std::vec::Vec<crate::types::ActionIdentifier>>,
18    /// <p>The definition of the requested policy.</p>
19    pub definition: ::std::option::Option<crate::types::PolicyDefinitionDetail>,
20    /// <p>The date and time that the policy was originally created.</p>
21    pub created_date: ::aws_smithy_types::DateTime,
22    /// <p>The date and time that the policy was last updated.</p>
23    pub last_updated_date: ::aws_smithy_types::DateTime,
24    /// <p>The effect of the decision that a policy returns to an authorization request. For example, <code>"effect": "Permit"</code>.</p>
25    pub effect: ::std::option::Option<crate::types::PolicyEffect>,
26    _request_id: Option<String>,
27}
28impl GetPolicyOutput {
29    /// <p>The ID of the policy store that contains the policy that you want information about.</p>
30    pub fn policy_store_id(&self) -> &str {
31        use std::ops::Deref;
32        self.policy_store_id.deref()
33    }
34    /// <p>The unique ID of the policy that you want information about.</p>
35    pub fn policy_id(&self) -> &str {
36        use std::ops::Deref;
37        self.policy_id.deref()
38    }
39    /// <p>The type of the policy.</p>
40    pub fn policy_type(&self) -> &crate::types::PolicyType {
41        &self.policy_type
42    }
43    /// <p>The principal specified in the policy's scope. This element isn't included in the response when <code>Principal</code> isn't present in the policy content.</p>
44    pub fn principal(&self) -> ::std::option::Option<&crate::types::EntityIdentifier> {
45        self.principal.as_ref()
46    }
47    /// <p>The resource specified in the policy's scope. This element isn't included in the response when <code>Resource</code> isn't present in the policy content.</p>
48    pub fn resource(&self) -> ::std::option::Option<&crate::types::EntityIdentifier> {
49        self.resource.as_ref()
50    }
51    /// <p>The action that a policy permits or forbids. For example, <code>{"actions": \[{"actionId": "ViewPhoto", "actionType": "PhotoFlash::Action"}, {"entityID": "SharePhoto", "entityType": "PhotoFlash::Action"}\]}</code>.</p>
52    ///
53    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.actions.is_none()`.
54    pub fn actions(&self) -> &[crate::types::ActionIdentifier] {
55        self.actions.as_deref().unwrap_or_default()
56    }
57    /// <p>The definition of the requested policy.</p>
58    pub fn definition(&self) -> ::std::option::Option<&crate::types::PolicyDefinitionDetail> {
59        self.definition.as_ref()
60    }
61    /// <p>The date and time that the policy was originally created.</p>
62    pub fn created_date(&self) -> &::aws_smithy_types::DateTime {
63        &self.created_date
64    }
65    /// <p>The date and time that the policy was last updated.</p>
66    pub fn last_updated_date(&self) -> &::aws_smithy_types::DateTime {
67        &self.last_updated_date
68    }
69    /// <p>The effect of the decision that a policy returns to an authorization request. For example, <code>"effect": "Permit"</code>.</p>
70    pub fn effect(&self) -> ::std::option::Option<&crate::types::PolicyEffect> {
71        self.effect.as_ref()
72    }
73}
74impl ::aws_types::request_id::RequestId for GetPolicyOutput {
75    fn request_id(&self) -> Option<&str> {
76        self._request_id.as_deref()
77    }
78}
79impl GetPolicyOutput {
80    /// Creates a new builder-style object to manufacture [`GetPolicyOutput`](crate::operation::get_policy::GetPolicyOutput).
81    pub fn builder() -> crate::operation::get_policy::builders::GetPolicyOutputBuilder {
82        crate::operation::get_policy::builders::GetPolicyOutputBuilder::default()
83    }
84}
85
86/// A builder for [`GetPolicyOutput`](crate::operation::get_policy::GetPolicyOutput).
87#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
88#[non_exhaustive]
89pub struct GetPolicyOutputBuilder {
90    pub(crate) policy_store_id: ::std::option::Option<::std::string::String>,
91    pub(crate) policy_id: ::std::option::Option<::std::string::String>,
92    pub(crate) policy_type: ::std::option::Option<crate::types::PolicyType>,
93    pub(crate) principal: ::std::option::Option<crate::types::EntityIdentifier>,
94    pub(crate) resource: ::std::option::Option<crate::types::EntityIdentifier>,
95    pub(crate) actions: ::std::option::Option<::std::vec::Vec<crate::types::ActionIdentifier>>,
96    pub(crate) definition: ::std::option::Option<crate::types::PolicyDefinitionDetail>,
97    pub(crate) created_date: ::std::option::Option<::aws_smithy_types::DateTime>,
98    pub(crate) last_updated_date: ::std::option::Option<::aws_smithy_types::DateTime>,
99    pub(crate) effect: ::std::option::Option<crate::types::PolicyEffect>,
100    _request_id: Option<String>,
101}
102impl GetPolicyOutputBuilder {
103    /// <p>The ID of the policy store that contains the policy that you want information about.</p>
104    /// This field is required.
105    pub fn policy_store_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
106        self.policy_store_id = ::std::option::Option::Some(input.into());
107        self
108    }
109    /// <p>The ID of the policy store that contains the policy that you want information about.</p>
110    pub fn set_policy_store_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
111        self.policy_store_id = input;
112        self
113    }
114    /// <p>The ID of the policy store that contains the policy that you want information about.</p>
115    pub fn get_policy_store_id(&self) -> &::std::option::Option<::std::string::String> {
116        &self.policy_store_id
117    }
118    /// <p>The unique ID of the policy that you want information about.</p>
119    /// This field is required.
120    pub fn policy_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
121        self.policy_id = ::std::option::Option::Some(input.into());
122        self
123    }
124    /// <p>The unique ID of the policy that you want information about.</p>
125    pub fn set_policy_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
126        self.policy_id = input;
127        self
128    }
129    /// <p>The unique ID of the policy that you want information about.</p>
130    pub fn get_policy_id(&self) -> &::std::option::Option<::std::string::String> {
131        &self.policy_id
132    }
133    /// <p>The type of the policy.</p>
134    /// This field is required.
135    pub fn policy_type(mut self, input: crate::types::PolicyType) -> Self {
136        self.policy_type = ::std::option::Option::Some(input);
137        self
138    }
139    /// <p>The type of the policy.</p>
140    pub fn set_policy_type(mut self, input: ::std::option::Option<crate::types::PolicyType>) -> Self {
141        self.policy_type = input;
142        self
143    }
144    /// <p>The type of the policy.</p>
145    pub fn get_policy_type(&self) -> &::std::option::Option<crate::types::PolicyType> {
146        &self.policy_type
147    }
148    /// <p>The principal specified in the policy's scope. This element isn't included in the response when <code>Principal</code> isn't present in the policy content.</p>
149    pub fn principal(mut self, input: crate::types::EntityIdentifier) -> Self {
150        self.principal = ::std::option::Option::Some(input);
151        self
152    }
153    /// <p>The principal specified in the policy's scope. This element isn't included in the response when <code>Principal</code> isn't present in the policy content.</p>
154    pub fn set_principal(mut self, input: ::std::option::Option<crate::types::EntityIdentifier>) -> Self {
155        self.principal = input;
156        self
157    }
158    /// <p>The principal specified in the policy's scope. This element isn't included in the response when <code>Principal</code> isn't present in the policy content.</p>
159    pub fn get_principal(&self) -> &::std::option::Option<crate::types::EntityIdentifier> {
160        &self.principal
161    }
162    /// <p>The resource specified in the policy's scope. This element isn't included in the response when <code>Resource</code> isn't present in the policy content.</p>
163    pub fn resource(mut self, input: crate::types::EntityIdentifier) -> Self {
164        self.resource = ::std::option::Option::Some(input);
165        self
166    }
167    /// <p>The resource specified in the policy's scope. This element isn't included in the response when <code>Resource</code> isn't present in the policy content.</p>
168    pub fn set_resource(mut self, input: ::std::option::Option<crate::types::EntityIdentifier>) -> Self {
169        self.resource = input;
170        self
171    }
172    /// <p>The resource specified in the policy's scope. This element isn't included in the response when <code>Resource</code> isn't present in the policy content.</p>
173    pub fn get_resource(&self) -> &::std::option::Option<crate::types::EntityIdentifier> {
174        &self.resource
175    }
176    /// Appends an item to `actions`.
177    ///
178    /// To override the contents of this collection use [`set_actions`](Self::set_actions).
179    ///
180    /// <p>The action that a policy permits or forbids. For example, <code>{"actions": \[{"actionId": "ViewPhoto", "actionType": "PhotoFlash::Action"}, {"entityID": "SharePhoto", "entityType": "PhotoFlash::Action"}\]}</code>.</p>
181    pub fn actions(mut self, input: crate::types::ActionIdentifier) -> Self {
182        let mut v = self.actions.unwrap_or_default();
183        v.push(input);
184        self.actions = ::std::option::Option::Some(v);
185        self
186    }
187    /// <p>The action that a policy permits or forbids. For example, <code>{"actions": \[{"actionId": "ViewPhoto", "actionType": "PhotoFlash::Action"}, {"entityID": "SharePhoto", "entityType": "PhotoFlash::Action"}\]}</code>.</p>
188    pub fn set_actions(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::ActionIdentifier>>) -> Self {
189        self.actions = input;
190        self
191    }
192    /// <p>The action that a policy permits or forbids. For example, <code>{"actions": \[{"actionId": "ViewPhoto", "actionType": "PhotoFlash::Action"}, {"entityID": "SharePhoto", "entityType": "PhotoFlash::Action"}\]}</code>.</p>
193    pub fn get_actions(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::ActionIdentifier>> {
194        &self.actions
195    }
196    /// <p>The definition of the requested policy.</p>
197    /// This field is required.
198    pub fn definition(mut self, input: crate::types::PolicyDefinitionDetail) -> Self {
199        self.definition = ::std::option::Option::Some(input);
200        self
201    }
202    /// <p>The definition of the requested policy.</p>
203    pub fn set_definition(mut self, input: ::std::option::Option<crate::types::PolicyDefinitionDetail>) -> Self {
204        self.definition = input;
205        self
206    }
207    /// <p>The definition of the requested policy.</p>
208    pub fn get_definition(&self) -> &::std::option::Option<crate::types::PolicyDefinitionDetail> {
209        &self.definition
210    }
211    /// <p>The date and time that the policy was originally created.</p>
212    /// This field is required.
213    pub fn created_date(mut self, input: ::aws_smithy_types::DateTime) -> Self {
214        self.created_date = ::std::option::Option::Some(input);
215        self
216    }
217    /// <p>The date and time that the policy was originally created.</p>
218    pub fn set_created_date(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
219        self.created_date = input;
220        self
221    }
222    /// <p>The date and time that the policy was originally created.</p>
223    pub fn get_created_date(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
224        &self.created_date
225    }
226    /// <p>The date and time that the policy was last updated.</p>
227    /// This field is required.
228    pub fn last_updated_date(mut self, input: ::aws_smithy_types::DateTime) -> Self {
229        self.last_updated_date = ::std::option::Option::Some(input);
230        self
231    }
232    /// <p>The date and time that the policy was last updated.</p>
233    pub fn set_last_updated_date(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
234        self.last_updated_date = input;
235        self
236    }
237    /// <p>The date and time that the policy was last updated.</p>
238    pub fn get_last_updated_date(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
239        &self.last_updated_date
240    }
241    /// <p>The effect of the decision that a policy returns to an authorization request. For example, <code>"effect": "Permit"</code>.</p>
242    pub fn effect(mut self, input: crate::types::PolicyEffect) -> Self {
243        self.effect = ::std::option::Option::Some(input);
244        self
245    }
246    /// <p>The effect of the decision that a policy returns to an authorization request. For example, <code>"effect": "Permit"</code>.</p>
247    pub fn set_effect(mut self, input: ::std::option::Option<crate::types::PolicyEffect>) -> Self {
248        self.effect = input;
249        self
250    }
251    /// <p>The effect of the decision that a policy returns to an authorization request. For example, <code>"effect": "Permit"</code>.</p>
252    pub fn get_effect(&self) -> &::std::option::Option<crate::types::PolicyEffect> {
253        &self.effect
254    }
255    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
256        self._request_id = Some(request_id.into());
257        self
258    }
259
260    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
261        self._request_id = request_id;
262        self
263    }
264    /// Consumes the builder and constructs a [`GetPolicyOutput`](crate::operation::get_policy::GetPolicyOutput).
265    /// This method will fail if any of the following fields are not set:
266    /// - [`policy_store_id`](crate::operation::get_policy::builders::GetPolicyOutputBuilder::policy_store_id)
267    /// - [`policy_id`](crate::operation::get_policy::builders::GetPolicyOutputBuilder::policy_id)
268    /// - [`policy_type`](crate::operation::get_policy::builders::GetPolicyOutputBuilder::policy_type)
269    /// - [`created_date`](crate::operation::get_policy::builders::GetPolicyOutputBuilder::created_date)
270    /// - [`last_updated_date`](crate::operation::get_policy::builders::GetPolicyOutputBuilder::last_updated_date)
271    pub fn build(self) -> ::std::result::Result<crate::operation::get_policy::GetPolicyOutput, ::aws_smithy_types::error::operation::BuildError> {
272        ::std::result::Result::Ok(crate::operation::get_policy::GetPolicyOutput {
273            policy_store_id: self.policy_store_id.ok_or_else(|| {
274                ::aws_smithy_types::error::operation::BuildError::missing_field(
275                    "policy_store_id",
276                    "policy_store_id was not specified but it is required when building GetPolicyOutput",
277                )
278            })?,
279            policy_id: self.policy_id.ok_or_else(|| {
280                ::aws_smithy_types::error::operation::BuildError::missing_field(
281                    "policy_id",
282                    "policy_id was not specified but it is required when building GetPolicyOutput",
283                )
284            })?,
285            policy_type: self.policy_type.ok_or_else(|| {
286                ::aws_smithy_types::error::operation::BuildError::missing_field(
287                    "policy_type",
288                    "policy_type was not specified but it is required when building GetPolicyOutput",
289                )
290            })?,
291            principal: self.principal,
292            resource: self.resource,
293            actions: self.actions,
294            definition: self.definition,
295            created_date: self.created_date.ok_or_else(|| {
296                ::aws_smithy_types::error::operation::BuildError::missing_field(
297                    "created_date",
298                    "created_date was not specified but it is required when building GetPolicyOutput",
299                )
300            })?,
301            last_updated_date: self.last_updated_date.ok_or_else(|| {
302                ::aws_smithy_types::error::operation::BuildError::missing_field(
303                    "last_updated_date",
304                    "last_updated_date was not specified but it is required when building GetPolicyOutput",
305                )
306            })?,
307            effect: self.effect,
308            _request_id: self._request_id,
309        })
310    }
311}