aws_sdk_codeguruprofiler/operation/get_policy/
_get_policy_output.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>The structure representing the <code>getPolicyResponse</code>.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct GetPolicyOutput {
7    /// <p>The JSON-formatted resource-based policy attached to the <code>ProfilingGroup</code>.</p>
8    pub policy: ::std::string::String,
9    /// <p>A unique identifier for the current revision of the returned policy.</p>
10    pub revision_id: ::std::string::String,
11    _request_id: Option<String>,
12}
13impl GetPolicyOutput {
14    /// <p>The JSON-formatted resource-based policy attached to the <code>ProfilingGroup</code>.</p>
15    pub fn policy(&self) -> &str {
16        use std::ops::Deref;
17        self.policy.deref()
18    }
19    /// <p>A unique identifier for the current revision of the returned policy.</p>
20    pub fn revision_id(&self) -> &str {
21        use std::ops::Deref;
22        self.revision_id.deref()
23    }
24}
25impl ::aws_types::request_id::RequestId for GetPolicyOutput {
26    fn request_id(&self) -> Option<&str> {
27        self._request_id.as_deref()
28    }
29}
30impl GetPolicyOutput {
31    /// Creates a new builder-style object to manufacture [`GetPolicyOutput`](crate::operation::get_policy::GetPolicyOutput).
32    pub fn builder() -> crate::operation::get_policy::builders::GetPolicyOutputBuilder {
33        crate::operation::get_policy::builders::GetPolicyOutputBuilder::default()
34    }
35}
36
37/// A builder for [`GetPolicyOutput`](crate::operation::get_policy::GetPolicyOutput).
38#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
39#[non_exhaustive]
40pub struct GetPolicyOutputBuilder {
41    pub(crate) policy: ::std::option::Option<::std::string::String>,
42    pub(crate) revision_id: ::std::option::Option<::std::string::String>,
43    _request_id: Option<String>,
44}
45impl GetPolicyOutputBuilder {
46    /// <p>The JSON-formatted resource-based policy attached to the <code>ProfilingGroup</code>.</p>
47    /// This field is required.
48    pub fn policy(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
49        self.policy = ::std::option::Option::Some(input.into());
50        self
51    }
52    /// <p>The JSON-formatted resource-based policy attached to the <code>ProfilingGroup</code>.</p>
53    pub fn set_policy(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
54        self.policy = input;
55        self
56    }
57    /// <p>The JSON-formatted resource-based policy attached to the <code>ProfilingGroup</code>.</p>
58    pub fn get_policy(&self) -> &::std::option::Option<::std::string::String> {
59        &self.policy
60    }
61    /// <p>A unique identifier for the current revision of the returned policy.</p>
62    /// This field is required.
63    pub fn revision_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
64        self.revision_id = ::std::option::Option::Some(input.into());
65        self
66    }
67    /// <p>A unique identifier for the current revision of the returned policy.</p>
68    pub fn set_revision_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
69        self.revision_id = input;
70        self
71    }
72    /// <p>A unique identifier for the current revision of the returned policy.</p>
73    pub fn get_revision_id(&self) -> &::std::option::Option<::std::string::String> {
74        &self.revision_id
75    }
76    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
77        self._request_id = Some(request_id.into());
78        self
79    }
80
81    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
82        self._request_id = request_id;
83        self
84    }
85    /// Consumes the builder and constructs a [`GetPolicyOutput`](crate::operation::get_policy::GetPolicyOutput).
86    /// This method will fail if any of the following fields are not set:
87    /// - [`policy`](crate::operation::get_policy::builders::GetPolicyOutputBuilder::policy)
88    /// - [`revision_id`](crate::operation::get_policy::builders::GetPolicyOutputBuilder::revision_id)
89    pub fn build(self) -> ::std::result::Result<crate::operation::get_policy::GetPolicyOutput, ::aws_smithy_types::error::operation::BuildError> {
90        ::std::result::Result::Ok(crate::operation::get_policy::GetPolicyOutput {
91            policy: self.policy.ok_or_else(|| {
92                ::aws_smithy_types::error::operation::BuildError::missing_field(
93                    "policy",
94                    "policy was not specified but it is required when building GetPolicyOutput",
95                )
96            })?,
97            revision_id: self.revision_id.ok_or_else(|| {
98                ::aws_smithy_types::error::operation::BuildError::missing_field(
99                    "revision_id",
100                    "revision_id was not specified but it is required when building GetPolicyOutput",
101                )
102            })?,
103            _request_id: self._request_id,
104        })
105    }
106}