Container for the parameters to the DescribeAlarms operation. Retrieves the specified alarms. If no alarms are specified, all alarms are returned. Alarms can be retrieved by using only a prefix for the alarm name, the alarm state, or a prefix for any action.
Inheritance: AmazonCloudWatchRequest
        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.CloudWatch.Model.DescribeAlarmsRequest();

            if (cmdletContext.ActionPrefix != null)
            {
                request.ActionPrefix = cmdletContext.ActionPrefix;
            }
            if (cmdletContext.AlarmNamePrefix != null)
            {
                request.AlarmNamePrefix = cmdletContext.AlarmNamePrefix;
            }
            if (cmdletContext.AlarmName != null)
            {
                request.AlarmNames = cmdletContext.AlarmName;
            }
            if (cmdletContext.AlarmType != null)
            {
                request.AlarmTypes = cmdletContext.AlarmType;
            }
            if (cmdletContext.ChildrenOfAlarmName != null)
            {
                request.ChildrenOfAlarmName = cmdletContext.ChildrenOfAlarmName;
            }
            if (cmdletContext.MaxRecord != null)
            {
                request.MaxRecords = AutoIterationHelpers.ConvertEmitLimitToServiceTypeInt32(cmdletContext.MaxRecord.Value);
            }
            if (cmdletContext.ParentsOfAlarmName != null)
            {
                request.ParentsOfAlarmName = cmdletContext.ParentsOfAlarmName;
            }
            if (cmdletContext.StateValue != null)
            {
                request.StateValue = cmdletContext.StateValue;
            }

            // 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);
        }
        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.CloudWatch.Model.DescribeAlarmsRequest();

            if (cmdletContext.ActionPrefix != null)
            {
                request.ActionPrefix = cmdletContext.ActionPrefix;
            }
            if (cmdletContext.AlarmNamePrefix != null)
            {
                request.AlarmNamePrefix = cmdletContext.AlarmNamePrefix;
            }
            if (cmdletContext.AlarmName != null)
            {
                request.AlarmNames = cmdletContext.AlarmName;
            }
            if (cmdletContext.AlarmType != null)
            {
                request.AlarmTypes = cmdletContext.AlarmType;
            }
            if (cmdletContext.ChildrenOfAlarmName != null)
            {
                request.ChildrenOfAlarmName = cmdletContext.ChildrenOfAlarmName;
            }
            if (cmdletContext.ParentsOfAlarmName != null)
            {
                request.ParentsOfAlarmName = cmdletContext.ParentsOfAlarmName;
            }
            if (cmdletContext.StateValue != null)
            {
                request.StateValue = cmdletContext.StateValue;
            }

            // 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)
            {
                // The service has a maximum page size of 100. If the user has
                // asked for more items than page max, and there is no page size
                // configured, we rely on the service ignoring the set maximum
                // and giving us 100 items back. If a page size is set, that will
                // be used to configure the pagination.
                // We'll make further calls to satisfy the user's request.
                _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)
                {
                    int correctPageSize = Math.Min(100, _emitLimit.Value);
                    request.MaxRecords = AutoIterationHelpers.ConvertEmitLimitToInt32(correctPageSize);
                }

                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.MetricAlarms.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 DescribeAlarms operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAlarms operation on AmazonCloudWatchClient.</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 EndDescribeAlarms
        ///         operation.</returns>
        public IAsyncResult BeginDescribeAlarms(DescribeAlarmsRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new DescribeAlarmsRequestMarshaller();
            var unmarshaller = DescribeAlarmsResponseUnmarshaller.Instance;

            return BeginInvoke<DescribeAlarmsRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 internal DescribeAlarmsPaginator(IAmazonCloudWatch client, DescribeAlarmsRequest request)
 {
     this._client  = client;
     this._request = request;
 }
        /// <summary>
        /// <para> Retrieves alarms with the specified names. If no name is specified, all alarms for the user are returned. Alarms can be retrieved by
        /// using only a prefix for the alarm name, the alarm state, or a prefix for any action. </para>
        /// </summary>
        /// 
        /// <param name="describeAlarmsRequest">Container for the necessary parameters to execute the DescribeAlarms service method on
        /// AmazonCloudWatch.</param>
        /// 
        /// <returns>The response from the DescribeAlarms service method, as returned by AmazonCloudWatch.</returns>
        /// 
        /// <exception cref="T:Amazon.CloudWatch.Model.InvalidNextTokenException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<DescribeAlarmsResponse> DescribeAlarmsAsync(DescribeAlarmsRequest describeAlarmsRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DescribeAlarmsRequestMarshaller();
            var unmarshaller = DescribeAlarmsResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, DescribeAlarmsRequest, DescribeAlarmsResponse>(describeAlarmsRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
        /// <summary>
        /// Retrieves alarms with the specified names. If no name is specified, all alarms for
        /// the user are returned. Alarms can be retrieved by using only a prefix for the alarm
        /// name, the alarm state, or a prefix for any action.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the DescribeAlarms service method.</param>
        /// 
        /// <returns>The response from the DescribeAlarms service method, as returned by CloudWatch.</returns>
        /// <exception cref="Amazon.CloudWatch.Model.InvalidNextTokenException">
        /// The next token specified is invalid.
        /// </exception>
        public DescribeAlarmsResponse DescribeAlarms(DescribeAlarmsRequest request)
        {
            var marshaller = new DescribeAlarmsRequestMarshaller();
            var unmarshaller = DescribeAlarmsResponseUnmarshaller.Instance;

            return Invoke<DescribeAlarmsRequest,DescribeAlarmsResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// <para> Retrieves alarms with the specified names. If no name is specified, all alarms for the user are returned. Alarms can be retrieved by
        /// using only a prefix for the alarm name, the alarm state, or a prefix for any action. </para>
        /// </summary>
        /// 
        /// <param name="describeAlarmsRequest">Container for the necessary parameters to execute the DescribeAlarms service method on
        /// AmazonCloudWatch.</param>
        /// 
        /// <returns>The response from the DescribeAlarms service method, as returned by AmazonCloudWatch.</returns>
        /// 
        /// <exception cref="T:Amazon.CloudWatch.Model.InvalidNextTokenException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public async Task<DescribeAlarmsResponse> DescribeAlarmsAsync(DescribeAlarmsRequest describeAlarmsRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DescribeAlarmsRequestMarshaller();
            var unmarshaller = DescribeAlarmsResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, DescribeAlarmsRequest, DescribeAlarmsResponse>(describeAlarmsRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeAlarms operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAlarms 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<DescribeAlarmsResponse> DescribeAlarmsAsync(DescribeAlarmsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DescribeAlarmsRequestMarshaller();
            var unmarshaller = DescribeAlarmsResponseUnmarshaller.Instance;

            return InvokeAsync<DescribeAlarmsRequest,DescribeAlarmsResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
 /// Cloudwatch, go to Amazon CloudWatch Metrics, Namespaces, and Dimensions Reference in the <i>Amazon CloudWatch Developer Guide</i> .
 /// </para>
 /// </summary>
 /// 
 /// <param name="getMetricStatisticsRequest">Container for the necessary parameters to execute the GetMetricStatistics service method on
 ///          AmazonCloudWatch.</param>
 /// 
 /// <returns>The response from the GetMetricStatistics service method, as returned by AmazonCloudWatch.</returns>
 /// 
 /// <exception cref="InvalidParameterValueException"/>
 /// <exception cref="InternalServiceException"/>
 /// <exception cref="InvalidParameterCombinationException"/>
 /// <exception cref="MissingRequiredParameterException"/>
 public GetMetricStatisticsResponse GetMetricStatistics(GetMetricStatisticsRequest getMetricStatisticsRequest)
 {
     IAsyncResult asyncResult = invokeGetMetricStatistics(getMetricStatisticsRequest, null, null, true);
        #endregion
    
        #region EnableAlarmActions

        /// <summary>
        /// <para> Enables actions for the specified alarms. </para>
        /// </summary>
        /// 
        {
            return endOperation<PutMetricAlarmResponse>(asyncResult);
        }
        
        IAsyncResult invokePutMetricAlarm(PutMetricAlarmRequest putMetricAlarmRequest, AsyncCallback callback, object state, bool synchronized)
        {
            IRequest irequest = new PutMetricAlarmRequestMarshaller().Marshall(putMetricAlarmRequest);
            var unmarshaller = PutMetricAlarmResponseUnmarshaller.GetInstance();
            AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
            Invoke(result);
            return result;
        }
        
        

        #endregion
    
		internal DescribeAlarmsResponse DescribeAlarms(DescribeAlarmsRequest request)
        {
            var task = DescribeAlarmsAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
 /// <summary>
 /// Paginator for DescribeAlarms operation
 ///</summary>
 public IDescribeAlarmsPaginator DescribeAlarms(DescribeAlarmsRequest request)
 {
     return(new DescribeAlarmsPaginator(this.client, request));
 }
 private Amazon.CloudWatch.Model.DescribeAlarmsResponse CallAWSServiceOperation(IAmazonCloudWatch client, Amazon.CloudWatch.Model.DescribeAlarmsRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudWatch", "DescribeAlarms");
     try
     {
         #if DESKTOP
         return(client.DescribeAlarms(request));
         #elif CORECLR
         return(client.DescribeAlarmsAsync(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;
     }
 }
		internal DescribeAlarmsResponse DescribeAlarms(DescribeAlarmsRequest request)
        {
            var task = DescribeAlarmsAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
 /// <summary>
 /// <para> Retrieves alarms with the specified names. If no name is
 /// specified, all alarms for the user are returned. Alarms can be
 /// retrieved by using only a prefix for the alarm name, the alarm state,
 /// or a prefix for any action. </para>
 /// </summary>
 /// 
 /// <param name="describeAlarmsRequest">Container for the necessary
 ///           parameters to execute the DescribeAlarms service method on
 ///           AmazonCloudWatch.</param>
 /// 
 /// <returns>The response from the DescribeAlarms service method, as
 ///         returned by AmazonCloudWatch.</returns>
 /// 
 /// <exception cref="InvalidNextTokenException"/>
 public DescribeAlarmsResponse DescribeAlarms(DescribeAlarmsRequest describeAlarmsRequest)
 {
     IRequest<DescribeAlarmsRequest> request = new DescribeAlarmsRequestMarshaller().Marshall(describeAlarmsRequest);
     DescribeAlarmsResponse response = Invoke<DescribeAlarmsRequest, DescribeAlarmsResponse> (request, this.signer, DescribeAlarmsResponseUnmarshaller.GetInstance());
     return response;
 }
Beispiel #17
0
    public static void CWDescribeAlarms()
    {
      #region CWDescribeAlarms
      var client = new AmazonCloudWatchClient();

      var request = new DescribeAlarmsRequest
      {
        AlarmNames = new List<string>() 
          { "awseb-e-b36EXAMPLE-stack-CloudwatchAlarmLow-1KAKH4EXAMPLE" },
        MaxRecords = 1,
        StateValue = StateValue.ALARM
      };

      var response = new DescribeAlarmsResponse();

      do
      {
        response = client.DescribeAlarms(request);

        foreach (var alarm in response.MetricAlarms)
        {
          Console.WriteLine(alarm.AlarmName);
          Console.WriteLine(alarm.AlarmDescription);
          Console.WriteLine(alarm.MetricName + " " +
              alarm.ComparisonOperator + " " + alarm.Threshold);
          Console.WriteLine();
        }

        request.NextToken = response.NextToken;

      } while (!string.IsNullOrEmpty(response.NextToken));
      #endregion

      Console.ReadLine();
    }