Class: Fog::CDN::AWS::Real

Inherits:
Object
  • Object
show all
Includes:
AWS::CredentialFetcher::ConnectionMethods
Defined in:
lib/fog/aws/cdn.rb,
lib/fog/aws/requests/cdn/get_distribution.rb,
lib/fog/aws/requests/cdn/get_invalidation.rb,
lib/fog/aws/requests/cdn/post_distribution.rb,
lib/fog/aws/requests/cdn/post_invalidation.rb,
lib/fog/aws/requests/cdn/delete_distribution.rb,
lib/fog/aws/requests/cdn/get_distribution_list.rb,
lib/fog/aws/requests/cdn/get_invalidation_list.rb,
lib/fog/aws/requests/cdn/put_distribution_config.rb,
lib/fog/aws/requests/cdn/get_streaming_distribution.rb,
lib/fog/aws/requests/cdn/post_streaming_distribution.rb,
lib/fog/aws/requests/cdn/delete_streaming_distribution.rb,
lib/fog/aws/requests/cdn/get_streaming_distribution_list.rb,
lib/fog/aws/requests/cdn/put_streaming_distribution_config.rb

Instance Method Summary collapse

Methods included from AWS::CredentialFetcher::ConnectionMethods

#refresh_credentials_if_expired

Constructor Details

#initialize(options = {}) ⇒ Real

Initialize connection to Cloudfront

Notes

options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection

Examples

cdn = Fog::AWS::CDN.new(
  :aws_access_key_id => your_aws_access_key_id,
  :aws_secret_access_key => your_aws_secret_access_key
)

Parameters

  • options<~Hash> - config arguments for connection. Defaults to {}.

Returns

  • cdn object with connection to aws.



146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/fog/aws/cdn.rb', line 146

def initialize(options={})
  require 'fog/core/parser'

  @use_iam_profile = options[:use_iam_profile]
  setup_credentials(options)
  @connection_options = options[:connection_options] || {}
  @host       = options[:host]      || 'cloudfront.amazonaws.com'
  @path       = options[:path]      || '/'
  @persistent = options.fetch(:persistent, true)
  @port       = options[:port]      || 443
  @scheme     = options[:scheme]    || 'https'
  @version    = options[:version]  || '2010-11-01'
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end

Instance Method Details

#delete_distribution(distribution_id, etag) ⇒ Object

Delete a distribution from CloudFront.

Parameters:

  • distribution_id (String)

    Id of distribution to delete.

  • etag (String)

    etag of that distribution from earlier get or put

See Also:



13
14
15
16
17
18
19
20
21
# File 'lib/fog/aws/requests/cdn/delete_distribution.rb', line 13

def delete_distribution(distribution_id, etag)
  request({
    :expects    => 204,
    :headers    => { 'If-Match' => etag },
    :idempotent => true,
    :method     => 'DELETE',
    :path       => "/distribution/#{distribution_id}"
  })
end

#delete_streaming_distribution(distribution_id, etag) ⇒ Object

Delete a streaming distribution from CloudFront.

Parameters:

  • distribution_id (String)

    Id of distribution to delete.

  • etag (String)

    Etag of that distribution from earlier get or put

See Also:



13
14
15
16
17
18
19
20
21
# File 'lib/fog/aws/requests/cdn/delete_streaming_distribution.rb', line 13

def delete_streaming_distribution(distribution_id, etag)
  request({
    :expects    => 204,
    :headers    => { 'If-Match' => etag },
    :idempotent => true,
    :method     => 'DELETE',
    :path       => "/streaming-distribution/#{distribution_id}"
  })
end

#get_distribution(distribution_id) ⇒ Excon::Response

Get information about a distribution from CloudFront.

Parameters:

  • distribution_id (String)

    Id of distribution.

