From 4d6c0500cb76135b24d3a6a16510a562bea1b88b Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Mon, 10 Apr 2023 18:41:40 +0200 Subject: [PATCH] first build of the model --- build.gradle.kts | 30 +++++++++++++++ idl/k2v.smithy | 53 -------------------------- model/k2v.smithy | 96 +++++++++++++++++++++++++++++++++++++++++++++++ smithy-build.json | 8 ++++ 4 files changed, 134 insertions(+), 53 deletions(-) create mode 100644 build.gradle.kts delete mode 100644 idl/k2v.smithy create mode 100644 model/k2v.smithy create mode 100644 smithy-build.json diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..17d61b48 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,30 @@ +plugins { + id("software.amazon.smithy").version("0.6.0") +} + +buildscript { + dependencies { + + // This dependency is required in order to apply the "openapi" + // plugin in smithy-build.json + classpath("software.amazon.smithy:smithy-openapi:1.29.0") + } +} + +repositories { + mavenLocal() + mavenCentral() +} + +dependencies { + implementation("software.amazon.smithy:smithy-model:1.29.0") + implementation("software.amazon.smithy:smithy-aws-traits:1.29.0") +} + +configure { + // Uncomment this to use a custom projection when building the JAR. + // projection = "foo" +} + +// Uncomment to disable creating a JAR. +//tasks["jar"].enabled = false diff --git a/idl/k2v.smithy b/idl/k2v.smithy deleted file mode 100644 index 62eb106b..00000000 --- a/idl/k2v.smithy +++ /dev/null @@ -1,53 +0,0 @@ -$version: "2" -namespace org.deuxfleurs.garage.k2v - -service Item { - version: "2023-04-10" - resources: [ Item ] - operations: [ PollItem ] -} - -resource Item { - read: ReadItem - put: InsertItem - delete: DeleteItem - list: ReadIndex -} - -operation ReadItem { - input: ReadItemInput - output: ReadItemOutput -} - -@input -structure ReadItemInput { - bucket: String - partitionKey: String - sortKey: String -} - -@output -union ReadItemOutput { - list: ReadItemOutputList - raw: blob -} - -@sparse -list ReadItemOutputList { - member: String -} - -operation PollItem { - input: - output: -} - -operation InsertItem { - input: - output: -} - -operation DeleteItem { - input: - output: -} diff --git a/model/k2v.smithy b/model/k2v.smithy new file mode 100644 index 00000000..bf51f25b --- /dev/null +++ b/model/k2v.smithy @@ -0,0 +1,96 @@ +$version: "2" +namespace org.deuxfleurs.garage.k2v + +use aws.api#service +use aws.auth#sigv4 +use aws.protocols#restJson1 + +@service(sdkId: "k2v") +@sigv4(name: "k2v") +@restJson1 +service K2V { + version: "2023-04-10" + resources: [ Item ] + //operations: [ PollItem, ReadIndex, InsertBatch, DeleteBatch, PollRange ] +} + +resource Item { + read: ReadItem + put: InsertItem + //delete: DeleteItem + //list: ReadBatch +} + +@mixin +structure KeySelector { + @required + @httpLabel + bucketName: String + + @required + @httpLabel + partitionKey: String + + @required + @httpQuery("sort_key") + sortKey: String +} + +@readonly +@http(method: "GET", uri: "/{bucketName}/{partitionKey}", code: 200) +operation ReadItem { + input: ReadItemInput + output: ReadItemOutput +} + +@input +structure ReadItemInput with [KeySelector] {} + +@output +structure ReadItemOutput { + value: ItemList +} + +@sparse +list ItemList { + member: Blob +} + +@idempotent +@http(method: "PUT", uri: "/{bucketName}/{partitionKey}", code: 204) +operation InsertItem { + input: InsertItemInput +} + +@input +structure InsertItemInput with [KeySelector] {} + +//operation DeleteItem { +// input: String +// output: String +//} + +//operation PollItem { +// input: String +// output: String +//} + +//operation ReadIndex { +// input: String +// output: String +//} + +//operation InsertBatch { +// input: String +// output: String +//} + +//operation DeleteBatch { +// input: String +// output: String +//} + +//operation PollRange { +// input: String +// output: String +//} diff --git a/smithy-build.json b/smithy-build.json new file mode 100644 index 00000000..29de8a18 --- /dev/null +++ b/smithy-build.json @@ -0,0 +1,8 @@ +{ + "version": "1.0", + "plugins": { + "openapi": { + "service": "org.deuxfleurs.garage.k2v#K2V" + } + } +}