aws_sdk_sts/types/
_credentials.rs1#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
6pub struct Credentials {
7 pub access_key_id: ::std::string::String,
9 pub secret_access_key: ::std::string::String,
11 pub session_token: ::std::string::String,
13 pub expiration: ::aws_smithy_types::DateTime,
15}
16impl Credentials {
17 pub fn access_key_id(&self) -> &str {
19 use std::ops::Deref;
20 self.access_key_id.deref()
21 }
22 pub fn secret_access_key(&self) -> &str {
24 use std::ops::Deref;
25 self.secret_access_key.deref()
26 }
27 pub fn session_token(&self) -> &str {
29 use std::ops::Deref;
30 self.session_token.deref()
31 }
32 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 pub fn builder() -> crate::types::builders::CredentialsBuilder {
50 crate::types::builders::CredentialsBuilder::default()
51 }
52}
53
54#[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 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 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 pub fn get_access_key_id(&self) -> &::std::option::Option<::std::string::String> {
77 &self.access_key_id
78 }
79 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 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 pub fn get_secret_access_key(&self) -> &::std::option::Option<::std::string::String> {
92 &self.secret_access_key
93 }
94 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 pub fn set_session_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
102 self.session_token = input;
103 self
104 }
105 pub fn get_session_token(&self) -> &::std::option::Option<::std::string::String> {
107 &self.session_token
108 }
109 pub fn expiration(mut self, input: ::aws_smithy_types::DateTime) -> Self {
112 self.expiration = ::std::option::Option::Some(input);
113 self
114 }
115 pub fn set_expiration(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
117 self.expiration = input;
118 self
119 }
120 pub fn get_expiration(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
122 &self.expiration
123 }
124 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}