internal virtual DescribeAlarmsResponse DescribeAlarms(DescribeAlarmsRequest request)
        {
            var marshaller   = DescribeAlarmsRequestMarshaller.Instance;
            var unmarshaller = DescribeAlarmsResponseUnmarshaller.Instance;

            return(Invoke <DescribeAlarmsRequest, DescribeAlarmsResponse>(request, marshaller, unmarshaller));
        }
Example #2
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonCloudWatchConfig config = new AmazonCloudWatchConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonCloudWatchClient client = new AmazonCloudWatchClient(creds, config);

            DescribeAlarmsResponse resp = new DescribeAlarmsResponse();

            do
            {
                DescribeAlarmsRequest req = new DescribeAlarmsRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxRecords = maxItems
                };

                resp = client.DescribeAlarms(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.MetricAlarms)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
        /// <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));
        }
Example #4
0
        /// <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);
        }
        private async Task <IDictionary <string, MetricAlarm> > ReadAllAlarms()
        {
            var    alarms        = new List <MetricAlarm>();
            string lastAlarmName = null;

            do
            {
                var request = new DescribeAlarmsRequest
                {
                    NextToken = lastAlarmName
                };

                var alarmsResponse = await _cloudWatchClient.DescribeAlarmsAsync(request);

                if (alarmsResponse != null)
                {
                    alarms.AddRange(alarmsResponse.MetricAlarms);
                    lastAlarmName = alarmsResponse.NextToken;
                }
                else
                {
                    lastAlarmName = null;
                }
            }while (lastAlarmName != null);

            _logger.Info($"Preloaded all {alarms.Count} alarms");

            return(alarms.ToDictionary(a => a.AlarmName));
        }
Example #6
0
        /// <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>
        /// 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));
        }
Example #8
0
 IAsyncResult invokeDescribeAlarms(DescribeAlarmsRequest describeAlarmsRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new DescribeAlarmsRequestMarshaller().Marshall(describeAlarmsRequest);
     var unmarshaller = DescribeAlarmsResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
Example #9
0
        /// <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>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/monitoring-2010-08-01/DescribeAlarms">REST API Reference for DescribeAlarms Operation</seealso>
        public virtual Task <DescribeAlarmsResponse> DescribeAlarmsAsync(DescribeAlarmsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = DescribeAlarmsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = DescribeAlarmsResponseUnmarshaller.Instance;

            return(InvokeAsync <DescribeAlarmsResponse>(request, options, cancellationToken));
        }
Example #10
0
        internal virtual DescribeAlarmsResponse DescribeAlarms(DescribeAlarmsRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = DescribeAlarmsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = DescribeAlarmsResponseUnmarshaller.Instance;

            return(Invoke <DescribeAlarmsResponse>(request, options));
        }
Example #11
0
        internal DescribeAlarmsResponse DescribeAlarms(DescribeAlarmsRequest request)
        {
            var task = DescribeAlarmsAsync(request);

            try
            {
                return(task.Result);
            }
            catch (AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return(null);
            }
        }
Example #12
0
        /// <summary>
        /// 本接口用于获取告警策略。
        /// </summary>
        /// <param name="req"><see cref="DescribeAlarmsRequest"/></param>
        /// <returns><see cref="DescribeAlarmsResponse"/></returns>
        public DescribeAlarmsResponse DescribeAlarmsSync(DescribeAlarmsRequest req)
        {
            JsonResponseModel <DescribeAlarmsResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "DescribeAlarms");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <DescribeAlarmsResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
Example #13
0
 public static void DescribeAlarms()
 {
     using (var cloudWatch = new AmazonCloudWatchClient(RegionEndpoint.USWest2))
     {
         var request = new DescribeAlarmsRequest();
         request.StateValue = "INSUFFICIENT_DATA";
         request.AlarmNames = new List <string> {
             "Alarm1", "Alarm2"
         };
         do
         {
             var response = cloudWatch.DescribeAlarms(request);
             foreach (var alarm in response.MetricAlarms)
             {
                 Console.WriteLine(alarm.AlarmName);
             }
             request.NextToken = response.NextToken;
         } while (request.NextToken != null);
     }
 }
Example #14
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();
        }
Example #15
0
 /// <summary>
 /// Initiates the asynchronous execution of the DescribeAlarms operation.
 /// <seealso cref="Amazon.CloudWatch.AmazonCloudWatch.DescribeAlarms"/>
 /// </summary>
 ///
 /// <param name="describeAlarmsRequest">Container for the necessary parameters to execute the DescribeAlarms operation on
 ///          AmazonCloudWatch.</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 describeAlarmsRequest, AsyncCallback callback, object state)
 {
     return(invokeDescribeAlarms(describeAlarmsRequest, callback, state, false));
 }
Example #16
0
        /// <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)
        {
            IAsyncResult asyncResult = invokeDescribeAlarms(describeAlarmsRequest, null, null, true);

            return(EndDescribeAlarms(asyncResult));
        }
Example #17
0
 /// <summary>
 ///  查询报警规则列表
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public async Task <DescribeAlarmsResponse> DescribeAlarms(DescribeAlarmsRequest request)
 {
     return(await new DescribeAlarmsExecutor().Client(this).Execute <DescribeAlarmsResponse, DescribeAlarmsResult, DescribeAlarmsRequest>(request).ConfigureAwait(false));
 }
Example #18
0
 /// <summary>
 ///  查询报警规则列表
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public DescribeAlarmsResponse DescribeAlarms(DescribeAlarmsRequest request)
 {
     return(new DescribeAlarmsExecutor().Client(this).Execute <DescribeAlarmsResponse, DescribeAlarmsResult, DescribeAlarmsRequest>(request));
 }