Example #1
0
        public void DeleteModel_Success()
        {
            IClient client = CreateClient();

            IRequest request = Substitute.For <IRequest>();

            client.DeleteAsync(Arg.Any <string>())
            .Returns(request);

            #region Response
            InlineResponse200 response = new InlineResponse200()
            {
                Deleted = "true"
            };
            #endregion

            request.WithArgument(Arg.Any <string>(), Arg.Any <string>())
            .Returns(request);
            request.As <InlineResponse200>()
            .Returns(Task.FromResult(response));

            NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService(client);
            service.VersionDate = "versionDate";

            var result = service.DeleteModel("modelId");

            Assert.IsNotNull(result);
            client.Received().DeleteAsync(Arg.Any <string>());
            Assert.IsNotNull(result.Deleted);
        }
        public void DeleteModel_No_VersionDate()
        {
            NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService("versionDate", new NoAuthAuthenticator());

            service.VersionDate = null;

            service.DeleteModel("modelId");
        }
Example #3
0
        public void DeleteModel_No_VersionDate()
        {
            NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService("username", "password", "versionDate");

            service.VersionDate = null;

            service.DeleteModel("modelId");
        }
        private InlineResponse200 DeleteModel(string modelId)
        {
            Console.WriteLine("\nAttempting to DeleteModel()");
            var result = _service.DeleteModel(modelId: modelId);

            if (result != null)
            {
                Console.WriteLine("DeleteModel() succeeded:\n{0}", JsonConvert.SerializeObject(result, Formatting.Indented));
            }
            else
            {
                Console.WriteLine("Failed to DeleteModel()");
            }

            return(result);
        }
        public void DeleteModel()
        {
            TokenOptions tokenOptions = new TokenOptions()
            {
                IamApiKey  = apikey,
                ServiceUrl = url
            };

            NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService(tokenOptions, versionDate);

            var result = service.DeleteModel(
                modelId: modelId
                );

            Console.WriteLine(result.Response);
        }
Example #6
0
        public void DeleteModel()
        {
            IamConfig config = new IamConfig(
                apikey: apikey
                );

            NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService(versionDate, config);

            service.SetEndpoint(url);

            var result = service.DeleteModel(
                modelId: modelId
                );

            Console.WriteLine(result.Response);
        }
        public void DeleteModel()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}"
                );

            NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService("2019-07-12", authenticator);

            service.SetServiceUrl("{serviceUrl}");

            var result = service.DeleteModel(
                modelId: "model_id"
                );

            Console.WriteLine(result.Response);
        }
        private IEnumerator ExampleDeleteModel()
        {
            DeleteModelResults deleteModelResponse = null;

            service.DeleteModel(
                callback: (DetailedResponse <DeleteModelResults> response, IBMError error) =>
            {
                Log.Debug("NaturalLanguageUnderstandingServiceV1", "DeleteModel result: {0}", response.Response);
                deleteModelResponse = response.Result;
            },
                modelId: "<modelId>" // Enter model Id here
                );

            while (deleteModelResponse == null)
            {
                yield return(null);
            }
        }
Example #9
0
        public void DeleteModel_Catch_Exception()
        {
            IClient client = CreateClient();

            IRequest request = Substitute.For <IRequest>();

            client.DeleteAsync(Arg.Any <string>())
            .Returns(x =>
            {
                throw new AggregateException(new ServiceResponseException(Substitute.For <IResponse>(),
                                                                          Substitute.For <HttpResponseMessage>(HttpStatusCode.BadRequest),
                                                                          string.Empty));
            });

            NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService(client);

            service.VersionDate = "2017-02-27";

            service.DeleteModel("modelID");
        }
Example #10
0
        public void DeleteModel_Success()
        {
            IClient  client  = Substitute.For <IClient>();
            IRequest request = Substitute.For <IRequest>();

            client.DeleteAsync(Arg.Any <string>())
            .Returns(request);

            NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService(client);
            var versionDate = "versionDate";

            service.Version = versionDate;

            var modelId = "modelId";

            var result = service.DeleteModel(modelId: modelId);

            request.Received().WithArgument("version", versionDate);
            client.Received().DeleteAsync($"{service.ServiceUrl}/v1/models/{modelId}");
        }
Example #11
0
        public void DeleteModel_No_Model_Id()
        {
            NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService("username", "password", "versionDate");

            service.DeleteModel(null);
        }
        public void DeleteModel_No_Model_Id()
        {
            NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService("versionDate", new NoAuthAuthenticator());

            service.DeleteModel(null);
        }