class Fog::Rackspace::CDNV2::Real
Public Class Methods
new(options = {})
click to toggle source
# File lib/fog/rackspace/cdn_v2.rb, line 58 def initialize(options = {}) @rackspace_api_key = options[:rackspace_api_key] @rackspace_username = options[:rackspace_username] @rackspace_auth_url = options[:rackspace_auth_url] @rackspace_region = options[:rackspace_region] @connection_options = options[:connection_options] || {} @rackspace_must_reauthenticate = false authenticate @persistent = options[:persistent] || false @connection = Fog::Core::Connection.new(endpoint_uri.to_s, @persistent, @connection_options) end
Public Instance Methods
authenticate(options={})
click to toggle source
Calls superclass method
Fog::Rackspace::Service#authenticate
# File lib/fog/rackspace/cdn_v2.rb, line 98 def authenticate(options={}) super({ :rackspace_api_key => @rackspace_api_key, :rackspace_username => @rackspace_username, :rackspace_auth_url => @rackspace_auth_url, :connection_options => @connection_options }) end
create_service(service)
click to toggle source
# File lib/fog/rackspace/requests/cdn_v2/create_service.rb, line 2 def create_service(service) request( :expects => [201, 202], :method => 'POST', :body => Fog::JSON.encode(service), :path => "services" ) end
delete_assets(service, options={})
click to toggle source
# File lib/fog/rackspace/requests/cdn_v2/delete_assets.rb, line 2 def delete_assets(service, options={}) uri = request_uri("services/#{service.id}/assets", options) request( :expects => 202, :method => 'DELETE', :path => uri, :headers => { :accept => "*/*" } ) end
delete_service(service)
click to toggle source
# File lib/fog/rackspace/requests/cdn_v2/delete_service.rb, line 2 def delete_service(service) request( :expects => 202, :method => 'DELETE', :path => "services/#{service.id}" ) end
endpoint_uri(service_endpoint_url=nil)
click to toggle source
Calls superclass method
Fog::Rackspace::Service#endpoint_uri
# File lib/fog/rackspace/cdn_v2.rb, line 119 def endpoint_uri(service_endpoint_url=nil) @uri = super(@rackspace_endpoint || service_endpoint_url) end
get_flavor(id)
click to toggle source
# File lib/fog/rackspace/requests/cdn_v2/get_flavor.rb, line 2 def get_flavor(id) request( :expects => [200], :method => 'GET', :path => "flavors/#{id}" ) end
get_home_document()
click to toggle source
# File lib/fog/rackspace/requests/cdn_v2/get_home_document.rb, line 2 def get_home_document request( :expects => [200], :method => 'GET', :path => "" ) end
get_ping()
click to toggle source
# File lib/fog/rackspace/requests/cdn_v2/get_ping.rb, line 2 def get_ping request( :expects => [204], :method => 'GET', :path => "ping", :headers => { :accept => "*/*" } ) end
get_service(id)
click to toggle source
# File lib/fog/rackspace/requests/cdn_v2/get_service.rb, line 2 def get_service(id) request( :expects => 200, :method => 'GET', :path => "services/#{id}" ) end
home_document()
click to toggle source
# File lib/fog/rackspace/cdn_v2.rb, line 94 def home_document self.get_home_document.body end
list_flavors()
click to toggle source
# File lib/fog/rackspace/requests/cdn_v2/list_flavors.rb, line 2 def list_flavors request( :expects => [200], :method => 'GET', :path => "flavors" ) end
list_services(options={})
click to toggle source
# File lib/fog/rackspace/requests/cdn_v2/list_services.rb, line 2 def list_services(options={}) request( :expects => [200], :method => 'GET', :path => request_uri("services", options) ) end
ping()
click to toggle source
# File lib/fog/rackspace/cdn_v2.rb, line 90 def ping self.get_ping.status == 204 end
region()
click to toggle source
# File lib/fog/rackspace/cdn_v2.rb, line 115 def region @rackspace_region end
request(params, parse_json = true)
click to toggle source
Calls superclass method
Fog::Rackspace::Service#request
# File lib/fog/rackspace/cdn_v2.rb, line 72 def request(params, parse_json = true) super rescue Excon::Errors::NotFound => error raise NotFound.slurp(error, self) rescue Excon::Errors::BadRequest => error raise BadRequest.slurp(error, self) rescue Excon::Errors::InternalServerError => error raise InternalServerError.slurp(error, self) rescue Excon::Errors::HTTPStatusError => error raise ServiceError.slurp(error, self) end
request_id_header()
click to toggle source
# File lib/fog/rackspace/cdn_v2.rb, line 111 def request_id_header "x-raxcdn-id" end
request_uri(path, options={})
click to toggle source
# File lib/fog/rackspace/cdn_v2.rb, line 84 def request_uri(path, options={}) return path if options == {} require "addressable/uri" Addressable::URI.new({:path=>path, :query_values=>options}).request_uri end
service_name()
click to toggle source
# File lib/fog/rackspace/cdn_v2.rb, line 107 def service_name :rackCDN end
update_service(service)
click to toggle source
# File lib/fog/rackspace/requests/cdn_v2/update_service.rb, line 2 def update_service(service) request( :expects => [201, 202], :method => 'PATCH', :headers => {"Content-Type" => "application/json-patch+json"}, :body => Fog::JSON.encode(service.operations), :path => "services/#{service.id}" ) service.operations = [] end