1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[rackspace|storage] first pass of cdn support

This commit is contained in:
geemus 2010-10-20 16:58:15 -07:00
parent 8aec42583e
commit 8a651fe1c6
4 changed files with 124 additions and 2 deletions

View file

@ -0,0 +1,39 @@
module Fog
module Rackspace
class Storage
class Real
# List existing cdn-enabled storage containers
#
# ==== Parameters
# * options<~Hash>:
# * 'enabled_only'<~Boolean> - Set to true to limit results to cdn enabled containers
# * 'limit'<~Integer> - Upper limit to number of results returned
# * 'marker'<~String> - Only return objects with name greater than this value
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * container<~String>: Name of container
def get_cdn_containers(options = {})
response = cdn_request(
:expects => [200, 204],
:method => 'GET',
:path => '',
:query => {'format' => 'json'}.merge!(options)
)
response
end
end
class Mock
def get_cdn_containers(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,41 @@
module Fog
module Rackspace
class Storage
class Real
# List cdn properties for a container
#
# ==== Parameters
# * container<~String> - Name of container to retrieve info for
#
# ==== Returns
# * response<~Excon::Response>:
# * headers<~Hash>:
# * 'X-CDN-Enabled'<~Boolean> - cdn status for container
# * 'X-CDN-URI'<~String> - cdn url for this container
# * 'X-TTL'<~String> - integer seconds before data expires, defaults to 86400 (1 day)
# * 'X-Log-Retention'<~Boolean> - ?
# * 'X-User-Agent-ACL'<~String> - ?
# * 'X-Referrer-ACL'<~String> - ?
def head_cdn_container(container)
response = cdn_request(
:expects => 204,
:method => 'HEAD',
:path => container,
:query => {'format' => 'json'}
)
response
end
end
class Mock
def head_cdn_container(container)
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,38 @@
module Fog
module Rackspace
class Storage
class Real
# modify CDN properties for a container
#
# ==== Parameters
# * name<~String> - Name for container, should be < 256 bytes and must not contain '/'
# # options<~Hash>:
# * 'X-CDN-Enabled'<~Boolean> - cdn status for container
# * 'X-CDN-URI'<~String> - cdn url for this container
# * 'X-TTL'<~String> - integer seconds before data expires, defaults to 86400 (1 day), in 3600..259200
# * 'X-Log-Retention'<~Boolean> - ?
# * 'X-User-Agent-ACL'<~String> - ?
# * 'X-Referrer-ACL'<~String> - ?
def put_cdn_container(name, options = {})
response = cdn_request(
:expects => [201, 202],
:headers => options,
:method => 'PUT',
:path => CGI.escape(name)
)
response
end
end
class Mock
def put_cdn_container(name, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -14,11 +14,14 @@ module Fog
request :delete_container request :delete_container
request :delete_object request :delete_object
request :get_container request :get_container
request :get_cdn_containers
request :get_containers request :get_containers
request :get_object request :get_object
request :head_cdn_container
request :head_container request :head_container
request :head_containers request :head_containers
request :head_object request :head_object
request :put_cdn_container
request :put_container request :put_container
request :put_object request :put_object
@ -94,10 +97,11 @@ module Fog
end end
def reload def reload
@connection.reset @cdn_connection.reset
@storage_connection.reset
end end
def cdn_request(params) def cdn_request(params, parse_json = true)
begin begin
response = @cdn_connection.request(params.merge!({ response = @cdn_connection.request(params.merge!({
:headers => { :headers => {