raws_show/sts/
identity.rs1use super::*;
2
3#[derive(Debug, Serialize)]
4#[serde(rename_all = "PascalCase")]
5struct CallerIdentity {
6 user_id: String,
7 account: String,
8 arn: String,
9}
10
11impl Show for CallerIdentity {
12 fn _fmt(&self) -> Box<dyn fmt::Display + '_> {
13 todo!()
14 }
15
16 fn json(&self) -> String {
17 json::to_string_pretty(self).unwrap_or_default()
18 }
19}
20
21impl Show for aws_sdk_sts::operation::get_caller_identity::GetCallerIdentityOutput {
22 fn _fmt(&self) -> Box<dyn fmt::Display + '_> {
23 Box::new(fmtools::fmt!(
24 { prefixed_item("ACCOUNT", self.account()) } " "
25 { prefixed_item("USER_ID", self.user_id()) } " "
26 { prefixed_item("ARN", self.arn()) }
27 ))
28 }
29
30 fn json(&self) -> String {
31 CallerIdentity::from(self).json()
32 }
33}
34
35impl fmt::Display for CallerIdentity {
36 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37 format_args!("{} {} {}", self.account, self.user_id, self.arn).fmt(f)
38 }
39}
40
41impl From<&aws_sdk_sts::operation::get_caller_identity::GetCallerIdentityOutput>
42 for CallerIdentity
43{
44 fn from(output: &aws_sdk_sts::operation::get_caller_identity::GetCallerIdentityOutput) -> Self {
45 let user_id = output.user_id().unwrap_or_default().to_string();
46 let account = output.account().unwrap_or_default().to_string();
47 let arn = output.arn().unwrap_or_default().to_string();
48 Self {
49 user_id,
50 account,
51 arn,
52 }
53 }
54}