Returns:

  • (Excon::Response)
    • body [Hash]:

      • S3Origin [Hash]:

        • DNSName [String] - Origin to associate with distribution, ie ‘mybucket.s3.amazonaws.com’.

        • OriginAccessIdentity [String] - Optional: Used when serving private content.

      or

      • CustomOrigin [Hash]:

        • DNSName [String] - Origin to associate with distribution, ie ‘www.example.com’.

        • HTTPPort [Integer] - HTTP port of origin, in [80, 443] or (1024…65535).

        • HTTPSPort [Integer] - HTTPS port of origin, in [80, 443] or (1024…65535).

        • OriginProtocolPolicy [String] - Policy on using http vs https, in [‘http-only’, ‘match-viewer’].

      • Id [String] Id of distribution.

      • LastModifiedTime [String] - Timestamp of last modification of distribution.

      • Status [String] - Status of distribution.

      • DistributionConfig [Array]:

        • CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s.

        • CNAME [Array] - Array of associated cnames.

        • Comment [String] - Comment associated with distribution.

        • Enabled [Boolean] - Whether or not distribution is enabled.

        • InProgressInvalidationBatches [Integer] - Number of invalidation batches in progress.

        • Logging [Hash]:

          • Bucket [String] - Bucket logs are stored in.

          • Prefix [String] - Prefix logs are stored with.

        • Origin [String] - S3 origin bucket.

        • TrustedSigners [Array] - Trusted signers.

See Also:



41
42
43
44
45
46
47
48
49
# File 'lib/fog/aws/requests/cdn/get_distribution.rb', line 41

def get_distribution(distribution_id)
  request({
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::Parsers::CDN::AWS::Distribution.new,
    :path       => "/distribution/#{distribution_id}"
  })
end

#get_distribution_list(options = {}) ⇒ Excon::Response

Returns * body [Hash]:

* IsTruncated [Boolean] - Whether or not the listing is truncated.
* Marker [String] Marker specified for query.
* MaxItems [Integer] - Maximum number of keys specified for query.
* NextMarker [String] - Marker to specify for next page (id of last result of current page).
* DistributionSummary [Array]:
  * S3Origin [Hash]:
    * DNSName [String] - Origin to associate with distribution, ie 'mybucket.s3.amazonaws.com'.
    * OriginAccessIdentity [String] - Optional: Used when serving private content.
  or
  * CustomOrigin [Hash]:
    * DNSName [String] - Origin to associate with distribution, ie 'www.example.com'.
    * HTTPPort [Integer] - HTTP port of origin, in [80, 443] or (1024...65535).
    * HTTPSPort [Integer] - HTTPS port of origin, in [80, 443] or (1024...65535).
  * OriginProtocolPolicy [String] - Policy on using http vs https, in ['http-only', 'match-viewer'].
  * Comment [String] - Comment associated with distribution.
  * CNAME [Array] - Array of associated cnames.
  * Enabled [Boolean] - Whether or not distribution is enabled.
  * Id [String] - Id of distribution.
  * LastModifiedTime [String] - Timestamp of last modification of distribution.
  * Origin [String] - S3 origin bucket.
  * Status [String] - Status of distribution.
  * TrustedSigners [Array] - Trusted signers.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • MaxItems (Integer)

    Limits number of object keys returned.

Returns:

  • (Excon::Response)
    • body [Hash]:

      • IsTruncated [Boolean] - Whether or not the listing is truncated.

      • Marker [String] Marker specified for query.

      • MaxItems [Integer] - Maximum number of keys specified for query.

      • NextMarker [String] - Marker to specify for next page (id of last result of current page).

      • DistributionSummary [Array]:

        • S3Origin [Hash]:

          • DNSName [String] - Origin to associate with distribution, ie ‘mybucket.s3.amazonaws.com’.

          • OriginAccessIdentity [String] - Optional: Used when serving private content.

        or

        • CustomOrigin [Hash]:

          • DNSName [String] - Origin to associate with distribution, ie ‘www.example.com’.

          • HTTPPort [Integer] - HTTP port of origin, in [80, 443] or (1024…65535).

          • HTTPSPort [Integer] - HTTPS port of origin, in [80, 443] or (1024…65535).

        • OriginProtocolPolicy [String] - Policy on using http vs https, in [‘http-only’, ‘match-viewer’].

        • Comment [String] - Comment associated with distribution.

        • CNAME [Array] - Array of associated cnames.

        • Enabled [Boolean] - Whether or not distribution is enabled.

        • Id [String] - Id of distribution.

        • LastModifiedTime [String] - Timestamp of last modification of distribution.

        • Origin [String] - S3 origin bucket.

        • Status [String] - Status of distribution.

        • TrustedSigners [Array] - Trusted signers.

