Example usage for com.amazonaws.services.cloudfront.model StreamingDistributionConfig StreamingDistributionConfig

List of usage examples for com.amazonaws.services.cloudfront.model StreamingDistributionConfig StreamingDistributionConfig

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudfront.model StreamingDistributionConfig StreamingDistributionConfig.

Prototype

public StreamingDistributionConfig(String callerReference, S3Origin s3Origin, Boolean enabled) 

Source Link

Document

Constructs a new StreamingDistributionConfig object.

Usage

From source file:ch.cyberduck.core.cloudfront.CloudFrontDistributionConfiguration.java

License:Open Source License

/**
 * Amazon CloudFront Extension to create a new distribution configuration
 *
 * @return Distribution configuration/*from   w ww. ja  va 2  s.  c  o  m*/
 */
protected StreamingDistribution createStreamingDistribution(final Path container,
        final Distribution distribution) throws BackgroundException {
    if (log.isDebugEnabled()) {
        log.debug(String.format("Create new %s distribution", distribution.getMethod().toString()));
    }
    final AmazonCloudFront client = client(container);
    final URI origin = this.getOrigin(container, distribution.getMethod());
    final String originId = String.format("%s-%s", preferences.getProperty("application.name"),
            new AlphanumericRandomStringService().random());
    final StreamingDistributionConfig config = new StreamingDistributionConfig(
            new AlphanumericRandomStringService().random(), new S3Origin(origin.getHost(), StringUtils.EMPTY),
            distribution.isEnabled()).withComment(originId)
                    .withTrustedSigners(new TrustedSigners().withEnabled(false).withQuantity(0))
                    .withAliases(new Aliases().withItems(distribution.getCNAMEs())
                            .withQuantity(distribution.getCNAMEs().length));
    // Make bucket name fully qualified
    final String loggingTarget = ServiceUtils.generateS3HostnameForBucket(distribution.getLoggingContainer(),
            false, new S3Protocol().getDefaultHostname());
    if (log.isDebugEnabled()) {
        log.debug(String.format("Set logging target for %s to %s", distribution, loggingTarget));
    }
    config.setLogging(new StreamingLoggingConfig().withEnabled(distribution.isLogging())
            .withBucket(loggingTarget).withPrefix(preferences.getProperty("cloudfront.logging.prefix")));
    return client.createStreamingDistribution(new CreateStreamingDistributionRequest(config))
            .getStreamingDistribution();
}