protected override void ProcessRecord()
 {
     AmazonAutoScaling client = base.GetClient();
     Amazon.AutoScaling.Model.DescribeAutoScalingGroupsRequest request = new Amazon.AutoScaling.Model.DescribeAutoScalingGroupsRequest();
     if (string.IsNullOrEmpty(this._AutoScalingGroupNames))
     {
         request.AutoScalingGroupNames.Add(this._AutoScalingGroupNames);
     }
     Amazon.AutoScaling.Model.DescribeAutoScalingGroupsResponse response = client.DescribeAutoScalingGroups(request);
     base.WriteObject(response.DescribeAutoScalingGroupsResult, true);
 }
        /// <summary>
        /// <para> Returns a full description of each Auto Scaling group in the given list. This includes all Amazon EC2 instances that are members of
        /// the group. If a list of names is not provided, the service returns the full details of all Auto Scaling groups. </para> <para> This action
        /// supports pagination by returning a token if there are more pages to retrieve. To get the next page, call this action again with the returned
        /// token as the <c>NextToken</c> parameter. </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAutoScalingGroups service
        /// method on AmazonAutoScaling.</param>
        /// 
        /// <returns>The response from the DescribeAutoScalingGroups service method, as returned by AmazonAutoScaling.</returns>
        /// 
        /// <exception cref="T:Amazon.AutoScaling.Model.InvalidNextTokenException" />
		public DescribeAutoScalingGroupsResponse DescribeAutoScalingGroups(DescribeAutoScalingGroupsRequest request)
        {
            var task = DescribeAutoScalingGroupsAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeAutoScalingGroups operation.
        /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAutoScalingGroups 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 EndDescribeAutoScalingGroups
        ///         operation.</returns>
        public IAsyncResult BeginDescribeAutoScalingGroups(DescribeAutoScalingGroupsRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new DescribeAutoScalingGroupsRequestMarshaller();
            var unmarshaller = DescribeAutoScalingGroupsResponseUnmarshaller.Instance;

            return BeginInvoke<DescribeAutoScalingGroupsRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
		internal DescribeAutoScalingGroupsResponse DescribeAutoScalingGroups(DescribeAutoScalingGroupsRequest request)
        {
            var task = DescribeAutoScalingGroupsAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
Exemplo n.º 5
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext      = context as CmdletContext;
            var useParameterSelect = this.Select.StartsWith("^") || this.PassThru.IsPresent;

            // create request and set iteration invariants
            var request = new Amazon.AutoScaling.Model.DescribeAutoScalingGroupsRequest();

            if (cmdletContext.AutoScalingGroupName != null)
            {
                request.AutoScalingGroupNames = cmdletContext.AutoScalingGroupName;
            }
            if (cmdletContext.Filter != null)
            {
                request.Filters = cmdletContext.Filter;
            }

            // Initialize loop variants and commence piping
            System.String _nextToken      = null;
            int?          _emitLimit      = null;
            int           _retrievedSoFar = 0;

            if (AutoIterationHelpers.HasValue(cmdletContext.NextToken))
            {
                _nextToken = cmdletContext.NextToken;
            }
            if (cmdletContext.MaxRecord.HasValue)
            {
                _emitLimit = cmdletContext.MaxRecord;
            }
            var _userControllingPaging = this.NoAutoIteration.IsPresent || ParameterWasBound(nameof(this.NextToken));

            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            do
            {
                request.NextToken = _nextToken;
                if (_emitLimit.HasValue)
                {
                    request.MaxRecords = AutoIterationHelpers.ConvertEmitLimitToInt32(_emitLimit.Value);
                }

                CmdletOutput output;

                try
                {
                    var    response       = CallAWSServiceOperation(client, request);
                    object pipelineOutput = null;
                    if (!useParameterSelect)
                    {
                        pipelineOutput = cmdletContext.Select(response, this);
                    }
                    output = new CmdletOutput
                    {
                        PipelineOutput  = pipelineOutput,
                        ServiceResponse = response
                    };
                    int _receivedThisCall = response.AutoScalingGroups.Count;

                    _nextToken       = response.NextToken;
                    _retrievedSoFar += _receivedThisCall;
                    if (_emitLimit.HasValue)
                    {
                        _emitLimit -= _receivedThisCall;
                    }
                }
                catch (Exception e)
                {
                    if (_retrievedSoFar == 0 || !_emitLimit.HasValue)
                    {
                        output = new CmdletOutput {
                            ErrorResponse = e
                        };
                    }
                    else
                    {
                        break;
                    }
                }

                ProcessOutput(output);
            } while (!_userControllingPaging && AutoIterationHelpers.HasValue(_nextToken) && (!_emitLimit.HasValue || _emitLimit.Value >= 1));


            if (useParameterSelect)
            {
                WriteObject(cmdletContext.Select(null, this));
            }


            return(null);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeAutoScalingGroups operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAutoScalingGroups 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<DescribeAutoScalingGroupsResponse> DescribeAutoScalingGroupsAsync(DescribeAutoScalingGroupsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DescribeAutoScalingGroupsRequestMarshaller();
            var unmarshaller = DescribeAutoScalingGroupsResponseUnmarshaller.Instance;

            return InvokeAsync<DescribeAutoScalingGroupsRequest,DescribeAutoScalingGroupsResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
 /// <summary>
 /// <para> Returns a full description of each Auto Scaling group in the given list. This includes all Amazon EC2 instances that are members of
 /// the group. If a list of names is not provided, the service returns the full details of all Auto Scaling groups. </para> <para> This action
 /// supports pagination by returning a token if there are more pages to retrieve. To get the next page, call this action again with the returned
 /// token as the <c>NextToken</c> parameter. </para>
 /// </summary>
 /// 
 /// <param name="describeAutoScalingGroupsRequest">Container for the necessary parameters to execute the DescribeAutoScalingGroups service
 ///          method on AmazonAutoScaling.</param>
 /// 
 /// <returns>The response from the DescribeAutoScalingGroups service method, as returned by AmazonAutoScaling.</returns>
 /// 
 /// <exception cref="InvalidNextTokenException"/>
 public DescribeAutoScalingGroupsResponse DescribeAutoScalingGroups(DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest)
 {
     IAsyncResult asyncResult = invokeDescribeAutoScalingGroups(describeAutoScalingGroupsRequest, null, null, true);
     return EndDescribeAutoScalingGroups(asyncResult);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the DescribeAutoScalingGroups operation.
 /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling.DescribeAutoScalingGroups"/>
 /// </summary>
 /// 
 /// <param name="describeAutoScalingGroupsRequest">Container for the necessary parameters to execute the DescribeAutoScalingGroups 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>
 /// 
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking
 ///         EndDescribeAutoScalingGroups operation.</returns>
 public IAsyncResult BeginDescribeAutoScalingGroups(DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest, AsyncCallback callback, object state)
 {
     return invokeDescribeAutoScalingGroups(describeAutoScalingGroupsRequest, callback, state, false);
 }
        /// <summary>
        /// Callback function for BeginDescribeAutoScalingGroups async call to monitor the shutdown of a ASG
        /// </summary>
        /// <param name="result"></param>
        private void AutoScalingGroupShutdownInfoCallback(IAsyncResult result)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                AmazonAutoScalingClient client = GetAutoScaleClient();
                DescribeAutoScalingGroupsResponse resp = client.EndDescribeAutoScalingGroups(result);
                List<AutoScalingGroup> asgroups = resp.DescribeAutoScalingGroupsResult.AutoScalingGroups;
                foreach (AutoScalingGroup asg in asgroups)
                {
                    if (asg.AutoScalingGroupName == ((ViewModel)this.DataContext).SelectedAutoScalingGroup.AutoScalingGroup.AutoScalingGroupName)
                    {
                        if (asg.Instances.Count() == 0)
                        {
                            shutdownTimer.Stop();
                            if (result.AsyncState != null)
                            {
                                ((ViewModel)this.DataContext).BusyContent = "Scanning Auto Scaling Activities";
                                shutdownTimer.Tag = "activities";
                                shutdownTimer.Start();
                            }
                            else
                            {
                                DescribeAutoScalingGroupsRequest asreq = new DescribeAutoScalingGroupsRequest();
                                IAsyncResult asresult = client.BeginDescribeAutoScalingGroups(asreq, AutoScalingGroupInfoCallback, "full");
                            }
                        }
                    }
                }

            }));
        }
        /// <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>
        /// Tick event handler for shutdownTimer to poll AWS for updated information on auto scaling group shutdown
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void shutdownTimer_Tick(object sender, EventArgs e)
        {
            AmazonAutoScalingClient client = GetAutoScaleClient();
            if (shutdownTimer.Tag != null)
            {
                if (shutdownTimer.Tag.ToString() == "activities")
                {
                    DescribeScalingActivitiesRequest req = new DescribeScalingActivitiesRequest();
                    req.AutoScalingGroupName = ((ViewModel)this.DataContext).SelectedAutoScalingGroup.AutoScalingGroup.AutoScalingGroupName;
                    IAsyncResult dasgresult = client.BeginDescribeScalingActivities(req, AutoScalingGroupScalingActivityInfoCallback, null);
                    return;
                }
            }

            DescribeAutoScalingGroupsRequest asreq = new DescribeAutoScalingGroupsRequest();
            IAsyncResult asresult = client.BeginDescribeAutoScalingGroups(asreq, AutoScalingGroupShutdownInfoCallback, shutdownTimer.Tag);
        }
 /// <summary>
 /// Callback function for BeginSetDesiredCapacity async call to update an ASG desired capacity based on user changes in AsgWindow
 /// </summary>
 /// <param name="result"></param>
 private void SetDesiredCapacityCallback(IAsyncResult result)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
     {
         AmazonAutoScalingClient client = GetAutoScaleClient();
         SetDesiredCapacityResponse resp = client.EndSetDesiredCapacity(result);
         DescribeAutoScalingGroupsRequest asreq = new DescribeAutoScalingGroupsRequest();
         IAsyncResult asresult = client.BeginDescribeAutoScalingGroups(asreq, AutoScalingGroupInfoCallback, "full");
         vm.IsBusy = false;
     }));
 }
 /// <summary>
 /// Tick event handler for monitorTimer to poll AWS for updated information on instance information for auto scaling groups
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void monitorTimer_Tick(object sender, EventArgs e)
 {
     if (vm.RefreshCountdown == 0)
     {
         vm.RefreshCountdown = vm.SelectedRefreshPeriod.Period; //vm.RefreshRate;
         AmazonAutoScalingClient client = GetAutoScaleClient();
         DescribeAutoScalingGroupsRequest asreq = new DescribeAutoScalingGroupsRequest();
         asreq.AutoScalingGroupNames.Add(((ViewModel)this.DataContext).SelectedAutoScalingGroup.AutoScalingGroup.AutoScalingGroupName);
         IAsyncResult asresult = client.BeginDescribeAutoScalingGroups(asreq, AutoScalingGroupInfoCallback, "instances");
     }
     else
     {
         vm.RefreshCountdown -= 1;
     }
 }
 /// <summary>
 /// <para> Returns a full description of each Auto Scaling group in the given list. This includes all Amazon EC2 instances that are members of
 /// the group. If a list of names is not provided, the service returns the full details of all Auto Scaling groups. </para> <para> This action
 /// supports pagination by returning a token if there are more pages to retrieve. To get the next page, call this action again with the returned
 /// token as the <c>NextToken</c> parameter. </para>
 /// </summary>
 /// 
 /// <param name="describeAutoScalingGroupsRequest">Container for the necessary parameters to execute the DescribeAutoScalingGroups service
 ///           method on AmazonAutoScaling.</param>
 /// 
 /// <returns>The response from the DescribeAutoScalingGroups service method, as returned by AmazonAutoScaling.</returns>
 /// 
 /// <exception cref="InvalidNextTokenException"/>
 public DescribeAutoScalingGroupsResponse DescribeAutoScalingGroups(DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest)
 {
     IRequest<DescribeAutoScalingGroupsRequest> request = new DescribeAutoScalingGroupsRequestMarshaller().Marshall(describeAutoScalingGroupsRequest);
     DescribeAutoScalingGroupsResponse response = Invoke<DescribeAutoScalingGroupsRequest, DescribeAutoScalingGroupsResponse> (request, this.signer, DescribeAutoScalingGroupsResponseUnmarshaller.GetInstance());
     return response;
 }
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeAutoScalingGroups operation.
        /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling.DescribeAutoScalingGroups"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAutoScalingGroups 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<DescribeAutoScalingGroupsResponse> DescribeAutoScalingGroupsAsync(DescribeAutoScalingGroupsRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DescribeAutoScalingGroupsRequestMarshaller();
            var unmarshaller = DescribeAutoScalingGroupsResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, DescribeAutoScalingGroupsRequest, DescribeAutoScalingGroupsResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
