Unverified Commit 970f69bf authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Create a table in the example (#226)

parent 8f844c57
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -5,10 +5,10 @@

use std::error::Error;


use dynamodb::operation::{CreateTable, ListTables};
use dynamodb::{Credentials, Endpoint, Region};
use env_logger::Env;
use dynamodb::{Endpoint, Region, Credentials};
use dynamodb::operation::ListTables;
use dynamodb::model::{KeySchemaElement, KeyType, ProvisionedThroughput, AttributeDefinition, ScalarAttributeType};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
@@ -20,7 +20,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
        .credentials_provider(Credentials::from_keys(
            "<fill me in2>",
            "<fill me in>",
            None
            None,
        ))
        // To use real DynamoDB, delete this line:
        .endpoint_resolver(Endpoint::immutable(http::Uri::from_static(
@@ -33,5 +33,17 @@ async fn main() -> Result<(), Box<dyn Error>> {
    // Currently this fails, pending the merge of https://github.com/awslabs/smithy-rs/pull/202
    let tables = client.call(op).await?;
    println!("Current DynamoDB tables: {:?}", tables);

    let new_table = client
        .call(
            CreateTable::builder()
                .table_name("test-table")
                .key_schema(vec![KeySchemaElement::builder().attribute_name("k").key_type(KeyType::Hash).build()])
                .attribute_definitions(vec![AttributeDefinition::builder().attribute_name("k").attribute_type(ScalarAttributeType::S).build()])
                .provisioned_throughput(ProvisionedThroughput::builder().write_capacity_units(10).read_capacity_units(10).build())
                .build(&config),
        )
        .await?;
    println!("new table: {:#?}", &new_table.table_description.unwrap().table_arn.unwrap());
    Ok(())
}
+3 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ dependencies {

data class CodegenTest(val service: String, val module: String, val extraConfig: String? = null)

val CodgenTests = listOf(
val CodegenTests = listOf(
    CodegenTest("com.amazonaws.dynamodb#DynamoDB_20120810", "dynamo"),
    CodegenTest("com.amazonaws.ebs#Ebs", "ebs"),
    CodegenTest("aws.protocoltests.json10#JsonRpc10", "json_rpc10"),
@@ -77,7 +77,7 @@ fun generateSmithyBuild(tests: List<CodegenTest>): String {
task("generateSmithyBuild") {
    description = "generate smithy-build.json"
    doFirst {
        projectDir.resolve("smithy-build.json").writeText(generateSmithyBuild(CodgenTests))
        projectDir.resolve("smithy-build.json").writeText(generateSmithyBuild(CodegenTests))
    }
}

@@ -93,7 +93,7 @@ fun generateCargoWorkspace(tests: List<CodegenTest>): String {
task("generateCargoWorkspace") {
    description = "generate Cargo.toml workspace file"
    doFirst {
        buildDir.resolve("smithyprojections/codegen-test/Cargo.toml").writeText(generateCargoWorkspace(CodgenTests))
        buildDir.resolve("smithyprojections/codegen-test/Cargo.toml").writeText(generateCargoWorkspace(CodegenTests))
    }
}

codegen-test/dynamo-it/.gitignore

deleted100644 → 0
+0 −1
Original line number Diff line number Diff line
target/

codegen-test/dynamo-it/Cargo.lock

deleted100644 → 0
+0 −1194

File deleted.

Preview size limit exceeded, changes collapsed.

Loading