public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonPricingConfig config = new AmazonPricingConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonPricingClient client = new AmazonPricingClient(creds, config); DescribeServicesResponse resp = new DescribeServicesResponse(); do { DescribeServicesRequest req = new DescribeServicesRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.DescribeServices(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Services) { AddObject(obj); } foreach (var obj in resp.FormatVersion) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { DescribeServicesResponse response = new DescribeServicesResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("FormatVersion", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.FormatVersion = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("NextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Services", targetDepth)) { var unmarshaller = new ListUnmarshaller <Service, ServiceUnmarshaller>(ServiceUnmarshaller.Instance); response.Services = unmarshaller.Unmarshall(context); continue; } } return(response); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { DescribeServicesResponse response = new DescribeServicesResponse(); context.Read(); UnmarshallResult(context, response); return(response); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { DescribeServicesResponse response = new DescribeServicesResponse(); context.Read(); response.DescribeServicesResult = DescribeServicesResultUnmarshaller.GetInstance().Unmarshall(context); return(response); }
private static void UnmarshallResult(JsonUnmarshallerContext context, DescribeServicesResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; while (context.Read()) { if (context.TestExpression("services", targetDepth)) { context.Read(); if (context.CurrentTokenType == JsonToken.Null) { response.Services = null; continue; } response.Services = new List <Service>(); ServiceUnmarshaller unmarshaller = ServiceUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } response.Services.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.CurrentDepth <= originalDepth) { return; } } return; }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonAWSSupportConfig config = new AmazonAWSSupportConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonAWSSupportClient client = new AmazonAWSSupportClient(creds, config); DescribeServicesResponse resp = new DescribeServicesResponse(); DescribeServicesRequest req = new DescribeServicesRequest { }; resp = client.DescribeServices(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Services) { AddObject(obj); } }
private async Task GetQueueStatsAsync(QueueConfiguration queueConfiguration, string url, CancellationToken stoppingToken) { GetQueueAttributesResponse queueAttributes = await GetQueueAttributesAsync(queueConfiguration.Name, url, stoppingToken); if (queueAttributes?.HttpStatusCode != HttpStatusCode.OK) { return; } var stats = new SqsStats( queueConfiguration.Name, url, queueAttributes.ApproximateNumberOfMessages, queueAttributes.ApproximateNumberOfMessagesDelayed, queueAttributes.ApproximateNumberOfMessagesNotVisible ); if (queueConfiguration.HasConsumer) { DescribeServicesResponse serviceResponse = await GetServiceDetailsAsync(queueConfiguration.ConsumerCluster, queueConfiguration.ConsumerService); if (serviceResponse?.HttpStatusCode == HttpStatusCode.OK && serviceResponse.Services.Any()) { Service serviceDetails = serviceResponse.Services.First(); stats = stats.WithConsumerStats( queueConfiguration.ConsumerCluster, queueConfiguration.ConsumerService, serviceDetails.RunningCount, serviceDetails.DesiredCount, serviceDetails.PendingCount ); } } await _mediator.Publish(stats, stoppingToken); }