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);

            DescribeImportSnapshotTasksResponse resp = new DescribeImportSnapshotTasksResponse();

            do
            {
                DescribeImportSnapshotTasksRequest req = new DescribeImportSnapshotTasksRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.DescribeImportSnapshotTasks(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.ImportSnapshotTasks)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
Пример #2
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DescribeImportSnapshotTasksResponse response = new DescribeImportSnapshotTasksResponse();

            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("importSnapshotTaskSet/item", targetDepth))
                    {
                        var unmarshaller = ImportSnapshotTaskUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.ImportSnapshotTasks.Add(item);
                        continue;
                    }
                    if (context.TestExpression("nextToken", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.NextToken = unmarshaller.Unmarshall(context);
                        continue;
                    }
                }
            }

            return(response);
        }