Object
# File lib/fog/rackspace/cdn.rb, line 47 def initialize(options={}) require 'multi_json' @connection_options = options[:connection_options] || {} credentials = Fog::Rackspace.authenticate(options, @connection_options) @auth_token = credentials['X-Auth-Token'] @enabled = false @persistent = options[:persistent] || false if credentials['X-CDN-Management-Url'] uri = URI.parse(credentials['X-CDN-Management-Url']) @host = uri.host @path = uri.path @port = uri.port @scheme = uri.scheme @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) @enabled = true end end
# File lib/fog/rackspace/cdn.rb, line 66 def enabled? @enabled end
List existing cdn-enabled storage containers
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
response<~Excon::Response>:
body<~Array>:
container<~String>: Name of container
# File lib/fog/rackspace/requests/cdn/get_containers.rb, line 18 def get_containers(options = {}) response = request( :expects => [200, 204], :method => 'GET', :path => '', :query => {'format' => 'json'}.merge!(options) ) response end
List cdn properties for a container
container<~String> - Name of container to retrieve info for
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> - ?
# File lib/fog/rackspace/requests/cdn/head_container.rb, line 20 def head_container(container) response = request( :expects => 204, :method => 'HEAD', :path => container, :query => {'format' => 'json'} ) response end
modify CDN properties for a container
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> - ?
# File lib/fog/rackspace/requests/cdn/post_container.rb, line 17 def post_container(name, options = {}) response = request( :expects => [201, 202], :headers => options, :method => 'POST', :path => CGI.escape(name) ) response end
enable CDN for a container
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> - ?
# File lib/fog/rackspace/requests/cdn/put_container.rb, line 17 def put_container(name, options = {}) response = request( :expects => [201, 202], :headers => options, :method => 'PUT', :path => CGI.escape(name) ) response end
# File lib/fog/rackspace/cdn.rb, line 70 def reload @cdn_connection.reset end
# File lib/fog/rackspace/cdn.rb, line 74 def request(params, parse_json = true) begin response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, :path => "#{@path}/#{params[:path]}", })) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Storage::Rackspace::NotFound.slurp(error) else error end end if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %{application/json} response.body = MultiJson.decode(response.body) end response end
Generated with the Darkfish Rdoc Generator 2.