private static void UnmarshallResult(XmlUnmarshallerContext context, DescribeAlarmHistoryResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("AlarmHistoryItems/member", targetDepth)) { var unmarshaller = AlarmHistoryItemUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.AlarmHistoryItems.Add(item); continue; } if (context.TestExpression("NextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } } } return; }
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(); }
/// <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)); }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { DescribeAlarmHistoryResponse response = new DescribeAlarmHistoryResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if (context.TestExpression("DescribeAlarmHistoryResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return(response); }
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)); }
/// <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); }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { DescribeAlarmHistoryResponse response = new DescribeAlarmHistoryResponse(); while (context.Read()) { if (context.IsStartElement) { if (context.TestExpression("DescribeAlarmHistoryResult", 2)) { response.DescribeAlarmHistoryResult = DescribeAlarmHistoryResultUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context); } } } return(response); }
private static void UnmarshallResult(XmlUnmarshallerContext context, DescribeAlarmHistoryResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("AlarmHistoryItems/member", targetDepth)) { response.AlarmHistoryItems.Add(AlarmHistoryItemUnmarshaller.GetInstance().Unmarshall(context)); continue; } if (context.TestExpression("NextToken", targetDepth)) { response.NextToken = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } return; }
public static DescribeAlarmHistoryResponse Unmarshall(UnmarshallerContext context) { DescribeAlarmHistoryResponse describeAlarmHistoryResponse = new DescribeAlarmHistoryResponse(); describeAlarmHistoryResponse.HttpResponse = context.HttpResponse; describeAlarmHistoryResponse.Success = context.BooleanValue("DescribeAlarmHistory.Success"); describeAlarmHistoryResponse.Code = context.StringValue("DescribeAlarmHistory.Code"); describeAlarmHistoryResponse.Message = context.StringValue("DescribeAlarmHistory.Message"); describeAlarmHistoryResponse.Total = context.StringValue("DescribeAlarmHistory.Total"); describeAlarmHistoryResponse.RequestId = context.StringValue("DescribeAlarmHistory.RequestId"); List <DescribeAlarmHistoryResponse.DescribeAlarmHistory_AlarmHistory> describeAlarmHistoryResponse_alarmHistoryList = new List <DescribeAlarmHistoryResponse.DescribeAlarmHistory_AlarmHistory>(); for (int i = 0; i < context.Length("DescribeAlarmHistory.AlarmHistoryList.Length"); i++) { DescribeAlarmHistoryResponse.DescribeAlarmHistory_AlarmHistory alarmHistory = new DescribeAlarmHistoryResponse.DescribeAlarmHistory_AlarmHistory(); alarmHistory.Id = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].Id"); alarmHistory.AlertName = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].AlertName"); alarmHistory.GroupId = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].GroupId"); alarmHistory._Namespace = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].Namespace"); alarmHistory.MetricName = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].MetricName"); alarmHistory.Dimensions = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].Dimensions"); alarmHistory.Expression = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].Expression"); alarmHistory.EvaluationCount = context.IntegerValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].EvaluationCount"); alarmHistory._Value = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].Value"); alarmHistory.AlertTime = context.LongValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].AlertTime"); alarmHistory.LastTime = context.LongValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].LastTime"); alarmHistory.Level = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].Level"); alarmHistory.PreLevel = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].PreLevel"); alarmHistory.RuleName = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].RuleName"); alarmHistory.State = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].State"); alarmHistory.Status = context.IntegerValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].Status"); alarmHistory.UserId = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].UserId"); alarmHistory.Webhooks = context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].Webhooks"); List <string> alarmHistory_contactGroups = new List <string>(); for (int j = 0; j < context.Length("DescribeAlarmHistory.AlarmHistoryList[" + i + "].ContactGroups.Length"); j++) { alarmHistory_contactGroups.Add(context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].ContactGroups[" + j + "]")); } alarmHistory.ContactGroups = alarmHistory_contactGroups; List <string> alarmHistory_contacts = new List <string>(); for (int j = 0; j < context.Length("DescribeAlarmHistory.AlarmHistoryList[" + i + "].Contacts.Length"); j++) { alarmHistory_contacts.Add(context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].Contacts[" + j + "]")); } alarmHistory.Contacts = alarmHistory_contacts; List <string> alarmHistory_contactALIIMs = new List <string>(); for (int j = 0; j < context.Length("DescribeAlarmHistory.AlarmHistoryList[" + i + "].ContactALIIMs.Length"); j++) { alarmHistory_contactALIIMs.Add(context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].ContactALIIMs[" + j + "]")); } alarmHistory.ContactALIIMs = alarmHistory_contactALIIMs; List <string> alarmHistory_contactSmses = new List <string>(); for (int j = 0; j < context.Length("DescribeAlarmHistory.AlarmHistoryList[" + i + "].ContactSmses.Length"); j++) { alarmHistory_contactSmses.Add(context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].ContactSmses[" + j + "]")); } alarmHistory.ContactSmses = alarmHistory_contactSmses; List <string> alarmHistory_contactMails = new List <string>(); for (int j = 0; j < context.Length("DescribeAlarmHistory.AlarmHistoryList[" + i + "].ContactMails.Length"); j++) { alarmHistory_contactMails.Add(context.StringValue("DescribeAlarmHistory.AlarmHistoryList[" + i + "].ContactMails[" + j + "]")); } alarmHistory.ContactMails = alarmHistory_contactMails; describeAlarmHistoryResponse_alarmHistoryList.Add(alarmHistory); } describeAlarmHistoryResponse.AlarmHistoryList = describeAlarmHistoryResponse_alarmHistoryList; return(describeAlarmHistoryResponse); }