See Also:



41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/aws/requests/cdn/get_distribution_list.rb', line 41

def get_distribution_list(options = {})
  request({
    :expects    => 200,
    :idempotent => true,
    :method   => 'GET',
    :parser   => Fog::Parsers::CDN::AWS::GetDistributionList.new,
    :path       => "/distribution",
    :query      => options
  })
end

#get_invalidation(distribution_id, invalidation_id) ⇒ Excon::Response

Get invalidation.

Parameters:

  • distribution_id (String)

    Distribution id.

  • invalidation_id (String)

    Invalidation id.

Returns:

  • (Excon::Response)
    • body [Hash]:

      • Id [String] - Invalidation id.

      • Status [String]

      • CreateTime [String]

      • InvalidationBatch [Array]:

        • Path [String]

See Also:



23
24
25
26
27
28
29
30
31
# File 'lib/fog/aws/requests/cdn/get_invalidation.rb', line 23

def get_invalidation(distribution_id, invalidation_id)
  request({
    :expects    => 200,
    :idempotent => true,
    :method   => 'GET',
    :parser   => Fog::Parsers::CDN::AWS::GetInvalidation.new,
    :path       => "/distribution/#{distribution_id}/invalidation/#{invalidation_id}"
  })
end

#get_invalidation_list(distribution_id, options = {}) ⇒ Excon::Response

Get invalidation list.

Parameters:

  • options (Hash) (defaults to: {})

    Config arguments for list.

Options Hash (options):

  • Marker (String)

    Limits object keys to only those that appear lexicographically after its value.

  • MaxItems (Integer)

    Limits number of object keys returned.

Returns:

  • (Excon::Response)
    • body [Hash]:

      • IsTruncated [Boolean] - Whether or not the listing is truncated.

      • Marker [String] - Marker specified for query.

      • MaxItems [Integer] - Maximum number of keys specified for query.

      • NextMarker [String] - Marker to specify for next page (id of last result of current page).

      • InvalidationSummary [Array]:

        • Id [String]

        • Status [String]

See Also:



26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/aws/requests/cdn/get_invalidation_list.rb', line 26

def get_invalidation_list(distribution_id, options = {})
  request({
    :expects    => 200,
    :idempotent => true,
    :method   => 'GET',
    :parser   => Fog::Parsers::CDN::AWS::GetInvalidationList.new,
    :path       => "/distribution/#{distribution_id}/invalidation",
    :query      => options
  })
end

#get_streaming_distribution(distribution_id) ⇒ Excon::Response

Get information about a streaming distribution from CloudFront.

Parameters:

  • distribution_id (String)

    Id of distribution.

Returns:

  • (Excon::Response)
    • body [Hash]:

      • S3Origin [Hash]:

        • DNSName [String] - Origin to associate with distribution, ie ‘mybucket.s3.amazonaws.com’.

        • OriginAccessIdentity [String] - Optional: Used when serving private content.

      • Id [String] - Id of distribution.

      • LastModifiedTime [String] - Timestamp of last modification of distribution.

      • Status [String] - Status of distribution.

      • StreamingDistributionConfig [Array]:

        • CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s.

        • CNAME [Array] - Array of associated cnames.

        • Comment [String] - Comment associated with distribution.

        • Enabled [Boolean] - Whether or not distribution is enabled.

        • InProgressInvalidationBatches [Integer] - Number of invalidation batches in progress.

        • Logging [Hash]:

          • Bucket [String] - Bucket logs are stored in.

          • Prefix [String] - Prefix logs are stored with.

        • Origin [String] - S3 origin bucket.

        • TrustedSigners [Array] - Trusted signers.

See Also:



34
35
36
37
38
39
40
41
42
# File 'lib/fog/aws/requests/cdn/get_streaming_distribution.rb', line 34

def get_streaming_distribution(distribution_id)
  request({
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::Parsers::CDN::AWS::StreamingDistribution.new,
    :path       => "/streaming-distribution/#{distribution_id}"
  })
end

#get_streaming_distribution_list(options = {}) ⇒ Excon::Response

List information about distributions in CloudFront.

Parameters:

  • options (Hash) (defaults to: {})

    Config arguments for list.

