raws_pricing/
lib.rs

1use aws_sdk_pricing as pricing;
2use clap::{Args, Subcommand};
3
4use config::Config;
5use error::RawsError;
6
7mod pricelist;
8mod services;
9
10type PricingResult<T = Box<dyn show::Show>> = Result<T, pricing::Error>;
11
12/// AWS Pricing Information
13#[derive(Debug, Subcommand)]
14pub enum Pricing {
15    DescribeServices(services::DescribeServices),
16    GetAttributeValues(services::GetAttributeValues),
17    GetProducts(services::GetProducts),
18    GetPriceListFileUrl(pricelist::GetPriceListFileUrl),
19    ListPriceLists(pricelist::ListPriceLists),
20}
21
22impl Pricing {
23    async fn execute(self, config: &Config) -> PricingResult {
24        match self {
25            Self::DescribeServices(describe_services) => describe_services.execute(config).await,
26            Self::GetAttributeValues(get_attribute_values) => {
27                get_attribute_values.execute(config).await
28            }
29            Self::GetProducts(get_products) => get_products.execute(config).await,
30            Self::GetPriceListFileUrl(get_price_list_file_url) => {
31                get_price_list_file_url.execute(config).await
32            }
33            Self::ListPriceLists(list_price_lists) => list_price_lists.execute(config).await,
34        }
35    }
36
37    pub async fn dispatch(self, config: Config) -> Result<(), RawsError<pricing::Error>> {
38        self.execute(&config)
39            .await
40            .map(|output| config.show(output))?;
41        Ok(())
42    }
43}