Skip to main content

aws_sdk_iam/types/
_context_entry.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Contains information about a condition context key. It includes the name of the key and specifies the value (or values, if the context key supports multiple values) to use in the simulation. This information is used when evaluating the <code>Condition</code> elements of the input policies.</p>
4/// <p>This data type is used as an input parameter to <a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_SimulateCustomPolicy.html">SimulateCustomPolicy</a> and <a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_SimulatePrincipalPolicy.html">SimulatePrincipalPolicy</a>.</p>
5#[non_exhaustive]
6#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
7pub struct ContextEntry {
8    /// <p>The full name of a condition context key, including the service prefix. For example, <code>aws:SourceIp</code> or <code>s3:VersionId</code>.</p>
9    pub context_key_name: ::std::option::Option<::std::string::String>,
10    /// <p>The value (or values, if the condition context key supports multiple values) to provide to the simulation when the key is referenced by a <code>Condition</code> element in an input policy.</p>
11    pub context_key_values: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
12    /// <p>The data type of the value (or values) specified in the <code>ContextKeyValues</code> parameter.</p>
13    pub context_key_type: ::std::option::Option<crate::types::ContextKeyTypeEnum>,
14}
15impl ContextEntry {
16    /// <p>The full name of a condition context key, including the service prefix. For example, <code>aws:SourceIp</code> or <code>s3:VersionId</code>.</p>
17    pub fn context_key_name(&self) -> ::std::option::Option<&str> {
18        self.context_key_name.as_deref()
19    }
20    /// <p>The value (or values, if the condition context key supports multiple values) to provide to the simulation when the key is referenced by a <code>Condition</code> element in an input policy.</p>
21    ///
22    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.context_key_values.is_none()`.
23    pub fn context_key_values(&self) -> &[::std::string::String] {
24        self.context_key_values.as_deref().unwrap_or_default()
25    }
26    /// <p>The data type of the value (or values) specified in the <code>ContextKeyValues</code> parameter.</p>
27    pub fn context_key_type(&self) -> ::std::option::Option<&crate::types::ContextKeyTypeEnum> {
28        self.context_key_type.as_ref()
29    }
30}
31impl ContextEntry {
32    /// Creates a new builder-style object to manufacture [`ContextEntry`](crate::types::ContextEntry).
33    pub fn builder() -> crate::types::builders::ContextEntryBuilder {
34        crate::types::builders::ContextEntryBuilder::default()
35    }
36}
37
38/// A builder for [`ContextEntry`](crate::types::ContextEntry).
39#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
40#[non_exhaustive]
41pub struct ContextEntryBuilder {
42    pub(crate) context_key_name: ::std::option::Option<::std::string::String>,
43    pub(crate) context_key_values: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
44    pub(crate) context_key_type: ::std::option::Option<crate::types::ContextKeyTypeEnum>,
45}
46impl ContextEntryBuilder {
47    /// <p>The full name of a condition context key, including the service prefix. For example, <code>aws:SourceIp</code> or <code>s3:VersionId</code>.</p>
48    pub fn context_key_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
49        self.context_key_name = ::std::option::Option::Some(input.into());
50        self
51    }
52    /// <p>The full name of a condition context key, including the service prefix. For example, <code>aws:SourceIp</code> or <code>s3:VersionId</code>.</p>
53    pub fn set_context_key_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
54        self.context_key_name = input;
55        self
56    }
57    /// <p>The full name of a condition context key, including the service prefix. For example, <code>aws:SourceIp</code> or <code>s3:VersionId</code>.</p>
58    pub fn get_context_key_name(&self) -> &::std::option::Option<::std::string::String> {
59        &self.context_key_name
60    }
61    /// Appends an item to `context_key_values`.
62    ///
63    /// To override the contents of this collection use [`set_context_key_values`](Self::set_context_key_values).
64    ///
65    /// <p>The value (or values, if the condition context key supports multiple values) to provide to the simulation when the key is referenced by a <code>Condition</code> element in an input policy.</p>
66    pub fn context_key_values(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
67        let mut v = self.context_key_values.unwrap_or_default();
68        v.push(input.into());
69        self.context_key_values = ::std::option::Option::Some(v);
70        self
71    }
72    /// <p>The value (or values, if the condition context key supports multiple values) to provide to the simulation when the key is referenced by a <code>Condition</code> element in an input policy.</p>
73    pub fn set_context_key_values(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
74        self.context_key_values = input;
75        self
76    }
77    /// <p>The value (or values, if the condition context key supports multiple values) to provide to the simulation when the key is referenced by a <code>Condition</code> element in an input policy.</p>
78    pub fn get_context_key_values(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
79        &self.context_key_values
80    }
81    /// <p>The data type of the value (or values) specified in the <code>ContextKeyValues</code> parameter.</p>
82    pub fn context_key_type(mut self, input: crate::types::ContextKeyTypeEnum) -> Self {
83        self.context_key_type = ::std::option::Option::Some(input);
84        self
85    }
86    /// <p>The data type of the value (or values) specified in the <code>ContextKeyValues</code> parameter.</p>
87    pub fn set_context_key_type(mut self, input: ::std::option::Option<crate::types::ContextKeyTypeEnum>) -> Self {
88        self.context_key_type = input;
89        self
90    }
91    /// <p>The data type of the value (or values) specified in the <code>ContextKeyValues</code> parameter.</p>
92    pub fn get_context_key_type(&self) -> &::std::option::Option<crate::types::ContextKeyTypeEnum> {
93        &self.context_key_type
94    }
95    /// Consumes the builder and constructs a [`ContextEntry`](crate::types::ContextEntry).
96    pub fn build(self) -> crate::types::ContextEntry {
97        crate::types::ContextEntry {
98            context_key_name: self.context_key_name,
99            context_key_values: self.context_key_values,
100            context_key_type: self.context_key_type,
101        }
102    }
103}