Exemple #1
0
        /// <summary>Snippet for DeleteKnowledgeBaseAsync</summary>
        public async Task DeleteKnowledgeBaseAsync()
        {
            // Snippet: DeleteKnowledgeBaseAsync(string, CallSettings)
            // Additional: DeleteKnowledgeBaseAsync(string, CancellationToken)
            // Create client
            KnowledgeBasesClient knowledgeBasesClient = await KnowledgeBasesClient.CreateAsync();

            // Initialize request argument(s)
            string name = "projects/[PROJECT]/knowledgeBases/[KNOWLEDGE_BASE]";
            // Make the request
            await knowledgeBasesClient.DeleteKnowledgeBaseAsync(name);

            // End snippet
        }
Exemple #2
0
        /// <summary>Snippet for DeleteKnowledgeBaseAsync</summary>
        public async Task DeleteKnowledgeBaseResourceNamesAsync()
        {
            // Snippet: DeleteKnowledgeBaseAsync(KnowledgeBaseName, CallSettings)
            // Additional: DeleteKnowledgeBaseAsync(KnowledgeBaseName, CancellationToken)
            // Create client
            KnowledgeBasesClient knowledgeBasesClient = await KnowledgeBasesClient.CreateAsync();

            // Initialize request argument(s)
            KnowledgeBaseName name = KnowledgeBaseName.FromProjectKnowledgeBase("[PROJECT]", "[KNOWLEDGE_BASE]");
            // Make the request
            await knowledgeBasesClient.DeleteKnowledgeBaseAsync(name);

            // End snippet
        }
