Ejemplo n.º 1
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DescribeVolumeStatusResponse response = new DescribeVolumeStatusResponse();

            int targetDepth = 2;

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("volumeStatusSet/item", targetDepth))
                    {
                        response.VolumeStatuses.Add(VolumeStatusItemUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                    if (context.TestExpression("nextToken", targetDepth))
                    {
                        response.NextToken = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                }
            }


            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DescribeVolumeStatusResponse response = new DescribeVolumeStatusResponse();

            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("volumeStatusSet/item", targetDepth))
                    {
                        var unmarshaller = VolumeStatusItemUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.VolumeStatuses.Add(item);
                        continue;
                    }
                }
            }

            return(response);
        }
Ejemplo n.º 3
0
        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);

            DescribeVolumeStatusResponse resp = new DescribeVolumeStatusResponse();

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

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

                foreach (var obj in resp.VolumeStatuses)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }