- AWS Code Sample demonstrates how to list the available Amazon Rekognition collections.

/** * Copyright, Inc. or its affiliates. All Rights Reserved. * * This file is licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. A copy of * the License is located at * * * * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.example.rekognition; import; import; import; import; import; import java.util.List; public class ListCollections { public static void main(String[] args) { Region region = Region.US_EAST_2; RekognitionClient rekClient = RekognitionClient.builder() .region(region) .build(); System.out.println("Listing collections"); listAllCollections(rekClient); } public static void listAllCollections(RekognitionClient rekClient) { try { // Create a ListCollectionsRequest object ListCollectionsRequest listCollectionsRequest = ListCollectionsRequest.builder() .maxResults(10) .build(); // Invoke the listCollections method ListCollectionsResponse response = rekClient.listCollections(listCollectionsRequest); // Display the results List<String> collectionIds = response.collectionIds(); for (String resultId : collectionIds) { System.out.println(resultId); } } catch (RekognitionException e) { System.out.println(e.getMessage()); System.exit(1); } } }

Sample Details

Service: Amazon Rekognition

Last tested: 6-10-2020

Author: scmacdon - AWS

Type: full-example