1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
23/// <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>
8pub access_key_id: ::std::string::String,
9/// <p>The secret access key that can be used to sign requests.</p>
10pub secret_access_key: ::std::string::String,
11/// <p>The token that users must pass to the service API to use the temporary credentials.</p>
12pub session_token: ::std::string::String,
13/// <p>The date on which the current credentials expire.</p>
14pub expiration: ::aws_smithy_types::DateTime,
15}
16impl Credentials {
17/// <p>The access key ID that identifies the temporary security credentials.</p>
18pub fn access_key_id(&self) -> &str {
19use std::ops::Deref;
20self.access_key_id.deref()
21 }
22/// <p>The secret access key that can be used to sign requests.</p>
23pub fn secret_access_key(&self) -> &str {
24use std::ops::Deref;
25self.secret_access_key.deref()
26 }
27/// <p>The token that users must pass to the service API to use the temporary credentials.</p>
28pub fn session_token(&self) -> &str {
29use std::ops::Deref;
30self.session_token.deref()
31 }
32/// <p>The date on which the current credentials expire.</p>
33pub fn expiration(&self) -> &::aws_smithy_types::DateTime {
34&self.expiration
35 }
36}
37impl ::std::fmt::Debug for Credentials {
38fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
39let 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).
49pub fn builder() -> crate::types::builders::CredentialsBuilder {
50crate::types::builders::CredentialsBuilder::default()
51 }
52}
5354/// A builder for [`Credentials`](crate::types::Credentials).
55#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
56#[non_exhaustive]
57pub struct CredentialsBuilder {
58pub(crate) access_key_id: ::std::option::Option<::std::string::String>,
59pub(crate) secret_access_key: ::std::option::Option<::std::string::String>,
60pub(crate) session_token: ::std::option::Option<::std::string::String>,
61pub(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.
66pub fn access_key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
67self.access_key_id = ::std::option::Option::Some(input.into());
68self
69}
70/// <p>The access key ID that identifies the temporary security credentials.</p>
71pub fn set_access_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
72self.access_key_id = input;
73self
74}
75/// <p>The access key ID that identifies the temporary security credentials.</p>
76pub 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.
81pub fn secret_access_key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
82self.secret_access_key = ::std::option::Option::Some(input.into());
83self
84}
85/// <p>The secret access key that can be used to sign requests.</p>
86pub fn set_secret_access_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
87self.secret_access_key = input;
88self
89}
90/// <p>The secret access key that can be used to sign requests.</p>
91pub 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.
96pub fn session_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
97self.session_token = ::std::option::Option::Some(input.into());
98self
99}
100/// <p>The token that users must pass to the service API to use the temporary credentials.</p>
101pub fn set_session_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
102self.session_token = input;
103self
104}
105/// <p>The token that users must pass to the service API to use the temporary credentials.</p>
106pub 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.
111pub fn expiration(mut self, input: ::aws_smithy_types::DateTime) -> Self {
112self.expiration = ::std::option::Option::Some(input);
113self
114}
115/// <p>The date on which the current credentials expire.</p>
116pub fn set_expiration(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
117self.expiration = input;
118self
119}
120/// <p>The date on which the current credentials expire.</p>
121pub 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)
130pub 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 {
160fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
161let 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}