Skip to content

Commit

Permalink
feat: enable ddbv2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham Chaturvedi committed Oct 24, 2024
1 parent e602cbf commit 5a5a5cc
Show file tree
Hide file tree
Showing 19 changed files with 551 additions and 22 deletions.
116 changes: 112 additions & 4 deletions TestModels/aws-sdks/ddbv2/Model/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -3604,10 +3604,10 @@
"com.amazonaws.dynamodb#DisableKinesisStreamingDestination": {
"type": "operation",
"input": {
"target": "com.amazonaws.dynamodb#KinesisStreamingDestinationInput"
"target": "com.amazonaws.dynamodb#DisableKinesisStreamingDestinationInput"
},
"output": {
"target": "com.amazonaws.dynamodb#KinesisStreamingDestinationOutput"
"target": "com.amazonaws.dynamodb#DisableKinesisStreamingDestinationOutput"
},
"errors": [
{
Expand Down Expand Up @@ -4944,10 +4944,10 @@
"com.amazonaws.dynamodb#EnableKinesisStreamingDestination": {
"type": "operation",
"input": {
"target": "com.amazonaws.dynamodb#KinesisStreamingDestinationInput"
"target": "com.amazonaws.dynamodb#EnableKinesisStreamingDestinationInput"
},
"output": {
"target": "com.amazonaws.dynamodb#KinesisStreamingDestinationOutput"
"target": "com.amazonaws.dynamodb#EnableKinesisStreamingDestinationOutput"
},
"errors": [
{
Expand Down Expand Up @@ -7260,6 +7260,114 @@
}
}
},
"com.amazonaws.dynamodb#DisableKinesisStreamingDestinationInput": {
"type": "structure",
"members": {
"TableName": {
"target": "com.amazonaws.dynamodb#TableArn",
"traits": {
"smithy.api#documentation": "<p>The name of the DynamoDB table. You can also provide the Amazon Resource Name (ARN) of the\n table in this parameter.</p>",
"smithy.api#required": {}
}
},
"StreamArn": {
"target": "com.amazonaws.dynamodb#StreamArn",
"traits": {
"smithy.api#documentation": "<p>The ARN for a Kinesis data stream.</p>",
"smithy.api#required": {}
}
},
"EnableKinesisStreamingConfiguration": {
"target": "com.amazonaws.dynamodb#EnableKinesisStreamingConfiguration",
"traits": {
"smithy.api#documentation": "<p>The source for the Kinesis streaming information that is being enabled.</p>"
}
}
}
},
"com.amazonaws.dynamodb#DisableKinesisStreamingDestinationOutput": {
"type": "structure",
"members": {
"TableName": {
"target": "com.amazonaws.dynamodb#TableName",
"traits": {
"smithy.api#documentation": "<p>The name of the table being modified.</p>"
}
},
"StreamArn": {
"target": "com.amazonaws.dynamodb#StreamArn",
"traits": {
"smithy.api#documentation": "<p>The ARN for the specific Kinesis data stream.</p>"
}
},
"DestinationStatus": {
"target": "com.amazonaws.dynamodb#DestinationStatus",
"traits": {
"smithy.api#documentation": "<p>The current status of the replication.</p>"
}
},
"EnableKinesisStreamingConfiguration": {
"target": "com.amazonaws.dynamodb#EnableKinesisStreamingConfiguration",
"traits": {
"smithy.api#documentation": "<p>The destination for the Kinesis streaming information that is being enabled.</p>"
}
}
}
},
"com.amazonaws.dynamodb#EnableKinesisStreamingDestinationInput": {
"type": "structure",
"members": {
"TableName": {
"target": "com.amazonaws.dynamodb#TableArn",
"traits": {
"smithy.api#documentation": "<p>The name of the DynamoDB table. You can also provide the Amazon Resource Name (ARN) of the\n table in this parameter.</p>",
"smithy.api#required": {}
}
},
"StreamArn": {
"target": "com.amazonaws.dynamodb#StreamArn",
"traits": {
"smithy.api#documentation": "<p>The ARN for a Kinesis data stream.</p>",
"smithy.api#required": {}
}
},
"EnableKinesisStreamingConfiguration": {
"target": "com.amazonaws.dynamodb#EnableKinesisStreamingConfiguration",
"traits": {
"smithy.api#documentation": "<p>The source for the Kinesis streaming information that is being enabled.</p>"
}
}
}
},
"com.amazonaws.dynamodb#EnableKinesisStreamingDestinationOutput": {
"type": "structure",
"members": {
"TableName": {
"target": "com.amazonaws.dynamodb#TableName",
"traits": {
"smithy.api#documentation": "<p>The name of the table being modified.</p>"
}
},
"StreamArn": {
"target": "com.amazonaws.dynamodb#StreamArn",
"traits": {
"smithy.api#documentation": "<p>The ARN for the specific Kinesis data stream.</p>"
}
},
"DestinationStatus": {
"target": "com.amazonaws.dynamodb#DestinationStatus",
"traits": {
"smithy.api#documentation": "<p>The current status of the replication.</p>"
}
},
"EnableKinesisStreamingConfiguration": {
"target": "com.amazonaws.dynamodb#EnableKinesisStreamingConfiguration",
"traits": {
"smithy.api#documentation": "<p>The destination for the Kinesis streaming information that is being enabled.</p>"
}
}
}
},
"com.amazonaws.dynamodb#LastUpdateDateTime": {
"type": "timestamp"
},
Expand Down
20 changes: 20 additions & 0 deletions TestModels/aws-sdks/ddbv2/codegen-patches/dotnet/dafny-4.5.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/TestModels/aws-sdks/ddb/runtimes/net/Generated/TypeConversion.cs b/TestModels/aws-sdks/ddb/runtimes/net/Generated/TypeConversion.cs
index a2b924092..58c542008 100644
--- a/TestModels/aws-sdks/ddb/runtimes/net/Generated/TypeConversion.cs
+++ b/TestModels/aws-sdks/ddb/runtimes/net/Generated/TypeConversion.cs
@@ -213,11 +213,10 @@ namespace Com.Amazonaws.Dynamodb
}
public static Amazon.DynamoDBv2.Model.ConditionalCheckFailedException FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException(software.amazon.cryptography.services.dynamodb.internaldafny.types.Error_ConditionalCheckFailedException value)
{
- return new Amazon.DynamoDBv2.Model.ConditionalCheckFailedException(
- FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException__M7_message(value._message)
- ,
- FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException__M4_Item(value._Item)
- );
+ var conditionalCheckFailedException = new Amazon.DynamoDBv2.Model.ConditionalCheckFailedException(
+ FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException__M7_message(value._message));
+ conditionalCheckFailedException.Item = FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException__M4_Item(value._Item);
+ return conditionalCheckFailedException;
}
public static software.amazon.cryptography.services.dynamodb.internaldafny.types.Error_ConditionalCheckFailedException ToDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException(Amazon.DynamoDBv2.Model.ConditionalCheckFailedException value)
{
20 changes: 20 additions & 0 deletions TestModels/aws-sdks/ddbv2/codegen-patches/dotnet/dafny-4.8.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/TestModels/aws-sdks/ddb/runtimes/net/Generated/TypeConversion.cs b/TestModels/aws-sdks/ddb/runtimes/net/Generated/TypeConversion.cs
index a2b924092..58c542008 100644
--- a/TestModels/aws-sdks/ddb/runtimes/net/Generated/TypeConversion.cs
+++ b/TestModels/aws-sdks/ddb/runtimes/net/Generated/TypeConversion.cs
@@ -213,11 +213,10 @@ namespace Com.Amazonaws.Dynamodb
}
public static Amazon.DynamoDBv2.Model.ConditionalCheckFailedException FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException(software.amazon.cryptography.services.dynamodb.internaldafny.types.Error_ConditionalCheckFailedException value)
{
- return new Amazon.DynamoDBv2.Model.ConditionalCheckFailedException(
- FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException__M7_message(value._message)
- ,
- FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException__M4_Item(value._Item)
- );
+ var conditionalCheckFailedException = new Amazon.DynamoDBv2.Model.ConditionalCheckFailedException(
+ FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException__M7_message(value._message));
+ conditionalCheckFailedException.Item = FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException__M4_Item(value._Item);
+ return conditionalCheckFailedException;
}
public static software.amazon.cryptography.services.dynamodb.internaldafny.types.Error_ConditionalCheckFailedException ToDafny_N3_com__N9_amazonaws__N8_dynamodb__S31_ConditionalCheckFailedException(Amazon.DynamoDBv2.Model.ConditionalCheckFailedException value)
{
94 changes: 94 additions & 0 deletions TestModels/aws-sdks/ddbv2/runtimes/java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import java.io.File
import java.io.FileInputStream
import java.util.Properties
import java.net.URI
import javax.annotation.Nullable

plugins {
`java-library`
`maven-publish`
}

var props = Properties().apply {
load(FileInputStream(File(rootProject.rootDir, "../../project.properties")))
}
var dafnyVersion = props.getProperty("dafnyVersion")

group = "software.amazon.cryptography"
version = "1.0-SNAPSHOT"
description = "ComAmazonawsDynamodb"

var caUrl: URI? = null
@Nullable
val caUrlStr: String? = System.getenv("CODEARTIFACT_URL_JAVA_CONVERSION")
if (!caUrlStr.isNullOrBlank()) {
caUrl = URI.create(caUrlStr)
}

var caPassword: String? = null
@Nullable
val caPasswordString: String? = System.getenv("CODEARTIFACT_AUTH_TOKEN")
if (!caPasswordString.isNullOrBlank()) {
caPassword = caPasswordString
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
sourceSets["main"].java {
srcDir("src/main/java")
srcDir("src/main/dafny-generated")
srcDir("src/main/smithy-generated")
}
sourceSets["test"].java {
srcDir("src/test/dafny-generated")
}
}

repositories {
mavenCentral()
mavenLocal()
if (caUrl != null && caPassword != null) {
maven {
name = "CodeArtifact"
url = caUrl!!
credentials {
username = "aws"
password = caPassword!!
}
}
}
}

dependencies {
implementation("org.dafny:DafnyRuntime:${dafnyVersion}")
implementation("software.amazon.cryptography:StandardLibrary:1.0-SNAPSHOT")
implementation("software.amazon.smithy.dafny:conversion:0.1.1")
implementation(platform("software.amazon.awssdk:bom:2.28.28"))
implementation("software.amazon.awssdk:dynamodb")
}

publishing {
publications.create<MavenPublication>("maven") {
groupId = "software.amazon.cryptography"
artifactId = "ComAmazonawsDynamodb"
from(components["java"])
}
repositories { mavenLocal() }
}

tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
}

tasks.withType<Wrapper>() {
gradleVersion = "7.6"
}

tasks {
register("runTests", JavaExec::class.java) {
mainClass.set("TestsFromDafny")
classpath = sourceSets["test"].runtimeClasspath
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package software.amazon.cryptography.services.dynamodb.internaldafny;

import static software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence;
import static software.amazon.smithy.dafny.conversion.ToNative.Simple.String;

import StandardLibraryInterop_Compile.WrappersInterop;
import Wrappers_Compile.Option;
import Wrappers_Compile.Result;
import dafny.DafnySequence;
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.cryptography.services.dynamodb.internaldafny.types.Error;
import software.amazon.cryptography.services.dynamodb.internaldafny.types.IDynamoDBClient;

public class __default
extends software.amazon.cryptography.services.dynamodb.internaldafny._ExternBase___default {

public static Result<IDynamoDBClient, Error> DynamoDBClient() {
try {
Region region = new DefaultAwsRegionProviderChain().getRegion();
final DynamoDbClient ddbClient = DynamoDbClient
.builder()
.region(region)
.build();

IDynamoDBClient shim = new Shim(ddbClient, region.toString());
return CreateSuccessOfClient(shim);
} catch (Exception e) {
Error dafny_error = Error.create_InternalServerError(
WrappersInterop.CreateStringSome(CharacterSequence(e.getMessage()))
);
return CreateFailureOfError(dafny_error);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package software.amazon.cryptography.services.dynamodb.internaldafny.types;

public class __default
extends software.amazon.cryptography.services.dynamodb.internaldafny.types._ExternBase___default {}
29 changes: 29 additions & 0 deletions TestModels/aws-sdks/ddbv2/runtimes/net/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
###############################
# Core EditorConfig Options #
# See https://github.com/dotnet/format/blob/main/docs/Supported-.editorconfig-options.md
###############################
root = true
# All files
[*]
indent_style = space

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2

# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 2
insert_final_newline = true

# Rider is wrong, dotnet_diagnostic is supported
# noinspection EditorConfigKeyCorrectness
[*.{cs,vb}]
dotnet_diagnostic.CS0436.severity = none # The type <> ... conflicts with the imported type <> in ...
dotnet_diagnostic.CS0162.severity = none # Unreachable code detected
dotnet_diagnostic.CS0618.severity = none # obsolete
dotnet_diagnostic.CS0168.severity = none # Unused variable
34 changes: 34 additions & 0 deletions TestModels/aws-sdks/ddbv2/runtimes/net/DDBv2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RootNamespace>DDBv2</RootNamespace>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<TargetFrameworks>net6.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DafnyRuntime" Version="4.8.1" />
<PackageReference Include="AWSSDK.Core" Version="3.7.400.38" />
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.402.2" />
<PackageReference Include="ObjectDumper.NET" Version="3.5.6" />
<!--
System.Collections.Immutable can be removed once dafny.msbuild is updated with
https://github.com/dafny-lang/dafny.msbuild/pull/10 and versioned
-->
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
<!-- Work around for dafny-lang/dafny/issues/1951; remove once resolved -->
<PackageReference Include="System.ValueTuple" Version="4.5.0" />

<Compile Include="Extern/**/*.cs" />
<Compile Include="Generated/**/*.cs" />
<Compile Include="ImplementationFromDafny.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../../../dafny-dependencies/StandardLibrary/runtimes/net/STD.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 5a5a5cc

Please sign in to comment.