module Fog::CDN::Rackspace::Base

Constants

URI_HEADERS

Public Instance Methods

endpoint_uri(service_endpoint_url=nil) click to toggle source
Calls superclass method
# File lib/fog/rackspace/cdn.rb, line 38
def endpoint_uri(service_endpoint_url=nil)
  @uri = super(@rackspace_cdn_url || service_endpoint_url, :rackspace_cdn_url)
end
publish_container(container, publish = true) click to toggle source

Publish container to CDN @param [Fog::Storage::Rackspace::Directory] container directory to publish @param [Boolean] publish If true directory is published. If false directory is unpublished. @return [Hash] hash containing urls for published container @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404 @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400 @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500 @raise [Fog::Storage::Rackspace::ServiceError]

# File lib/fog/rackspace/cdn.rb, line 50
def publish_container(container, publish = true)
  enabled = publish ? 'True' : 'False'
  response = put_container(container.key, 'X-Cdn-Enabled' => enabled)
  return {} unless publish
  urls_from_headers(response.headers)
end
region() click to toggle source
# File lib/fog/rackspace/cdn.rb, line 30
def region
  @rackspace_region
end
request_id_header() click to toggle source
# File lib/fog/rackspace/cdn.rb, line 34
def request_id_header
  "X-Trans-Id"
end
service_name() click to toggle source
# File lib/fog/rackspace/cdn.rb, line 26
def service_name
  :cloudFilesCDN
end
urls(container) click to toggle source

Returns hash of urls for container @param [Fog::Storage::Rackspace::Directory] container to retrieve urls for @return [Hash] hash containing urls for published container @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400 @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500 @raise [Fog::Storage::Rackspace::ServiceError] @note If unable to find container or container is not published this method will return an empty hash.

# File lib/fog/rackspace/cdn.rb, line 64
def urls(container)
  begin 
    response = head_container(container.key)
    return {} unless response.headers['X-Cdn-Enabled'] == 'True'
    urls_from_headers response.headers
  rescue Fog::Service::NotFound
    {}
  end
end

Private Instance Methods

urls_from_headers(headers) click to toggle source
# File lib/fog/rackspace/cdn.rb, line 76
def urls_from_headers(headers)
  h = {}
  URI_HEADERS.keys.each do | header |
    key = URI_HEADERS[header]              
    h[key] = headers[header]
  end
  h
end