Options Hash (options):

  • Marker (String)

    Limits object keys to only those that appear lexicographically after its value.

  • MaxItems (Integer)

    Limits number of object keys returned.

Returns:

  • (Excon::Response)
    • body [Hash]:

      • IsTruncated [Boolean] - Whether or not the listing is truncated.

      • Marker [String] - Marker specified for query.

      • MaxItems [Integer] - Maximum number of keys specified for query.

      • NextMarker [String] - Marker to specify for next page (id of last result of current page).

      • StreamingDistributionSummary [Array]:

        • S3Origin [Hash]:

          • DNSName [String] - Origin to associate with distribution, ie ‘mybucket.s3.amazonaws.com’.

          • OriginAccessIdentity [String] - Optional: Used when serving private content.

        or

        • CustomOrigin [Hash]:

          • DNSName [String] - Origin to associate with distribution, ie ‘www.example.com’.

          • HTTPPort [Integer] - HTTP port of origin, in [80, 443] or (1024…65535).

          • HTTPSPort [Integer] - HTTPS port of origin, in [80, 443] or (1024…65535).

        • OriginProtocolPolicy [String] - Policy on using http vs https, in [‘http-only’, ‘match-viewer’].

        • Comment [String] - Comment associated with distribution.

        • CNAME [Array] - Array of associated cnames.

        • Enabled [Boolean] - Whether or not distribution is enabled.

        • Id [String] - Id of distribution.

        • LastModifiedTime [String] - Timestamp of last modification of distribution.

        • Origin [String] - S3 origin bucket.

        • Status [String] - Status of distribution.

        • TrustedSigners [Array] - Trusted signers.

See Also:



41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/aws/requests/cdn/get_streaming_distribution_list.rb', line 41

def get_streaming_distribution_list(options = {})
  request({
    :expects    => 200,
    :idempotent => true,
    :method   => 'GET',
    :parser   => Fog::Parsers::CDN::AWS::GetStreamingDistributionList.new,
    :path       => "/streaming-distribution",
    :query      => options
  })
end

#post_distribution(options = {}) ⇒ Excon::Response

Create a new distribution in CloudFront.

Parameters:

  • options (Hash) (defaults to: {})

    Config for distribution.

    REQUIRED:

    • S3Origin [Hash]:

      • DNSName [String] Origin to associate with distribution, ie ‘mybucket.s3.amazonaws.com’.

      • OriginAccessIdentity [String] Optional: used when serving private content.

    or

    • CustomOrigin [Hash]:

      • DNSName [String] Origin to associate with distribution, ie ‘www.example.com’.

      • HTTPPort [Integer] Optional HTTP port of origin, in [80, 443] or (1024…65535), defaults to 80.

      • HTTPSPort [Integer] Optional HTTPS port of origin, in [80, 443] or (1024…65535), defaults to 443.

      • OriginProtocolPolicy [String] Policy on using http vs https, in [‘http-only’, ‘match-viewer’].

    OPTIONAL:

    • CallerReference [String] Used to prevent replay, defaults to Time.now.to_i.to_s.

    • Comment [String] Optional comment about distribution.

    • CNAME [Array] Optional array of strings to set as CNAMEs.

    • DefaultRootObject [String] Optional default object to return for ‘/’.

    • Enabled [Boolean] Whether or not distribution should accept requests, defaults to true.

    • Logging [Hash]: Optional logging config.

      • Bucket [String] Bucket to store logs in, ie ‘mylogs.s3.amazonaws.com’.

      • Prefix [String] Optional prefix for log filenames, ie ‘myprefix/’.

    • OriginAccessIdentity [String] Used for serving private content, in format ‘origin-access-identity/cloudfront/ID’.

    • RequiredProtocols [String] Optional, set to ‘https’ to force https connections.

    • TrustedSigners [Array] Optional grant of rights to up to 5 aws accounts to generate signed URLs for private content, elements are either ‘Self’ for your own account or an AWS Account Number.

