Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.
Benutzen ListIdentityPools mit einem AWS SDK oder CLI
Die folgenden Code-Beispiele zeigen, wie ListIdentityPools verwendet wird.
- CLI
-
- AWS CLI
-
So listen Sie Identitätspools auf
Folgendes
list-identity-poolsBeispiel listet Identitätspools auf. Es werden maximal 20 Identitätspools aufgeführt.aws cognito-identity list-identity-pools \ --max-results20Ausgabe:
{ "IdentityPools": [ { "IdentityPoolId": "us-west-2:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "IdentityPoolName": "MyIdentityPool" }, { "IdentityPoolId": "us-west-2:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "IdentityPoolName": "AnotherIdentityPool" }, { "IdentityPoolId": "us-west-2:a1b2c3d4-5678-90ab-cdef-EXAMPLE33333", "IdentityPoolName": "IdentityPoolRegionA" } ] }Weitere Informationen finden Sie unter Amazon-Cognito-Identitätspools im Amazon-Cognito-Entwicklerhandbuch.
-
Einzelheiten zur API finden Sie unter ListIdentityPools
in AWS CLI Befehlsreferenz.
-
- Java
-
- SDK für Java 2.x
-
Anmerkung
Es gibt noch mehr GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.cognitoidentity.CognitoIdentityClient; import software.amazon.awssdk.services.cognitoidentity.model.ListIdentityPoolsRequest; import software.amazon.awssdk.services.cognitoidentity.model.ListIdentityPoolsResponse; import software.amazon.awssdk.services.cognitoidentityprovider.model.CognitoIdentityProviderException; /** * 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 ListIdentityPools { public static void main(String[] args) { CognitoIdentityClient cognitoClient = CognitoIdentityClient.builder() .region(Region.US_EAST_1) .build(); listIdPools(cognitoClient); cognitoClient.close(); } public static void listIdPools(CognitoIdentityClient cognitoClient) { try { ListIdentityPoolsRequest poolsRequest = ListIdentityPoolsRequest.builder() .maxResults(15) .build(); ListIdentityPoolsResponse response = cognitoClient.listIdentityPools(poolsRequest); response.identityPools().forEach(pool -> { System.out.println("Pool ID: " + pool.identityPoolId()); System.out.println("Pool name: " + pool.identityPoolName()); }); } catch (CognitoIdentityProviderException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }-
Einzelheiten zur API finden Sie unter ListIdentityPools in AWS SDK for Java 2.x API-Referenz.
-
- PowerShell
-
- Werkzeuge für PowerShell V4
-
Beispiel 1: Ruft eine Liste vorhandener Identitätspools ab.
Get-CGIIdentityPoolListAusgabe:
IdentityPoolId IdentityPoolName -------------- ---------------- us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1 CommonTests1 us-east-1:118d242d-204e-4b88-b803-EXAMPLEGUID2 Tests2 us-east-1:15d49393-ab16-431a-b26e-EXAMPLEGUID3 CommonTests13-
API-Details finden Sie unter ListIdentityPools in AWS -Tools für PowerShell Cmdlet-Referenz (V4).
-
- Werkzeuge für PowerShell V5
-
Beispiel 1: Ruft eine Liste vorhandener Identitätspools ab.
Get-CGIIdentityPoolListAusgabe:
IdentityPoolId IdentityPoolName -------------- ---------------- us-east-1:0de2af35-2988-4d0b-b22d-EXAMPLEGUID1 CommonTests1 us-east-1:118d242d-204e-4b88-b803-EXAMPLEGUID2 Tests2 us-east-1:15d49393-ab16-431a-b26e-EXAMPLEGUID3 CommonTests13-
API-Details finden Sie unter ListIdentityPools in AWS -Tools für PowerShell Cmdlet-Referenz (V5).
-
- Swift
-
- SDK für Swift
-
Anmerkung
Es gibt noch mehr GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. import AWSCognitoIdentity /// Return the ID of the identity pool with the specified name. /// /// - Parameters: /// - name: The name of the identity pool whose ID should be returned. /// /// - Returns: A string containing the ID of the specified identity pool /// or `nil` on error or if not found. /// func getIdentityPoolID(name: String) async throws -> String? { let listPoolsInput = ListIdentityPoolsInput(maxResults: 25) // Use "Paginated" to get all the objects. // This lets the SDK handle the 'nextToken' field in "ListIdentityPoolsOutput". let pages = cognitoIdentityClient.listIdentityPoolsPaginated(input: listPoolsInput) do { for try await page in pages { guard let identityPools = page.identityPools else { print("ERROR: listIdentityPoolsPaginated returned nil contents.") continue } /// Read pages of identity pools from Cognito until one is found /// whose name matches the one specified in the `name` parameter. /// Return the matching pool's ID. for pool in identityPools { if pool.identityPoolName == name { return pool.identityPoolId! } } } } catch { print("ERROR: getIdentityPoolID:", dump(error)) throw error } return nil }Rufen Sie ID eines vorhandenen Identitätspools ab oder erstellen Sie sie, wenn sie nicht bereits vorhanden ist.
import AWSCognitoIdentity /// Return the ID of the identity pool with the specified name. /// /// - Parameters: /// - name: The name of the identity pool whose ID should be returned /// /// - Returns: A string containing the ID of the specified identity pool. /// Returns `nil` if there's an error or if the pool isn't found. /// public func getOrCreateIdentityPoolID(name: String) async throws -> String? { // See if the pool already exists. If it doesn't, create it. do { guard let poolId = try await getIdentityPoolID(name: name) else { return try await createIdentityPool(name: name) } return poolId } catch { print("ERROR: getOrCreateIdentityPoolID:", dump(error)) throw error } }-
Weitere Informationen finden Sie im Entwicklerhandbuch zum AWS -SDK für Swift.
-
Einzelheiten zur API finden Sie unter ListIdentityPools
in AWS SDK für Swift API-Referenz.
-
Für eine vollständige Liste von AWS SDK-Entwicklerhandbücher und Codebeispiele finden Sie unter Verwenden Sie diesen Dienst mit einem AWS SDK. Dieses Thema enthält auch Informationen zu den ersten Schritten und Details zu früheren SDK-Versionen.