/// <summary>Snippet for CreateAutoscalingPolicyAsync</summary> public async Task CreateAutoscalingPolicyResourceNames2Async() { // Snippet: CreateAutoscalingPolicyAsync(RegionName, AutoscalingPolicy, CallSettings) // Additional: CreateAutoscalingPolicyAsync(RegionName, AutoscalingPolicy, CancellationToken) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) RegionName parent = RegionName.FromProjectRegion("[PROJECT]", "[REGION]"); AutoscalingPolicy policy = new AutoscalingPolicy(); // Make the request AutoscalingPolicy response = await autoscalingPolicyServiceClient.CreateAutoscalingPolicyAsync(parent, policy); // End snippet }
/// <summary>Snippet for CreateAutoscalingPolicyAsync</summary> public async Task CreateAutoscalingPolicyAsync() { // Snippet: CreateAutoscalingPolicyAsync(string, AutoscalingPolicy, CallSettings) // Additional: CreateAutoscalingPolicyAsync(string, AutoscalingPolicy, CancellationToken) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) string parent = "projects/[PROJECT]/locations/[LOCATION]"; AutoscalingPolicy policy = new AutoscalingPolicy(); // Make the request AutoscalingPolicy response = await autoscalingPolicyServiceClient.CreateAutoscalingPolicyAsync(parent, policy); // End snippet }
/// <summary>Snippet for CreateAutoscalingPolicyAsync</summary> public async Task CreateAutoscalingPolicyAsync() { // Snippet: CreateAutoscalingPolicyAsync(string,AutoscalingPolicy,CallSettings) // Additional: CreateAutoscalingPolicyAsync(string,AutoscalingPolicy,CancellationToken) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) string formattedParent = new RegionName("[PROJECT]", "[REGION]").ToString(); AutoscalingPolicy policy = new AutoscalingPolicy(); // Make the request AutoscalingPolicy response = await autoscalingPolicyServiceClient.CreateAutoscalingPolicyAsync(formattedParent, policy); // End snippet }
/// <summary>Snippet for ListAutoscalingPolicies</summary> public async Task ListAutoscalingPoliciesRequestObjectAsync() { // Snippet: ListAutoscalingPoliciesAsync(ListAutoscalingPoliciesRequest, CallSettings) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) ListAutoscalingPoliciesRequest request = new ListAutoscalingPoliciesRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), }; // Make the request PagedAsyncEnumerable <ListAutoscalingPoliciesResponse, AutoscalingPolicy> response = autoscalingPolicyServiceClient.ListAutoscalingPoliciesAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((AutoscalingPolicy 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((ListAutoscalingPoliciesResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (AutoscalingPolicy 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 <AutoscalingPolicy> 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 (AutoscalingPolicy 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 DeleteAutoscalingPolicyAsync</summary> public async Task DeleteAutoscalingPolicyRequestObjectAsync() { // Snippet: DeleteAutoscalingPolicyAsync(DeleteAutoscalingPolicyRequest, CallSettings) // Additional: DeleteAutoscalingPolicyAsync(DeleteAutoscalingPolicyRequest, CancellationToken) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) DeleteAutoscalingPolicyRequest request = new DeleteAutoscalingPolicyRequest { AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), }; // Make the request await autoscalingPolicyServiceClient.DeleteAutoscalingPolicyAsync(request); // End snippet }
/// <summary>Snippet for UpdateAutoscalingPolicyAsync</summary> public async Task UpdateAutoscalingPolicyRequestObjectAsync() { // Snippet: UpdateAutoscalingPolicyAsync(UpdateAutoscalingPolicyRequest, CallSettings) // Additional: UpdateAutoscalingPolicyAsync(UpdateAutoscalingPolicyRequest, CancellationToken) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) UpdateAutoscalingPolicyRequest request = new UpdateAutoscalingPolicyRequest { Policy = new AutoscalingPolicy(), }; // Make the request AutoscalingPolicy response = await autoscalingPolicyServiceClient.UpdateAutoscalingPolicyAsync(request); // End snippet }
/// <summary>Snippet for GetAutoscalingPolicyAsync</summary> public async Task GetAutoscalingPolicyAsync_RequestObject() { // Snippet: GetAutoscalingPolicyAsync(GetAutoscalingPolicyRequest,CallSettings) // Additional: GetAutoscalingPolicyAsync(GetAutoscalingPolicyRequest,CancellationToken) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) GetAutoscalingPolicyRequest request = new GetAutoscalingPolicyRequest { Name = new AutoscalingPolicyName("[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]").ToString(), }; // Make the request AutoscalingPolicy response = await autoscalingPolicyServiceClient.GetAutoscalingPolicyAsync(request); // End snippet }
/// <summary>Snippet for CreateAutoscalingPolicyAsync</summary> public async Task CreateAutoscalingPolicyRequestObjectAsync() { // Snippet: CreateAutoscalingPolicyAsync(CreateAutoscalingPolicyRequest, CallSettings) // Additional: CreateAutoscalingPolicyAsync(CreateAutoscalingPolicyRequest, CancellationToken) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) CreateAutoscalingPolicyRequest request = new CreateAutoscalingPolicyRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Policy = new AutoscalingPolicy(), }; // Make the request AutoscalingPolicy response = await autoscalingPolicyServiceClient.CreateAutoscalingPolicyAsync(request); // End snippet }