aws-sdk-ssm 1.131.0

AWS SDK for Amazon Simple Systems Manager (SSM)
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>The temporary security credentials, which include an access key ID, a secret access key, and a security (or session) token.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
pub struct Credentials {
    /// <p>The access key ID that identifies the temporary security credentials.</p>
    pub access_key_id: ::std::string::String,
    /// <p>The secret access key that can be used to sign requests.</p>
    pub secret_access_key: ::std::string::String,
    /// <p>The token that users must pass to the service API to use the temporary credentials.</p>
    pub session_token: ::std::string::String,
    /// <p>The datetime on which the current credentials expire.</p>
    pub expiration_time: ::aws_smithy_types::DateTime,
}
impl Credentials {
    /// <p>The access key ID that identifies the temporary security credentials.</p>
    pub fn access_key_id(&self) -> &str {
        use std::ops::Deref;
        self.access_key_id.deref()
    }
    /// <p>The secret access key that can be used to sign requests.</p>
    pub fn secret_access_key(&self) -> &str {
        use std::ops::Deref;
        self.secret_access_key.deref()
    }
    /// <p>The token that users must pass to the service API to use the temporary credentials.</p>
    pub fn session_token(&self) -> &str {
        use std::ops::Deref;
        self.session_token.deref()
    }
    /// <p>The datetime on which the current credentials expire.</p>
    pub fn expiration_time(&self) -> &::aws_smithy_types::DateTime {
        &self.expiration_time
    }
}
impl ::std::fmt::Debug for Credentials {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        let mut formatter = f.debug_struct("Credentials");
        formatter.field("access_key_id", &self.access_key_id);
        formatter.field("secret_access_key", &"*** Sensitive Data Redacted ***");
        formatter.field("session_token", &"*** Sensitive Data Redacted ***");
        formatter.field("expiration_time", &self.expiration_time);
        formatter.finish()
    }
}
static CREDENTIALS_MEMBER_ACCESS_KEY_ID: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_member(
    ::aws_smithy_schema::ShapeId::from_parts("com.amazonaws.ssm#Credentials$AccessKeyId", "com.amazonaws.ssm", "Credentials"),
    ::aws_smithy_schema::ShapeType::String,
    "AccessKeyId",
    0,
);
static CREDENTIALS_MEMBER_SECRET_ACCESS_KEY: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_member(
    ::aws_smithy_schema::ShapeId::from_parts("com.amazonaws.ssm#Credentials$SecretAccessKey", "com.amazonaws.ssm", "Credentials"),
    ::aws_smithy_schema::ShapeType::String,
    "SecretAccessKey",
    1,
);
static CREDENTIALS_MEMBER_SESSION_TOKEN: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_member(
    ::aws_smithy_schema::ShapeId::from_parts("com.amazonaws.ssm#Credentials$SessionToken", "com.amazonaws.ssm", "Credentials"),
    ::aws_smithy_schema::ShapeType::String,
    "SessionToken",
    2,
);
static CREDENTIALS_MEMBER_EXPIRATION_TIME: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_member(
    ::aws_smithy_schema::ShapeId::from_parts("com.amazonaws.ssm#Credentials$ExpirationTime", "com.amazonaws.ssm", "Credentials"),
    ::aws_smithy_schema::ShapeType::Timestamp,
    "ExpirationTime",
    3,
);
static CREDENTIALS_SCHEMA: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_struct(
    ::aws_smithy_schema::ShapeId::from_parts("com.amazonaws.ssm#Credentials", "com.amazonaws.ssm", "Credentials"),
    ::aws_smithy_schema::ShapeType::Structure,
    &[
        &CREDENTIALS_MEMBER_ACCESS_KEY_ID,
        &CREDENTIALS_MEMBER_SECRET_ACCESS_KEY,
        &CREDENTIALS_MEMBER_SESSION_TOKEN,
        &CREDENTIALS_MEMBER_EXPIRATION_TIME,
    ],
);
impl Credentials {
    /// The schema for this shape.
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = &CREDENTIALS_SCHEMA;
}
impl ::aws_smithy_schema::serde::SerializableStruct for Credentials {
    fn schema(&self) -> &::aws_smithy_schema::Schema<'_> {
        Self::SCHEMA
    }

    #[allow(unused_variables, clippy::diverging_sub_expression)]
    fn serialize_members(
        &self,
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
        {
            let val = &self.access_key_id;
            ser.write_string(&CREDENTIALS_MEMBER_ACCESS_KEY_ID, val)?;
        }
        {
            let val = &self.secret_access_key;
            ser.write_string(&CREDENTIALS_MEMBER_SECRET_ACCESS_KEY, val)?;
        }
        {
            let val = &self.session_token;
            ser.write_string(&CREDENTIALS_MEMBER_SESSION_TOKEN, val)?;
        }
        {
            let val = &self.expiration_time;
            ser.write_timestamp(&CREDENTIALS_MEMBER_EXPIRATION_TIME, val)?;
        }
        Ok(())
    }
}
impl crate::types::builders::CredentialsBuilder {
    #[allow(
        unused_variables,
        unreachable_code,
        clippy::single_match,
        clippy::match_single_binding,
        clippy::diverging_sub_expression
    )]
    pub(crate) fn deserialize_members(
        &mut self,
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
        deserializer.read_struct(&CREDENTIALS_SCHEMA, &mut |member, deser| {
            match member.member_index() {
                Some(0) => {
                    self.access_key_id = Some(deser.read_string(member)?);
                }
                Some(1) => {
                    self.secret_access_key = Some(deser.read_string(member)?);
                }
                Some(2) => {
                    self.session_token = Some(deser.read_string(member)?);
                }
                Some(3) => {
                    self.expiration_time = Some(deser.read_timestamp(member)?);
                }
                _ => {}
            }
            Ok(())
        })
    }
}

