For more information about desired capacity, see What Is Auto Scaling? in the Auto Scaling User Guide.
protected override void ProcessRecord() { AmazonAutoScaling client = base.GetClient(); Amazon.AutoScaling.Model.SetDesiredCapacityRequest request = new Amazon.AutoScaling.Model.SetDesiredCapacityRequest(); request.AutoScalingGroupName = this._AutoScalingGroupName; request.DesiredCapacity = this._DesiredCapacity; Amazon.AutoScaling.Model.SetDesiredCapacityResponse response = client.SetDesiredCapacity(request); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.AutoScaling.Model.SetDesiredCapacityRequest(); if (cmdletContext.AutoScalingGroupName != null) { request.AutoScalingGroupName = cmdletContext.AutoScalingGroupName; } if (cmdletContext.DesiredCapacity != null) { request.DesiredCapacity = cmdletContext.DesiredCapacity.Value; } if (cmdletContext.HonorCooldown != null) { request.HonorCooldown = cmdletContext.HonorCooldown.Value; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); }
/// <summary> /// Initiates the asynchronous execution of the SetDesiredCapacity operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the SetDesiredCapacity operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<SetDesiredCapacityResponse> SetDesiredCapacityAsync(SetDesiredCapacityRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new SetDesiredCapacityRequestMarshaller(); var unmarshaller = SetDesiredCapacityResponseUnmarshaller.Instance; return InvokeAsync<SetDesiredCapacityRequest,SetDesiredCapacityResponse>(request, marshaller, unmarshaller, cancellationToken); }
internal SetDesiredCapacityResponse SetDesiredCapacity(SetDesiredCapacityRequest request) { var marshaller = new SetDesiredCapacityRequestMarshaller(); var unmarshaller = SetDesiredCapacityResponseUnmarshaller.Instance; return Invoke<SetDesiredCapacityRequest,SetDesiredCapacityResponse>(request, marshaller, unmarshaller); }
IAsyncResult invokeSetDesiredCapacity(SetDesiredCapacityRequest setDesiredCapacityRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new SetDesiredCapacityRequestMarshaller().Marshall(setDesiredCapacityRequest); var unmarshaller = SetDesiredCapacityResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the SetDesiredCapacity operation. /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling.SetDesiredCapacity"/> /// </summary> /// /// <param name="setDesiredCapacityRequest">Container for the necessary parameters to execute the SetDesiredCapacity operation on /// AmazonAutoScaling.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> public IAsyncResult BeginSetDesiredCapacity(SetDesiredCapacityRequest setDesiredCapacityRequest, AsyncCallback callback, object state) { return invokeSetDesiredCapacity(setDesiredCapacityRequest, callback, state, false); }
/// <summary> /// <para> Sets the desired size of the specified AutoScalingGroup. </para> /// </summary> /// /// <param name="setDesiredCapacityRequest">Container for the necessary parameters to execute the SetDesiredCapacity service method on /// AmazonAutoScaling.</param> /// /// <exception cref="ScalingActivityInProgressException"/> public SetDesiredCapacityResponse SetDesiredCapacity(SetDesiredCapacityRequest setDesiredCapacityRequest) { IAsyncResult asyncResult = invokeSetDesiredCapacity(setDesiredCapacityRequest, null, null, true); return EndSetDesiredCapacity(asyncResult); }
/// <summary> /// Initiates the asynchronous execution of the SetDesiredCapacity operation. /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling.SetDesiredCapacity"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the SetDesiredCapacity operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<SetDesiredCapacityResponse> SetDesiredCapacityAsync(SetDesiredCapacityRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new SetDesiredCapacityRequestMarshaller(); var unmarshaller = SetDesiredCapacityResponseUnmarshaller.GetInstance(); return Invoke<IRequest, SetDesiredCapacityRequest, SetDesiredCapacityResponse>(request, marshaller, unmarshaller, signer, cancellationToken); }
/// <summary> /// <para> Sets the desired size of the specified AutoScalingGroup. </para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the SetDesiredCapacity service method on /// AmazonAutoScaling.</param> /// /// <exception cref="T:Amazon.AutoScaling.Model.ScalingActivityInProgressException" /> public SetDesiredCapacityResponse SetDesiredCapacity(SetDesiredCapacityRequest request) { var task = SetDesiredCapacityAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
private Amazon.AutoScaling.Model.SetDesiredCapacityResponse CallAWSServiceOperation(IAmazonAutoScaling client, Amazon.AutoScaling.Model.SetDesiredCapacityRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Auto Scaling", "SetDesiredCapacity"); try { #if DESKTOP return(client.SetDesiredCapacity(request)); #elif CORECLR return(client.SetDesiredCapacityAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
/// <summary> /// Initiates the asynchronous execution of the SetDesiredCapacity operation. /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the SetDesiredCapacity operation on AmazonAutoScalingClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndSetDesiredCapacity /// operation.</returns> public IAsyncResult BeginSetDesiredCapacity(SetDesiredCapacityRequest request, AsyncCallback callback, object state) { var marshaller = new SetDesiredCapacityRequestMarshaller(); var unmarshaller = SetDesiredCapacityResponseUnmarshaller.Instance; return BeginInvoke<SetDesiredCapacityRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Callback function for BeginUpdateAutoScalingGroup async call to update an ASG based on user changes in AsgWindow /// </summary> /// <param name="result"></param> private void UpdateAutoScaleGroupCallback(IAsyncResult result) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { AmazonAutoScalingClient client = GetAutoScaleClient(); UpdateAutoScalingGroupResponse resp = client.EndUpdateAutoScalingGroup(result); if (vm.ASGroup.DesiredCapacity != vm.SelectedAutoScalingGroup.AutoScalingGroup.DesiredCapacity) { if (vm.ASGroup.DesiredCapacity > vm.ASGroup.MaxSize) { vm.ASGroup.DesiredCapacity = vm.ASGroup.MaxSize; } if (vm.ASGroup.DesiredCapacity < vm.ASGroup.MinSize) { vm.ASGroup.DesiredCapacity = vm.ASGroup.MinSize; } if (((ViewModel)this.DataContext).ASGroup.DesiredCapacity != 0) { vm.IsBusy = true; SetDesiredCapacityRequest sdcreq = new SetDesiredCapacityRequest(); sdcreq.AutoScalingGroupName = vm.SelectedAutoScalingGroup.AutoScalingGroup.AutoScalingGroupName; sdcreq.DesiredCapacity = vm.ASGroup.DesiredCapacity; IAsyncResult sdcresult = client.BeginSetDesiredCapacity(sdcreq, SetDesiredCapacityCallback, null); return; } vm.ASGroup = new Models.AsgShell(); DescribeAutoScalingGroupsRequest asreq = new DescribeAutoScalingGroupsRequest(); IAsyncResult asresult = client.BeginDescribeAutoScalingGroups(asreq, AutoScalingGroupInfoCallback, "full"); } else { vm.IsBusy = false; } vm.ASGroup = null; })); }
/// <summary> /// <para> Adjusts the desired size of the AutoScalingGroup by initiating scaling activities. When reducing the size of the group, it is not /// possible to define which Amazon EC2 instances will be terminated. This applies to any Auto Scaling decisions that might result in /// terminating instances. </para> <para> There are two common use cases for <c>SetDesiredCapacity</c> : /// one for users of the Auto Scaling triggering system, and another for developers who write their own triggering systems. Both use /// cases relate to the concept of cooldown. </para> <para> In the first case, if you use the Auto Scaling triggering system, /// <c>SetDesiredCapacity</c> changes the size of your Auto Scaling group without regard to the cooldown period. This could be useful, for /// example, if Auto Scaling did something unexpected for some reason. If your cooldown period is 10 minutes, Auto Scaling would normally reject /// requests to change the size of the group for that entire 10-minute period. The <c>SetDesiredCapacity</c> command allows you to circumvent /// this restriction and change the size of the group before the end of the cooldown period. </para> <para> In the second case, if you write /// your own triggering system, you can use <c>SetDesiredCapacity</c> to control the size of your Auto Scaling group. If you want the same /// cooldown functionality that Auto Scaling offers, you can configure <c>SetDesiredCapacity</c> to honor cooldown by setting the /// <c>HonorCooldown</c> parameter to <c>true</c> . /// </para> /// </summary> /// /// <param name="setDesiredCapacityRequest">Container for the necessary parameters to execute the SetDesiredCapacity service method on /// AmazonAutoScaling.</param> /// /// <exception cref="ScalingActivityInProgressException"/> public SetDesiredCapacityResponse SetDesiredCapacity(SetDesiredCapacityRequest setDesiredCapacityRequest) { IRequest<SetDesiredCapacityRequest> request = new SetDesiredCapacityRequestMarshaller().Marshall(setDesiredCapacityRequest); SetDesiredCapacityResponse response = Invoke<SetDesiredCapacityRequest, SetDesiredCapacityResponse> (request, this.signer, SetDesiredCapacityResponseUnmarshaller.GetInstance()); return response; }
internal SetDesiredCapacityResponse SetDesiredCapacity(SetDesiredCapacityRequest request) { var task = SetDesiredCapacityAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// Initiates the asynchronous execution of the SetDesiredCapacity operation. /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling.SetDesiredCapacity"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the SetDesiredCapacity operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public async Task<SetDesiredCapacityResponse> SetDesiredCapacityAsync(SetDesiredCapacityRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new SetDesiredCapacityRequestMarshaller(); var unmarshaller = SetDesiredCapacityResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, SetDesiredCapacityRequest, SetDesiredCapacityResponse>(request, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }