/// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DescribeClustersResponse response = new DescribeClustersResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("clusters", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Cluster, ClusterUnmarshaller>(ClusterUnmarshaller.Instance);
                    response.Clusters = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("failures", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Failure, FailureUnmarshaller>(FailureUnmarshaller.Instance);
                    response.Failures = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Пример #2
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DescribeClustersResponse response = new DescribeClustersResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("DescribeClustersResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return(response);
        }
Пример #3
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, DescribeClustersResponse response)
        {
            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("clusters/member", targetDepth))
                    {
                        var unmarshaller = ClusterUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.Clusters.Add(item);
                        continue;
                    }
                    if (context.TestExpression("failures/member", targetDepth))
                    {
                        var unmarshaller = FailureUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.Failures.Add(item);
                        continue;
                    }
                }
            }

            return;
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonRedshiftConfig config = new AmazonRedshiftConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonRedshiftClient client = new AmazonRedshiftClient(creds, config);

            DescribeClustersResponse resp = new DescribeClustersResponse();

            do
            {
                DescribeClustersRequest req = new DescribeClustersRequest
                {
                    Marker = resp.Marker
                    ,
                    MaxRecords = maxItems
                };

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

                foreach (var obj in resp.Clusters)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.Marker));
        }
Пример #5
0
        public static DescribeClustersResponse Unmarshall(UnmarshallerContext context)
        {
            DescribeClustersResponse describeClustersResponse = new DescribeClustersResponse();

            describeClustersResponse.HttpResponse = context.HttpResponse;
            describeClustersResponse.RequestId    = context.StringValue("DescribeClusters.RequestId");
            describeClustersResponse.TotalCount   = context.LongValue("DescribeClusters.TotalCount");
            describeClustersResponse.PageNumber   = context.IntegerValue("DescribeClusters.PageNumber");
            describeClustersResponse.PageSize     = context.IntegerValue("DescribeClusters.PageSize");

            List <DescribeClustersResponse.DescribeClusters_Cluster> describeClustersResponse_clusters = new List <DescribeClustersResponse.DescribeClusters_Cluster>();

            for (int i = 0; i < context.Length("DescribeClusters.Clusters.Length"); i++)
            {
                DescribeClustersResponse.DescribeClusters_Cluster cluster = new DescribeClustersResponse.DescribeClusters_Cluster();
                cluster.ClusterId       = context.StringValue("DescribeClusters.Clusters[" + i + "].ClusterId");
                cluster.ClusterName     = context.StringValue("DescribeClusters.Clusters[" + i + "].ClusterName");
                cluster.Status          = context.StringValue("DescribeClusters.Clusters[" + i + "].Status");
                cluster.PayType         = context.StringValue("DescribeClusters.Clusters[" + i + "].PayType");
                cluster.CreatedTime     = context.StringValue("DescribeClusters.Clusters[" + i + "].CreatedTime");
                cluster.ExpireTime      = context.StringValue("DescribeClusters.Clusters[" + i + "].ExpireTime");
                cluster.MajorVersion    = context.StringValue("DescribeClusters.Clusters[" + i + "].MajorVersion");
                cluster.MinorVersion    = context.StringValue("DescribeClusters.Clusters[" + i + "].MinorVersion");
                cluster.DataCenterCount = context.IntegerValue("DescribeClusters.Clusters[" + i + "].DataCenterCount");
                cluster.LockMode        = context.StringValue("DescribeClusters.Clusters[" + i + "].LockMode");

                describeClustersResponse_clusters.Add(cluster);
            }
            describeClustersResponse.Clusters = describeClustersResponse_clusters;

            return(describeClustersResponse);
        }
Пример #6
0
        public static DescribeClustersResponse Unmarshall(UnmarshallerContext context)
        {
            DescribeClustersResponse describeClustersResponse = new DescribeClustersResponse();

            describeClustersResponse.HttpResponse = context.HttpResponse;

            return(describeClustersResponse);
        }
Пример #7
0
        public void SetUp()
        {
            var stepClusterMock = new Mock <IAmazonDAX>();

            _firstPage = new DescribeClustersResponse
            {
                NextToken = "token-1",
                Clusters  = new List <Cluster>
                {
                    new Cluster
                    {
                        ClusterName = "ClusterName - 1"
                    }
                }
            };

            _secondPage = new DescribeClustersResponse
            {
                NextToken = "token-2",
                Clusters  = new List <Cluster>
                {
                    new Cluster
                    {
                        ClusterName = "ClusterName - 2"
                    }
                }
            };


            _thirdPage = new DescribeClustersResponse
            {
                Clusters = new List <Cluster>
                {
                    new Cluster
                    {
                        ClusterName = "ClusterName - 3"
                    }
                }
            };

            stepClusterMock.Setup(c => c.DescribeClustersAsync(
                                      It.Is <DescribeClustersRequest>(r => r.NextToken == null)
                                      , It.IsAny <CancellationToken>()))
            .ReturnsAsync(_firstPage);

            stepClusterMock.Setup(c => c.DescribeClustersAsync(
                                      It.Is <DescribeClustersRequest>(r => r.NextToken == "token-1")
                                      , It.IsAny <CancellationToken>()))
            .ReturnsAsync(_secondPage);

            stepClusterMock.Setup(c => c.DescribeClustersAsync(
                                      It.Is <DescribeClustersRequest>(r => r.NextToken == "token-2")
                                      , It.IsAny <CancellationToken>()))
            .ReturnsAsync(_thirdPage);

            _source = new DaxSource(stepClusterMock.Object);
        }