impl Credentials {
    /// Deserializes this structure from a [`ShapeDeserializer`].
    pub fn deserialize(
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
        let mut builder = Self::builder();
        builder.deserialize_members(deserializer)?;
        builder.access_key_id = builder.access_key_id.or(Some(String::new()));
        builder.secret_access_key = builder.secret_access_key.or(Some(String::new()));
        builder.session_token = builder.session_token.or(Some(String::new()));
        builder.expiration_time = builder.expiration_time.or(Some(::aws_smithy_types::DateTime::from_secs(0)));
        builder.build().map_err(|e| aws_smithy_schema::serde::SerdeError::custom(e.to_string()))
    }
}
impl Credentials {
    /// Creates a new builder-style object to manufacture [`Credentials`](crate::types::Credentials).
    pub fn builder() -> crate::types::builders::CredentialsBuilder {
        crate::types::builders::CredentialsBuilder::default()
    }
}

/// A builder for [`Credentials`](crate::types::Credentials).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
#[non_exhaustive]
pub struct CredentialsBuilder {
    pub(crate) access_key_id: ::std::option::Option<::std::string::String>,
    pub(crate) secret_access_key: ::std::option::Option<::std::string::String>,
    pub(crate) session_token: ::std::option::Option<::std::string::String>,
    pub(crate) expiration_time: ::std::option::Option<::aws_smithy_types::DateTime>,
}
impl CredentialsBuilder {
    /// <p>The access key ID that identifies the temporary security credentials.</p>
    /// This field is required.
    pub fn access_key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.access_key_id = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The access key ID that identifies the temporary security credentials.</p>
    pub fn set_access_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.access_key_id = input;
        self
    }
    /// <p>The access key ID that identifies the temporary security credentials.</p>
    pub fn get_access_key_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.access_key_id
    }
    /// <p>The secret access key that can be used to sign requests.</p>
    /// This field is required.
    pub fn secret_access_key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.secret_access_key = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The secret access key that can be used to sign requests.</p>
    pub fn set_secret_access_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.secret_access_key = input;
        self
    }
    /// <p>The secret access key that can be used to sign requests.</p>
    pub fn get_secret_access_key(&self) -> &::std::option::Option<::std::string::String> {
        &self.secret_access_key
    }
    /// <p>The token that users must pass to the service API to use the temporary credentials.</p>
    /// This field is required.
    pub fn session_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.session_token = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The token that users must pass to the service API to use the temporary credentials.</p>
    pub fn set_session_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.session_token = input;
        self
    }
    /// <p>The token that users must pass to the service API to use the temporary credentials.</p>
    pub fn get_session_token(&self) -> &::std::option::Option<::std::string::String> {
        &self.session_token
    }
    /// <p>The datetime on which the current credentials expire.</p>
    /// This field is required.
    pub fn expiration_time(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.expiration_time = ::std::option::Option::Some(input);
        self
    }
    /// <p>The datetime on which the current credentials expire.</p>
    pub fn set_expiration_time(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.expiration_time = input;
        self
    }
    /// <p>The datetime on which the current credentials expire.</p>
    pub fn get_expiration_time(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        &self.expiration_time
    }
    /// Consumes the builder and constructs a [`Credentials`](crate::types::Credentials).
    /// This method will fail if any of the following fields are not set:
    /// - [`access_key_id`](crate::types::builders::CredentialsBuilder::access_key_id)
    /// - [`secret_access_key`](crate::types::builders::CredentialsBuilder::secret_access_key)
    /// - [`session_token`](crate::types::builders::CredentialsBuilder::session_token)
    /// - [`expiration_time`](crate::types::builders::CredentialsBuilder::expiration_time)
    pub fn build(self) -> ::std::result::Result<crate::types::Credentials, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Credentials {
            access_key_id: self.access_key_id.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "access_key_id",
                    "access_key_id was not specified but it is required when building Credentials",
                )
            })?,
            secret_access_key: self.secret_access_key.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "secret_access_key",
                    "secret_access_key was not specified but it is required when building Credentials",
                )
            })?,
            session_token: self.session_token.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "session_token",
                    "session_token was not specified but it is required when building Credentials",
                )
            })?,
            expiration_time: self.expiration_time.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "expiration_time",
                    "expiration_time was not specified but it is required when building Credentials",
                )
            })?,
        })
    }
}
impl ::std::fmt::Debug for CredentialsBuilder {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        let mut formatter = f.debug_struct("CredentialsBuilder");
        formatter.field("access_key_id", &self.access_key_id);
        formatter.field("secret_access_key", &"*** Sensitive Data Redacted ***");
        formatter.field("session_token", &"*** Sensitive Data Redacted ***");
        formatter.field("expiration_time", &self.expiration_time);
        formatter.finish()
    }
}