Module: Cloudfront::Invalidation::Invalidations

Included in:
Cloudfront
Defined in:
lib/cloudfront/invalidation/invalidations.rb

Constant Summary collapse

INVALIDATION_URL =
"/#{Cloudfront::Utils::Api.version}/distribution/%s/invalidation"

Instance Method Summary collapse

Instance Method Details

#invalidation_get(distribution_id, invalidation_id) ⇒ Faraday::Response

gets the invalidation information.

Parameters:

  • distribution_id (String)

    The id of the distribution.

  • invalidation_id (String)

    The id of the invalidation.

Returns:

  • (Faraday::Response)

    the response from cloudfront



39
40
41
# File 'lib/cloudfront/invalidation/invalidations.rb', line 39

def invalidation_get(distribution_id, invalidation_id)
  connection.get INVALIDATION_URL % distribution_id + '/' + invalidation_id
end

#invalidation_list(distribution_id, max_items = 0, marker = "") ⇒ Faraday::Response

Lists all the invalidations.

Parameters:

  • distribution_id (String)

    The id of the distribution.

  • max_items (int) (defaults to: 0)

    the max items to be retrieved

  • marker (String) (defaults to: "")

    The invalidation from which begins the list.

Returns:

  • (Faraday::Response)

    the response from cloudfront



27
28
29
30
31
32
33
# File 'lib/cloudfront/invalidation/invalidations.rb', line 27

def invalidation_list(distribution_id, max_items = 0, marker = "")
  connection.get do |request|
    request.url INVALIDATION_URL % distribution_id
    request.params['Marker'] = marker unless marker.nil? || marker.strip.empty?
    request.params['MaxItems'] = max_items if max_items > 0
  end
end

#invalidation_send(distribution_id, files, caller_reference = nil) ⇒ Faraday::Response

Invalidates files

Parameters:

  • distribution_id (String)

    The id of the distribution.

  • files (Array)

    an array of files to be invalidated.

  • caller_reference (String) (defaults to: nil)

    The custom caller reference to be added to the request.

Returns:

  • (Faraday::Response)

    the response from cloudfront



15
16
17
18
19
20
# File 'lib/cloudfront/invalidation/invalidations.rb', line 15

def invalidation_send(distribution_id, files, caller_reference = nil)
  connection.post do |request|
    request.url INVALIDATION_URL % distribution_id
    request.body = invalidation_body(files, caller_reference)
  end
end