aws_sdk_workdocs/types/
_search_principal_type.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Filter based on UserIds or GroupIds.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct SearchPrincipalType {
7    /// <p>UserIds or GroupIds.</p>
8    pub id: ::std::string::String,
9    /// <p>The Role of a User or Group.</p>
10    pub roles: ::std::option::Option<::std::vec::Vec<crate::types::PrincipalRoleType>>,
11}
12impl SearchPrincipalType {
13    /// <p>UserIds or GroupIds.</p>
14    pub fn id(&self) -> &str {
15        use std::ops::Deref;
16        self.id.deref()
17    }
18    /// <p>The Role of a User or Group.</p>
19    ///
20    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.roles.is_none()`.
21    pub fn roles(&self) -> &[crate::types::PrincipalRoleType] {
22        self.roles.as_deref().unwrap_or_default()
23    }
24}
25impl SearchPrincipalType {
26    /// Creates a new builder-style object to manufacture [`SearchPrincipalType`](crate::types::SearchPrincipalType).
27    pub fn builder() -> crate::types::builders::SearchPrincipalTypeBuilder {
28        crate::types::builders::SearchPrincipalTypeBuilder::default()
29    }
30}
31
32/// A builder for [`SearchPrincipalType`](crate::types::SearchPrincipalType).
33#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
34#[non_exhaustive]
35pub struct SearchPrincipalTypeBuilder {
36    pub(crate) id: ::std::option::Option<::std::string::String>,
37    pub(crate) roles: ::std::option::Option<::std::vec::Vec<crate::types::PrincipalRoleType>>,
38}
39impl SearchPrincipalTypeBuilder {
40    /// <p>UserIds or GroupIds.</p>
41    /// This field is required.
42    pub fn id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
43        self.id = ::std::option::Option::Some(input.into());
44        self
45    }
46    /// <p>UserIds or GroupIds.</p>
47    pub fn set_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
48        self.id = input;
49        self
50    }
51    /// <p>UserIds or GroupIds.</p>
52    pub fn get_id(&self) -> &::std::option::Option<::std::string::String> {
53        &self.id
54    }
55    /// Appends an item to `roles`.
56    ///
57    /// To override the contents of this collection use [`set_roles`](Self::set_roles).
58    ///
59    /// <p>The Role of a User or Group.</p>
60    pub fn roles(mut self, input: crate::types::PrincipalRoleType) -> Self {
61        let mut v = self.roles.unwrap_or_default();
62        v.push(input);
63        self.roles = ::std::option::Option::Some(v);
64        self
65    }
66    /// <p>The Role of a User or Group.</p>
67    pub fn set_roles(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::PrincipalRoleType>>) -> Self {
68        self.roles = input;
69        self
70    }
71    /// <p>The Role of a User or Group.</p>
72    pub fn get_roles(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::PrincipalRoleType>> {
73        &self.roles
74    }
75    /// Consumes the builder and constructs a [`SearchPrincipalType`](crate::types::SearchPrincipalType).
76    /// This method will fail if any of the following fields are not set:
77    /// - [`id`](crate::types::builders::SearchPrincipalTypeBuilder::id)
78    pub fn build(self) -> ::std::result::Result<crate::types::SearchPrincipalType, ::aws_smithy_types::error::operation::BuildError> {
79        ::std::result::Result::Ok(crate::types::SearchPrincipalType {
80            id: self.id.ok_or_else(|| {
81                ::aws_smithy_types::error::operation::BuildError::missing_field(
82                    "id",
83                    "id was not specified but it is required when building SearchPrincipalType",
84                )
85            })?,
86            roles: self.roles,
87        })
88    }
89}