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

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

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



            return;
        }
Esempio n. 2
0
        public void Only_Retrieve_Distributions_Once()
        {
            var cloudfrontClient = new Mock <AmazonCloudFront>();

            var distributionId = Guid.NewGuid().ToString();
            var bucket         = Guid.NewGuid().ToString();
            var distribution   = bucket + ".s3.amazonaws.com";
            var key            = Guid.NewGuid().ToString();

            var listDistributionsResponse = new ListDistributionsResponse();

            listDistributionsResponse.Distribution.Add(new CloudFrontDistribution
            {
                Id = distributionId,
                DistributionConfig = new CloudFrontDistributionConfig
                {
                    S3Origin = new S3Origin(distribution, null)
                }
            });

            cloudfrontClient.Setup(cfc => cfc.ListDistributions())
            .Returns(listDistributionsResponse);

            var invalidator = new CloudFrontInvalidator(cloudfrontClient.Object);

            invalidator.InvalidateObject(bucket, key);
            invalidator.InvalidateObject(bucket, key);

            cloudfrontClient.Verify(cfc => cfc.PostInvalidation(It.Is <PostInvalidationRequest>(pir => pir.DistributionId == distributionId &&
                                                                                                pir.InvalidationBatch.Paths.Count == 1 &&
                                                                                                pir.InvalidationBatch.Paths.First() == key)), Times.Exactly(2));

            cloudfrontClient.Verify(cfc => cfc.ListDistributions(), Times.Once());
        }
Esempio n. 3
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonCloudFrontConfig config = new AmazonCloudFrontConfig();

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

            ListDistributionsResponse resp = new ListDistributionsResponse();

            do
            {
                ListDistributionsRequest req = new ListDistributionsRequest
                {
                    Marker = resp.DistributionListNextMarker
                    ,
                    MaxItems = maxItems
                };

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

                foreach (var obj in resp.DistributionListItems)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.DistributionListNextMarker));
        }
        public void SetUp()
        {
            var stepCloudFrontMock = new Mock <IAmazonCloudFront>();

            _firstPage  = BuildListResponse(1);
            _secondPage = BuildListResponse(2);
            _thirdPage  = BuildListResponse(null);

            stepCloudFrontMock.Setup(c => c.ListDistributionsAsync(
                                         It.Is <ListDistributionsRequest>(r => r.Marker == null),
                                         It.IsAny <CancellationToken>()))
            .ReturnsAsync(_firstPage);

            stepCloudFrontMock.Setup(c => c.ListDistributionsAsync(
                                         It.Is <ListDistributionsRequest>(r => r.Marker == "token-1"),
                                         It.IsAny <CancellationToken>()))
            .ReturnsAsync(_secondPage);

            stepCloudFrontMock.Setup(c => c.ListDistributionsAsync(
                                         It.Is <ListDistributionsRequest>(r => r.Marker == "token-2"),
                                         It.IsAny <CancellationToken>()))
            .ReturnsAsync(_thirdPage);

            _source = new CloudFrontSource(stepCloudFrontMock.Object);
        }
        public List <string> GetCloudFrontDistributionDomains()
        {
            ListDistributionsRequest  request  = new ListDistributionsRequest();
            ListDistributionsResponse response = _client.ListDistributions(request);

            return(response.Distribution.Select(dist => dist.DomainName).ToList());
        }
Esempio n. 6
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            ListDistributionsResponse response = new ListDistributionsResponse();

            UnmarshallResult(context, response);

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

            response.ListDistributionsResult = ListDistributionsResultUnmarshaller.GetInstance().Unmarshall(context);


            return(response);
        }