Skip to content

Commit

Permalink
Add client creation example to SDK crate READMEs (#1571)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdisanti authored Jul 25, 2022
1 parent 24f0749 commit 7d2a659
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand All @@ -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
Expand Down

0 comments on commit 7d2a659

Please sign in to comment.