/// <summary>Snippet for UpdateWorkflowAsync</summary> public async Task UpdateWorkflowAsync() { // Snippet: UpdateWorkflowAsync(Workflow, FieldMask, CallSettings) // Additional: UpdateWorkflowAsync(Workflow, FieldMask, CancellationToken) // Create client WorkflowsClient workflowsClient = await WorkflowsClient.CreateAsync(); // Initialize request argument(s) Workflow workflow = new Workflow(); FieldMask updateMask = new FieldMask(); // Make the request Operation <Workflow, OperationMetadata> response = await workflowsClient.UpdateWorkflowAsync(workflow, updateMask); // Poll until the returned long-running operation is complete Operation <Workflow, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Workflow 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 <Workflow, OperationMetadata> retrievedResponse = await workflowsClient.PollOnceUpdateWorkflowAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Workflow retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for DeleteWorkflowAsync</summary> public async Task DeleteWorkflowResourceNamesAsync() { // Snippet: DeleteWorkflowAsync(WorkflowName, CallSettings) // Additional: DeleteWorkflowAsync(WorkflowName, CancellationToken) // Create client WorkflowsClient workflowsClient = await WorkflowsClient.CreateAsync(); // Initialize request argument(s) WorkflowName name = WorkflowName.FromProjectLocationWorkflow("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); // Make the request Operation <Empty, OperationMetadata> response = await workflowsClient.DeleteWorkflowAsync(name); // Poll until the returned long-running operation is complete Operation <Empty, OperationMetadata> 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, OperationMetadata> retrievedResponse = await workflowsClient.PollOnceDeleteWorkflowAsync(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 }
/// <summary>Snippet for CreateWorkflowAsync</summary> public async Task CreateWorkflowResourceNamesAsync() { // Snippet: CreateWorkflowAsync(LocationName, Workflow, string, CallSettings) // Additional: CreateWorkflowAsync(LocationName, Workflow, string, CancellationToken) // Create client WorkflowsClient workflowsClient = await WorkflowsClient.CreateAsync(); // Initialize request argument(s) LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"); Workflow workflow = new Workflow(); string workflowId = ""; // Make the request Operation <Workflow, OperationMetadata> response = await workflowsClient.CreateWorkflowAsync(parent, workflow, workflowId); // Poll until the returned long-running operation is complete Operation <Workflow, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Workflow 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 <Workflow, OperationMetadata> retrievedResponse = await workflowsClient.PollOnceCreateWorkflowAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Workflow retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for ListWorkflowsAsync</summary> public async Task ListWorkflowsRequestObjectAsync() { // Snippet: ListWorkflowsAsync(ListWorkflowsRequest, CallSettings) // Create client WorkflowsClient workflowsClient = await WorkflowsClient.CreateAsync(); // Initialize request argument(s) ListWorkflowsRequest request = new ListWorkflowsRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Filter = "", OrderBy = "", }; // Make the request PagedAsyncEnumerable <ListWorkflowsResponse, Workflow> response = workflowsClient.ListWorkflowsAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((Workflow 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((ListWorkflowsResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Workflow 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 <Workflow> 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 (Workflow 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 GetWorkflowAsync</summary> public async Task GetWorkflowResourceNamesAsync() { // Snippet: GetWorkflowAsync(WorkflowName, CallSettings) // Additional: GetWorkflowAsync(WorkflowName, CancellationToken) // Create client WorkflowsClient workflowsClient = await WorkflowsClient.CreateAsync(); // Initialize request argument(s) WorkflowName name = WorkflowName.FromProjectLocationWorkflow("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); // Make the request Workflow response = await workflowsClient.GetWorkflowAsync(name); // End snippet }
/// <summary>Snippet for GetWorkflowAsync</summary> public async Task GetWorkflowAsync() { // Snippet: GetWorkflowAsync(string, CallSettings) // Additional: GetWorkflowAsync(string, CancellationToken) // Create client WorkflowsClient workflowsClient = await WorkflowsClient.CreateAsync(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/workflows/[WORKFLOW]"; // Make the request Workflow response = await workflowsClient.GetWorkflowAsync(name); // End snippet }