ListDistributionsAsync() public method

Initiates the asynchronous execution of the ListDistributions operation.
public ListDistributionsAsync ( ListDistributionsRequest request, System cancellationToken = default(CancellationToken) ) : Task
request Amazon.CloudFront.Model.ListDistributionsRequest Container for the necessary parameters to execute the ListDistributions operation.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
return Task
        private async Task<CloudFrontSetting> CreateCloudFrontDistributionAsync(string bucketName, bool shouldCache = true)
        {
            using (
                var client = new AmazonCloudFrontClient(cfConfigurationProvider.AccessKey,
                    cfConfigurationProvider.SecretKey, cfConfigurationProvider.RegionEndpoint))
            {
                var originId = $"S3-{bucketName}";
                var distrubtions = await client.ListDistributionsAsync();

                var existingDist =
                    distrubtions.DistributionList.Items.SingleOrDefault(
                        summary => summary.Origins.Items.Any(origin => origin.Id == originId));

                if (existingDist != null)
                {
                    return new CloudFrontSetting {BucketName = bucketName, DomainName = existingDist.DomainName};
                }

                var distributionConfig = new DistributionConfig
                {
                    CallerReference = bucketName,
                    Enabled = true,
                    Comment = string.Empty,
                    Origins = new Origins
                    {
                        Items =
                        {
                            new Origin
                            {
                                Id = originId,
                                DomainName =
                                    string.Format("{0}.s3.amazonaws.com", bucketName),
                                S3OriginConfig = new S3OriginConfig {OriginAccessIdentity = string.Empty}
                            }
                        },
                        Quantity = 1
                    },
                    DefaultCacheBehavior = new DefaultCacheBehavior
                    {
                        AllowedMethods = new AllowedMethods {Items = {"HEAD", "GET"}, Quantity = 2},
                        ForwardedValues =
                            new ForwardedValues
                            {
                                Headers =
                                    new Headers
                                    {
                                        Items =
                                        {
                                            "Access-Control-Request-Headers",
                                            "Access-Control-Request-Method",
                                            "Origin"
                                        },
                                        Quantity = 3
                                    },
                                QueryString = true,
                                Cookies = new CookiePreference {Forward = new ItemSelection("none")}
                            },
                        TrustedSigners = new TrustedSigners {Enabled = false, Quantity = 0},
                        MinTTL = 0,
                        MaxTTL = 31536000,
                        DefaultTTL = shouldCache ? 86400 : 0,
                        TargetOriginId = string.Format("S3-{0}", bucketName),
                        ViewerProtocolPolicy = new ViewerProtocolPolicy("allow-all"),
                    },
                    PriceClass = PriceClass.PriceClass_All
                };
                var request = new CreateDistributionRequest(distributionConfig);
                var response = await client.CreateDistributionAsync(request);
                return new CloudFrontSetting
                {
                    BucketName = response.Distribution.DistributionConfig.CallerReference,
                    DomainName = response.Distribution.DomainName
                };
            }
        }
        /// <summary>
        /// Checks if Cloudfront with CNAME already exists.  Returns true if it exist, otherwise false.
        /// </summary>
        /// <returns></returns>
        private async Task<GetDistributionResponse> GetDistributionByCNAMEAsync()
        {
            loggerProvider.GetLogger().Debug($"Checking if cloudfront exists. [CNAME: {cfConfigurationProvider.CNAME}]");
            using (var client = new AmazonCloudFrontClient(cfConfigurationProvider.AccessKey, cfConfigurationProvider.SecretKey, cfConfigurationProvider.RegionEndpoint))
            {
                var listDistributionResponse = await client.ListDistributionsAsync();
                var distributionSummary = listDistributionResponse.DistributionList.Items.SingleOrDefault(cf => cf.Aliases.Items.Any(alias => alias.ToLower().StartsWith(cfConfigurationProvider.CNAME.ToLower())));


                if (distributionSummary == null)
                {
                    return null;
                }
                else
                {
                    var distributionResponse = await client.GetDistributionAsync(new GetDistributionRequest(distributionSummary.Id));
                    return distributionResponse;
                }

            }
        }