aws_sdk_sts/types/
_credentials.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Amazon Web Services credentials for API authentication.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
6pub struct Credentials {
7    /// <p>The access key ID that identifies the temporary security credentials.</p>
8    pub access_key_id: ::std::string::String,
9    /// <p>The secret access key that can be used to sign requests.</p>
10    pub secret_access_key: ::std::string::String,
11    /// <p>The token that users must pass to the service API to use the temporary credentials.</p>
12    pub session_token: ::std::string::String,
13    /// <p>The date on which the current credentials expire.</p>
14    pub expiration: ::aws_smithy_types::DateTime,
15}
16impl Credentials {
17    /// <p>The access key ID that identifies the temporary security credentials.</p>
18    pub fn access_key_id(&self) -> &str {
19        use std::ops::Deref;
20        self.access_key_id.deref()
21    }
22    /// <p>The secret access key that can be used to sign requests.</p>
23    pub fn secret_access_key(&self) -> &str {
24        use std::ops::Deref;
25        self.secret_access_key.deref()
26    }
27    /// <p>The token that users must pass to the service API to use the temporary credentials.</p>
28    pub fn session_token(&self) -> &str {
29        use std::ops::Deref;
30        self.session_token.deref()
31    }
32    /// <p>The date on which the current credentials expire.</p>
33    pub fn expiration(&self) -> &::aws_smithy_types::DateTime {
34        &self.expiration
35    }
36}
37impl ::std::fmt::Debug for Credentials {
38    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
39        let mut formatter = f.debug_struct("Credentials");
40        formatter.field("access_key_id", &"*** Sensitive Data Redacted ***");
41        formatter.field("secret_access_key", &"*** Sensitive Data Redacted ***");
42        formatter.field("session_token", &"*** Sensitive Data Redacted ***");
43        formatter.field("expiration", &"*** Sensitive Data Redacted ***");
44        formatter.finish()
45    }
46}
47impl Credentials {
48    /// Creates a new builder-style object to manufacture [`Credentials`](crate::types::Credentials).
49    pub fn builder() -> crate::types::builders::CredentialsBuilder {
50        crate::types::builders::CredentialsBuilder::default()
51    }
52}
53
54/// A builder for [`Credentials`](crate::types::Credentials).
55#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
56#[non_exhaustive]
57pub struct CredentialsBuilder {
58    pub(crate) access_key_id: ::std::option::Option<::std::string::String>,
59    pub(crate) secret_access_key: ::std::option::Option<::std::string::String>,
60    pub(crate) session_token: ::std::option::Option<::std::string::String>,
61    pub(crate) expiration: ::std::option::Option<::aws_smithy_types::DateTime>,
62}
63impl CredentialsBuilder {
64    /// <p>The access key ID that identifies the temporary security credentials.</p>
65    /// This field is required.
66    pub fn access_key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
67        self.access_key_id = ::std::option::Option::Some(input.into());
68        self
69    }
70    /// <p>The access key ID that identifies the temporary security credentials.</p>
71    pub fn set_access_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
72        self.access_key_id = input;
73        self
74    }
75    /// <p>The access key ID that identifies the temporary security credentials.</p>
76    pub fn get_access_key_id(&self) -> &::std::option::Option<::std::string::String> {
77        &self.access_key_id
78    }
79    /// <p>The secret access key that can be used to sign requests.</p>
80    /// This field is required.
81    pub fn secret_access_key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
82        self.secret_access_key = ::std::option::Option::Some(input.into());
83        self
84    }
85    /// <p>The secret access key that can be used to sign requests.</p>
86    pub fn set_secret_access_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
87        self.secret_access_key = input;
88        self
89    }
90    /// <p>The secret access key that can be used to sign requests.</p>
91    pub fn get_secret_access_key(&self) -> &::std::option::Option<::std::string::String> {
92        &self.secret_access_key
93    }
94    /// <p>The token that users must pass to the service API to use the temporary credentials.</p>
95    /// This field is required.
96    pub fn session_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
97        self.session_token = ::std::option::Option::Some(input.into());
98        self
99    }
100    /// <p>The token that users must pass to the service API to use the temporary credentials.</p>
101    pub fn set_session_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
102        self.session_token = input;
103        self
104    }
105    /// <p>The token that users must pass to the service API to use the temporary credentials.</p>
106    pub fn get_session_token(&self) -> &::std::option::Option<::std::string::String> {
107        &self.session_token
108    }
109    /// <p>The date on which the current credentials expire.</p>
110    /// This field is required.
111    pub fn expiration(mut self, input: ::aws_smithy_types::DateTime) -> Self {
112        self.expiration = ::std::option::Option::Some(input);
113        self
114    }
115    /// <p>The date on which the current credentials expire.</p>
116    pub fn set_expiration(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
117        self.expiration = input;
118        self
119    }
120    /// <p>The date on which the current credentials expire.</p>
121    pub fn get_expiration(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
122        &self.expiration
123    }
124    /// Consumes the builder and constructs a [`Credentials`](crate::types::Credentials).
125    /// This method will fail if any of the following fields are not set:
126    /// - [`access_key_id`](crate::types::builders::CredentialsBuilder::access_key_id)
127    /// - [`secret_access_key`](crate::types::builders::CredentialsBuilder::secret_access_key)
128    /// - [`session_token`](crate::types::builders::CredentialsBuilder::session_token)
129    /// - [`expiration`](crate::types::builders::CredentialsBuilder::expiration)
130    pub fn build(self) -> ::std::result::Result<crate::types::Credentials, ::aws_smithy_types::error::operation::BuildError> {
131        ::std::result::Result::Ok(crate::types::Credentials {
132            access_key_id: self.access_key_id.ok_or_else(|| {
133                ::aws_smithy_types::error::operation::BuildError::missing_field(
134                    "access_key_id",
135                    "access_key_id was not specified but it is required when building Credentials",
136                )
137            })?,
138            secret_access_key: self.secret_access_key.ok_or_else(|| {
139                ::aws_smithy_types::error::operation::BuildError::missing_field(
140                    "secret_access_key",
141                    "secret_access_key was not specified but it is required when building Credentials",
142                )
143            })?,
144            session_token: self.session_token.ok_or_else(|| {
145                ::aws_smithy_types::error::operation::BuildError::missing_field(
146                    "session_token",
147                    "session_token was not specified but it is required when building Credentials",
148                )
149            })?,
150            expiration: self.expiration.ok_or_else(|| {
151                ::aws_smithy_types::error::operation::BuildError::missing_field(
152                    "expiration",
153                    "expiration was not specified but it is required when building Credentials",
154                )
155            })?,
156        })
157    }
158}
159impl ::std::fmt::Debug for CredentialsBuilder {
160    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
161        let mut formatter = f.debug_struct("CredentialsBuilder");
162        formatter.field("access_key_id", &"*** Sensitive Data Redacted ***");
163        formatter.field("secret_access_key", &"*** Sensitive Data Redacted ***");
164        formatter.field("session_token", &"*** Sensitive Data Redacted ***");
165        formatter.field("expiration", &"*** Sensitive Data Redacted ***");
166        formatter.finish()
167    }
168}