-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[autosync] Fix developer guide URL (#1262)
* Update README.md to fix invalid Developer Guide URL The old guide: https://github.com/awslabs/aws-sdk-rust/blob/main/Guide.md has been deleted and changed to: https://docs.aws.amazon.com/sdk-for-rust/latest/dg/welcome.html See: #325 Signed-off-by: bin liu <[email protected]> * Update invalid Developer Guide URL in AwsReadmeDecorator.kt The old guide: https://github.com/awslabs/aws-sdk-rust/blob/main/Guide.md has been deleted and changed to: https://docs.aws.amazon.com/sdk-for-rust/latest/dg/welcome.html See: #325 Signed-off-by: bin liu <[email protected]> * Add fixing Developer Guide link to CHANGELOG.next.toml Signed-off-by: bin liu <[email protected]> Co-authored-by: Russell Cohen <[email protected]>
- Loading branch information
1 parent
5394207
commit 6de1bf6
Showing
303 changed files
with
526 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
75056c6a780529692e1b44e18402352205f9e1f6 | ||
622712058f0f7fcfd7383dc12289e64afba68e39 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. | ||
[package] | ||
name = "sitewise-code-examples" | ||
version = "0.1.0" | ||
authors = ["Lawrence Xiao <[email protected]>"] | ||
edition = "2021" | ||
publish = false | ||
[dependencies.aws-config] | ||
path = "../../sdk/aws-config" | ||
version = "0.9.0" | ||
|
||
[dependencies.aws-sdk-iotsitewise] | ||
path = "../../sdk/iotsitewise" | ||
version = "0.9.0" | ||
|
||
[dependencies.aws-smithy-types-convert] | ||
features = ["convert-chrono"] | ||
path = "../../sdk/aws-smithy-types-convert" | ||
version = "0.39.0" | ||
|
||
[dependencies.tokio] | ||
version = "1" | ||
features = ["full"] | ||
|
||
[dependencies.structopt] | ||
version = "0.3" | ||
default-features = false | ||
|
||
[dependencies.tracing-subscriber] | ||
version = "0.3.5" | ||
features = ["env-filter"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# AWS SDK for Rust code examples for AWS IoT SiteWise | ||
|
||
## Purpose | ||
|
||
These examples demonstrate how to perform several AWS IoT SiteWise operations using the developer preview version of the AWS SDK for Rust. | ||
|
||
AWS IoT SiteWise is a managed service that simplifies collecting, organizing, and analyzing industrial equipment data. | ||
|
||
## Code examples | ||
|
||
- [List assets](src/bin/list-assets.rs) (ListAssets) | ||
|
||
## ⚠ Important | ||
|
||
- Running this code might result in charges to your AWS account. | ||
- We recommend that you grant this code least privilege, | ||
or at most the minimum permissions required to perform the task. | ||
For more information, see | ||
[Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege) | ||
in the AWS Identity and Access Management User Guide. | ||
- This code has not been tested in all AWS Regions. | ||
Some AWS services are available only in specific | ||
[Regions](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). | ||
|
||
## Running the code examples | ||
|
||
### Prerequisites | ||
|
||
You must have an AWS account with your default credentials and AWS Region configured as described in [https://github.com/awslabs/aws-sdk-rust](https://github.com/awslabs/aws-sdk-rust). | ||
|
||
### list-assets.rs | ||
|
||
This example lists AWS IoT SiteWise assets in the Region. | ||
|
||
`cargo run --bin list-assets -- -f FILTER [-a ASSET-MODEL-ID] [-r REGION] [-v]` | ||
|
||
- _FILTER_ is the type of filter. It must be one of the following: | ||
- ALL - The list includes all assets for a given asset model ID. The _ASSET-MODEL-ID_ parameter is required if you filter by ALL. | ||
- TOP_LEVEL - The list includes only top-level assets in the asset hierarchy tree. | ||
- _ASSET-MODEL-ID_ The ID of the asset model by which to filter the list of assets. This parameter is required if you choose ALL for _FILTER_. | ||
- _REGION_ The Region in which the client is created. | ||
If not supplied, uses the value of the __AWS_REGION__ environment variable. | ||
If the environment variable is not set, defaults to __us-west-2__. | ||
- __-v__ displays additional information. | ||
|
||
If the example succeeds, it displays the Amazon Resource Name (ARN) of the new role. | ||
|
||
## Resources | ||
|
||
- [AWS SDK for Rust repo](https://github.com/awslabs/aws-sdk-rust) | ||
- - [AWS SDK for Rust API Reference for AWS IoT SiteWise](https://docs.rs/aws-sdk-iotsitewise) | ||
- [AWS SDK for Rust API Reference Guide](https://awslabs.github.io/aws-sdk-rust/aws_sdk_config/index.html) | ||
|
||
## Contributing | ||
|
||
To propose a new code example to the AWS documentation team, | ||
see [CONTRIBUTING.md](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/CONTRIBUTING.md). | ||
The team prefers to create code examples that show broad scenarios rather than individual API calls. | ||
|
||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
use aws_config::meta::region::RegionProviderChain; | ||
use aws_sdk_iotsitewise::{model::ListAssetsFilter, Client, Error, Region, PKG_VERSION}; | ||
use aws_smithy_types_convert::date_time::DateTimeExt; | ||
use structopt::StructOpt; | ||
|
||
#[derive(Debug, StructOpt)] | ||
struct Opt { | ||
/// The AWS Region. | ||
#[structopt(short, long)] | ||
region: Option<String>, | ||
|
||
/// The asset model id. | ||
#[structopt(short, long)] | ||
asset_model_id: Option<String>, | ||
|
||
/// The filter. | ||
#[structopt(short, long)] | ||
filter: String, | ||
|
||
/// Whether to display additional information. | ||
#[structopt(short, long)] | ||
verbose: bool, | ||
} | ||
|
||
// List the assets under AWS IoT SiteWise. | ||
// snippet-start:[sitewise.rust.list-assets] | ||
async fn list_assets( | ||
client: &Client, | ||
filter: ListAssetsFilter, | ||
asset_model_id: Option<String>, | ||
) -> Result<(), Error> { | ||
let resp = client | ||
.list_assets() | ||
.filter(filter) | ||
.set_asset_model_id(asset_model_id) | ||
.send() | ||
.await?; | ||
|
||
println!("Assets:"); | ||
|
||
for asset in resp.asset_summaries.unwrap() { | ||
println!(" ID: {}", asset.id.as_deref().unwrap_or_default()); | ||
println!(" ARN: {}", asset.arn.as_deref().unwrap_or_default()); | ||
println!(" Name: {}", asset.name.as_deref().unwrap_or_default()); | ||
println!( | ||
" Asset Model ID: {}", | ||
asset.asset_model_id.as_deref().unwrap_or_default() | ||
); | ||
println!( | ||
" Creation Date: {}", | ||
asset.creation_date.unwrap().to_chrono_utc() | ||
); | ||
println!( | ||
" Last Update Date: {}", | ||
asset.last_update_date.unwrap().to_chrono_utc() | ||
); | ||
println!( | ||
" Current Status: {}", | ||
asset.status.unwrap().state.unwrap().as_str() | ||
); | ||
|
||
println!(" Assets Hierarchies:"); | ||
|
||
for hierarchy in asset.hierarchies.unwrap() { | ||
println!( | ||
" Hierarchy ID: {}", | ||
hierarchy.id.as_deref().unwrap_or_default() | ||
); | ||
println!( | ||
" Hierarchy Name: {}", | ||
hierarchy.name.as_deref().unwrap_or_default() | ||
); | ||
} | ||
|
||
println!(); | ||
} | ||
|
||
println!(); | ||
|
||
Ok(()) | ||
} | ||
// snippet-end:[sitewise.rust.list-assets] | ||
|
||
/// Lists the ID, Amazon Resource Name (ARN), name, asset_model_id, creation_date, last_update_data, | ||
/// status, and hierarchies of your AWS IoT SiteWise assets in the Region. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `-f FILTER` - The type of filter. | ||
/// Must be one of the following: | ||
/// - ALL - The list includes all assets for a given asset model ID. The assetModelId parameter | ||
/// is required if you filter by ALL. | ||
/// - TOP_LEVEL - The list includes only top-level assets in the asset hierarchy tree. | ||
/// * `[-a ASSET-MODEL-ID]` - The ID of the asset model by which to filter the list of assets. | ||
/// This parameter is required if you choose ALL for filter. | ||
/// * `[-r REGION]` - The Region in which the client is created. | ||
/// If not supplied, uses the value of the **AWS_REGION** environment variable. | ||
/// If the environment variable is not set, defaults to **us-west-2**. | ||
/// * `[-v]` - Whether to display information. | ||
#[tokio::main] | ||
async fn main() -> Result<(), Error> { | ||
tracing_subscriber::fmt::init(); | ||
let Opt { | ||
region, | ||
asset_model_id, | ||
filter, | ||
verbose, | ||
} = Opt::from_args(); | ||
|
||
let region_provider = RegionProviderChain::first_try(region.map(Region::new)) | ||
.or_default_provider() | ||
.or_else(Region::new("us-west-2")); | ||
println!(); | ||
|
||
if verbose { | ||
println!("IoT client version: {}", PKG_VERSION); | ||
println!( | ||
"Region: {}", | ||
region_provider.region().await.unwrap().as_ref() | ||
); | ||
println!("Filter: {}", &filter); | ||
println!(); | ||
} | ||
|
||
let shared_config = aws_config::from_env().region(region_provider).load().await; | ||
let client = Client::new(&shared_config); | ||
let filter: ListAssetsFilter = ListAssetsFilter::from(filter.as_str()); | ||
|
||
list_assets(&client, filter, asset_model_id).await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.