Returns:

  • (Excon::Response)
    • body [Hash]:

      • DomainName [String] - Domain name of distribution.

      • Id [String] - Id of distribution.

      • LastModifiedTime [String] - Timestamp of last modification of distribution.

      • Status [String] - Status of distribution.

      • DistributionConfig [Array]:

        • CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s.

        • CNAME [Array] - Array of associated cnames.

        • Comment [String] - Comment associated with distribution.

        • Enabled [Boolean] - Whether or not distribution is enabled.

        • Logging [Hash]:

          • Bucket [String] - Bucket logs are stored in.

          • Prefix [String] - Prefix logs are stored with.

        • Origin [String] - S3 origin bucket.

        • TrustedSigners [Array] - Trusted signers.

See Also:



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fog/aws/requests/cdn/post_distribution.rb', line 54

def post_distribution(options = {})
  options['CallerReference'] = Time.now.to_i.to_s
  data = '<?xml version="1.0" encoding="UTF-8"?>'
  data << "<DistributionConfig xmlns=\"http://cloudfront.amazonaws.com/doc/#{@version}/\">"
  for key, value in options
    case value
    when Array
      for item in value
        data << "<#{key}>#{item}</#{key}>"
      end
    when Hash
      data << "<#{key}>"
      for inner_key, inner_value in value
        data << "<#{inner_key}>#{inner_value}</#{inner_key}>"
      end
      data << "</#{key}>"
    else
      data << "<#{key}>#{value}</#{key}>"
    end
  end
  data << "</DistributionConfig>"
  request({
    :body       => data,
    :expects    => 201,
    :headers    => { 'Content-Type' => 'text/xml' },
    :idempotent => true,
    :method     => 'POST',
    :parser     => Fog::Parsers::CDN::AWS::Distribution.new,
    :path       => "/distribution"
  })
end

#post_invalidation(distribution_id, paths, caller_reference = Time.now.to_i.to_s) ⇒ Excon::Response

List information about distributions in CloudFront.

Parameters:

  • distribution_id (String)

    Id of distribution for invalidations.

  • paths (Array)

    Array of string paths to objects to invalidate.

  • caller_reference (String) (defaults to: Time.now.to_i.to_s)

    Used to prevent replay, defaults to Time.now.to_i.to_s.

Returns:

  • (Excon::Response)
    • body [Hash]:

      • Id [String] - Id of invalidation.

      • Status [String] - Status of invalidation.

      • CreateTime [Integer] - Time of invalidation creation.

      • InvalidationBatch [Array]:

        • Path [Array] - Array of strings of objects to invalidate.

        • CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s.

See Also:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/aws/requests/cdn/post_invalidation.rb', line 25

def post_invalidation(distribution_id, paths, caller_reference = Time.now.to_i.to_s)
  body = '<?xml version="1.0" encoding="UTF-8"?>'
  body << "<InvalidationBatch>"
  for path in [*paths]
    body << "<Path>" << path << "</Path>"
  end
  body << "<CallerReference>" << caller_reference << "</CallerReference>"
  body << "</InvalidationBatch>"
  request({
    :body       => body,
    :expects    => 201,
    :headers    => {'Content-Type' => 'text/xml'},
    :idempotent => true,
    :method     => 'POST',
    :parser     => Fog::Parsers::CDN::AWS::PostInvalidation.new,
    :path       => "/distribution/#{distribution_id}/invalidation"
  })
end

#post_streaming_distribution(options = {}) ⇒ Excon::Response

Create a new streaming distribution in CloudFront.

Parameters:

  • options (Hash) (defaults to: {})

    Config for distribution.

    REQUIRED:

    • S3Origin [Hash]:

      • DNSName [String] Origin to associate with distribution, ie ‘mybucket.s3.amazonaws.com’.

    OPTIONAL:

    • CallerReference [String] Used to prevent replay, defaults to Time.now.to_i.to_s.

    • Comment [String] Optional comment about distribution.

    • CNAME [Array] Optional array of strings to set as CNAMEs.

    • Enabled [Boolean] Whether or not distribution should accept requests, defaults to true.

    • Logging [Hash]: Optional logging config.

      • Bucket [String] Bucket to store logs in, ie ‘mylogs.s3.amazonaws.com’.

      • Prefix [String] Optional prefix for log filenames, ie ‘myprefix/’.