Exemple #3
0
        /// <summary>Snippet for ListKnowledgeBasesAsync</summary>
        public async Task ListKnowledgeBasesRequestObjectAsync()
        {
            // Snippet: ListKnowledgeBasesAsync(ListKnowledgeBasesRequest, CallSettings)
            // Create client
            KnowledgeBasesClient knowledgeBasesClient = await KnowledgeBasesClient.CreateAsync();

            // Initialize request argument(s)
            ListKnowledgeBasesRequest request = new ListKnowledgeBasesRequest
            {
                ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
                Filter = "",
            };
            // Make the request
            PagedAsyncEnumerable <ListKnowledgeBasesResponse, KnowledgeBase> response = knowledgeBasesClient.ListKnowledgeBasesAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((KnowledgeBase item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListKnowledgeBasesResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (KnowledgeBase item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <KnowledgeBase> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (KnowledgeBase item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Exemple #4
0
        /// <summary>Snippet for UpdateKnowledgeBaseAsync</summary>
        public async Task UpdateKnowledgeBaseAsync()
        {
            // Snippet: UpdateKnowledgeBaseAsync(KnowledgeBase, FieldMask, CallSettings)
            // Additional: UpdateKnowledgeBaseAsync(KnowledgeBase, FieldMask, CancellationToken)
            // Create client
            KnowledgeBasesClient knowledgeBasesClient = await KnowledgeBasesClient.CreateAsync();

            // Initialize request argument(s)
            KnowledgeBase knowledgeBase = new KnowledgeBase();
            FieldMask     updateMask    = new FieldMask();
            // Make the request
            KnowledgeBase response = await knowledgeBasesClient.UpdateKnowledgeBaseAsync(knowledgeBase, updateMask);

            // End snippet
        }
Exemple #5
0
        /// <summary>Snippet for CreateKnowledgeBaseAsync</summary>
        public async Task CreateKnowledgeBaseResourceNames2Async()
        {
            // Snippet: CreateKnowledgeBaseAsync(LocationName, KnowledgeBase, CallSettings)
            // Additional: CreateKnowledgeBaseAsync(LocationName, KnowledgeBase, CancellationToken)
            // Create client
            KnowledgeBasesClient knowledgeBasesClient = await KnowledgeBasesClient.CreateAsync();

            // Initialize request argument(s)
            LocationName  parent        = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            KnowledgeBase knowledgeBase = new KnowledgeBase();
            // Make the request
            KnowledgeBase response = await knowledgeBasesClient.CreateKnowledgeBaseAsync(parent, knowledgeBase);

            // End snippet
        }
Exemple #6
0
        /// <summary>Snippet for CreateKnowledgeBaseAsync</summary>
        public async Task CreateKnowledgeBaseAsync()
        {
            // Snippet: CreateKnowledgeBaseAsync(string, KnowledgeBase, CallSettings)
            // Additional: CreateKnowledgeBaseAsync(string, KnowledgeBase, CancellationToken)
            // Create client
            KnowledgeBasesClient knowledgeBasesClient = await KnowledgeBasesClient.CreateAsync();

            // Initialize request argument(s)
            string        parent        = "projects/[PROJECT]";
            KnowledgeBase knowledgeBase = new KnowledgeBase();
            // Make the request
            KnowledgeBase response = await knowledgeBasesClient.CreateKnowledgeBaseAsync(parent, knowledgeBase);

            // End snippet
        }
Exemple #7
0
        /// <summary>Snippet for GetKnowledgeBaseAsync</summary>
        public async Task GetKnowledgeBaseRequestObjectAsync()
        {
            // Snippet: GetKnowledgeBaseAsync(GetKnowledgeBaseRequest, CallSettings)
            // Additional: GetKnowledgeBaseAsync(GetKnowledgeBaseRequest, CancellationToken)
            // Create client
            KnowledgeBasesClient knowledgeBasesClient = await KnowledgeBasesClient.CreateAsync();

            // Initialize request argument(s)
            GetKnowledgeBaseRequest request = new GetKnowledgeBaseRequest
            {
                KnowledgeBaseName = KnowledgeBaseName.FromProjectKnowledgeBase("[PROJECT]", "[KNOWLEDGE_BASE]"),
            };
            // Make the request
            KnowledgeBase response = await knowledgeBasesClient.GetKnowledgeBaseAsync(request);

            // End snippet
        }
Exemple #8
0
        /// <summary>Snippet for UpdateKnowledgeBaseAsync</summary>
        public async Task UpdateKnowledgeBaseRequestObjectAsync()
        {
            // Snippet: UpdateKnowledgeBaseAsync(UpdateKnowledgeBaseRequest, CallSettings)
            // Additional: UpdateKnowledgeBaseAsync(UpdateKnowledgeBaseRequest, CancellationToken)
            // Create client
            KnowledgeBasesClient knowledgeBasesClient = await KnowledgeBasesClient.CreateAsync();

            // Initialize request argument(s)
            UpdateKnowledgeBaseRequest request = new UpdateKnowledgeBaseRequest
            {
                KnowledgeBase = new KnowledgeBase(),
                UpdateMask    = new FieldMask(),
            };
            // Make the request
            KnowledgeBase response = await knowledgeBasesClient.UpdateKnowledgeBaseAsync(request);

            // End snippet
        }
Exemple #9
0
        /// <summary>Snippet for CreateKnowledgeBaseAsync</summary>
        public async Task CreateKnowledgeBaseRequestObjectAsync()
        {
            // Snippet: CreateKnowledgeBaseAsync(CreateKnowledgeBaseRequest, CallSettings)
            // Additional: CreateKnowledgeBaseAsync(CreateKnowledgeBaseRequest, CancellationToken)
            // Create client
            KnowledgeBasesClient knowledgeBasesClient = await KnowledgeBasesClient.CreateAsync();

            // Initialize request argument(s)
            CreateKnowledgeBaseRequest request = new CreateKnowledgeBaseRequest
            {
                ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
                KnowledgeBase       = new KnowledgeBase(),
            };
            // Make the request
            KnowledgeBase response = await knowledgeBasesClient.CreateKnowledgeBaseAsync(request);

            // End snippet
        }