Exemplo n.º 16
0
 internal DescribeAutoScalingGroupsPaginator(IAmazonAutoScaling client, DescribeAutoScalingGroupsRequest request)
 {
     this._client  = client;
     this._request = request;
 }
        /// <summary>
        /// Callback function for BeginCreateAutoScalingGroup async call to create an ASG
        /// </summary>
        /// <param name="result"></param>
        private void CreateAutoScaleGroupCallback(IAsyncResult result)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                try
                {
                    AmazonAutoScalingClient client = GetAutoScaleClient();
                    CreateAutoScalingGroupResponse resp = client.EndCreateAutoScalingGroup(result);
                    DescribeAutoScalingGroupsRequest asreq = new DescribeAutoScalingGroupsRequest();
                    IAsyncResult asresult = client.BeginDescribeAutoScalingGroups(asreq, AutoScalingGroupInfoCallback, "full,new");
                }
                catch (Exception ex)
                {
                    ((ViewModel)this.DataContext).IsBusy = false;
                    MessageBox.Show(Window.GetWindow(this), "Error occured while creating auto scaling group.\n" + ex.Message, "Error", MessageBoxButton.OK);
                }

            }));
        }
Exemplo n.º 18
0
 IAsyncResult invokeDescribeAutoScalingGroups(DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new DescribeAutoScalingGroupsRequestMarshaller().Marshall(describeAutoScalingGroupsRequest);
     var unmarshaller = DescribeAutoScalingGroupsResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
        /// <summary>
        /// Callback function for BeginDeleteAutoScalingGroup async call to delete an ASG
        /// </summary>
        /// <param name="result"></param>
        private void DeleteAutoScalingGroupCallback(IAsyncResult result)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                AmazonAutoScalingClient client = GetAutoScaleClient();
                DeleteAutoScalingGroupResponse resp = client.EndDeleteAutoScalingGroup(result);
                DescribeAutoScalingGroupsRequest asreq = new DescribeAutoScalingGroupsRequest();
                IAsyncResult asresult = client.BeginDescribeAutoScalingGroups(asreq, AutoScalingGroupInfoCallback, "full,delete");

            }));
        }
        internal DescribeAutoScalingGroupsResponse DescribeAutoScalingGroups(DescribeAutoScalingGroupsRequest request)
        {
            var marshaller = new DescribeAutoScalingGroupsRequestMarshaller();
            var unmarshaller = DescribeAutoScalingGroupsResponseUnmarshaller.Instance;

            return Invoke<DescribeAutoScalingGroupsRequest,DescribeAutoScalingGroupsResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// Load auto scaling groups to view model with AWS data based on region selected and EC2 classic/vpc
        /// </summary>
        private void LoadAutoScalingGroups(AmazonAutoScalingClient asClient)
        {
            try
            {
                DescribeAutoScalingGroupsRequest asreq = new DescribeAutoScalingGroupsRequest();
                DescribeAutoScalingGroupsResponse asresp = asClient.DescribeAutoScalingGroups(asreq);
                Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                {
                    vm.AutoScalingGroups.Clear();
                }));
                foreach (AutoScalingGroup asg in asresp.DescribeAutoScalingGroupsResult.AutoScalingGroups)
                {
                    if (vm.IsVpc)
                    {
                        if (!string.IsNullOrEmpty(asg.VPCZoneIdentifier) && vm.SelectedVpc != null)
                        {
                            foreach (Models.ConsoleSubnet subnet in vm.SelectedVpc.Subnets)
                            {
                                if (asg.VPCZoneIdentifier.Contains(subnet.Subnet.SubnetId))
                                {
                                    //vm.AutoScalingGroups.Add(asg);
                                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                                    {
                                        vm.AutoScalingGroups.Add(new Models.ConsoleASG() { AutoScalingGroup = asg });
                                    }));
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(asg.VPCZoneIdentifier))
                        {
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                            {
                                vm.AutoScalingGroups.Add(new Models.ConsoleASG() { AutoScalingGroup = asg });
                            }));
                        }
                    }
                }

                Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                {
                    for (int i = 0; i < vm.AutoScalingGroups.Count(); i++)
                    {
                        DescribeNotificationConfigurationsRequest nreq = new DescribeNotificationConfigurationsRequest();
                        nreq.WithAutoScalingGroupNames(vm.AutoScalingGroups[i].AutoScalingGroup.AutoScalingGroupName);
                        DescribeNotificationConfigurationsResponse nresp = asClient.DescribeNotificationConfigurations(nreq);
                        vm.AutoScalingGroups[i].NotificationConfigurations = new List<NotificationConfiguration>();
                        foreach (NotificationConfiguration nc in nresp.DescribeNotificationConfigurationsResult.NotificationConfigurations)
                        {
                            vm.AutoScalingGroups[i].NotificationConfigurations.Add(nc);
                        }
                    }
                }));
            }
            catch (Exception ex)
            {
                LogManager.LogEntry(ex.Message);
                LogManager.LogEntry(ex.StackTrace);
                throw new DataLoadingException("Error occurred loading auto scaling groups for region and environment type");
            }
        }
