/// <summary>Snippet for CreateWorkloadAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task CreateWorkloadAsync() { // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) string parent = "organizations/[ORGANIZATION]/locations/[LOCATION]"; Workload workload = new Workload(); // Make the request Operation <Workload, CreateWorkloadOperationMetadata> response = await assuredWorkloadsServiceClient.CreateWorkloadAsync(parent, workload); // Poll until the returned long-running operation is complete Operation <Workload, CreateWorkloadOperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Workload 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 <Workload, CreateWorkloadOperationMetadata> retrievedResponse = await assuredWorkloadsServiceClient.PollOnceCreateWorkloadAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Workload retrievedResult = retrievedResponse.Result; } }
/// <summary>Snippet for CreateWorkloadAsync</summary> public async Task CreateWorkloadResourceNamesAsync() { // Snippet: CreateWorkloadAsync(LocationName, Workload, CallSettings) // Additional: CreateWorkloadAsync(LocationName, Workload, CancellationToken) // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) LocationName parent = LocationName.FromOrganizationLocation("[ORGANIZATION]", "[LOCATION]"); Workload workload = new Workload(); // Make the request Operation <Workload, CreateWorkloadOperationMetadata> response = await assuredWorkloadsServiceClient.CreateWorkloadAsync(parent, workload); // Poll until the returned long-running operation is complete Operation <Workload, CreateWorkloadOperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Workload 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 <Workload, CreateWorkloadOperationMetadata> retrievedResponse = await assuredWorkloadsServiceClient.PollOnceCreateWorkloadAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Workload retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for GetWorkloadAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetWorkloadAsync() { // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) string name = "organizations/[ORGANIZATION]/locations/[LOCATION]/workloads/[WORKLOAD]"; // Make the request Workload response = await assuredWorkloadsServiceClient.GetWorkloadAsync(name); }
/// <summary>Snippet for GetWorkloadAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetWorkloadResourceNamesAsync() { // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) WorkloadName name = WorkloadName.FromOrganizationLocationWorkload("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]"); // Make the request Workload response = await assuredWorkloadsServiceClient.GetWorkloadAsync(name); }
/// <summary>Snippet for UpdateWorkloadAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task UpdateWorkloadAsync() { // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) Workload workload = new Workload(); FieldMask updateMask = new FieldMask(); // Make the request Workload response = await assuredWorkloadsServiceClient.UpdateWorkloadAsync(workload, updateMask); }
/// <summary>Snippet for GetWorkloadAsync</summary> public async Task GetWorkloadResourceNamesAsync() { // Snippet: GetWorkloadAsync(WorkloadName, CallSettings) // Additional: GetWorkloadAsync(WorkloadName, CancellationToken) // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) WorkloadName name = WorkloadName.FromOrganizationLocationWorkload("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]"); // Make the request Workload response = await assuredWorkloadsServiceClient.GetWorkloadAsync(name); // End snippet }
/// <summary>Snippet for GetWorkloadAsync</summary> public async Task GetWorkloadAsync() { // Snippet: GetWorkloadAsync(string, CallSettings) // Additional: GetWorkloadAsync(string, CancellationToken) // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) string name = "organizations/[ORGANIZATION]/locations/[LOCATION]/workloads/[WORKLOAD]"; // Make the request Workload response = await assuredWorkloadsServiceClient.GetWorkloadAsync(name); // End snippet }
/// <summary>Snippet for DeleteWorkloadAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task DeleteWorkloadRequestObjectAsync() { // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) DeleteWorkloadRequest request = new DeleteWorkloadRequest { WorkloadName = WorkloadName.FromOrganizationLocationWorkload("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]"), Etag = "", }; // Make the request await assuredWorkloadsServiceClient.DeleteWorkloadAsync(request); }
/// <summary>Snippet for UpdateWorkloadAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task UpdateWorkloadRequestObjectAsync() { // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) UpdateWorkloadRequest request = new UpdateWorkloadRequest { Workload = new Workload(), UpdateMask = new FieldMask(), }; // Make the request Workload response = await assuredWorkloadsServiceClient.UpdateWorkloadAsync(request); }
/// <summary>Snippet for ListWorkloadsAsync</summary> public async Task ListWorkloadsRequestObjectAsync() { // Snippet: ListWorkloadsAsync(ListWorkloadsRequest, CallSettings) // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) ListWorkloadsRequest request = new ListWorkloadsRequest { ParentAsLocationName = LocationName.FromOrganizationLocation("[ORGANIZATION]", "[LOCATION]"), Filter = "", }; // Make the request PagedAsyncEnumerable <ListWorkloadsResponse, Workload> response = assuredWorkloadsServiceClient.ListWorkloadsAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((Workload 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((ListWorkloadsResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Workload 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 <Workload> 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 (Workload 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 UpdateWorkloadAsync</summary> public async Task UpdateWorkloadAsync() { // Snippet: UpdateWorkloadAsync(Workload, FieldMask, CallSettings) // Additional: UpdateWorkloadAsync(Workload, FieldMask, CancellationToken) // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) Workload workload = new Workload(); FieldMask updateMask = new FieldMask(); // Make the request Workload response = await assuredWorkloadsServiceClient.UpdateWorkloadAsync(workload, updateMask); // End snippet }
/// <summary>Snippet for DeleteWorkloadAsync</summary> public async Task DeleteWorkloadRequestObjectAsync() { // Snippet: DeleteWorkloadAsync(DeleteWorkloadRequest, CallSettings) // Additional: DeleteWorkloadAsync(DeleteWorkloadRequest, CancellationToken) // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) DeleteWorkloadRequest request = new DeleteWorkloadRequest { WorkloadName = WorkloadName.FromOrganizationLocationWorkload("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]"), Etag = "", }; // Make the request await assuredWorkloadsServiceClient.DeleteWorkloadAsync(request); // End snippet }
/// <summary>Snippet for UpdateWorkloadAsync</summary> public async Task UpdateWorkloadRequestObjectAsync() { // Snippet: UpdateWorkloadAsync(UpdateWorkloadRequest, CallSettings) // Additional: UpdateWorkloadAsync(UpdateWorkloadRequest, CancellationToken) // Create client AssuredWorkloadsServiceClient assuredWorkloadsServiceClient = await AssuredWorkloadsServiceClient.CreateAsync(); // Initialize request argument(s) UpdateWorkloadRequest request = new UpdateWorkloadRequest { Workload = new Workload(), UpdateMask = new FieldMask(), }; // Make the request Workload response = await assuredWorkloadsServiceClient.UpdateWorkloadAsync(request); // End snippet }