use std::fmt;
use chrono::{DateTime, Utc};
use crate::{cache::Expiry, sso};
#[allow(clippy::module_name_repetitions)]
pub struct SessionCredentials {
pub access_key_id: String,
pub secret_access_key: String,
pub session_token: String,
pub expires_at: DateTime<Utc>,
}
impl fmt::Debug for SessionCredentials {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("SessionCredentials")
.field("access_key_id", &self.access_key_id)
.field("expires_at", &self.expires_at)
.finish()
}
}
impl Expiry for SessionCredentials {
fn expires_at(&self) -> DateTime<Utc> {
self.expires_at
}
}
impl From<sso::GetRoleCredentialsResponse> for SessionCredentials {
fn from(res: sso::GetRoleCredentialsResponse) -> Self {
Self {
access_key_id: res.access_key_id,
secret_access_key: res.secret_access_key,
session_token: res.session_token,
expires_at: res.expires_at,
}
}
}