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:
parent
8aec42583e
commit
8a651fe1c6
4 changed files with 124 additions and 2 deletions
39
lib/fog/rackspace/requests/storage/get_cdn_containers.rb
Normal file
39
lib/fog/rackspace/requests/storage/get_cdn_containers.rb
Normal 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
|
41
lib/fog/rackspace/requests/storage/head_cdn_container.rb
Normal file
41
lib/fog/rackspace/requests/storage/head_cdn_container.rb
Normal 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
|
38
lib/fog/rackspace/requests/storage/put_cdn_container.rb
Normal file
38
lib/fog/rackspace/requests/storage/put_cdn_container.rb
Normal 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
|
|
@ -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 => {
|
||||||
|
|
Loading…
Reference in a new issue