public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonEC2Config config = new AmazonEC2Config(); config.RegionEndpoint = region; ConfigureClient(config); AmazonEC2Client client = new AmazonEC2Client(creds, config); DescribePublicIpv4PoolsResponse resp = new DescribePublicIpv4PoolsResponse(); do { DescribePublicIpv4PoolsRequest req = new DescribePublicIpv4PoolsRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.DescribePublicIpv4Pools(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.PublicIpv4Pools) { 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(XmlUnmarshallerContext context) { DescribePublicIpv4PoolsResponse response = new DescribePublicIpv4PoolsResponse(); 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("nextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("publicIpv4PoolSet/item", targetDepth)) { var unmarshaller = PublicIpv4PoolUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.PublicIpv4Pools.Add(item); continue; } } } return(response); }