Returns:

  • (Excon::Response)
    • body:

      • Id [String] - Id of distribution.

      • Status’ - Status of distribution.

      • LastModifiedTime [String] - Timestamp of last modification of distribution.

      • DomainName [String] - Domain name of distribution.

      • StreamingDistributionConfig [Array]:

        • CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s.

        • CNAME [Array] - Array of associated cnames.

        • Comment [String] - Comment associated with distribution.

        • Enabled [Boolean] - Whether or not distribution is enabled.

        • Logging [Hash]:

          • Bucket [String] - Bucket logs are stored in.

          • Prefix [String] - Prefix logs are stored with.

See Also:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fog/aws/requests/cdn/post_streaming_distribution.rb', line 41

def post_streaming_distribution(options = {})
  options['CallerReference'] = Time.now.to_i.to_s
  data = '<?xml version="1.0" encoding="UTF-8"?>'
  data << "<StreamingDistributionConfig xmlns=\"http://cloudfront.amazonaws.com/doc/#{@version}/\">"
  for key, value in options
    case value
    when Array
      for item in value
        data << "<#{key}>#{item}</#{key}>"
      end
    when Hash
      data << "<#{key}>"
      for inner_key, inner_value in value
        data << "<#{inner_key}>#{inner_value}</#{inner_key}>"
      end
      data << "</#{key}>"
    else
      data << "<#{key}>#{value}</#{key}>"
    end
  end
  data << "</StreamingDistributionConfig>"
  request({
    :body       => data,
    :expects    => 201,
    :headers    => { 'Content-Type' => 'text/xml' },
    :idempotent => true,
    :method     => 'POST',
    :parser     => Fog::Parsers::CDN::AWS::StreamingDistribution.new,
    :path       => "/streaming-distribution"
  })
end

#put_distribution_config(distribution_id, etag, options = {}) ⇒ Excon::Response

Update a distribution in CloudFront.

Parameters:

  • distribution_id (String)

    Id of distribution to update config for.

  • options (Hash) (defaults to: {})

    Config for distribution.

    REQUIRED:

    • S3Origin [Hash]:

      • DNSName [String] - origin to associate with distribution, ie ‘mybucket.s3.amazonaws.com’.

      • OriginAccessIdentity [String] - Optional: Used when serving private content.

    or

    • CustomOrigin [Hash]:

      • DNSName [String] - Origin to associate with distribution, ie ‘www.example.com’.

      • HTTPPort [Integer] - HTTP port of origin, in [80, 443] or (1024…65535).

      • HTTPSPort [Integer] - HTTPS port of origin, in [80, 443] or (1024…65535).

      • OriginProtocolPolicy [String] - Policy on using http vs https, in [‘http-only’, ‘match-viewer’].

    OPTIONAL:

    • CallerReference [String] Used to prevent replay, defaults to Time.now.to_i.to_s.

    • Comment [String] Optional comment about distribution.

    • CNAME [Array] Optional array of strings to set as CNAMEs.

    • DefaultRootObject [String] Optional default object to return for ‘/’.

    • Enabled [Boolean] Whether or not distribution should accept requests, defaults to true.

    • Logging [Hash]: Optional logging config.

      • Bucket [String] Bucket to store logs in, ie ‘mylogs.s3.amazonaws.com’.

      • Prefix [String] Optional prefix for log filenames, ie ‘myprefix/’.

    • OriginAccessIdentity [String] Used for serving private content, in format ‘origin-access-identity/cloudfront/ID’.

    • RequiredProtocols [String] Optional, set to ‘https’ to force https connections.

    • TrustedSigners [Array] Optional grant of rights to up to 5 aws accounts to generate signed URLs for private content, elements are either ‘Self’ for your own account or an AWS Account Number.

Returns:

  • (Excon::Response)
    • body [Hash]:

      • DomainName [String]: Domain name of distribution.

      • Id [String] - Id of distribution.

      • LastModifiedTime [String] - Timestamp of last modification of distribution.

      • Status [String] - Status of distribution.

      • DistributionConfig [Array]:

        • CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s.

        • CNAME [Array] - Array of associated cnames.

        • Comment [String] - Comment associated with distribution.

        • Enabled [Boolean] - Whether or not distribution is enabled.

        • Logging [Hash]:

          • Bucket [String] - Bucket logs are stored in.

          • Prefix [String] - Prefix logs are stored with.

        • Origin [String] - S3 origin bucket.

        • TrustedSigners [Array] - Trusted signers.

