Module: Cloudfront::OriginAccessIdentity

Included in:
Cloudfront
Defined in:
lib/cloudfront/origin_access_identity/origin_access_identity.rb

Constant Summary collapse

URL =
"/#{Cloudfront::Utils::Api.version}/origin-access-identity/cloudfront"

Instance Method Summary collapse

Instance Method Details

#get_origin_access_identity_wrapper(hash) ⇒ Object



55
56
# File 'lib/cloudfront/origin_access_identity/origin_access_identity.rb', line 55

def get_origin_access_identity_wrapper(hash)
end

#origin_access_identity_create(origin_access_identity = nil) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/cloudfront/origin_access_identity/origin_access_identity.rb', line 10

def origin_access_identity_create(origin_access_identity = nil)
  origin_access_identity ||= OriginAccessIdentity.new
  connection.post do |request|
    request.url URL
    request.body = origin_access_identity.to_xml
  end
end

#origin_access_identity_delete(origin_access_identity_id) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cloudfront/origin_access_identity/origin_access_identity.rb', line 42

def origin_access_identity_delete(origin_access_identity_id)
  # 1. get the origin_access_identity configuration
  response = origin_access_identity_get_config(origin_access_identity_id)
  etag = response.headers['etag']
  raise Cloudfront::Exceptions::MissingEtagException.new("The etag for the origin_access_identity #{origin_access_identity_id} is missing") if etag.nil? || etag.blank?

  # 2. send a delete request with the returned etag
  connection.delete do |request|
    request.url URL + '/' + origin_access_identity_id
    request.headers['If-Match'] = etag
  end
end

#origin_access_identity_get(origin_access_identity_id) ⇒ Object



26
27
28
# File 'lib/cloudfront/origin_access_identity/origin_access_identity.rb', line 26

def origin_access_identity_get(origin_access_identity_id)
  connection.get URL + '/' + origin_access_identity_id
end

#origin_access_identity_get_config(origin_access_identity_id) ⇒ Object



30
31
32
# File 'lib/cloudfront/origin_access_identity/origin_access_identity.rb', line 30

def origin_access_identity_get_config(origin_access_identity_id)
  connection.get URL + '/' + origin_access_identity_id + '/config'
end

#origin_access_identity_list(max_items = 0, marker = "") ⇒ Object



18
19
20
21
22
23
24
# File 'lib/cloudfront/origin_access_identity/origin_access_identity.rb', line 18

def origin_access_identity_list(max_items = 0, marker = "")
  connection.get do |request|
    request.url URL
    request.params['Marker'] = marker unless marker.nil? || marker.blank?
    request.params['MaxItems'] = max_items if max_items > 0
  end
end

#origin_access_identity_put_config(origin_access_identity_id, origin_access_identity, etag) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/cloudfront/origin_access_identity/origin_access_identity.rb', line 34

def origin_access_identity_put_config(origin_access_identity_id, origin_access_identity, etag)
  connection.put do |request|
    request.url URL + '/' + origin_access_identity_id + '/config'
    request.headers['If-Match'] = etag
    request.body = origin_access_identity.to_xml
  end
end