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-maestrodev-1.15.0.20130927082724 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.15.0.20130829165835 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.15.0 lib/fog/aws/models/cdn/distributions_helper.rb
gapinc-fog-1.14.0 lib/fog/aws/models/cdn/distributions_helper.rb
fog-maestrodev-1.14.0.20130806165225 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.14.0 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.13.0 lib/fog/aws/models/cdn/distributions_helper.rb
gapinc-fog-1.12.1.2 lib/fog/aws/models/cdn/distributions_helper.rb
gapinc-fog-1.12.1.1 lib/fog/aws/models/cdn/distributions_helper.rb
gapinc-fog-1.12.1a lib/fog/aws/models/cdn/distributions_helper.rb
gapinc-fog-1.12.1 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.12.1 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.12.0 lib/fog/aws/models/cdn/distributions_helper.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/aws/models/cdn/distributions_helper.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.11.1 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.11.0 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.10.1 lib/fog/aws/models/cdn/distributions_helper.rb
fog-test-me-1.10.0 lib/fog/aws/models/cdn/distributions_helper.rb