Unverified Commit 7d2a6595 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Add client creation example to SDK crate READMEs (#1571)

parent 24f0749e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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"
+21 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ class AwsReadmeDecorator : RustCodegenDecorator<ClientCodegenContext> {
                codegenContext.settings.getService(codegenContext.model).getTrait<DocumentationTrait>()?.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<ClientCodegenContext> {
                    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