Merge pull request #68 from relaxdiego/fix/simplify_base_url
Rename base_url_for to base_url and remove enpoint_type parameter since the endpoint_type is already defined in the request file's meta declarations.
This commit is contained in:
@@ -17,7 +17,7 @@ module Aviator
|
|||||||
private
|
private
|
||||||
|
|
||||||
|
|
||||||
def base_url_for(endpoint_type)
|
def base_url
|
||||||
if session_data[:base_url]
|
if session_data[:base_url]
|
||||||
session_data[:base_url]
|
session_data[:base_url]
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/os-networks"
|
"#{ base_url }/os-networks"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/os-hosts/#{ params[:host_name] }"
|
"#{ base_url }/os-hosts/#{ params[:host_name] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
url = "#{ base_url_for :admin }/os-hosts"
|
url = "#{ base_url }/os-hosts"
|
||||||
|
|
||||||
filters = []
|
filters = []
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers"
|
"#{ base_url }/servers"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/images/#{ params[:id]}"
|
"#{ base_url }/images/#{ params[:id]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }"
|
"#{ base_url }/servers/#{ params[:id] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/flavors/#{ params[:id] }"
|
"#{ base_url }/flavors/#{ params[:id] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/images/#{ params[:id]}"
|
"#{ base_url }/images/#{ params[:id]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/os-networks/#{ params[:id] }"
|
"#{ base_url }/os-networks/#{ params[:id] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }"
|
"#{ base_url }/servers/#{ params[:id] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
url = "#{ base_url_for :public }/servers/#{ params[:id] }/ips"
|
url = "#{ base_url }/servers/#{ params[:id] }/ips"
|
||||||
url += "/#{ params[:networkID] }" if params[:networkID]
|
url += "/#{ params[:networkID] }" if params[:networkID]
|
||||||
url
|
url
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
str = "#{ base_url_for :public }/flavors"
|
str = "#{ base_url }/flavors"
|
||||||
str += "/detail" if params[:details]
|
str += "/detail" if params[:details]
|
||||||
str += params_to_querystring(optional_params + required_params - [:details])
|
str += params_to_querystring(optional_params + required_params - [:details])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
str = "#{ base_url_for :public }/images"
|
str = "#{ base_url }/images"
|
||||||
str += "/detail" if params[:details]
|
str += "/detail" if params[:details]
|
||||||
str += params_to_querystring(optional_params + required_params - [:details])
|
str += params_to_querystring(optional_params + required_params - [:details])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/os-networks"
|
"#{ base_url }/os-networks"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
str = "#{ base_url_for :public }/servers"
|
str = "#{ base_url }/servers"
|
||||||
str += "/detail" if params[:details]
|
str += "/detail" if params[:details]
|
||||||
|
|
||||||
filters = []
|
filters = []
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
uri = URI(base_url_for(:public))
|
uri = URI(base_url)
|
||||||
"#{ uri.scheme }://#{ uri.host }:#{ uri.port.to_s }/v2/"
|
"#{ uri.scheme }://#{ uri.host }:#{ uri.port.to_s }/v2/"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }/action"
|
"#{ base_url }/servers/#{ params[:id] }/action"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/servers/#{ params[:id] }"
|
"#{ base_url }/servers/#{ params[:id] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ module Aviator
|
|||||||
|
|
||||||
def url
|
def url
|
||||||
p = params
|
p = params
|
||||||
"#{ base_url_for :admin }/tenants/#{ p[:tenant_id] }/users/#{ p[:user_id] }/roles/OS-KSADM/#{ p[:role_id] }"
|
"#{ base_url }/tenants/#{ p[:tenant_id] }/users/#{ p[:user_id] }/roles/OS-KSADM/#{ p[:role_id] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/tenants"
|
"#{ base_url }/tenants"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Aviator
|
|||||||
|
|
||||||
def url
|
def url
|
||||||
p = params
|
p = params
|
||||||
"#{ base_url_for :admin }/tenants/#{ p[:tenant_id] }/users/#{ p[:user_id] }/roles/OS-KSADM/#{ p[:role_id] }"
|
"#{ base_url }/tenants/#{ p[:tenant_id] }/users/#{ p[:user_id] }/roles/OS-KSADM/#{ p[:role_id] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/tenants/#{ params[:id]}"
|
"#{ base_url }/tenants/#{ params[:id]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
str = "#{ base_url_for :admin }/tenants"
|
str = "#{ base_url }/tenants"
|
||||||
str += params_to_querystring(optional_params + required_params)
|
str += params_to_querystring(optional_params + required_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :admin }/tenants/#{ params[:id] }"
|
"#{ base_url }/tenants/#{ params[:id] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
str = "#{ base_url_for :public }/tenants"
|
str = "#{ base_url }/tenants"
|
||||||
str += params_to_querystring(optional_params + required_params)
|
str += params_to_querystring(optional_params + required_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
uri = URI(base_url_for(:public))
|
uri = URI(base_url)
|
||||||
"#{ uri.scheme }://#{ uri.host }:#{ uri.port.to_s }/v2.0/"
|
"#{ uri.scheme }://#{ uri.host }:#{ uri.port.to_s }/v2.0/"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
uri = URI(base_url_for(:public))
|
uri = URI(base_url)
|
||||||
"#{ uri.scheme }://#{ uri.host }:#{ uri.port.to_s }/v1/"
|
"#{ uri.scheme }://#{ uri.host }:#{ uri.port.to_s }/v1/"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
uri = URI(base_url_for(:admin))
|
uri = URI(base_url)
|
||||||
"#{ uri.scheme }://#{ uri.host }:#{ uri.port.to_s }/v1/projects"
|
"#{ uri.scheme }://#{ uri.host }:#{ uri.port.to_s }/v1/projects"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ module Aviator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/volumes"
|
"#{ base_url }/volumes"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module Aviator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/volumes/#{ params[:id] }"
|
"#{ base_url }/volumes/#{ params[:id] }"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module Aviator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/volumes/#{ params[:id] }"
|
"#{ base_url }/volumes/#{ params[:id] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ module Aviator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/types"
|
"#{ base_url }/types"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ module Aviator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
str = "#{ base_url_for :public }/volumes"
|
str = "#{ base_url }/volumes"
|
||||||
str += "/detail" if params[:details]
|
str += "/detail" if params[:details]
|
||||||
str += params_to_querystring(optional_params + required_params - [:details])
|
str += params_to_querystring(optional_params + required_params - [:details])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
uri = URI(base_url_for(:public))
|
uri = URI(base_url)
|
||||||
"#{ uri.scheme }://#{ uri.host }:#{ uri.port.to_s }/v1/"
|
"#{ uri.scheme }://#{ uri.host }:#{ uri.port.to_s }/v1/"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ module Aviator
|
|||||||
|
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"#{ base_url_for :public }/volumes/#{ params[:id] }"
|
"#{ base_url }/volumes/#{ params[:id] }"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class Aviator::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
describe '::base_url_for' do
|
describe '::base_url' do
|
||||||
|
|
||||||
it 'must throw a MissingServiceEndpointError when the service\'s endpoint can\'t be found' do
|
it 'must throw a MissingServiceEndpointError when the service\'s endpoint can\'t be found' do
|
||||||
default_session_data = JSON.parse('{"access": {"token": {"issued_at": "2013-09-25T20:21:55.453783",
|
default_session_data = JSON.parse('{"access": {"token": {"issued_at": "2013-09-25T20:21:55.453783",
|
||||||
@@ -79,7 +79,7 @@ class Aviator::Test
|
|||||||
|
|
||||||
request = klass.new(default_session_data)
|
request = klass.new(default_session_data)
|
||||||
|
|
||||||
the_method = lambda { request.send(:base_url_for, :public) }
|
the_method = lambda { request.send(:base_url) }
|
||||||
|
|
||||||
the_method.must_raise Aviator::Service::MissingServiceEndpointError
|
the_method.must_raise Aviator::Service::MissingServiceEndpointError
|
||||||
end
|
end
|
||||||
@@ -99,7 +99,7 @@ class Aviator::Test
|
|||||||
|
|
||||||
request = klass.new(default_session_data)
|
request = klass.new(default_session_data)
|
||||||
|
|
||||||
request.send(:base_url_for, :public).must_equal base_url
|
request.send(:base_url).must_equal base_url
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user