コード例 #1
0
        private void DeleteDocument()
        {
            Console.WriteLine(string.Format("\nCalling DeleteDocument()..."));

            if (string.IsNullOrEmpty(_createdEnvironmentId))
            {
                throw new ArgumentNullException("_createdEnvironmentId is null");
            }

            if (string.IsNullOrEmpty(_createdCollectionId))
            {
                throw new ArgumentNullException("_createdCollectionId is null");
            }

            if (string.IsNullOrEmpty(_createdDocumentId))
            {
                throw new ArgumentNullException("_createdDocumentId is null");
            }

            var result = _discovery.DeleteDocument(_createdEnvironmentId, _createdCollectionId, _createdDocumentId);

            if (result != null)
            {
                Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
                _createdDocumentId = null;
            }
            else
            {
                Console.WriteLine("result is null.");
            }
        }
コード例 #2
0
        public void DeleteDocument()
        {
            Console.WriteLine(string.Format("\nCalling DeleteDocument()..."));

            if (string.IsNullOrEmpty(_createdEnvironmentId))
            {
                Assert.Fail("_createdEnvironmentId is null");
            }

            if (string.IsNullOrEmpty(_createdCollectionId))
            {
                Assert.Fail("_createdCollectionId is null");
            }

            if (string.IsNullOrEmpty(_createdDocumentId))
            {
                Assert.Fail("_createdDocumentId is null");
            }

            var result = _discovery.DeleteDocument(_createdEnvironmentId, _createdCollectionId, _createdDocumentId);

            if (result != null)
            {
                Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
                _createdDocumentId = null;
            }
            else
            {
                Console.WriteLine("result is null.");
            }

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Status == DeleteDocumentResponse.StatusEnum.DELETED);
        }
コード例 #3
0
        public void TestAddDeleteDocument()
        {
            DetailedResponse <DocumentAccepted> addDocumentResult = null;

            using (FileStream fs = File.OpenRead(filepathToIngest))
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    fs.CopyTo(ms);

                    service.WithHeader("X-Watson-Test", "1");
                    addDocumentResult = service.AddDocument(
                        projectId: projectId,
                        collectionId: collectionId,
                        file: ms,
                        filename: "watson_beats_jeopardy.html",
                        fileContentType: "text/html",
                        metadata: metadata,
                        xWatsonDiscoveryForce: false
                        );
                }
            }

            Assert.IsNotNull(addDocumentResult.Result);
            Assert.IsNotNull(addDocumentResult.Result.DocumentId);
            Assert.IsNotNull(addDocumentResult.Result.Status);

            var documentId = addDocumentResult.Result.DocumentId;

            service.WithHeader("X-Watson-Test", "1");
            var deleteDocumentResult = service.DeleteDocument(
                projectId: projectId,
                collectionId: collectionId,
                documentId: documentId,
                xWatsonDiscoveryForce: false
                );

            Assert.IsNotNull(deleteDocumentResult.Result);
            Assert.IsNotNull(deleteDocumentResult.Result.DocumentId);
            Assert.IsNotNull(deleteDocumentResult.Result.Status);
        }
        //[UnityTest, Order(99)]
        public IEnumerator TestDeleteDocument()
        {
            Log.Debug("DiscoveryServiceV2IntegrationTests", "Attempting to DeleteDocument...");
            DeleteDocumentResponse deleteDocumentResponse = null;

            service.DeleteDocument(
                callback: (DetailedResponse <DeleteDocumentResponse> response, IBMError error) =>
            {
                Log.Debug("DiscoveryServiceV2IntegrationTests", "DeleteDocument result: {0}", response.Response);
                deleteDocumentResponse = response.Result;
                Assert.IsNotNull(deleteDocumentResponse);
                Assert.IsNull(error);
            },
                projectId: projectId,
                collectionId: collectionId,
                documentId: documentId
                );

            while (deleteDocumentResponse == null)
            {
                yield return(null);
            }
        }
