Ejemplo n.º 1
0
        /// <summary>Snippet for TrainFlowAsync</summary>
        public async Task TrainFlowResourceNamesAsync()
        {
            // Snippet: TrainFlowAsync(FlowName, CallSettings)
            // Additional: TrainFlowAsync(FlowName, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            FlowName name = FlowName.FromProjectLocationAgentFlow("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]");
            // Make the request
            Operation <Empty, Struct> response = await flowsClient.TrainFlowAsync(name);

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

            // Retrieve the operation result
            Empty result = completedResponse.Result;

            // 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 flowsClient.PollOnceTrainFlowAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Empty retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Ejemplo n.º 2
0
        /// <summary>Snippet for GetFlowValidationResultAsync</summary>
        public async Task GetFlowValidationResultResourceNamesAsync()
        {
            // Snippet: GetFlowValidationResultAsync(FlowValidationResultName, CallSettings)
            // Additional: GetFlowValidationResultAsync(FlowValidationResultName, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            FlowValidationResultName name = FlowValidationResultName.FromProjectLocationAgentFlow("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]");
            // Make the request
            FlowValidationResult response = await flowsClient.GetFlowValidationResultAsync(name);

            // End snippet
        }
Ejemplo n.º 3
0
        /// <summary>Snippet for GetFlowValidationResultAsync</summary>
        public async Task GetFlowValidationResultAsync()
        {
            // Snippet: GetFlowValidationResultAsync(string, CallSettings)
            // Additional: GetFlowValidationResultAsync(string, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/flows/[FLOW]/validationResult";
            // Make the request
            FlowValidationResult response = await flowsClient.GetFlowValidationResultAsync(name);

            // End snippet
        }
Ejemplo n.º 4
0
        /// <summary>Snippet for DeleteFlowAsync</summary>
        public async Task DeleteFlowAsync()
        {
            // Snippet: DeleteFlowAsync(string, CallSettings)
            // Additional: DeleteFlowAsync(string, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/flows/[FLOW]";
            // Make the request
            await flowsClient.DeleteFlowAsync(name);

            // End snippet
        }
Ejemplo n.º 5
0
        /// <summary>Snippet for ListFlowsAsync</summary>
        public async Task ListFlowsRequestObjectAsync()
        {
            // Snippet: ListFlowsAsync(ListFlowsRequest, CallSettings)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            ListFlowsRequest request = new ListFlowsRequest
            {
                ParentAsAgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"),
                LanguageCode      = "",
            };
            // Make the request
            PagedAsyncEnumerable <ListFlowsResponse, Flow> response = flowsClient.ListFlowsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Flow 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((ListFlowsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Flow 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 <Flow> 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 (Flow 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
        }
Ejemplo n.º 6
0
        /// <summary>Snippet for CreateFlowAsync</summary>
        public async Task CreateFlowAsync()
        {
            // Snippet: CreateFlowAsync(string, Flow, CallSettings)
            // Additional: CreateFlowAsync(string, Flow, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]";
            Flow   flow   = new Flow();
            // Make the request
            Flow response = await flowsClient.CreateFlowAsync(parent, flow);

            // End snippet
        }
Ejemplo n.º 7
0
        /// <summary>Snippet for UpdateFlowAsync</summary>
        public async Task UpdateFlowAsync()
        {
            // Snippet: UpdateFlowAsync(Flow, FieldMask, CallSettings)
            // Additional: UpdateFlowAsync(Flow, FieldMask, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            Flow      flow       = new Flow();
            FieldMask updateMask = new FieldMask();
            // Make the request
            Flow response = await flowsClient.UpdateFlowAsync(flow, updateMask);

            // End snippet
        }
Ejemplo n.º 8
0
        /// <summary>Snippet for CreateFlowAsync</summary>
        public async Task CreateFlowResourceNamesAsync()
        {
            // Snippet: CreateFlowAsync(AgentName, Flow, CallSettings)
            // Additional: CreateFlowAsync(AgentName, Flow, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            AgentName parent = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]");
            Flow      flow   = new Flow();
            // Make the request
            Flow response = await flowsClient.CreateFlowAsync(parent, flow);

            // End snippet
        }
Ejemplo n.º 9
0
        /// <summary>Snippet for GetFlowValidationResultAsync</summary>
        public async Task GetFlowValidationResultRequestObjectAsync()
        {
            // Snippet: GetFlowValidationResultAsync(GetFlowValidationResultRequest, CallSettings)
            // Additional: GetFlowValidationResultAsync(GetFlowValidationResultRequest, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            GetFlowValidationResultRequest request = new GetFlowValidationResultRequest
            {
                FlowValidationResultName = FlowValidationResultName.FromProjectLocationAgentFlow("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]"),
                LanguageCode             = "",
            };
            // Make the request
            FlowValidationResult response = await flowsClient.GetFlowValidationResultAsync(request);

            // End snippet
        }
Ejemplo n.º 10
0
        /// <summary>Snippet for DeleteFlowAsync</summary>
        public async Task DeleteFlowRequestObjectAsync()
        {
            // Snippet: DeleteFlowAsync(DeleteFlowRequest, CallSettings)
            // Additional: DeleteFlowAsync(DeleteFlowRequest, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            DeleteFlowRequest request = new DeleteFlowRequest
            {
                FlowName = FlowName.FromProjectLocationAgentFlow("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]"),
                Force    = false,
            };
            // Make the request
            await flowsClient.DeleteFlowAsync(request);

            // End snippet
        }
Ejemplo n.º 11
0
        /// <summary>Snippet for UpdateFlowAsync</summary>
        public async Task UpdateFlowRequestObjectAsync()
        {
            // Snippet: UpdateFlowAsync(UpdateFlowRequest, CallSettings)
            // Additional: UpdateFlowAsync(UpdateFlowRequest, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            UpdateFlowRequest request = new UpdateFlowRequest
            {
                Flow         = new Flow(),
                UpdateMask   = new FieldMask(),
                LanguageCode = "",
            };
            // Make the request
            Flow response = await flowsClient.UpdateFlowAsync(request);

            // End snippet
        }
Ejemplo n.º 12
0
        /// <summary>Snippet for CreateFlowAsync</summary>
        public async Task CreateFlowRequestObjectAsync()
        {
            // Snippet: CreateFlowAsync(CreateFlowRequest, CallSettings)
            // Additional: CreateFlowAsync(CreateFlowRequest, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            CreateFlowRequest request = new CreateFlowRequest
            {
                ParentAsAgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"),
                Flow         = new Flow(),
                LanguageCode = "",
            };
            // Make the request
            Flow response = await flowsClient.CreateFlowAsync(request);

            // End snippet
        }
Ejemplo n.º 13
0
        /// <summary>Snippet for ExportFlowAsync</summary>
        public async Task ExportFlowRequestObjectAsync()
        {
            // Snippet: ExportFlowAsync(ExportFlowRequest, CallSettings)
            // Additional: ExportFlowAsync(ExportFlowRequest, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            ExportFlowRequest request = new ExportFlowRequest
            {
                FlowName = FlowName.FromProjectLocationAgentFlow("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]"),
                FlowUri  = "",
                IncludeReferencedFlows = false,
            };
            // Make the request
            Operation <ExportFlowResponse, Struct> response = await flowsClient.ExportFlowAsync(request);

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

            // Retrieve the operation result
            ExportFlowResponse result = completedResponse.Result;

            // 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 <ExportFlowResponse, Struct> retrievedResponse = await flowsClient.PollOnceExportFlowAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                ExportFlowResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Ejemplo n.º 14
0
        /// <summary>Snippet for ImportFlowAsync</summary>
        public async Task ImportFlowRequestObjectAsync()
        {
            // Snippet: ImportFlowAsync(ImportFlowRequest, CallSettings)
            // Additional: ImportFlowAsync(ImportFlowRequest, CancellationToken)
            // Create client
            FlowsClient flowsClient = await FlowsClient.CreateAsync();

            // Initialize request argument(s)
            ImportFlowRequest request = new ImportFlowRequest
            {
                ParentAsAgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"),
                FlowUri           = "",
                ImportOption      = ImportFlowRequest.Types.ImportOption.Unspecified,
            };
            // Make the request
            Operation <ImportFlowResponse, Struct> response = await flowsClient.ImportFlowAsync(request);

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

            // Retrieve the operation result
            ImportFlowResponse result = completedResponse.Result;

            // 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 <ImportFlowResponse, Struct> retrievedResponse = await flowsClient.PollOnceImportFlowAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                ImportFlowResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }