rusty_cdk_core/dynamodb/
dto.rs1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3use crate::{dto_methods, ref_struct};
4use crate::shared::{Id, UpdateDeletePolicyDTO};
5
6#[derive(Debug, Serialize, Deserialize)]
7pub(crate) enum TableType {
8 #[serde(rename = "AWS::DynamoDB::Table")]
9 TableType
10}
11
12ref_struct!(TableRef);
13
14#[derive(Debug, Serialize, Deserialize)]
15pub struct Table {
16 #[serde(skip)]
17 pub(super) id: Id,
18 #[serde(skip)]
19 pub(super) resource_id: String,
20 #[serde(rename = "Type")]
21 pub(super) r#type: TableType,
22 #[serde(rename = "Properties")]
23 pub(super) properties: TableProperties,
24 #[serde(flatten)]
25 pub(super) update_delete_policy_dto: UpdateDeletePolicyDTO
26}
27dto_methods!(Table);
28
29#[derive(Debug, Serialize, Deserialize)]
30pub struct TableProperties {
31 #[serde(rename = "KeySchema")]
32 pub(super) key_schema: Vec<KeySchema>,
33 #[serde(rename = "AttributeDefinitions")]
34 pub(super) attribute_definitions: Vec<AttributeDefinition>,
35 #[serde(rename = "BillingMode")]
36 pub(super) billing_mode: String,
37 #[serde(rename = "ProvisionedThroughput", skip_serializing_if = "Option::is_none")]
38 pub(super) provisioned_throughput: Option<ProvisionedThroughput>,
39 #[serde(rename = "OnDemandThroughput", skip_serializing_if = "Option::is_none")]
40 pub(super) on_demand_throughput: Option<OnDemandThroughput>,
41 }
49
50#[derive(Debug, Serialize, Deserialize)]
51pub struct AttributeDefinition {
52 #[serde(rename = "AttributeName")]
53 pub(super) attribute_name: String,
54 #[serde(rename = "AttributeType")]
55 pub(super) attribute_type: String,
56}
57
58#[derive(Debug, Serialize, Deserialize)]
59pub struct KeySchema {
60 #[serde(rename = "AttributeName")]
61 pub(super) attribute_name: String,
62 #[serde(rename = "KeyType")]
63 pub(super) key_type: String,
64}
65
66#[derive(Debug, Serialize, Deserialize)]
67pub struct ProvisionedThroughput {
68 #[serde(rename = "ReadCapacityUnits")]
69 pub(super) read_capacity: u32,
70 #[serde(rename = "WriteCapacityUnits")]
71 pub(super) write_capacity: u32,
72}
73
74#[derive(Debug, Serialize, Deserialize)]
75pub struct OnDemandThroughput {
76 #[serde(rename = "MaxReadRequestUnits", skip_serializing_if = "Option::is_none")]
77 pub(super) max_read_capacity: Option<u32>,
78 #[serde(rename = "MaxWriteRequestUnits", skip_serializing_if = "Option::is_none")]
79 pub(super) max_write_capacity: Option<u32>,
80}