Пример #1
0
        /// <summary>Snippet for BatchDeleteIntentsAsync</summary>
        public async Task BatchDeleteIntentsAsync()
        {
            // Snippet: BatchDeleteIntentsAsync(ProjectAgentName,IEnumerable<Intent>,CallSettings)
            // Additional: BatchDeleteIntentsAsync(ProjectAgentName,IEnumerable<Intent>,CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            ProjectAgentName     parent  = new ProjectAgentName("[PROJECT]");
            IEnumerable <Intent> intents = new List <Intent>();
            // Make the request
            Operation <Empty, Struct> response =
                await intentsClient.BatchDeleteIntentsAsync(parent, intents);

            // Poll until the returned long-running operation is complete
            Operation <Empty, Struct> completedResponse =
                await response.PollUntilCompletedAsync();

            // The long-running operation is now complete.

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Empty, Struct> retrievedResponse =
                await intentsClient.PollOnceBatchDeleteIntentsAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // The long-running operation is now complete.
            }
            // End snippet
        }
Пример #2
0
        /// <summary>Snippet for BatchDeleteIntentsAsync</summary>
        public async Task BatchDeleteIntentsAsync_RequestObject()
        {
            // Snippet: BatchDeleteIntentsAsync(BatchDeleteIntentsRequest,CallSettings)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            BatchDeleteIntentsRequest request = new BatchDeleteIntentsRequest
            {
                ParentAsProjectAgentName = new ProjectAgentName("[PROJECT]"),
                Intents = { },
            };
            // Make the request
            Operation <Empty, Struct> response =
                await intentsClient.BatchDeleteIntentsAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <Empty, Struct> completedResponse =
                await response.PollUntilCompletedAsync();

            // The long-running operation is now complete.

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Empty, Struct> retrievedResponse =
                await intentsClient.PollOnceBatchDeleteIntentsAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // The long-running operation is now complete.
            }
            // End snippet
        }
        /// <summary>Snippet for ListIntentsAsync</summary>
        public async Task ListIntentsRequestObjectAsync()
        {
            // Snippet: ListIntentsAsync(ListIntentsRequest, CallSettings)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            ListIntentsRequest request = new ListIntentsRequest
            {
                ParentAsAgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"),
                LanguageCode      = "",
                IntentView        = IntentView.Unspecified,
            };
            // Make the request
            PagedAsyncEnumerable <ListIntentsResponse, Intent> response = intentsClient.ListIntentsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Intent 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((ListIntentsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Intent 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 <Intent> 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 (Intent 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
        }
        /// <summary>Snippet for DeleteIntentAsync</summary>
        public async Task DeleteIntentResourceNamesAsync()
        {
            // Snippet: DeleteIntentAsync(IntentName, CallSettings)
            // Additional: DeleteIntentAsync(IntentName, CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            IntentName name = IntentName.FromProjectLocationAgentIntent("[PROJECT]", "[LOCATION]", "[AGENT]", "[INTENT]");
            // Make the request
            await intentsClient.DeleteIntentAsync(name);

            // End snippet
        }
Пример #5
0
        /// <summary>Snippet for DeleteIntentAsync</summary>
        public async Task DeleteIntentAsync()
        {
            // Snippet: DeleteIntentAsync(IntentName,CallSettings)
            // Additional: DeleteIntentAsync(IntentName,CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            IntentName name = new IntentName("[PROJECT]", "[INTENT]");
            // Make the request
            await intentsClient.DeleteIntentAsync(name);

            // End snippet
        }
        /// <summary>Snippet for DeleteIntentAsync</summary>
        public async Task DeleteIntentAsync()
        {
            // Snippet: DeleteIntentAsync(string, CallSettings)
            // Additional: DeleteIntentAsync(string, CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/intents/[INTENT]";
            // Make the request
            await intentsClient.DeleteIntentAsync(name);

            // End snippet
        }
Пример #7
0
        /// <summary>Snippet for UpdateIntentAsync</summary>
        public async Task UpdateIntentAsync1()
        {
            // Snippet: UpdateIntentAsync(Intent,string,CallSettings)
            // Additional: UpdateIntentAsync(Intent,string,CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            Intent intent       = new Intent();
            string languageCode = "";
            // Make the request
            Intent response = await intentsClient.UpdateIntentAsync(intent, languageCode);

            // End snippet
        }
Пример #8
0
        /// <summary>Snippet for CreateIntentAsync</summary>
        public async Task CreateIntentAsync1()
        {
            // Snippet: CreateIntentAsync(ProjectAgentName,Intent,CallSettings)
            // Additional: CreateIntentAsync(ProjectAgentName,Intent,CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            ProjectAgentName parent = new ProjectAgentName("[PROJECT]");
            Intent           intent = new Intent();
            // Make the request
            Intent response = await intentsClient.CreateIntentAsync(parent, intent);

            // End snippet
        }
Пример #9
0
        /// <summary>Snippet for GetIntentAsync</summary>
        public async Task GetIntentAsync2()
        {
            // Snippet: GetIntentAsync(IntentName,string,CallSettings)
            // Additional: GetIntentAsync(IntentName,string,CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            IntentName name         = new IntentName("[PROJECT]", "[INTENT]");
            string     languageCode = "";
            // Make the request
            Intent response = await intentsClient.GetIntentAsync(name, languageCode);

            // End snippet
        }
        /// <summary>Snippet for UpdateIntentAsync</summary>
        public async Task UpdateIntentAsync()
        {
            // Snippet: UpdateIntentAsync(Intent, FieldMask, CallSettings)
            // Additional: UpdateIntentAsync(Intent, FieldMask, CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            Intent    intent     = new Intent();
            FieldMask updateMask = new FieldMask();
            // Make the request
            Intent response = await intentsClient.UpdateIntentAsync(intent, updateMask);

            // End snippet
        }
        /// <summary>Snippet for CreateIntentAsync</summary>
        public async Task CreateIntentResourceNamesAsync()
        {
            // Snippet: CreateIntentAsync(AgentName, Intent, CallSettings)
            // Additional: CreateIntentAsync(AgentName, Intent, CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            AgentName parent = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]");
            Intent    intent = new Intent();
            // Make the request
            Intent response = await intentsClient.CreateIntentAsync(parent, intent);

            // End snippet
        }
        /// <summary>Snippet for CreateIntentAsync</summary>
        public async Task CreateIntentAsync()
        {
            // Snippet: CreateIntentAsync(string, Intent, CallSettings)
            // Additional: CreateIntentAsync(string, Intent, CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]";
            Intent intent = new Intent();
            // Make the request
            Intent response = await intentsClient.CreateIntentAsync(parent, intent);

            // End snippet
        }
        /// <summary>Snippet for UpdateIntentAsync</summary>
        public async Task UpdateIntentAsync_RequestObject()
        {
            // Snippet: UpdateIntentAsync(UpdateIntentRequest,CallSettings)
            // Additional: UpdateIntentAsync(UpdateIntentRequest,CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            UpdateIntentRequest request = new UpdateIntentRequest
            {
                Intent = new Intent(),
            };
            // Make the request
            Intent response = await intentsClient.UpdateIntentAsync(request);

            // End snippet
        }
Пример #14
0
        /// <summary>Snippet for DeleteIntentAsync</summary>
        public async Task DeleteIntentAsync_RequestObject()
        {
            // Snippet: DeleteIntentAsync(DeleteIntentRequest,CallSettings)
            // Additional: DeleteIntentAsync(DeleteIntentRequest,CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            DeleteIntentRequest request = new DeleteIntentRequest
            {
                IntentName = new IntentName("[PROJECT]", "[INTENT]"),
            };
            // Make the request
            await intentsClient.DeleteIntentAsync(request);

            // End snippet
        }
Пример #15
0
        public async Task <ActionResult <dynamic> > Message([FromQuery(Name = "q")] string query)
        {
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            ProjectAgentName parent = new ProjectAgentName("party-supplier");

            PagedAsyncEnumerable <ListIntentsResponse, Intent> response =
                intentsClient.ListIntentsAsync(parent);

            var results = new List <Intent>();
            await response.ForEachAsync(item =>
            {
                results.Add(item);
            });

            return(results);
        }
        /// <summary>Snippet for GetIntentAsync</summary>
        public async Task GetIntentRequestObjectAsync()
        {
            // Snippet: GetIntentAsync(GetIntentRequest, CallSettings)
            // Additional: GetIntentAsync(GetIntentRequest, CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            GetIntentRequest request = new GetIntentRequest
            {
                IntentName   = IntentName.FromProjectLocationAgentIntent("[PROJECT]", "[LOCATION]", "[AGENT]", "[INTENT]"),
                LanguageCode = "",
            };
            // Make the request
            Intent response = await intentsClient.GetIntentAsync(request);

            // End snippet
        }
Пример #17
0
        /// <summary>Snippet for CreateIntentAsync</summary>
        public async Task CreateIntentAsync_RequestObject()
        {
            // Snippet: CreateIntentAsync(CreateIntentRequest,CallSettings)
            // Additional: CreateIntentAsync(CreateIntentRequest,CancellationToken)
            // Create client
            IntentsClient intentsClient = await IntentsClient.CreateAsync();

            // Initialize request argument(s)
            CreateIntentRequest request = new CreateIntentRequest
            {
                ParentAsProjectAgentName = new ProjectAgentName("[PROJECT]"),
                Intent = new Intent(),
            };
            // Make the request
            Intent response = await intentsClient.CreateIntentAsync(request);

            // End snippet
        }