aws_sdk_grafana/types/
_update_instruction.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Contains the instructions for one Grafana role permission update in a <a href="https://docs.aws.amazon.com/grafana/latest/APIReference/API_UpdatePermissions.html">UpdatePermissions</a> operation.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct UpdateInstruction {
7    /// <p>Specifies whether this update is to add or revoke role permissions.</p>
8    pub action: crate::types::UpdateAction,
9    /// <p>The role to add or revoke for the user or the group specified in <code>users</code>.</p>
10    pub role: crate::types::Role,
11    /// <p>A structure that specifies the user or group to add or revoke the role for.</p>
12    pub users: ::std::vec::Vec<crate::types::User>,
13}
14impl UpdateInstruction {
15    /// <p>Specifies whether this update is to add or revoke role permissions.</p>
16    pub fn action(&self) -> &crate::types::UpdateAction {
17        &self.action
18    }
19    /// <p>The role to add or revoke for the user or the group specified in <code>users</code>.</p>
20    pub fn role(&self) -> &crate::types::Role {
21        &self.role
22    }
23    /// <p>A structure that specifies the user or group to add or revoke the role for.</p>
24    pub fn users(&self) -> &[crate::types::User] {
25        use std::ops::Deref;
26        self.users.deref()
27    }
28}
29impl UpdateInstruction {
30    /// Creates a new builder-style object to manufacture [`UpdateInstruction`](crate::types::UpdateInstruction).
31    pub fn builder() -> crate::types::builders::UpdateInstructionBuilder {
32        crate::types::builders::UpdateInstructionBuilder::default()
33    }
34}
35
36/// A builder for [`UpdateInstruction`](crate::types::UpdateInstruction).
37#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
38#[non_exhaustive]
39pub struct UpdateInstructionBuilder {
40    pub(crate) action: ::std::option::Option<crate::types::UpdateAction>,
41    pub(crate) role: ::std::option::Option<crate::types::Role>,
42    pub(crate) users: ::std::option::Option<::std::vec::Vec<crate::types::User>>,
43}
44impl UpdateInstructionBuilder {
45    /// <p>Specifies whether this update is to add or revoke role permissions.</p>
46    /// This field is required.
47    pub fn action(mut self, input: crate::types::UpdateAction) -> Self {
48        self.action = ::std::option::Option::Some(input);
49        self
50    }
51    /// <p>Specifies whether this update is to add or revoke role permissions.</p>
52    pub fn set_action(mut self, input: ::std::option::Option<crate::types::UpdateAction>) -> Self {
53        self.action = input;
54        self
55    }
56    /// <p>Specifies whether this update is to add or revoke role permissions.</p>
57    pub fn get_action(&self) -> &::std::option::Option<crate::types::UpdateAction> {
58        &self.action
59    }
60    /// <p>The role to add or revoke for the user or the group specified in <code>users</code>.</p>
61    /// This field is required.
62    pub fn role(mut self, input: crate::types::Role) -> Self {
63        self.role = ::std::option::Option::Some(input);
64        self
65    }
66    /// <p>The role to add or revoke for the user or the group specified in <code>users</code>.</p>
67    pub fn set_role(mut self, input: ::std::option::Option<crate::types::Role>) -> Self {
68        self.role = input;
69        self
70    }
71    /// <p>The role to add or revoke for the user or the group specified in <code>users</code>.</p>
72    pub fn get_role(&self) -> &::std::option::Option<crate::types::Role> {
73        &self.role
74    }
75    /// Appends an item to `users`.
76    ///
77    /// To override the contents of this collection use [`set_users`](Self::set_users).
78    ///
79    /// <p>A structure that specifies the user or group to add or revoke the role for.</p>
80    pub fn users(mut self, input: crate::types::User) -> Self {
81        let mut v = self.users.unwrap_or_default();
82        v.push(input);
83        self.users = ::std::option::Option::Some(v);
84        self
85    }
86    /// <p>A structure that specifies the user or group to add or revoke the role for.</p>
87    pub fn set_users(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::User>>) -> Self {
88        self.users = input;
89        self
90    }
91    /// <p>A structure that specifies the user or group to add or revoke the role for.</p>
92    pub fn get_users(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::User>> {
93        &self.users
94    }
95    /// Consumes the builder and constructs a [`UpdateInstruction`](crate::types::UpdateInstruction).
96    /// This method will fail if any of the following fields are not set:
97    /// - [`action`](crate::types::builders::UpdateInstructionBuilder::action)
98    /// - [`role`](crate::types::builders::UpdateInstructionBuilder::role)
99    /// - [`users`](crate::types::builders::UpdateInstructionBuilder::users)
100    pub fn build(self) -> ::std::result::Result<crate::types::UpdateInstruction, ::aws_smithy_types::error::operation::BuildError> {
101        ::std::result::Result::Ok(crate::types::UpdateInstruction {
102            action: self.action.ok_or_else(|| {
103                ::aws_smithy_types::error::operation::BuildError::missing_field(
104                    "action",
105                    "action was not specified but it is required when building UpdateInstruction",
106                )
107            })?,
108            role: self.role.ok_or_else(|| {
109                ::aws_smithy_types::error::operation::BuildError::missing_field(
110                    "role",
111                    "role was not specified but it is required when building UpdateInstruction",
112                )
113            })?,
114            users: self.users.ok_or_else(|| {
115                ::aws_smithy_types::error::operation::BuildError::missing_field(
116                    "users",
117                    "users was not specified but it is required when building UpdateInstruction",
118                )
119            })?,
120        })
121    }
122}