// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>Contains information about an IAM role. This structure is returned as a response element in several API operations that interact with roles.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Role {
/// <p>The path to the role. For more information about paths, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
pub path: ::std::string::String,
/// <p>The friendly name that identifies the role.</p>
pub role_name: ::std::string::String,
/// <p>The stable and unique string identifying the role. For more information about IDs, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
pub role_id: ::std::string::String,
/// <p>The Amazon Resource Name (ARN) specifying the role. For more information about ARNs and how to use them in policies, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i> guide.</p>
pub arn: ::std::string::String,
/// <p>The date and time, in <a href="http://www.iso.org/iso/iso8601">ISO 8601 date-time format</a>, when the role was created.</p>
pub create_date: ::aws_smithy_types::DateTime,
/// <p>The policy that grants an entity permission to assume the role.</p>
pub assume_role_policy_document: ::std::option::Option<::std::string::String>,
/// <p>A description of the role that you provide.</p>
pub description: ::std::option::Option<::std::string::String>,
/// <p>The maximum session duration (in seconds) for the specified role. Anyone who uses the CLI, or API to assume the role can specify the duration using the optional <code>DurationSeconds</code> API parameter or <code>duration-seconds</code> CLI parameter.</p>
pub max_session_duration: ::std::option::Option<i32>,
/// <p>The ARN of the policy used to set the permissions boundary for the role.</p>
/// <p>For more information about permissions boundaries, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html">Permissions boundaries for IAM identities </a> in the <i>IAM User Guide</i>.</p>
pub permissions_boundary: ::std::option::Option<crate::types::AttachedPermissionsBoundary>,
/// <p>A list of tags that are attached to the role. For more information about tagging, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html">Tagging IAM resources</a> in the <i>IAM User Guide</i>.</p>
pub tags: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>,
/// <p>Contains information about the last time that an IAM role was used. This includes the date and time and the Region in which the role was last used. Activity is only reported for the trailing 400 days. This period can be shorter if your Region began supporting these features within the last year. The role might have been used more than 400 days ago. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#access-advisor_tracking-period">Regions where data is tracked</a> in the <i>IAM user Guide</i>.</p>
pub role_last_used: ::std::option::Option<crate::types::RoleLastUsed>,
}
impl Role {
/// <p>The path to the role. For more information about paths, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
pub fn path(&self) -> &str {
use std::ops::Deref;
self.path.deref()
}
/// <p>The friendly name that identifies the role.</p>
pub fn role_name(&self) -> &str {
use std::ops::Deref;
self.role_name.deref()
}
/// <p>The stable and unique string identifying the role. For more information about IDs, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
pub fn role_id(&self) -> &str {
use std::ops::Deref;
self.role_id.deref()
}
/// <p>The Amazon Resource Name (ARN) specifying the role. For more information about ARNs and how to use them in policies, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i> guide.</p>
pub fn arn(&self) -> &str {
use std::ops::Deref;
self.arn.deref()
}
/// <p>The date and time, in <a href="http://www.iso.org/iso/iso8601">ISO 8601 date-time format</a>, when the role was created.</p>
pub fn create_date(&self) -> &::aws_smithy_types::DateTime {
&self.create_date
}
/// <p>The policy that grants an entity permission to assume the role.</p>
pub fn assume_role_policy_document(&self) -> ::std::option::Option<&str> {
self.assume_role_policy_document.as_deref()
}
/// <p>A description of the role that you provide.</p>
pub fn description(&self) -> ::std::option::Option<&str> {
self.description.as_deref()
}
/// <p>The maximum session duration (in seconds) for the specified role. Anyone who uses the CLI, or API to assume the role can specify the duration using the optional <code>DurationSeconds</code> API parameter or <code>duration-seconds</code> CLI parameter.</p>
pub fn max_session_duration(&self) -> ::std::option::Option<i32> {
self.max_session_duration
}
/// <p>The ARN of the policy used to set the permissions boundary for the role.</p>
/// <p>For more information about permissions boundaries, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html">Permissions boundaries for IAM identities </a> in the <i>IAM User Guide</i>.</p>
pub fn permissions_boundary(&self) -> ::std::option::Option<&crate::types::AttachedPermissionsBoundary> {
self.permissions_boundary.as_ref()
}
/// <p>A list of tags that are attached to the role. For more information about tagging, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html">Tagging IAM resources</a> in the <i>IAM User Guide</i>.</p>
///
/// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.tags.is_none()`.
pub fn tags(&self) -> &[crate::types::Tag] {
self.tags.as_deref().unwrap_or_default()
}
/// <p>Contains information about the last time that an IAM role was used. This includes the date and time and the Region in which the role was last used. Activity is only reported for the trailing 400 days. This period can be shorter if your Region began supporting these features within the last year. The role might have been used more than 400 days ago. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#access-advisor_tracking-period">Regions where data is tracked</a> in the <i>IAM user Guide</i>.</p>
pub fn role_last_used(&self) -> ::std::option::Option<&crate::types::RoleLastUsed> {
self.role_last_used.as_ref()
}
}
impl Role {
/// Creates a new builder-style object to manufacture [`Role`](crate::types::Role).
pub fn builder() -> crate::types::builders::RoleBuilder {
crate::types::builders::RoleBuilder::default()
}
}
/// A builder for [`Role`](crate::types::Role).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct RoleBuilder {
pub(crate) path: ::std::option::Option<::std::string::String>,
pub(crate) role_name: ::std::option::Option<::std::string::String>,
pub(crate) role_id: ::std::option::Option<::std::string::String>,
pub(crate) arn: ::std::option::Option<::std::string::String>,
pub(crate) create_date: ::std::option::Option<::aws_smithy_types::DateTime>,
pub(crate) assume_role_policy_document: ::std::option::Option<::std::string::String>,
pub(crate) description: ::std::option::Option<::std::string::String>,
pub(crate) max_session_duration: ::std::option::Option<i32>,
pub(crate) permissions_boundary: ::std::option::Option<crate::types::AttachedPermissionsBoundary>,
pub(crate) tags: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>,
pub(crate) role_last_used: ::std::option::Option<crate::types::RoleLastUsed>,
}
impl RoleBuilder {
/// <p>The path to the role. For more information about paths, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
/// This field is required.
pub fn path(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.path = ::std::option::Option::Some(input.into());
self
}
/// <p>The path to the role. For more information about paths, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
pub fn set_path(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.path = input;
self
}
/// <p>The path to the role. For more information about paths, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
pub fn get_path(&self) -> &::std::option::Option<::std::string::String> {
&self.path
}
/// <p>The friendly name that identifies the role.</p>
/// This field is required.
pub fn role_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.role_name = ::std::option::Option::Some(input.into());
self
}
/// <p>The friendly name that identifies the role.</p>
pub fn set_role_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.role_name = input;
self
}
/// <p>The friendly name that identifies the role.</p>
pub fn get_role_name(&self) -> &::std::option::Option<::std::string::String> {
&self.role_name
}
/// <p>The stable and unique string identifying the role. For more information about IDs, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
/// This field is required.
pub fn role_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.role_id = ::std::option::Option::Some(input.into());
self
}
/// <p>The stable and unique string identifying the role. For more information about IDs, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
pub fn set_role_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.role_id = input;
self
}
/// <p>The stable and unique string identifying the role. For more information about IDs, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i>.</p>
pub fn get_role_id(&self) -> &::std::option::Option<::std::string::String> {
&self.role_id
}
/// <p>The Amazon Resource Name (ARN) specifying the role. For more information about ARNs and how to use them in policies, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i> guide.</p>
/// This field is required.
pub fn arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.arn = ::std::option::Option::Some(input.into());
self
}
/// <p>The Amazon Resource Name (ARN) specifying the role. For more information about ARNs and how to use them in policies, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i> guide.</p>
pub fn set_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.arn = input;
self
}
/// <p>The Amazon Resource Name (ARN) specifying the role. For more information about ARNs and how to use them in policies, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html">IAM identifiers</a> in the <i>IAM User Guide</i> guide.</p>
pub fn get_arn(&self) -> &::std::option::Option<::std::string::String> {
&self.arn
}
/// <p>The date and time, in <a href="http://www.iso.org/iso/iso8601">ISO 8601 date-time format</a>, when the role was created.</p>
/// This field is required.
pub fn create_date(mut self, input: ::aws_smithy_types::DateTime) -> Self {
self.create_date = ::std::option::Option::Some(input);
self
}
/// <p>The date and time, in <a href="http://www.iso.org/iso/iso8601">ISO 8601 date-time format</a>, when the role was created.</p>
pub fn set_create_date(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
self.create_date = input;
self
}
/// <p>The date and time, in <a href="http://www.iso.org/iso/iso8601">ISO 8601 date-time format</a>, when the role was created.</p>
pub fn get_create_date(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
&self.create_date
}
/// <p>The policy that grants an entity permission to assume the role.</p>
pub fn assume_role_policy_document(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.assume_role_policy_document = ::std::option::Option::Some(input.into());
self
}
/// <p>The policy that grants an entity permission to assume the role.</p>
pub fn set_assume_role_policy_document(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.assume_role_policy_document = input;
self
}
/// <p>The policy that grants an entity permission to assume the role.</p>
pub fn get_assume_role_policy_document(&self) -> &::std::option::Option<::std::string::String> {
&self.assume_role_policy_document
}
/// <p>A description of the role that you provide.</p>
pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.description = ::std::option::Option::Some(input.into());
self
}
/// <p>A description of the role that you provide.</p>
pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.description = input;
self
}
/// <p>A description of the role that you provide.</p>
pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
&self.description
}
/// <p>The maximum session duration (in seconds) for the specified role. Anyone who uses the CLI, or API to assume the role can specify the duration using the optional <code>DurationSeconds</code> API parameter or <code>duration-seconds</code> CLI parameter.</p>
pub fn max_session_duration(mut self, input: i32) -> Self {
self.max_session_duration = ::std::option::Option::Some(input);
self
}
/// <p>The maximum session duration (in seconds) for the specified role. Anyone who uses the CLI, or API to assume the role can specify the duration using the optional <code>DurationSeconds</code> API parameter or <code>duration-seconds</code> CLI parameter.</p>
pub fn set_max_session_duration(mut self, input: ::std::option::Option<i32>) -> Self {
self.max_session_duration = input;
self
}
/// <p>The maximum session duration (in seconds) for the specified role. Anyone who uses the CLI, or API to assume the role can specify the duration using the optional <code>DurationSeconds</code> API parameter or <code>duration-seconds</code> CLI parameter.</p>
pub fn get_max_session_duration(&self) -> &::std::option::Option<i32> {
&self.max_session_duration
}
/// <p>The ARN of the policy used to set the permissions boundary for the role.</p>
/// <p>For more information about permissions boundaries, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html">Permissions boundaries for IAM identities </a> in the <i>IAM User Guide</i>.</p>
pub fn permissions_boundary(mut self, input: crate::types::AttachedPermissionsBoundary) -> Self {
self.permissions_boundary = ::std::option::Option::Some(input);
self
}
/// <p>The ARN of the policy used to set the permissions boundary for the role.</p>
/// <p>For more information about permissions boundaries, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html">Permissions boundaries for IAM identities </a> in the <i>IAM User Guide</i>.</p>
pub fn set_permissions_boundary(mut self, input: ::std::option::Option<crate::types::AttachedPermissionsBoundary>) -> Self {
self.permissions_boundary = input;
self
}
/// <p>The ARN of the policy used to set the permissions boundary for the role.</p>
/// <p>For more information about permissions boundaries, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html">Permissions boundaries for IAM identities </a> in the <i>IAM User Guide</i>.</p>
pub fn get_permissions_boundary(&self) -> &::std::option::Option<crate::types::AttachedPermissionsBoundary> {
&self.permissions_boundary
}
/// Appends an item to `tags`.
///
/// To override the contents of this collection use [`set_tags`](Self::set_tags).
///
/// <p>A list of tags that are attached to the role. For more information about tagging, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html">Tagging IAM resources</a> in the <i>IAM User Guide</i>.</p>
pub fn tags(mut self, input: crate::types::Tag) -> Self {
let mut v = self.tags.unwrap_or_default();
v.push(input);
self.tags = ::std::option::Option::Some(v);
self
}
/// <p>A list of tags that are attached to the role. For more information about tagging, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html">Tagging IAM resources</a> in the <i>IAM User Guide</i>.</p>
pub fn set_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>) -> Self {
self.tags = input;
self
}
/// <p>A list of tags that are attached to the role. For more information about tagging, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html">Tagging IAM resources</a> in the <i>IAM User Guide</i>.</p>
pub fn get_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Tag>> {
&self.tags
}
/// <p>Contains information about the last time that an IAM role was used. This includes the date and time and the Region in which the role was last used. Activity is only reported for the trailing 400 days. This period can be shorter if your Region began supporting these features within the last year. The role might have been used more than 400 days ago. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#access-advisor_tracking-period">Regions where data is tracked</a> in the <i>IAM user Guide</i>.</p>
pub fn role_last_used(mut self, input: crate::types::RoleLastUsed) -> Self {
self.role_last_used = ::std::option::Option::Some(input);
self
}
/// <p>Contains information about the last time that an IAM role was used. This includes the date and time and the Region in which the role was last used. Activity is only reported for the trailing 400 days. This period can be shorter if your Region began supporting these features within the last year. The role might have been used more than 400 days ago. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#access-advisor_tracking-period">Regions where data is tracked</a> in the <i>IAM user Guide</i>.</p>
pub fn set_role_last_used(mut self, input: ::std::option::Option<crate::types::RoleLastUsed>) -> Self {
self.role_last_used = input;
self
}
/// <p>Contains information about the last time that an IAM role was used. This includes the date and time and the Region in which the role was last used. Activity is only reported for the trailing 400 days. This period can be shorter if your Region began supporting these features within the last year. The role might have been used more than 400 days ago. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#access-advisor_tracking-period">Regions where data is tracked</a> in the <i>IAM user Guide</i>.</p>
pub fn get_role_last_used(&self) -> &::std::option::Option<crate::types::RoleLastUsed> {
&self.role_last_used
}
/// Consumes the builder and constructs a [`Role`](crate::types::Role).
/// This method will fail if any of the following fields are not set:
/// - [`path`](crate::types::builders::RoleBuilder::path)
/// - [`role_name`](crate::types::builders::RoleBuilder::role_name)
/// - [`role_id`](crate::types::builders::RoleBuilder::role_id)
/// - [`arn`](crate::types::builders::RoleBuilder::arn)
/// - [`create_date`](crate::types::builders::RoleBuilder::create_date)
pub fn build(self) -> ::std::result::Result<crate::types::Role, ::aws_smithy_types::error::operation::BuildError> {
::std::result::Result::Ok(crate::types::Role {
path: self.path.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"path",
"path was not specified but it is required when building Role",
)
})?,
role_name: self.role_name.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"role_name",
"role_name was not specified but it is required when building Role",
)
})?,
role_id: self.role_id.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"role_id",
"role_id was not specified but it is required when building Role",
)
})?,
arn: self.arn.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field("arn", "arn was not specified but it is required when building Role")
})?,
create_date: self.create_date.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"create_date",
"create_date was not specified but it is required when building Role",
)
})?,
assume_role_policy_document: self.assume_role_policy_document,
description: self.description,
max_session_duration: self.max_session_duration,
permissions_boundary: self.permissions_boundary,
tags: self.tags,
role_last_used: self.role_last_used,
})
}
}