Пример #1
0
        internal virtual DescribeAlarmHistoryResponse DescribeAlarmHistory(DescribeAlarmHistoryRequest request)
        {
            var marshaller   = DescribeAlarmHistoryRequestMarshaller.Instance;
            var unmarshaller = DescribeAlarmHistoryResponseUnmarshaller.Instance;

            return(Invoke <DescribeAlarmHistoryRequest, DescribeAlarmHistoryResponse>(request, marshaller, unmarshaller));
        }
        /// <summary>
        /// Retrieves the CloudWatch alarm history for the alarm name passed
        /// to the method.
        /// </summary>
        /// <param name="client">An initialized CloudWatch client object.</param>
        /// <param name="alarmName">The CloudWatch alarm for which to retrieve
        /// history information.</param>
        public static async Task DescribeAlarmHistoriesAsync(IAmazonCloudWatch client, string alarmName)
        {
            var request = new DescribeAlarmHistoryRequest
            {
                AlarmName =
                    "ALARM_NAME",
                EndDateUtc      = DateTime.Today,
                HistoryItemType = HistoryItemType.Action,
                MaxRecords      = 1,
                StartDateUtc    = DateTime.Today.Subtract(TimeSpan.FromDays(30)),
            };

            var response = new DescribeAlarmHistoryResponse();

            do
            {
                response = await client.DescribeAlarmHistoryAsync(request);

                foreach (var item in response.AlarmHistoryItems)
                {
                    Console.WriteLine(item.AlarmName);
                    Console.WriteLine(item.HistorySummary);
                    Console.WriteLine();
                }

                request.NextToken = response.NextToken;
            } while (!string.IsNullOrEmpty(response.NextToken));
        }
Пример #3
0
        public static void CWDescribeAlarmHistory()
        {
            #region CWDescribeAlarmHistory
            var client = new AmazonCloudWatchClient();

            var request = new DescribeAlarmHistoryRequest
            {
                AlarmName =
                    "awseb-e-kkbEXAMPLE-stack-CloudwatchAlarmLow-1WVXD9EXAMPLE",
                EndDate         = DateTime.Today,
                HistoryItemType = HistoryItemType.Action,
                MaxRecords      = 1,
                StartDate       = DateTime.Today.Subtract(TimeSpan.FromDays(30))
            };

            var response = new DescribeAlarmHistoryResponse();

            do
            {
                response = client.DescribeAlarmHistory(request);

                foreach (var item in response.AlarmHistoryItems)
                {
                    Console.WriteLine(item.AlarmName);
                    Console.WriteLine(item.HistorySummary);
                    Console.WriteLine();
                }

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

            Console.ReadLine();
        }
Пример #4
0
        /// <summary>
        /// <para> Retrieves history for the specified alarm. Filter alarms by date range or item type. If an alarm name is not specified, Amazon
        /// CloudWatch returns histories for all of the owner's alarms. </para> <para><b>NOTE:</b> Amazon CloudWatch retains the history of an alarm for
        /// two weeks, whether or not you delete the alarm. </para>
        /// </summary>
        ///
        /// <param name="describeAlarmHistoryRequest">Container for the necessary parameters to execute the DescribeAlarmHistory service method on
        /// AmazonCloudWatch.</param>
        ///
        /// <returns>The response from the DescribeAlarmHistory 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 <DescribeAlarmHistoryResponse> DescribeAlarmHistoryAsync(DescribeAlarmHistoryRequest describeAlarmHistoryRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new DescribeAlarmHistoryRequestMarshaller();
            var unmarshaller = DescribeAlarmHistoryResponseUnmarshaller.GetInstance();

            return(Invoke <IRequest, DescribeAlarmHistoryRequest, DescribeAlarmHistoryResponse>(describeAlarmHistoryRequest, marshaller, unmarshaller, signer, cancellationToken));
        }
        /// <summary>
        /// Retrieves history for the specified alarm. Filter alarms by date range or item type.
        /// If an alarm name is not specified, Amazon CloudWatch returns histories for all of
        /// the owner's alarms.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the DescribeAlarmHistory service method.</param>
        ///
        /// <returns>The response from the DescribeAlarmHistory service method, as returned by CloudWatch.</returns>
        /// <exception cref="Amazon.CloudWatch.Model.InvalidNextTokenException">
        /// The next token specified is invalid.
        /// </exception>
        public DescribeAlarmHistoryResponse DescribeAlarmHistory(DescribeAlarmHistoryRequest request)
        {
            var marshaller   = new DescribeAlarmHistoryRequestMarshaller();
            var unmarshaller = DescribeAlarmHistoryResponseUnmarshaller.Instance;

            return(Invoke <DescribeAlarmHistoryRequest, DescribeAlarmHistoryResponse>(request, marshaller, unmarshaller));
        }
