authenticate(options={})
click to toggle source
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
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
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
def delete_service(service)
request(
:expects => 202,
:method => 'DELETE',
:path => "services/#{service.id}"
)
end
endpoint_uri(service_endpoint_url=nil)
click to toggle source
def endpoint_uri(service_endpoint_url=nil)
@uri = super(@rackspace_endpoint || service_endpoint_url)
end
get_flavor(id)
click to toggle source
def get_flavor(id)
request(
:expects => [200],
:method => 'GET',
:path => "flavors/#{id}"
)
end
get_home_document()
click to toggle source
def get_home_document
request(
:expects => [200],
:method => 'GET',
:path => ""
)
end
get_ping()
click to toggle source
def get_ping
request(
:expects => [204],
:method => 'GET',
:path => "ping",
:headers => { :accept => "*/*" }
)
end
get_service(id)
click to toggle source
def get_service(id)
request(
:expects => 200,
:method => 'GET',
:path => "services/#{id}"
)
end
home_document()
click to toggle source
def home_document
self.get_home_document.body
end
list_flavors()
click to toggle source
def list_flavors
request(
:expects => [200],
:method => 'GET',
:path => "flavors"
)
end
list_services(options={})
click to toggle source
def list_services(options={})
request(
:expects => [200],
:method => 'GET',
:path => request_uri("services", options)
)
end
ping()
click to toggle source
def ping
self.get_ping.status == 204
end
region()
click to toggle source
def region
@rackspace_region
end
request(params, parse_json = true)
click to toggle source
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_uri(path, options={})
click to toggle source
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
def service_name
:rackCDN
end
update_service(service)
click to toggle source
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