internal ListCollectionsResponse ListCollections(ListCollectionsRequest request) { var marshaller = new ListCollectionsRequestMarshaller(); var unmarshaller = ListCollectionsResponseUnmarshaller.Instance; return(Invoke <ListCollectionsRequest, ListCollectionsResponse>(request, marshaller, unmarshaller)); }
private bool CollectionExists() { ListCollectionsRequest request = new ListCollectionsRequest(); ListCollectionsResponse response = Client.ListCollections(request); return(response.CollectionIds.Contains(CollectionName)); }
// snippet-start:[Rekognition.dotnetv3.ListCollectionsExample] public static async Task Main() { var rekognitionClient = new AmazonRekognitionClient(); Console.WriteLine("Listing collections"); int limit = 10; var listCollectionsRequest = new ListCollectionsRequest { MaxResults = limit, }; var listCollectionsResponse = new ListCollectionsResponse(); do { if (listCollectionsResponse is not null) { listCollectionsRequest.NextToken = listCollectionsResponse.NextToken; } listCollectionsResponse = await rekognitionClient.ListCollectionsAsync(listCollectionsRequest); listCollectionsResponse.CollectionIds.ForEach(id => { Console.WriteLine(id); }); }while (listCollectionsResponse.NextToken is not null); }
public static void Example() { AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient(); Console.WriteLine("Listing collections"); int limit = 10; ListCollectionsResponse listCollectionsResponse = null; String paginationToken = null; do { if (listCollectionsResponse != null) { paginationToken = listCollectionsResponse.NextToken; } ListCollectionsRequest listCollectionsRequest = new ListCollectionsRequest() { MaxResults = limit, NextToken = paginationToken }; listCollectionsResponse = rekognitionClient.ListCollections(listCollectionsRequest); foreach (String resultId in listCollectionsResponse.CollectionIds) { Console.WriteLine(resultId); } } while (listCollectionsResponse != null && listCollectionsResponse.NextToken != null); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonRekognitionConfig config = new AmazonRekognitionConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonRekognitionClient client = new AmazonRekognitionClient(creds, config); ListCollectionsResponse resp = new ListCollectionsResponse(); do { ListCollectionsRequest req = new ListCollectionsRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.ListCollections(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.CollectionIds) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
public static string Collection(string collectionId) { try { var rekognitionClient = new AmazonRekognitionClient(RegionEndpoint.APSouth1); Console.WriteLine("Creating collection: " + collectionId); var createCollectionRequest = new CreateCollectionRequest() { CollectionId = collectionId }; int limit = 10; ListCollectionsResponse listCollectionsResponse = null; String paginationToken = null; if (listCollectionsResponse != null) { paginationToken = listCollectionsResponse.NextToken; } ListCollectionsRequest listCollectionsRequest = new ListCollectionsRequest() { MaxResults = limit, NextToken = paginationToken }; listCollectionsResponse = rekognitionClient.ListCollectionsAsync(listCollectionsRequest).Result; foreach (var resultId in listCollectionsResponse.CollectionIds) { if (resultId == collectionId) { return("OK"); } else { var createCollectionResponse = rekognitionClient.CreateCollectionAsync(createCollectionRequest); Console.WriteLine("CollectionArn : " + createCollectionResponse.Result.CollectionArn); if (createCollectionResponse.Result.StatusCode == 200) { return("OK"); } } } } catch (Exception ex) { Console.WriteLine("Exception occurred" + ex); return(""); } return(""); }
/// <summary> /// Initiates the asynchronous execution of the ListCollections operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListCollections operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <ListCollectionsResponse> ListCollectionsAsync(ListCollectionsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListCollectionsRequestMarshaller(); var unmarshaller = ListCollectionsResponseUnmarshaller.Instance; return(InvokeAsync <ListCollectionsRequest, ListCollectionsResponse>(request, marshaller, unmarshaller, cancellationToken)); }
public static List <String> GetFaceCollectionList() { List <String> _faceCollectionList = new List <string>(); _faceCollectionList.Clear(); using (rekognitionClient = new AmazonRekognitionClient(collectionRegion)) { ListingCollections(); } void ListingCollections() { try { int limit = 10; ListCollectionsResponse listCollectionsResponse = null; String paginationToken = null; do { if (listCollectionsResponse != null) { paginationToken = listCollectionsResponse.NextToken; } ListCollectionsRequest listCollectionsRequest = new ListCollectionsRequest() { MaxResults = limit, NextToken = paginationToken }; listCollectionsResponse = rekognitionClient.ListCollections(listCollectionsRequest); foreach (String resultId in listCollectionsResponse.CollectionIds) { _faceCollectionList.Add(resultId); } } while (listCollectionsResponse != null && listCollectionsResponse.NextToken != null); } catch (AmazonRekognitionException e) { Console.WriteLine("AmazonRekognitionException: " + e); } catch (Exception e) { Console.WriteLine("Error: " + e); } } return(_faceCollectionList); }
private async Task <List <string> > GetCollections(AmazonRekognitionClient rekognitionClient) { ListCollectionsResponse listCollectionsResponse = null; ListCollectionsRequest listCollectionsRequest = new ListCollectionsRequest() { //MaxResults = limit, //declare a limit //NextToken = paginationToken }; listCollectionsResponse = await rekognitionClient.ListCollectionsAsync(listCollectionsRequest); return(listCollectionsResponse.CollectionIds); }