See Also:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/fog/aws/requests/cdn/put_distribution_config.rb', line 55

def put_distribution_config(distribution_id, etag, options = {})
  data = '<?xml version="1.0" encoding="UTF-8"?>'
  data << "<DistributionConfig xmlns=\"http://cloudfront.amazonaws.com/doc/#{@version}/\">"
  for key, value in options
    case value
    when Array
      for item in value
        data << "<#{key}>#{item}</#{key}>"
      end
    when Hash
      data << "<#{key}>"
      for inner_key, inner_value in value
        data << "<#{inner_key}>#{inner_value}</#{inner_key}>"
      end
      data << "</#{key}>"
    else
      data << "<#{key}>#{value}</#{key}>"
    end
  end
  data << "</DistributionConfig>"
  request({
    :body       => data,
    :expects    => 200,
    :headers    => {
      'Content-Type'  => 'text/xml',
      'If-Match'      => etag
    },
    :idempotent => true,
    :method     => 'PUT',
    :parser     => Fog::Parsers::CDN::AWS::Distribution.new,
    :path       => "/distribution/#{distribution_id}/config"
  })
end

#put_streaming_distribution_config(distribution_id, etag, options = {}) ⇒ Excon::Response

Update a streaming distribution in CloudFront.

Parameters:

  • distribution_id (String)
    • Id of distribution to update config for.

  • options (Hash) (defaults to: {})
    • Config for distribution.

    REQUIRED:

    • S3Origin [Hash]:

      • DNSName [String] Origin to associate with distribution, ie ‘mybucket.s3.amazonaws.com’.

    OPTIONAL:

Options Hash (options):

  • CallerReference (String)

    Used to prevent replay, defaults to Time.now.to_i.to_s

  • Comment (String)

    Optional comment about distribution

  • CNAME (Array)

    Optional array of strings to set as CNAMEs

  • Enabled (Boolean)

    Whether or not distribution should accept requests, defaults to true

  • Logging (Hash)

    : Optional logging config

    • Bucket [String] Bucket to store logs in, ie ‘mylogs.s3.amazonaws.com’

    • Prefix String] Optional prefix for log filenames, ie ‘myprefix/’

Returns:

  • (Excon::Response)
    • body [Hash]:

      • DomainName [String] - Domain name of distribution.

      • Id [String] - Id of distribution.

      • LastModifiedTime [String] - Timestamp of last modification of distribution.

      • Status [String] - Status of distribution.

      • StreamingDistributionConfig [Array]:

        • CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s.

        • CNAME [Array] - Array of associated cnames.

        • Comment [String] - Comment associated with distribution.

        • Enabled [Boolean] - Whether or not distribution is enabled.

        • Logging [Hash]:

          • Bucket [String] - Bucket logs are stored in.

          • Prefix [String] - Prefix logs are stored with.

        • Origin [String] - S3 origin bucket.

        • TrustedSigners [Array] - Trusted signers.

See Also:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fog/aws/requests/cdn/put_streaming_distribution_config.rb', line 44

def put_streaming_distribution_config(distribution_id, etag, options = {})
  data = '<?xml version="1.0" encoding="UTF-8"?>'
  data << "<StreamingDistributionConfig xmlns=\"http://cloudfront.amazonaws.com/doc/#{@version}/\">"
  for key, value in options
    case value
    when Array
      for item in value
        data << "<#{key}>#{item}</#{key}>"
      end
    when Hash
      data << "<#{key}>"
      for inner_key, inner_value in value
        data << "<#{inner_key}>#{inner_value}</#{inner_key}>"
      end
      data << "</#{key}>"
    else
      data << "<#{key}>#{value}</#{key}>"
    end
  end
  data << "</StreamingDistributionConfig>"
  request({
    :body       => data,
    :expects    => 200,
    :headers    => {
      'Content-Type'  => 'text/xml',
      'If-Match'      => etag
    },
    :idempotent => true,
    :method     => 'PUT',
    :parser     => Fog::Parsers::CDN::AWS::StreamingDistribution.new,
    :path       => "/streaming-distribution/#{distribution_id}/config"
  })
end

#reloadObject



161
162
163
# File 'lib/fog/aws/cdn.rb', line 161

def reload
  @connection.reset
end