/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { DescribeProductsResponse response = new DescribeProductsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("NextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Products", targetDepth)) { var unmarshaller = new ListUnmarshaller <Product, ProductUnmarshaller>(ProductUnmarshaller.Instance); response.Products = unmarshaller.Unmarshall(context); continue; } } return(response); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonSecurityHubConfig config = new AmazonSecurityHubConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonSecurityHubClient client = new AmazonSecurityHubClient(creds, config); DescribeProductsResponse resp = new DescribeProductsResponse(); do { DescribeProductsRequest req = new DescribeProductsRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.DescribeProducts(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Products) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
public static DescribeProductsResponse Unmarshall(UnmarshallerContext context) { DescribeProductsResponse describeProductsResponse = new DescribeProductsResponse(); describeProductsResponse.HttpResponse = context.HttpResponse; describeProductsResponse.RequestId = context.StringValue("DescribeProducts.RequestId"); describeProductsResponse.PageNumber = context.IntegerValue("DescribeProducts.PageNumber"); describeProductsResponse.PageSize = context.IntegerValue("DescribeProducts.PageSize"); describeProductsResponse.TotalCount = context.IntegerValue("DescribeProducts.TotalCount"); List <DescribeProductsResponse.DescribeProducts_ProductItem> describeProductsResponse_productItems = new List <DescribeProductsResponse.DescribeProducts_ProductItem>(); for (int i = 0; i < context.Length("DescribeProducts.ProductItems.Length"); i++) { DescribeProductsResponse.DescribeProducts_ProductItem productItem = new DescribeProductsResponse.DescribeProducts_ProductItem(); productItem.Code = context.StringValue("DescribeProducts.ProductItems[" + i + "].Code"); productItem.Name = context.StringValue("DescribeProducts.ProductItems[" + i + "].Name"); productItem.CategoryId = context.LongValue("DescribeProducts.ProductItems[" + i + "].CategoryId"); productItem.SupplierId = context.LongValue("DescribeProducts.ProductItems[" + i + "].SupplierId"); productItem.SupplierName = context.StringValue("DescribeProducts.ProductItems[" + i + "].SupplierName"); productItem.ShortDescription = context.StringValue("DescribeProducts.ProductItems[" + i + "].ShortDescription"); productItem.Tags = context.StringValue("DescribeProducts.ProductItems[" + i + "].Tags"); productItem.SuggestedPrice = context.StringValue("DescribeProducts.ProductItems[" + i + "].SuggestedPrice"); productItem.TargetUrl = context.StringValue("DescribeProducts.ProductItems[" + i + "].TargetUrl"); productItem.ImageUrl = context.StringValue("DescribeProducts.ProductItems[" + i + "].ImageUrl"); productItem.Score = context.StringValue("DescribeProducts.ProductItems[" + i + "].Score"); productItem.OperationSystem = context.StringValue("DescribeProducts.ProductItems[" + i + "].OperationSystem"); productItem.WarrantyDate = context.StringValue("DescribeProducts.ProductItems[" + i + "].WarrantyDate"); productItem.DeliveryDate = context.StringValue("DescribeProducts.ProductItems[" + i + "].DeliveryDate"); productItem.DeliveryWay = context.StringValue("DescribeProducts.ProductItems[" + i + "].DeliveryWay"); describeProductsResponse_productItems.Add(productItem); } describeProductsResponse.ProductItems = describeProductsResponse_productItems; return(describeProductsResponse); }