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

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

Introduction

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

Prototype


public void setLogging(StreamingLoggingConfig logging) 

Source Link

Document

A complex type that controls whether access logs are written for the streaming distribution.

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 w  w . j a v a  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();
}

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

License:Open Source License

protected UpdateStreamingDistributionResult updateStreamingDistribution(final Path container,
        final Distribution distribution) throws IOException, BackgroundException {
    final URI origin = this.getOrigin(container, distribution.getMethod());
    if (log.isDebugEnabled()) {
        log.debug(String.format("Update %s distribution with origin %s", distribution.getMethod().toString(),
                origin));/*from  w  w  w .  j  a  va 2s.  c o  m*/
    }
    final AmazonCloudFront client = client(container);
    final GetStreamingDistributionConfigResult response = client
            .getStreamingDistributionConfig(new GetStreamingDistributionConfigRequest(distribution.getId()));
    final StreamingDistributionConfig config = response.getStreamingDistributionConfig()
            .withEnabled(distribution.isEnabled())
            .withS3Origin(new S3Origin(origin.getHost(), StringUtils.EMPTY)).withAliases(new Aliases()
                    .withItems(distribution.getCNAMEs()).withQuantity(distribution.getCNAMEs().length));
    if (distribution.isLogging()) {
        // 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.updateStreamingDistribution(
            new UpdateStreamingDistributionRequest(config, distribution.getId(), response.getETag()));
}