Skip to main content

aws_sdk_workdocs/types/
_share_principal.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Describes the recipient type and ID, if available.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct SharePrincipal {
7    /// <p>The ID of the recipient.</p>
8    pub id: ::std::string::String,
9    /// <p>The type of the recipient.</p>
10    pub r#type: crate::types::PrincipalType,
11    /// <p>The role of the recipient.</p>
12    pub role: crate::types::RoleType,
13}
14impl SharePrincipal {
15    /// <p>The ID of the recipient.</p>
16    pub fn id(&self) -> &str {
17        use std::ops::Deref;
18        self.id.deref()
19    }
20    /// <p>The type of the recipient.</p>
21    pub fn r#type(&self) -> &crate::types::PrincipalType {
22        &self.r#type
23    }
24    /// <p>The role of the recipient.</p>
25    pub fn role(&self) -> &crate::types::RoleType {
26        &self.role
27    }
28}
29impl SharePrincipal {
30    /// Creates a new builder-style object to manufacture [`SharePrincipal`](crate::types::SharePrincipal).
31    pub fn builder() -> crate::types::builders::SharePrincipalBuilder {
32        crate::types::builders::SharePrincipalBuilder::default()
33    }
34}
35
36/// A builder for [`SharePrincipal`](crate::types::SharePrincipal).
37#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
38#[non_exhaustive]
39pub struct SharePrincipalBuilder {
40    pub(crate) id: ::std::option::Option<::std::string::String>,
41    pub(crate) r#type: ::std::option::Option<crate::types::PrincipalType>,
42    pub(crate) role: ::std::option::Option<crate::types::RoleType>,
43}
44impl SharePrincipalBuilder {
45    /// <p>The ID of the recipient.</p>
46    /// This field is required.
47    pub fn id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
48        self.id = ::std::option::Option::Some(input.into());
49        self
50    }
51    /// <p>The ID of the recipient.</p>
52    pub fn set_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
53        self.id = input;
54        self
55    }
56    /// <p>The ID of the recipient.</p>
57    pub fn get_id(&self) -> &::std::option::Option<::std::string::String> {
58        &self.id
59    }
60    /// <p>The type of the recipient.</p>
61    /// This field is required.
62    pub fn r#type(mut self, input: crate::types::PrincipalType) -> Self {
63        self.r#type = ::std::option::Option::Some(input);
64        self
65    }
66    /// <p>The type of the recipient.</p>
67    pub fn set_type(mut self, input: ::std::option::Option<crate::types::PrincipalType>) -> Self {
68        self.r#type = input;
69        self
70    }
71    /// <p>The type of the recipient.</p>
72    pub fn get_type(&self) -> &::std::option::Option<crate::types::PrincipalType> {
73        &self.r#type
74    }
75    /// <p>The role of the recipient.</p>
76    /// This field is required.
77    pub fn role(mut self, input: crate::types::RoleType) -> Self {
78        self.role = ::std::option::Option::Some(input);
79        self
80    }
81    /// <p>The role of the recipient.</p>
82    pub fn set_role(mut self, input: ::std::option::Option<crate::types::RoleType>) -> Self {
83        self.role = input;
84        self
85    }
86    /// <p>The role of the recipient.</p>
87    pub fn get_role(&self) -> &::std::option::Option<crate::types::RoleType> {
88        &self.role
89    }
90    /// Consumes the builder and constructs a [`SharePrincipal`](crate::types::SharePrincipal).
91    /// This method will fail if any of the following fields are not set:
92    /// - [`id`](crate::types::builders::SharePrincipalBuilder::id)
93    /// - [`r#type`](crate::types::builders::SharePrincipalBuilder::type)
94    /// - [`role`](crate::types::builders::SharePrincipalBuilder::role)
95    pub fn build(self) -> ::std::result::Result<crate::types::SharePrincipal, ::aws_smithy_types::error::operation::BuildError> {
96        ::std::result::Result::Ok(crate::types::SharePrincipal {
97            id: self.id.ok_or_else(|| {
98                ::aws_smithy_types::error::operation::BuildError::missing_field(
99                    "id",
100                    "id was not specified but it is required when building SharePrincipal",
101                )
102            })?,
103            r#type: self.r#type.ok_or_else(|| {
104                ::aws_smithy_types::error::operation::BuildError::missing_field(
105                    "r#type",
106                    "r#type was not specified but it is required when building SharePrincipal",
107                )
108            })?,
109            role: self.role.ok_or_else(|| {
110                ::aws_smithy_types::error::operation::BuildError::missing_field(
111                    "role",
112                    "role was not specified but it is required when building SharePrincipal",
113                )
114            })?,
115        })
116    }
117}