

There are more AWS SDK examples available in the [AWS Doc SDK Examples](https://github.com/awsdocs/aws-doc-sdk-examples) GitHub repo.

# Code examples for Amazon Cognito Sync using AWS SDKs
<a name="cognito-sync_code_examples"></a>

The following code examples show you how to use Amazon Cognito Sync with an AWS software development kit (SDK).

*Actions* are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

**More resources**
+  **[ Amazon Cognito Sync Developer Guide](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-sync.html)** – More information about Amazon Cognito Sync.
+ **[Amazon Cognito Sync API Reference](https://docs.aws.amazon.com/cognitosync/latest/APIReference/Welcome.html)** – Details about all available Amazon Cognito Sync actions.
+ **[AWS Developer Center](https://aws.amazon.com/developer/code-examples/?awsf.sdk-code-examples-product=product%23cognito)** – Code examples that you can filter by category or full-text search.
+ **[AWS SDK Examples](https://github.com/awsdocs/aws-doc-sdk-examples)** – GitHub repo with complete code in preferred languages. Includes instructions for setting up and running the code.

**Contents**
+ [Basics](cognito-sync_code_examples_basics.md)
  + [Actions](cognito-sync_code_examples_actions.md)
    + [`ListIdentityPoolUsage`](cognito-sync_example_cognito-sync_ListIdentityPoolUsage_section.md)

# Basic examples for Amazon Cognito Sync using AWS SDKs
<a name="cognito-sync_code_examples_basics"></a>

The following code examples show how to use the basics of Amazon Cognito Sync with AWS SDKs. 

**Contents**
+ [Actions](cognito-sync_code_examples_actions.md)
  + [`ListIdentityPoolUsage`](cognito-sync_example_cognito-sync_ListIdentityPoolUsage_section.md)

# Actions for Amazon Cognito Sync using AWS SDKs
<a name="cognito-sync_code_examples_actions"></a>

The following code examples demonstrate how to perform individual Amazon Cognito Sync actions with AWS SDKs. Each example includes a link to GitHub, where you can find instructions for setting up and running the code. 

 The following examples include only the most commonly used actions. For a complete list, see the [Amazon Cognito Sync API Reference](https://docs.aws.amazon.com/cognitosync/latest/APIReference/Welcome.html). 

**Topics**
+ [`ListIdentityPoolUsage`](cognito-sync_example_cognito-sync_ListIdentityPoolUsage_section.md)

# Use `ListIdentityPoolUsage` with an AWS SDK
<a name="cognito-sync_example_cognito-sync_ListIdentityPoolUsage_section"></a>

The following code example shows how to use `ListIdentityPoolUsage`.

------
#### [ Rust ]

**SDK for Rust**  
 There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/rustv1/examples/cognitosync#code-examples). 

```
async fn show_pools(client: &Client) -> Result<(), Error> {
    let response = client
        .list_identity_pool_usage()
        .max_results(10)
        .send()
        .await?;

    let pools = response.identity_pool_usages();
    println!("Identity pools:");

    for pool in pools {
        println!(
            "  Identity pool ID:    {}",
            pool.identity_pool_id().unwrap_or_default()
        );
        println!(
            "  Data storage:        {}",
            pool.data_storage().unwrap_or_default()
        );
        println!(
            "  Sync sessions count: {}",
            pool.sync_sessions_count().unwrap_or_default()
        );
        println!(
            "  Last modified:       {}",
            pool.last_modified_date().unwrap().to_chrono_utc()?
        );
        println!();
    }

    println!("Next token: {}", response.next_token().unwrap_or_default());

    Ok(())
}
```
+  For API details, see [ListIdentityPoolUsage](https://docs.rs/aws-sdk-cognitosync/latest/aws_sdk_cognitosync/client/struct.Client.html#method.list_identity_pool_usage) in *AWS SDK for Rust API reference*. 

------