/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListAlertsResponse response = new ListAlertsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("AlertSummaryList", targetDepth)) { var unmarshaller = new ListUnmarshaller <AlertSummary, AlertSummaryUnmarshaller>(AlertSummaryUnmarshaller.Instance); response.AlertSummaryList = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("NextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } } return(response); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonLookoutMetricsConfig config = new AmazonLookoutMetricsConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonLookoutMetricsClient client = new AmazonLookoutMetricsClient(creds, config); ListAlertsResponse resp = new ListAlertsResponse(); do { ListAlertsRequest req = new ListAlertsRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.ListAlerts(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.AlertSummaryList) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
/// <summary>Prints all the alerts for the logged in user's default account.</summary> private void DisplayAllAlerts() { Console.WriteLine("================================================================="); Console.WriteLine("Listing all alerts"); Console.WriteLine("================================================================="); ListAlertsResponse alertsResponse = service.Accounts.Alerts.List(adSenseAccount.Name).Execute(); if (!alertsResponse.Alerts.IsNullOrEmpty()) { foreach (var alert in alertsResponse.Alerts) { Console.WriteLine("Alert with ID \"{0}\" type \"{1}\" and severity \"{2}\" was found.", alert.Name, alert.Type, alert.Severity); } } else { Console.WriteLine("No alerts found."); } Console.WriteLine(); }