Exemplo n.º 22
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;

            #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
            var useParameterSelect = this.Select.StartsWith("^") || this.PassThru.IsPresent;
            #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute

            // create request and set iteration invariants
            var request = new Amazon.AutoScaling.Model.DescribeAutoScalingGroupsRequest();

            if (cmdletContext.AutoScalingGroupName != null)
            {
                request.AutoScalingGroupNames = cmdletContext.AutoScalingGroupName;
            }
            if (cmdletContext.Filter != null)
            {
                request.Filters = cmdletContext.Filter;
            }
            if (cmdletContext.MaxRecord != null)
            {
                request.MaxRecords = AutoIterationHelpers.ConvertEmitLimitToServiceTypeInt32(cmdletContext.MaxRecord.Value);
            }

            // Initialize loop variant and commence piping
            var _nextToken             = cmdletContext.NextToken;
            var _userControllingPaging = this.NoAutoIteration.IsPresent || ParameterWasBound(nameof(this.NextToken));

            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);
            do
            {
                request.NextToken = _nextToken;

                CmdletOutput output;

                try
                {
                    var response = CallAWSServiceOperation(client, request);

                    object pipelineOutput = null;
                    if (!useParameterSelect)
                    {
                        pipelineOutput = cmdletContext.Select(response, this);
                    }
                    output = new CmdletOutput
                    {
                        PipelineOutput  = pipelineOutput,
                        ServiceResponse = response
                    };

                    _nextToken = response.NextToken;
                }
                catch (Exception e)
                {
                    output = new CmdletOutput {
                        ErrorResponse = e
                    };
                }

                ProcessOutput(output);
            } while (!_userControllingPaging && AutoIterationHelpers.HasValue(_nextToken));

            if (useParameterSelect)
            {
                WriteObject(cmdletContext.Select(null, this));
            }


            return(null);
        }
 /// <summary>
 /// Paginator for DescribeAutoScalingGroups operation
 ///</summary>
 public IDescribeAutoScalingGroupsPaginator DescribeAutoScalingGroups(DescribeAutoScalingGroupsRequest request)
 {
     return(new DescribeAutoScalingGroupsPaginator(this.client, request));
 }
Exemplo n.º 24
0
 private Amazon.AutoScaling.Model.DescribeAutoScalingGroupsResponse CallAWSServiceOperation(IAmazonAutoScaling client, Amazon.AutoScaling.Model.DescribeAutoScalingGroupsRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Auto Scaling", "DescribeAutoScalingGroups");
     try
     {
         #if DESKTOP
         return(client.DescribeAutoScalingGroups(request));
         #elif CORECLR
         return(client.DescribeAutoScalingGroupsAsync(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 DescribeAutoScalingGroups operation.
        /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling.DescribeAutoScalingGroups"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAutoScalingGroups 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<DescribeAutoScalingGroupsResponse> DescribeAutoScalingGroupsAsync(DescribeAutoScalingGroupsRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DescribeAutoScalingGroupsRequestMarshaller();
            var unmarshaller = DescribeAutoScalingGroupsResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, DescribeAutoScalingGroupsRequest, DescribeAutoScalingGroupsResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }