raws_account/
lib.rs

1use aws_sdk_account as account;
2use clap::{Args, Subcommand};
3
4use config::Config;
5use error::RawsError;
6
7mod contact;
8mod region;
9
10type AccountResult<T = Box<dyn show::Show>> = Result<T, account::Error>;
11
12/// Operations for Amazon Web Services Account Management
13#[derive(Debug, Subcommand)]
14pub enum Account {
15    EnableRegion(region::EnableRegion),
16    DisableRegion(region::DisableRegion),
17    ListRegions(region::ListRegions),
18    GetRegionOptStatus(region::GetRegionOptStatus),
19    GetAlternateContact(contact::GetAlternateContact),
20    DeleteAlternateContact(contact::DeleteAlternateContact),
21    PutAlternateContact(contact::PutAlternateContact),
22    GetContactInformation(contact::GetContactInformation),
23    PutContactInformation(contact::PutContactInformation),
24}
25
26impl Account {
27    async fn execute(self, config: &Config) -> AccountResult {
28        match self {
29            Self::EnableRegion(enable_region) => enable_region.execute(config).await,
30            Self::DisableRegion(disable_region) => disable_region.execute(config).await,
31            Self::ListRegions(list_regions) => list_regions.execute(config).await,
32            Self::GetRegionOptStatus(status) => status.execute(config).await,
33            Self::GetAlternateContact(get_alternate_contact) => {
34                get_alternate_contact.execute(config).await
35            }
36            Self::DeleteAlternateContact(delete_alternate_contact) => {
37                delete_alternate_contact.execute(config).await
38            }
39            Self::PutAlternateContact(put_alternate_contact) => {
40                put_alternate_contact.execute(config).await
41            }
42            Self::GetContactInformation(get_contact_information) => {
43                get_contact_information.execute(config).await
44            }
45            Self::PutContactInformation(put_contact_information) => {
46                put_contact_information.execute(config).await
47            }
48        }
49    }
50
51    pub async fn dispatch(self, config: Config) -> Result<(), RawsError<account::Error>> {
52        self.execute(&config)
53            .await
54            .map(|output| config.show(output))?;
55        Ok(())
56    }
57}