raws_dynamodb/lib.rs
1use aws_sdk_dynamodb as dynamodb;
2use aws_sdk_dynamodb::types;
3use clap::{Args, Subcommand};
4
5use config::Config;
6use error::RawsError;
7
8mod table;
9
10type DynamoResult<T = Box<dyn show::Show>> = Result<T, dynamodb::Error>;
11
12/// Amazon DynamoDB is a fully managed NoSQL database service
13///
14/// Amazon DynamoDB is a fully managed NoSQL database service that provides
15/// fast and predictable performance with seamless scalability. DynamoDB
16/// lets you offload the administrative burdens of operating and scaling a
17/// distributed database, so that you don't have to worry about hardware
18/// provisioning, setup and configuration, replication, software patching,
19/// or cluster scaling.
20///
21/// With DynamoDB, you can create database tables that can store and
22/// retrieve any amount of data, and serve any level of request traffic.
23/// You can scale up or scale down your tables' throughput capacity without
24/// downtime or performance degradation, and use the Amazon Web Services
25/// Management Console to monitor resource utilization and performance
26/// metrics.
27///
28/// DynamoDB automatically spreads the data and traffic for your tables
29/// over a sufficient number of servers to handle your throughput and
30/// storage requirements, while maintaining consistent and fast
31/// performance. All of your data is stored on solid state disks (SSDs) and
32/// automatically replicated across multiple Availability Zones in an
33/// Amazon Web Services Region, providing built-in high availability and
34/// data durability.
35#[derive(Debug, Subcommand)]
36#[command(verbatim_doc_comment)]
37pub enum DynamoDb {
38 CreateTable(table::CreateTable),
39 DeleteTable(table::DeleteTable),
40 DescribeTable(table::DescribeTable),
41 ListTables(table::ListTables),
42}
43
44impl DynamoDb {
45 async fn execute(self, config: &Config) -> DynamoResult {
46 match self {
47 Self::CreateTable(create_table) => create_table.execute(config).await,
48 Self::DeleteTable(delete_table) => delete_table.execute(config).await,
49 Self::DescribeTable(describe_table) => describe_table.execute(config).await,
50 Self::ListTables(list_tables) => list_tables.execute(config).await,
51 }
52 }
53
54 pub async fn dispatch(self, config: Config) -> Result<(), RawsError<dynamodb::Error>> {
55 self.execute(&config)
56 .await
57 .map(|output| config.show(output))?;
58 Ok(())
59 }
60}