Skip to main content

aws_sdk_s3/types/
_access_control_policy.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Contains the elements that set the ACL permissions for an object per grantee.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct AccessControlPolicy {
7    /// <p>A list of grants.</p>
8    pub grants: ::std::option::Option<::std::vec::Vec<crate::types::Grant>>,
9    /// <p>Container for the bucket owner's display name and ID.</p>
10    pub owner: ::std::option::Option<crate::types::Owner>,
11}
12impl AccessControlPolicy {
13    /// <p>A list of grants.</p>
14    ///
15    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.grants.is_none()`.
16    pub fn grants(&self) -> &[crate::types::Grant] {
17        self.grants.as_deref().unwrap_or_default()
18    }
19    /// <p>Container for the bucket owner's display name and ID.</p>
20    pub fn owner(&self) -> ::std::option::Option<&crate::types::Owner> {
21        self.owner.as_ref()
22    }
23}
24impl AccessControlPolicy {
25    /// Creates a new builder-style object to manufacture [`AccessControlPolicy`](crate::types::AccessControlPolicy).
26    pub fn builder() -> crate::types::builders::AccessControlPolicyBuilder {
27        crate::types::builders::AccessControlPolicyBuilder::default()
28    }
29}
30
31/// A builder for [`AccessControlPolicy`](crate::types::AccessControlPolicy).
32#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
33#[non_exhaustive]
34pub struct AccessControlPolicyBuilder {
35    pub(crate) grants: ::std::option::Option<::std::vec::Vec<crate::types::Grant>>,
36    pub(crate) owner: ::std::option::Option<crate::types::Owner>,
37}
38impl AccessControlPolicyBuilder {
39    /// Appends an item to `grants`.
40    ///
41    /// To override the contents of this collection use [`set_grants`](Self::set_grants).
42    ///
43    /// <p>A list of grants.</p>
44    pub fn grants(mut self, input: crate::types::Grant) -> Self {
45        let mut v = self.grants.unwrap_or_default();
46        v.push(input);
47        self.grants = ::std::option::Option::Some(v);
48        self
49    }
50    /// <p>A list of grants.</p>
51    pub fn set_grants(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Grant>>) -> Self {
52        self.grants = input;
53        self
54    }
55    /// <p>A list of grants.</p>
56    pub fn get_grants(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Grant>> {
57        &self.grants
58    }
59    /// <p>Container for the bucket owner's display name and ID.</p>
60    pub fn owner(mut self, input: crate::types::Owner) -> Self {
61        self.owner = ::std::option::Option::Some(input);
62        self
63    }
64    /// <p>Container for the bucket owner's display name and ID.</p>
65    pub fn set_owner(mut self, input: ::std::option::Option<crate::types::Owner>) -> Self {
66        self.owner = input;
67        self
68    }
69    /// <p>Container for the bucket owner's display name and ID.</p>
70    pub fn get_owner(&self) -> &::std::option::Option<crate::types::Owner> {
71        &self.owner
72    }
73    /// Consumes the builder and constructs a [`AccessControlPolicy`](crate::types::AccessControlPolicy).
74    pub fn build(self) -> crate::types::AccessControlPolicy {
75        crate::types::AccessControlPolicy {
76            grants: self.grants,
77            owner: self.owner,
78        }
79    }
80}