rusty_cdk_core/dynamodb/
dto.rs

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