Пример #6
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);

            DescribeAlarmHistoryResponse resp = new DescribeAlarmHistoryResponse();

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

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

                foreach (var obj in resp.AlarmHistoryItems)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
Пример #7
0
        /// <summary>
        /// <para> Retrieves history for the specified alarm. Filter alarms by
        /// date range or item type. If an alarm name is not specified, Amazon
        /// CloudWatch returns histories for all of the owner's alarms. </para>
        /// <para><b>NOTE:</b> Amazon CloudWatch retains the history of an alarm
        /// for two weeks, whether or not you delete the alarm. </para>
        /// </summary>
        ///
        /// <param name="describeAlarmHistoryRequest">Container for the necessary
        ///           parameters to execute the DescribeAlarmHistory service method on
        ///           AmazonCloudWatch.</param>
        ///
        /// <returns>The response from the DescribeAlarmHistory service method, as
        ///         returned by AmazonCloudWatch.</returns>
        ///
        /// <exception cref="InvalidNextTokenException"/>
        public DescribeAlarmHistoryResponse DescribeAlarmHistory(DescribeAlarmHistoryRequest describeAlarmHistoryRequest)
        {
            IRequest <DescribeAlarmHistoryRequest> request  = new DescribeAlarmHistoryRequestMarshaller().Marshall(describeAlarmHistoryRequest);
            DescribeAlarmHistoryResponse           response = Invoke <DescribeAlarmHistoryRequest, DescribeAlarmHistoryResponse> (request, this.signer, DescribeAlarmHistoryResponseUnmarshaller.GetInstance());

            return(response);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeAlarmHistory operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the DescribeAlarmHistory 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 <DescribeAlarmHistoryResponse> DescribeAlarmHistoryAsync(DescribeAlarmHistoryRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new DescribeAlarmHistoryRequestMarshaller();
            var unmarshaller = DescribeAlarmHistoryResponseUnmarshaller.Instance;

            return(InvokeAsync <DescribeAlarmHistoryRequest, DescribeAlarmHistoryResponse>(request, marshaller,
                                                                                           unmarshaller, cancellationToken));
        }
Пример #9
0
 IAsyncResult invokeDescribeAlarmHistory(DescribeAlarmHistoryRequest describeAlarmHistoryRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new DescribeAlarmHistoryRequestMarshaller().Marshall(describeAlarmHistoryRequest);
     var unmarshaller = DescribeAlarmHistoryResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
Пример #10
0
        internal virtual DescribeAlarmHistoryResponse DescribeAlarmHistory(DescribeAlarmHistoryRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = DescribeAlarmHistoryRequestMarshaller.Instance;
            options.ResponseUnmarshaller = DescribeAlarmHistoryResponseUnmarshaller.Instance;

            return(Invoke <DescribeAlarmHistoryResponse>(request, options));
        }
Пример #11
0
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeAlarmHistory operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the DescribeAlarmHistory 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/DescribeAlarmHistory">REST API Reference for DescribeAlarmHistory Operation</seealso>
        public virtual Task <DescribeAlarmHistoryResponse> DescribeAlarmHistoryAsync(DescribeAlarmHistoryRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = DescribeAlarmHistoryRequestMarshaller.Instance;
            options.ResponseUnmarshaller = DescribeAlarmHistoryResponseUnmarshaller.Instance;

            return(InvokeAsync <DescribeAlarmHistoryResponse>(request, options, cancellationToken));
        }
Пример #12
0
        internal DescribeAlarmHistoryResponse DescribeAlarmHistory(DescribeAlarmHistoryRequest request)
        {
            var task = DescribeAlarmHistoryAsync(request);

            try
            {
                return(task.Result);
            }
            catch (AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return(null);
            }
        }
Пример #13
0
 /// <summary>
 ///  报警历史列表
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public async Task <DescribeAlarmHistoryResponse> DescribeAlarmHistory(DescribeAlarmHistoryRequest request)
 {
     return(await new DescribeAlarmHistoryExecutor().Client(this).Execute <DescribeAlarmHistoryResponse, DescribeAlarmHistoryResult, DescribeAlarmHistoryRequest>(request).ConfigureAwait(false));
 }
Пример #14
0
 /// <summary>
 /// Initiates the asynchronous execution of the DescribeAlarmHistory operation.
 /// <seealso cref="Amazon.CloudWatch.AmazonCloudWatch.DescribeAlarmHistory"/>
 /// </summary>
 ///
 /// <param name="describeAlarmHistoryRequest">Container for the necessary parameters to execute the DescribeAlarmHistory 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
 ///         EndDescribeAlarmHistory operation.</returns>
 public IAsyncResult BeginDescribeAlarmHistory(DescribeAlarmHistoryRequest describeAlarmHistoryRequest, AsyncCallback callback, object state)
 {
     return(invokeDescribeAlarmHistory(describeAlarmHistoryRequest, callback, state, false));
 }
Пример #15
0
        /// <summary>
        /// <para> Retrieves history for the specified alarm. Filter alarms by date range or item type. If an alarm name is not specified, Amazon
        /// CloudWatch returns histories for all of the owner's alarms. </para> <para><b>NOTE:</b> Amazon CloudWatch retains the history of an alarm for
        /// two weeks, whether or not you delete the alarm. </para>
        /// </summary>
        ///
        /// <param name="describeAlarmHistoryRequest">Container for the necessary parameters to execute the DescribeAlarmHistory service method on
        ///          AmazonCloudWatch.</param>
        ///
        /// <returns>The response from the DescribeAlarmHistory service method, as returned by AmazonCloudWatch.</returns>
        ///
        /// <exception cref="InvalidNextTokenException"/>
        public DescribeAlarmHistoryResponse DescribeAlarmHistory(DescribeAlarmHistoryRequest describeAlarmHistoryRequest)
        {
            IAsyncResult asyncResult = invokeDescribeAlarmHistory(describeAlarmHistoryRequest, null, null, true);

            return(EndDescribeAlarmHistory(asyncResult));
        }
Пример #16
0
        public void TestSetAlarmStateAndHistory()
        {
            String metricName = this.GetType().Name + DateTime.Now.Ticks;

            PutMetricAlarmRequest[] rqs = CreateTwoNewAlarms(metricName);

            PutMetricAlarmRequest rq1 = rqs[0];
            PutMetricAlarmRequest rq2 = rqs[1];

            /*
             * Set the state
             */
            SetAlarmStateRequest setAlarmStateRequest = new SetAlarmStateRequest()
            {
                AlarmName   = rq1.AlarmName,
                StateValue  = "ALARM",
                StateReason = "manual"
            };

            Client.SetAlarmState(setAlarmStateRequest);
            setAlarmStateRequest = new SetAlarmStateRequest()
            {
                AlarmName   = rq2.AlarmName,
                StateValue  = "ALARM",
                StateReason = "manual"
            };

            Client.SetAlarmState(setAlarmStateRequest);

            DescribeAlarmsForMetricResult describeResult = Client
                                                           .DescribeAlarmsForMetric(
                new DescribeAlarmsForMetricRequest()
            {
                Dimensions = rq1.Dimensions,
                MetricName = metricName,
                Namespace  = rq1.Namespace
            });

            Assert.AreEqual(2, describeResult.MetricAlarms.Count);

            foreach (MetricAlarm alarm in describeResult.MetricAlarms)
            {
                Assert.IsTrue(rq1.AlarmName.Equals(alarm.AlarmName) ||
                              rq2.AlarmName.Equals(alarm.AlarmName));

                Assert.IsTrue("ALARM".Equals(alarm.StateValue) || "INSUFFICIENT_DATA".Equals(alarm.StateValue));
                if ("ALARM".Equals(alarm.StateValue))
                {
                    Assert.AreEqual(setAlarmStateRequest.StateReason, alarm.StateReason);
                }
            }

            /*
             * Get the history
             */
            DescribeAlarmHistoryRequest alarmHistoryRequest = new DescribeAlarmHistoryRequest()
            {
                AlarmName       = rq1.AlarmName,
                HistoryItemType = "StateUpdate"
            };

            DescribeAlarmHistoryResult historyResult = Client.DescribeAlarmHistory(alarmHistoryRequest);

            Assert.IsTrue(historyResult.AlarmHistoryItems.Count > 0);
        }
Пример #17
0
 /// <summary>
 ///  报警历史列表
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public DescribeAlarmHistoryResponse DescribeAlarmHistory(DescribeAlarmHistoryRequest request)
 {
     return(new DescribeAlarmHistoryExecutor().Client(this).Execute <DescribeAlarmHistoryResponse, DescribeAlarmHistoryResult, DescribeAlarmHistoryRequest>(request));
 }