コード例 #5
0
        public void DeleteDocument()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

            DiscoveryService service = new DiscoveryService("2019-04-30", authenticator);

            service.SetServiceUrl("{serviceUrl}");

            var result = service.DeleteDocument(
                environmentId: "{environmentId}",
                collectionId: "{collectionId}",
                documentId: "{documentId}"
                );

            Console.WriteLine(result.Response);
        }
コード例 #6
0
        public void DeleteDocument()
        {
            IamConfig config = new IamConfig(
                apikey: apikey
                );

            DiscoveryService service = new DiscoveryService(versionDate, config);

            service.SetEndpoint(url);

            var result = service.DeleteDocument(
                environmentId: environmentId,
                collectionId: collectionId,
                documentId: documentId
                );

            Console.WriteLine(result.Response);
        }
コード例 #7
0
        public void DeleteDocument()
        {
            TokenOptions tokenOptions = new TokenOptions()
            {
                IamApiKey  = apikey,
                ServiceUrl = url
            };

            DiscoveryService service = new DiscoveryService(tokenOptions, versionDate);

            var result = service.DeleteDocument(
                environmentId: environmentId,
                collectionId: collectionId,
                documentId: documentId
                );

            Console.WriteLine(result.Response);
        }
コード例 #8
0
        public void DeleteDocument()
        {
            CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
                url: "https://{cpd_cluster_host}{:port}",
                username: "******",
                password: "******"
                );

            DiscoveryService service = new DiscoveryService("2019-11-22", authenticator);

            service.SetServiceUrl("{https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api}");

            var result = service.DeleteDocument(
                projectId: "{project_id}",
                collectionId: "{collection_id}",
                documentId: "{document_id}"
                );

            Console.WriteLine(result.Response);
        }
        public void DeleteDocument_Success()
        {
            IClient  client  = Substitute.For <IClient>();
            IRequest request = Substitute.For <IRequest>();

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

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

            service.VersionDate = versionDate;

            var projectId             = "projectId";
            var collectionId          = "collectionId";
            var documentId            = "documentId";
            var xWatsonDiscoveryForce = false;

            var result = service.DeleteDocument(projectId: projectId, collectionId: collectionId, documentId: documentId, xWatsonDiscoveryForce: xWatsonDiscoveryForce);

            request.Received().WithArgument("version", versionDate);
            client.Received().DeleteAsync($"{service.ServiceUrl}/v2/projects/{projectId}/collections/{collectionId}/documents/{documentId}");
        }
コード例 #10
0
        public static void TearDown()
        {
            var environmentVariable =
                Environment.GetEnvironmentVariable("VCAP_SERVICES");

            var fileContent =
                File.ReadAllText(environmentVariable);

            var vcapServices =
                JObject.Parse(fileContent);

            string _endpoint = vcapServices["discovery"][0]["credentials"]["url"].Value <string>();
            string _username = vcapServices["discovery"][0]["credentials"]["username"].Value <string>();
            string _password = vcapServices["discovery"][0]["credentials"]["password"].Value <string>();

            DiscoveryService _discovery = new DiscoveryService(_username, _password, DiscoveryService.DISCOVERY_VERSION_DATE_2016_12_01);

            if (!string.IsNullOrEmpty(_createdEnvironmentId) && !string.IsNullOrEmpty(_createdCollectionId) && !string.IsNullOrEmpty(_createdDocumentId))
            {
                _discovery.DeleteDocument(_createdEnvironmentId, _createdCollectionId, _createdDocumentId);
            }

            if (!string.IsNullOrEmpty(_createdEnvironmentId) && !string.IsNullOrEmpty(_createdCollectionId))
            {
                _discovery.DeleteCollection(_createdEnvironmentId, _createdCollectionId);
            }

            if (!string.IsNullOrEmpty(_createdEnvironmentId) && !string.IsNullOrEmpty(_createdConfigurationId))
            {
                _discovery.DeleteConfiguration(_createdEnvironmentId, _createdConfigurationId);
            }

            if (!string.IsNullOrEmpty(_createdEnvironmentId))
            {
                _discovery.DeleteEnvironment(_createdEnvironmentId);
            }
        }