A distribution Configuration.

 /// <summary>
 /// Sets the DistributionConfig property
 /// </summary>
 /// <param name="distributionConfig">The value to set for the DistributionConfig property </param>
 /// <returns>this instance</returns>
 public GetDistributionConfigResult WithDistributionConfig(DistributionConfig distributionConfig)
 {
     this.distributionConfig = distributionConfig;
     return this;
 }
 /// <summary>
 /// Sets the DistributionConfig property
 /// </summary>
 /// <param name="distributionConfig">The value to set for the DistributionConfig property </param>
 /// <returns>this instance</returns>
 public GetDistributionConfigResult WithDistributionConfig(DistributionConfig distributionConfig)
 {
     this.distributionConfig = distributionConfig;
     return(this);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Instantiates UpdateDistributionRequest with the parameterized properties
 /// </summary>
 /// <param name="id">The distribution's id.</param>
 /// <param name="ifMatch">The value of the <code>ETag</code> header that you received when retrieving the distribution's configuration. For example: <code>E2QWRUHAPOMQZL</code>.</param>
 /// <param name="distributionConfig">The distribution's configuration information.</param>
 public UpdateDistributionRequest(string id, string ifMatch, DistributionConfig distributionConfig)
 {
     _id                 = id;
     _ifMatch            = ifMatch;
     _distributionConfig = distributionConfig;
 }
 /// <summary>
 /// Instantiates CreateDistributionRequest with the parameterized properties
 /// </summary>
 /// <param name="distributionConfig">The distribution's configuration information.</param>
 public CreateDistributionRequest(DistributionConfig distributionConfig)
 {
     _distributionConfig = distributionConfig;
 }
 /// <summary>
 /// Instantiates CreateDistributionRequest with the parameterized properties
 /// </summary>
 /// <param name="distributionConfig">The distribution's configuration information.</param>
 public CreateDistributionRequest(DistributionConfig distributionConfig)
 {
     _distributionConfig = distributionConfig;
 }
 public UpdateDistributionRequest WithDistributionConfig(DistributionConfig distributionConfig)
 {
     this.distributionConfig = distributionConfig;
     return(this);
 }
 /// <summary>
 /// Instantiates UpdateDistributionRequest with the parameterized properties
 /// </summary>
 /// <param name="id">The distribution's id.</param>
 /// <param name="ifMatch">The value of the ETag header you received when retrieving the distribution's configuration. For example: E2QWRUHAPOMQZL.</param>
 /// <param name="distributionConfig">The distribution's configuration information.</param>
 public UpdateDistributionRequest(string id, string ifMatch, DistributionConfig distributionConfig)
 {
     _id = id;
     _ifMatch = ifMatch;
     _distributionConfig = distributionConfig;
 }
 /// <summary>
 /// Sets the DistributionConfig property
 /// </summary>
 /// <param name="distributionConfig">The value to set for the DistributionConfig property </param>
 /// <returns>this instance</returns>
 public UpdateDistributionRequest WithDistributionConfig(DistributionConfig distributionConfig)
 {
     this.distributionConfig = distributionConfig;
     return this;
 }
Exemplo n.º 9
0
 public Distribution WithDistributionConfig(DistributionConfig distributionConfig)
 {
     this.distributionConfig = distributionConfig;
     return this;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Sets the DistributionConfig property
 /// </summary>
 /// <param name="distributionConfig">The value to set for the DistributionConfig property </param>
 /// <returns>this instance</returns>
 public Distribution WithDistributionConfig(DistributionConfig distributionConfig)
 {
     this.distributionConfig = distributionConfig;
     return(this);
 }
        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
                };
            }
        }