Sha256: f897263bb43217c693e2ddefd415cedd1e665fd220ff5c5a2e3c84f211fa4918

Contents?: true

Size: 1.27 KB

Versions: 22

Compression:

Stored size: 1.27 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

22 entries across 22 versions & 5 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/aws/models/cdn/distributions_helper.rb
fog-aws-0.1.1 lib/fog/aws/models/cdn/distributions_helper.rb
fog-aws-0.1.0 lib/fog/aws/models/cdn/distributions_helper.rb
fog-aws-0.0.8 lib/fog/aws/models/cdn/distributions_helper.rb
fog-aws-0.0.7 lib/fog/aws/models/cdn/distributions_helper.rb
fog-aws-0.0.6 lib/fog/aws/models/cdn/distributions_helper.rb
fog-aws-0.0.5 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.26.0 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.25.0 lib/fog/aws/models/cdn/distributions_helper.rb
nsidc-fog-1.24.1 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.24.0 lib/fog/aws/models/cdn/distributions_helper.rb
ns-fog-1.22.11 lib/fog/aws/models/cdn/distributions_helper.rb
ns-fog-1.22.10 lib/fog/aws/models/cdn/distributions_helper.rb
ns-fog-1.22.9 lib/fog/aws/models/cdn/distributions_helper.rb
ns-fog-1.22.8 lib/fog/aws/models/cdn/distributions_helper.rb
ns-fog-1.22.7 lib/fog/aws/models/cdn/distributions_helper.rb
ns-fog-1.22.6 lib/fog/aws/models/cdn/distributions_helper.rb
fog-1.23.0 lib/fog/aws/models/cdn/distributions_helper.rb
ns-fog-1.22.4 lib/fog/aws/models/cdn/distributions_helper.rb
ns-fog-1.22.3 lib/fog/aws/models/cdn/distributions_helper.rb