/// <summary>Snippet for CreateWorkflow</summary> public void CreateWorkflowRequestObject() { // Snippet: CreateWorkflow(CreateWorkflowRequest, CallSettings) // Create client WorkflowsClient workflowsClient = WorkflowsClient.Create(); // Initialize request argument(s) CreateWorkflowRequest request = new CreateWorkflowRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Workflow = new Workflow(), WorkflowId = "", }; // Make the request Operation <Workflow, OperationMetadata> response = workflowsClient.CreateWorkflow(request); // Poll until the returned long-running operation is complete Operation <Workflow, OperationMetadata> completedResponse = response.PollUntilCompleted(); // 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 = workflowsClient.PollOnceCreateWorkflow(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 GetWorkflow</summary> public void GetWorkflowResourceNames() { // Snippet: GetWorkflow(WorkflowName, CallSettings) // Create client WorkflowsClient workflowsClient = WorkflowsClient.Create(); // Initialize request argument(s) WorkflowName name = WorkflowName.FromProjectLocationWorkflow("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); // Make the request Workflow response = workflowsClient.GetWorkflow(name); // End snippet }
/// <summary>Snippet for GetWorkflow</summary> public void GetWorkflow() { // Snippet: GetWorkflow(string, CallSettings) // Create client WorkflowsClient workflowsClient = WorkflowsClient.Create(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/workflows/[WORKFLOW]"; // Make the request Workflow response = workflowsClient.GetWorkflow(name); // 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 }
/// <summary>Snippet for GetWorkflow</summary> public void GetWorkflowRequestObject() { // Snippet: GetWorkflow(GetWorkflowRequest, CallSettings) // Create client WorkflowsClient workflowsClient = WorkflowsClient.Create(); // Initialize request argument(s) GetWorkflowRequest request = new GetWorkflowRequest { WorkflowName = WorkflowName.FromProjectLocationWorkflow("[PROJECT]", "[LOCATION]", "[WORKFLOW]"), }; // Make the request Workflow response = workflowsClient.GetWorkflow(request); // End snippet }
/// <summary>Snippet for ListWorkflows</summary> public void ListWorkflowsResourceNames() { // Snippet: ListWorkflows(LocationName, string, int?, CallSettings) // Create client WorkflowsClient workflowsClient = WorkflowsClient.Create(); // Initialize request argument(s) LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"); // Make the request PagedEnumerable <ListWorkflowsResponse, Workflow> response = workflowsClient.ListWorkflows(parent); // Iterate over all response items, lazily performing RPCs as required foreach (Workflow item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (ListWorkflowsResponse page in response.AsRawResponses()) { // 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 = response.ReadPage(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 }