Пример #8
0
        public static DescribeClustersResponse Unmarshall(UnmarshallerContext context)
        {
            DescribeClustersResponse describeClustersResponse = new DescribeClustersResponse();

            describeClustersResponse.HttpResponse = context.HttpResponse;
            describeClustersResponse.RequestId    = context.StringValue("DescribeClusters.RequestId");
            describeClustersResponse.TotalCount   = context.LongValue("DescribeClusters.TotalCount");
            describeClustersResponse.PageNumber   = context.IntegerValue("DescribeClusters.PageNumber");
            describeClustersResponse.PageSize     = context.IntegerValue("DescribeClusters.PageSize");

            List <DescribeClustersResponse.DescribeClusters_Cluster> describeClustersResponse_clusters = new List <DescribeClustersResponse.DescribeClusters_Cluster>();

            for (int i = 0; i < context.Length("DescribeClusters.Clusters.Length"); i++)
            {
                DescribeClustersResponse.DescribeClusters_Cluster cluster = new DescribeClustersResponse.DescribeClusters_Cluster();
                cluster.ClusterId       = context.StringValue("DescribeClusters.Clusters[" + i + "].ClusterId");
                cluster.ClusterName     = context.StringValue("DescribeClusters.Clusters[" + i + "].ClusterName");
                cluster.Status          = context.StringValue("DescribeClusters.Clusters[" + i + "].Status");
                cluster.PayType         = context.StringValue("DescribeClusters.Clusters[" + i + "].PayType");
                cluster.CreatedTime     = context.StringValue("DescribeClusters.Clusters[" + i + "].CreatedTime");
                cluster.ExpireTime      = context.StringValue("DescribeClusters.Clusters[" + i + "].ExpireTime");
                cluster.MajorVersion    = context.StringValue("DescribeClusters.Clusters[" + i + "].MajorVersion");
                cluster.MinorVersion    = context.StringValue("DescribeClusters.Clusters[" + i + "].MinorVersion");
                cluster.DataCenterCount = context.IntegerValue("DescribeClusters.Clusters[" + i + "].DataCenterCount");
                cluster.LockMode        = context.StringValue("DescribeClusters.Clusters[" + i + "].LockMode");
                cluster.AutoRenewal     = context.BooleanValue("DescribeClusters.Clusters[" + i + "].AutoRenewal");
                cluster.AutoRenewPeriod = context.IntegerValue("DescribeClusters.Clusters[" + i + "].AutoRenewPeriod");

                List <DescribeClustersResponse.DescribeClusters_Cluster.DescribeClusters_Tag> cluster_tags = new List <DescribeClustersResponse.DescribeClusters_Cluster.DescribeClusters_Tag>();
                for (int j = 0; j < context.Length("DescribeClusters.Clusters[" + i + "].Tags.Length"); j++)
                {
                    DescribeClustersResponse.DescribeClusters_Cluster.DescribeClusters_Tag tag = new DescribeClustersResponse.DescribeClusters_Cluster.DescribeClusters_Tag();
                    tag.Key    = context.StringValue("DescribeClusters.Clusters[" + i + "].Tags[" + j + "].Key");
                    tag._Value = context.StringValue("DescribeClusters.Clusters[" + i + "].Tags[" + j + "].Value");

                    cluster_tags.Add(tag);
                }
                cluster.Tags = cluster_tags;

                describeClustersResponse_clusters.Add(cluster);
            }
            describeClustersResponse.Clusters = describeClustersResponse_clusters;

            return(describeClustersResponse);
        }
        public static DescribeClustersResponse Unmarshall(UnmarshallerContext context)
        {
            DescribeClustersResponse describeClustersResponse = new DescribeClustersResponse();

            describeClustersResponse.HttpResponse = context.HttpResponse;
            describeClustersResponse.RequestId    = context.StringValue("DescribeClusters.RequestId");

            List <DescribeClustersResponse.DescribeClusters_Cluster> describeClustersResponse_clusters = new List <DescribeClustersResponse.DescribeClusters_Cluster>();

            for (int i = 0; i < context.Length("DescribeClusters.Clusters.Length"); i++)
            {
                DescribeClustersResponse.DescribeClusters_Cluster cluster = new DescribeClustersResponse.DescribeClusters_Cluster();
                cluster.ClusterId = context.StringValue("DescribeClusters.Clusters[" + i + "].ClusterId");

                describeClustersResponse_clusters.Add(cluster);
            }
            describeClustersResponse.Clusters = describeClustersResponse_clusters;

            return(describeClustersResponse);
        }
Пример #10
0
        public static DescribeClustersResponse Unmarshall(UnmarshallerContext context)
        {
            DescribeClustersResponse describeClustersResponse = new DescribeClustersResponse()
            {
                HttpResponse = context.HttpResponse,
                RequestId    = context.StringValue("DescribeClusters.RequestId")
            };
            List <DescribeClustersResponse.Cluster> clusters = new List <DescribeClustersResponse.Cluster>();

            for (int i = 0; i < context.Length("DescribeClusters.Clusters.Length"); i++)
            {
                DescribeClustersResponse.Cluster cluster = new DescribeClustersResponse.Cluster()
                {
                    ClusterId = context.StringValue($"DescribeClusters.Clusters[{i}].ClusterId")
                };
                clusters.Add(cluster);
            }
            describeClustersResponse.Clusters = clusters;

            return(describeClustersResponse);
        }
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DescribeClustersResponse response = new DescribeClustersResponse();

            while (context.Read())
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("DescribeClustersResult", 2))
                    {
                        response.DescribeClustersResult = DescribeClustersResultUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context);
                    }
                }
            }


            return(response);
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, DescribeClustersResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("Marker", targetDepth))
                    {
                        response.Marker = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("Clusters/Cluster", targetDepth))
                    {
                        response.Clusters.Add(ClusterUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }



            return;
        }