Sha256: 38a853cd5aaae5228333052566b61dc9a0ba47e09afe2477eaf0317ff97fff16

Contents?: true

Size: 1.28 KB

Versions: 59

Compression:

Stored size: 1.28 KB

Contents

require 'fog/core/collection'

module Fog
  module CDN
    class AWS

      module DistributionsHelper
        
        def all(options = {})
          merge_attributes(options)
          data = list_distributions(options).body
          merge_attributes('IsTruncated' => data['IsTruncated'], 'Marker' => data['Marker'], 'MaxItems' => data['MaxItems'])
          if summary = data['DistributionSummary']
            load(summary.map { |a| { 'DistributionConfig' => a } })
          else
            load((data['StreamingDistributionSummary'] || {}).map { |a| { 'StreamingDistributionConfig' => a }})
          end
        end

        def get(dist_id)
          response = get_distribution(dist_id)
          data = response.body.merge({'ETag' => response.headers['ETag']})
          new(data)
        rescue Excon::Errors::NotFound
          nil
        end

        def each_distribution
          if !block_given?
            self
          else
            subset = dup.all

            subset.each_distribution_this_page {|f| yield f}
            while subset.is_truncated
              subset = subset.all('Marker' => subset.marker, 'MaxItems' => 1000)
              subset.each_distribution_this_page {|f| yield f}
            end

            self
          end
        end

      end

    end
  end
end

Version data entries

59 entries across 59 versions & 5 rubygems

Version Path
fog-1.22.0 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.21.0 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.20.0 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.19.0 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/aws/models/cdn/distributions_helper.rb