Doc AWS SDK Examples リポジトリには、他にも SDK の例があります。 AWS
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
AWS SDK を使用して Amazon Cognito ユーザープールを一覧表示する
以下のコード例は、Amazon Cognito ユーザープールを一覧表示する方法を示しています。
- .NET
-
- AWS SDK for .NET
-
注記
には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリ
での設定と実行の方法を確認してください。 /// <summary> /// List the Amazon Cognito user pools for an account. /// </summary> /// <returns>A list of UserPoolDescriptionType objects.</returns> public async Task<List<UserPoolDescriptionType>> ListUserPoolsAsync() { var userPools = new List<UserPoolDescriptionType>(); var userPoolsPaginator = _cognitoService.Paginators.ListUserPools(new ListUserPoolsRequest()); await foreach (var response in userPoolsPaginator.Responses) { userPools.AddRange(response.UserPools); } return userPools; }
-
API の詳細については、「 API リファレンスListUserPools」の「」を参照してください。 AWS SDK for .NET
-
- CLI
-
- AWS CLI
-
ユーザープールを一覧表示するには
次の例では、最大 20 のユーザープールを一覧表示します。
コマンド:
aws cognito-idp list-user-pools --max-results 20
出力:
{ "UserPools": [ { "CreationDate": 1547763720.822, "LastModifiedDate": 1547763720.822, "LambdaConfig": {}, "Id": "us-west-2_aaaaaaaaa", "Name": "MyUserPool" } ] }
-
API の詳細については、「 コマンドリファレンスListUserPools
」の「」を参照してください。 AWS CLI
-
- Java
-
- SDK for Java 2.x
-
注記
には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリ
での設定と実行の方法を確認してください。 import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.cognitoidentityprovider.CognitoIdentityProviderClient; import software.amazon.awssdk.services.cognitoidentityprovider.model.CognitoIdentityProviderException; import software.amazon.awssdk.services.cognitoidentityprovider.model.ListUserPoolsResponse; import software.amazon.awssdk.services.cognitoidentityprovider.model.ListUserPoolsRequest; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ListUserPools { public static void main(String[] args) { CognitoIdentityProviderClient cognitoClient = CognitoIdentityProviderClient.builder() .region(Region.US_EAST_1) .build(); listAllUserPools(cognitoClient); cognitoClient.close(); } public static void listAllUserPools(CognitoIdentityProviderClient cognitoClient) { try { ListUserPoolsRequest request = ListUserPoolsRequest.builder() .maxResults(10) .build(); ListUserPoolsResponse response = cognitoClient.listUserPools(request); response.userPools().forEach(userpool -> { System.out.println("User pool " + userpool.name() + ", User ID " + userpool.id()); }); } catch (CognitoIdentityProviderException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }
-
API の詳細については、「 API リファレンスListUserPools」の「」を参照してください。 AWS SDK for Java 2.x
-
- Rust
-
- SDK for Rust
-
注記
には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリ
での設定と実行の方法を確認してください。 async fn show_pools(client: &Client) -> Result<(), Error> { let response = client.list_user_pools().max_results(10).send().await?; let pools = response.user_pools(); println!("User pools:"); for pool in pools { println!(" ID: {}", pool.id().unwrap_or_default()); println!(" Name: {}", pool.name().unwrap_or_default()); println!(" Lambda Config: {:?}", pool.lambda_config().unwrap()); println!( " Last modified: {}", pool.last_modified_date().unwrap().to_chrono_utc()? ); println!( " Creation date: {:?}", pool.creation_date().unwrap().to_chrono_utc() ); println!(); } println!("Next token: {}", response.next_token().unwrap_or_default()); Ok(()) }
-
API の詳細については、ListUserPools
AWS「 SDK for Rust API リファレンス」の「」を参照してください。
-
ユーザーに関する情報を取得する
ユーザーの一覧表示