Class: Fog::CDN::AWS::Invalidations

Inherits:
Fog::Collection show all
Defined in:
lib/fog/aws/models/cdn/invalidations.rb

Instance Attribute Summary

Attributes inherited from Fog::Collection

#service

Instance Method Summary collapse

Methods inherited from Fog::Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Instance Method Details

#all(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/aws/models/cdn/invalidations.rb', line 19

def all(options = {})
  requires :distribution
  options[:max_items]  ||= max_items
  options.delete_if {|key, value| value.nil?}

  data = service.get_invalidation_list(distribution.identity, options).body

  merge_attributes(data.reject {|key, value| !['IsTruncated', 'MaxItems', 'NextMarker', 'Marker'].include?(key)})

  load(data['InvalidationSummary'])
end

#get(invalidation_id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/aws/models/cdn/invalidations.rb', line 31

def get(invalidation_id)
  requires :distribution

  data = service.get_invalidation(distribution.identity, invalidation_id).body

  if data
    invalidation = new(data)
  else
    nil
  end
rescue Excon::Errors::NotFound
  nil
end

#new(attributes = {}) ⇒ Object



45
46
47
48
# File 'lib/fog/aws/models/cdn/invalidations.rb', line 45

def new(attributes = {})
  requires :distribution
  super({ :distribution => distribution }.merge!(attributes))
end