From a75f113dc4711c6e2bb67f8b126bca692300ea56 Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Mon, 25 Jul 2022 13:29:17 -0700 Subject: [PATCH 1/2] Add client creation example to SDK crate READMEs --- .../smithy/rustsdk/AwsReadmeDecorator.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt index 858fe5f35f9..d146633194b 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsReadmeDecorator.kt @@ -42,6 +42,8 @@ class AwsReadmeDecorator : RustCodegenDecorator { codegenContext.settings.getService(codegenContext.model).getTrait()?.value ?: "" ) val moduleName = codegenContext.settings.moduleName + val snakeCaseModuleName = moduleName.replace('-', '_') + val shortModuleName = moduleName.removePrefix("aws-sdk-") writer.raw( """ @@ -68,6 +70,25 @@ class AwsReadmeDecorator : RustCodegenDecorator { tokio = { version = "1", features = ["full"] } ``` + Then in code, a client can be created with the following: + + ```rust + use $snakeCaseModuleName as $shortModuleName; + + #[tokio::main] + async fn main() -> Result<(), $shortModuleName::Error> { + let config = aws_config::load_from_env().await; + let client = $shortModuleName::Client::new(&config); + + // ... make some calls with the client + + Ok(()) + } + ``` + + See the [client documentation](https://docs.rs/$moduleName/latest/$snakeCaseModuleName/client/struct.Client.html) + for information on what calls can be made, and the inputs and outputs for each of those calls. + ## Using the SDK Until the SDK is released, we will be adding information about using the SDK to the From a4ee99d6c20d0c2a8598bdb5febbe1950c3f1188 Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Mon, 25 Jul 2022 13:32:32 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.next.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 5df921107a5..a643a6b7951 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -142,3 +142,9 @@ An example from the SDK is in [transcribe streaming](https://github.com/awslabs/ references = ["smithy-rs#1157"] meta = { "breaking" = true, "tada" = false, "bug" = false } author = "82marbag" + +[[aws-sdk-rust]] +message = "SDK crate READMEs now include an example of creating a client" +references = ["smithy-rs#1571", "smithy-rs#1385"] +meta = { "breaking" = false, "tada" = true, "bug" = false } +author = "jdisanti"