示例#1
0
    private void OnDeleteCollection(DeleteCollectionResponse resp, Dictionary <string, object> customData)
    {
        Log.Debug("ExampleDiscovery.OnDeleteCollection()", "Discovery - Delete collection Response: deleted:{0}", customData["json"].ToString());
        _createdCollectionID = default(string);

        _deleteCollectionTested = true;
    }
示例#2
0
        public DeleteCollectionResponse DeleteCollection(string environmentId, string collectionId)
        {
            if (string.IsNullOrEmpty(environmentId))
            {
                throw new ArgumentNullException(nameof(environmentId));
            }
            if (string.IsNullOrEmpty(collectionId))
            {
                throw new ArgumentNullException(nameof(collectionId));
            }

            if (string.IsNullOrEmpty(VersionDate))
            {
                throw new ArgumentNullException("versionDate cannot be null. Use 'DISCOVERY_VERSION_DATE_2016_12_01'");
            }

            DeleteCollectionResponse result = null;

            try
            {
                result = this.Client.WithAuthentication(this.UserName, this.Password)
                         .DeleteAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}")
                         .WithArgument("version", VersionDate)
                         .As <DeleteCollectionResponse>()
                         .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
        public async Task DeleteCollectionAsync_ShouldReturnError_WhenCollectionDoesNotExist()
        {
            DeleteCollectionResponse deleteCollectionResponse = await _collectionApi.DeleteCollectionAsync("NotACollection");

            Assert.False(deleteCollectionResponse.IsSuccess);
            Assert.True(deleteCollectionResponse.ResponseDetails.Error);
            Assert.Equal(1203, deleteCollectionResponse.ResponseDetails.ErrorNum);
        }
示例#4
0
        public static DeleteCollectionResponse Unmarshall(UnmarshallerContext context)
        {
            DeleteCollectionResponse deleteCollectionResponse = new DeleteCollectionResponse();

            deleteCollectionResponse.HttpResponse = context.HttpResponse;

            return(deleteCollectionResponse);
        }
示例#5
0
        private void OnDeleteJpCollection(DeleteCollectionResponse response, Dictionary <string, object> customData)
        {
            Log.Debug("TestDiscovery.OnDeleteJpCollection()", "Discovery - Delete jp collection Response: deleted:{0}", customData["json"].ToString());

            _createdJpCollection = default(string);
            Test(response != null);

            _deleteJpCollectionTested = true;
        }
示例#6
0
        private void DeleteCollection()
        {
            Console.WriteLine("Deleting existing collection: {0}", CollectionName);
            DeleteCollectionRequest request = new DeleteCollectionRequest()
            {
                CollectionId = CollectionName
            };

            DeleteCollectionResponse response = Client.DeleteCollection(request);

            Console.WriteLine("Collection deleted.");
        }
示例#7
0
    public static void Example()
    {
        AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient();

        String collectionId = "MyCollection";

        Console.WriteLine("Deleting collection: " + collectionId);

        DeleteCollectionRequest deleteCollectionRequest = new DeleteCollectionRequest()
        {
            CollectionId = collectionId
        };

        DeleteCollectionResponse deleteCollectionResponse = rekognitionClient.DeleteCollection(deleteCollectionRequest);

        Console.WriteLine(collectionId + ": " + deleteCollectionResponse.StatusCode);
    }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DeleteCollectionResponse response = new DeleteCollectionResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("StatusCode", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.StatusCode = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
示例#9
0
        public static void Delete(string _collectionId)
        {
            if (GetFaceCollectionList().Contains(_collectionId))
            {
                string collectionId = _collectionId;
                try
                {
                    using (rekognitionClient = new AmazonRekognitionClient(collectionRegion))
                    {
                        DeletingCollection();
                    }

                    void DeletingCollection()
                    {
                        Console.WriteLine("Deleting collection: " + collectionId);

                        DeleteCollectionRequest deleteCollectionRequest = new DeleteCollectionRequest()
                        {
                            CollectionId = collectionId
                        };

                        DeleteCollectionResponse deleteCollectionResponse = rekognitionClient.DeleteCollection(deleteCollectionRequest);

                        Console.WriteLine(collectionId + ": " + deleteCollectionResponse.StatusCode);
                    }
                }
                catch (AmazonRekognitionException e)
                {
                    Console.WriteLine("AmazonRekognitionException: " + e);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e);
                }
            }
        }