Skip to content

Commit

Permalink
chore: kms-lite Rust beneration (#473)
Browse files Browse the repository at this point in the history
Issue #, if available:
#413

Description of changes:
Fills MOST of the code generation target for kms-lite. Even with the operations trimmed down to only those used by the MPL, this is still a ton of boilerplate, so I mostly only implemented the operations that are actually tested (Encrypt, Decrypt, and GenerateDataKey). I may at least partially implement the beginnings of codegen to come back and fill in the rest as well as tackle #477.
  • Loading branch information
robin-aws authored Jul 16, 2024
1 parent 473d095 commit 1c23ec6
Show file tree
Hide file tree
Showing 47 changed files with 2,770 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_models_rust_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.74.1"
toolchain: "1.76.0"
rustflags: ""
components: rustfmt

Expand Down
36 changes: 18 additions & 18 deletions TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ index 00000000..ba2a8a6e
+pub mod builders;
diff --git b/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_input.rs a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_input.rs
new file mode 100644
index 00000000..1fb85690
index 00000000..58c53177
--- /dev/null
+++ a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_input.rs
@@ -0,0 +1,157 @@
Expand All @@ -684,7 +684,7 @@ index 00000000..1fb85690
+#[non_exhaustive]
+#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
+pub struct GetResourceDataInput {
+ pub(crate) blob_value: Option<Vec<u8>>,
+ pub(crate) blob_value: Option<aws_smithy_types::Blob>,
+ pub(crate) boolean_value: Option<bool>,
+ pub(crate) string_value: Option<String>,
+ pub(crate) integer_value: Option<i32>,
Expand All @@ -693,7 +693,7 @@ index 00000000..1fb85690
+
+impl GetResourceDataInput {
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn blob_value(&self) -> &Option<Vec<u8>> {
+ pub fn blob_value(&self) -> &Option<aws_smithy_types::Blob> {
+ &self.blob_value
+ }
+ #[allow(missing_docs)] // documentation missing in model
Expand Down Expand Up @@ -727,7 +727,7 @@ index 00000000..1fb85690
+ ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug,
+)]
+pub struct GetResourceDataInputBuilder {
+ blob_value: Option<Vec<u8>>,
+ blob_value: Option<aws_smithy_types::Blob>,
+ boolean_value: Option<bool>,
+ string_value: Option<String>,
+ integer_value: Option<i32>,
Expand All @@ -736,19 +736,19 @@ index 00000000..1fb85690
+
+impl GetResourceDataInputBuilder {
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn blob_value(mut self, input: Vec<u8>) -> Self {
+ pub fn blob_value(mut self, input: aws_smithy_types::Blob) -> Self {
+ self.blob_value = Some(input);
+ self
+ }
+
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn set_blob_value(mut self, input: Option<Vec<u8>>) -> Self {
+ pub fn set_blob_value(mut self, input: Option<aws_smithy_types::Blob>) -> Self {
+ self.blob_value = input;
+ self
+ }
+
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn get_blob_value(&self) -> &Option<Vec<u8>> {
+ pub fn get_blob_value(&self) -> &Option<aws_smithy_types::Blob> {
+ &self.blob_value
+ }
+
Expand Down Expand Up @@ -838,7 +838,7 @@ index 00000000..1fb85690
+}
diff --git b/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_output.rs a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_output.rs
new file mode 100644
index 00000000..d9f1b9f4
index 00000000..1814e59f
--- /dev/null
+++ a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/_get_resource_data_output.rs
@@ -0,0 +1,158 @@
Expand All @@ -847,7 +847,7 @@ index 00000000..d9f1b9f4
+#[non_exhaustive]
+#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
+pub struct GetResourceDataOutput {
+ pub(crate) blob_value: Option<Vec<u8>>,
+ pub(crate) blob_value: Option<aws_smithy_types::Blob>,
+ pub(crate) boolean_value: Option<bool>,
+ pub(crate) string_value: Option<String>,
+ pub(crate) integer_value: Option<i32>,
Expand All @@ -856,7 +856,7 @@ index 00000000..d9f1b9f4
+
+impl GetResourceDataOutput {
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn blob_value(&self) -> &Option<Vec<u8>> {
+ pub fn blob_value(&self) -> &Option<aws_smithy_types::Blob> {
+ &self.blob_value
+ }
+ #[allow(missing_docs)] // documentation missing in model
Expand Down Expand Up @@ -891,7 +891,7 @@ index 00000000..d9f1b9f4
+ ::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug,
+)]
+pub struct GetResourceDataOutputBuilder {
+ blob_value: Option<Vec<u8>>,
+ blob_value: Option<aws_smithy_types::Blob>,
+ boolean_value: Option<bool>,
+ string_value: Option<String>,
+ integer_value: Option<i32>,
Expand All @@ -900,19 +900,19 @@ index 00000000..d9f1b9f4
+
+impl GetResourceDataOutputBuilder {
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn blob_value(mut self, input: Vec<u8>) -> Self {
+ pub fn blob_value(mut self, input: aws_smithy_types::Blob) -> Self {
+ self.blob_value = Some(input);
+ self
+ }
+
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn set_blob_value(mut self, input: Option<Vec<u8>>) -> Self {
+ pub fn set_blob_value(mut self, input: Option<aws_smithy_types::Blob>) -> Self {
+ self.blob_value = input;
+ self
+ }
+
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn get_blob_value(&self) -> &Option<Vec<u8>> {
+ pub fn get_blob_value(&self) -> &Option<aws_smithy_types::Blob> {
+ &self.blob_value
+ }
+
Expand Down Expand Up @@ -1002,7 +1002,7 @@ index 00000000..d9f1b9f4
+}
diff --git b/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/builders.rs a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/builders.rs
new file mode 100644
index 00000000..94c5d853
index 00000000..9c1c4890
--- /dev/null
+++ a/TestModels/Resource/runtimes/rust/src/operation/get_resource_data/builders.rs
@@ -0,0 +1,148 @@
Expand Down Expand Up @@ -1070,19 +1070,19 @@ index 00000000..94c5d853
+ }
+
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn blob_value(mut self, input: impl ::std::convert::Into<Vec<u8>>) -> Self {
+ pub fn blob_value(mut self, input: impl ::std::convert::Into<aws_smithy_types::Blob>) -> Self {
+ self.inner = self.inner.blob_value(input.into());
+ self
+ }
+
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn set_blob_value(mut self, input: Option<Vec<u8>>) -> Self {
+ pub fn set_blob_value(mut self, input: Option<aws_smithy_types::Blob>) -> Self {
+ self.inner = self.inner.set_blob_value(input);
+ self
+ }
+
+ #[allow(missing_docs)] // documentation missing in model
+ pub fn get_blob_value(&self) -> &Option<Vec<u8>> {
+ pub fn get_blob_value(&self) -> &Option<aws_smithy_types::Blob> {
+ self.inner.get_blob_value()
+ }
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct GetResourceDataInput {
pub(crate) blob_value: Option<Vec<u8>>,
pub(crate) blob_value: Option<aws_smithy_types::Blob>,
pub(crate) boolean_value: Option<bool>,
pub(crate) string_value: Option<String>,
pub(crate) integer_value: Option<i32>,
Expand All @@ -12,7 +12,7 @@ pub struct GetResourceDataInput {

impl GetResourceDataInput {
#[allow(missing_docs)] // documentation missing in model
pub fn blob_value(&self) -> &Option<Vec<u8>> {
pub fn blob_value(&self) -> &Option<aws_smithy_types::Blob> {
&self.blob_value
}
#[allow(missing_docs)] // documentation missing in model
Expand Down Expand Up @@ -46,7 +46,7 @@ impl GetResourceDataInput {
::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug,
)]
pub struct GetResourceDataInputBuilder {
blob_value: Option<Vec<u8>>,
blob_value: Option<aws_smithy_types::Blob>,
boolean_value: Option<bool>,
string_value: Option<String>,
integer_value: Option<i32>,
Expand All @@ -55,19 +55,19 @@ pub struct GetResourceDataInputBuilder {

impl GetResourceDataInputBuilder {
#[allow(missing_docs)] // documentation missing in model
pub fn blob_value(mut self, input: Vec<u8>) -> Self {
pub fn blob_value(mut self, input: aws_smithy_types::Blob) -> Self {
self.blob_value = Some(input);
self
}

#[allow(missing_docs)] // documentation missing in model
pub fn set_blob_value(mut self, input: Option<Vec<u8>>) -> Self {
pub fn set_blob_value(mut self, input: Option<aws_smithy_types::Blob>) -> Self {
self.blob_value = input;
self
}

#[allow(missing_docs)] // documentation missing in model
pub fn get_blob_value(&self) -> &Option<Vec<u8>> {
pub fn get_blob_value(&self) -> &Option<aws_smithy_types::Blob> {
&self.blob_value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct GetResourceDataOutput {
pub(crate) blob_value: Option<Vec<u8>>,
pub(crate) blob_value: Option<aws_smithy_types::Blob>,
pub(crate) boolean_value: Option<bool>,
pub(crate) string_value: Option<String>,
pub(crate) integer_value: Option<i32>,
Expand All @@ -12,7 +12,7 @@ pub struct GetResourceDataOutput {

impl GetResourceDataOutput {
#[allow(missing_docs)] // documentation missing in model
pub fn blob_value(&self) -> &Option<Vec<u8>> {
pub fn blob_value(&self) -> &Option<aws_smithy_types::Blob> {
&self.blob_value
}
#[allow(missing_docs)] // documentation missing in model
Expand Down Expand Up @@ -47,7 +47,7 @@ impl GetResourceDataOutput {
::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug,
)]
pub struct GetResourceDataOutputBuilder {
blob_value: Option<Vec<u8>>,
blob_value: Option<aws_smithy_types::Blob>,
boolean_value: Option<bool>,
string_value: Option<String>,
integer_value: Option<i32>,
Expand All @@ -56,19 +56,19 @@ pub struct GetResourceDataOutputBuilder {

impl GetResourceDataOutputBuilder {
#[allow(missing_docs)] // documentation missing in model
pub fn blob_value(mut self, input: Vec<u8>) -> Self {
pub fn blob_value(mut self, input: aws_smithy_types::Blob) -> Self {
self.blob_value = Some(input);
self
}

#[allow(missing_docs)] // documentation missing in model
pub fn set_blob_value(mut self, input: Option<Vec<u8>>) -> Self {
pub fn set_blob_value(mut self, input: Option<aws_smithy_types::Blob>) -> Self {
self.blob_value = input;
self
}

#[allow(missing_docs)] // documentation missing in model
pub fn get_blob_value(&self) -> &Option<Vec<u8>> {
pub fn get_blob_value(&self) -> &Option<aws_smithy_types::Blob> {
&self.blob_value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ impl GetResourceDataFluentBuilder {
}

#[allow(missing_docs)] // documentation missing in model
pub fn blob_value(mut self, input: impl ::std::convert::Into<Vec<u8>>) -> Self {
pub fn blob_value(mut self, input: impl ::std::convert::Into<aws_smithy_types::Blob>) -> Self {
self.inner = self.inner.blob_value(input.into());
self
}

#[allow(missing_docs)] // documentation missing in model
pub fn set_blob_value(mut self, input: Option<Vec<u8>>) -> Self {
pub fn set_blob_value(mut self, input: Option<aws_smithy_types::Blob>) -> Self {
self.inner = self.inner.set_blob_value(input);
self
}

#[allow(missing_docs)] // documentation missing in model
pub fn get_blob_value(&self) -> &Option<Vec<u8>> {
pub fn get_blob_value(&self) -> &Option<aws_smithy_types::Blob> {
self.inner.get_blob_value()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn checkMostNone(name: String, output: GetResourceDataOutput) {

pub fn allSome() -> GetResourceDataInput {
GetResourceDataInput::builder()
.blob_value(vec![1u8])
.blob_value(aws_smithy_types::Blob::new(vec![1u8]))
.boolean_value(true)
.string_value("Some".to_string())
.integer_value(1)
Expand All @@ -68,7 +68,7 @@ pub fn allSome() -> GetResourceDataInput {

pub fn checkSome(name: String, output: GetResourceDataOutput) {
assert_eq!(Some(name + " Some"), *output.string_value());
assert_eq!(Some(vec![1u8]), *output.blob_value());
assert_eq!(Some(aws_smithy_types::Blob::new(vec![1u8])), *output.blob_value());
assert_eq!(Some(true), output.boolean_value());
assert_eq!(Some(1), output.integer_value());
assert_eq!(Some(1), output.long_value());
Expand Down
5 changes: 3 additions & 2 deletions TestModels/aws-sdks/kms-lite/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include ../../SharedMakefile.mk
NAMESPACE=com.amazonaws.kms

PROJECT_SERVICES := \
ComAmazonawsKms\
ComAmazonawsKms

SERVICE_NAMESPACE_ComAmazonawsKms=com.amazonaws.kms

Expand All @@ -18,6 +18,8 @@ SMITHY_DEPS=dafny-dependencies/Model/traits.smithy

AWS_SDK_CMD=--aws-sdk

SMITHY_MODEL_ROOT := $(LIBRARY_ROOT)/model

# This project has no dependencies
# DEPENDENT-MODELS:=

Expand All @@ -32,7 +34,6 @@ _polymorph_java:
$(GRADLEW) polymorphJava

# There is no wrapped target for aws-sdk types
_polymorph: ;
_polymorph_wrapped: ;
_polymorph_wrapped_dafny: ;
_polymorph_wrapped_net: ;
Expand Down
Loading

0 comments on commit 1c23ec6

Please sign in to comment.