mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|lb] added error page requests
This commit is contained in:
parent
9c3bf8edcc
commit
87778f5436
6 changed files with 91 additions and 0 deletions
|
@ -62,6 +62,9 @@ module Fog
|
|||
request :remove_monitor
|
||||
request :get_usage
|
||||
request :get_load_balancer_usage
|
||||
request :get_error_page
|
||||
request :set_error_page
|
||||
request :remove_error_page
|
||||
|
||||
module Shared
|
||||
|
||||
|
|
15
lib/fog/rackspace/requests/load_balancers/get_error_page.rb
Normal file
15
lib/fog/rackspace/requests/load_balancers/get_error_page.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancers
|
||||
class Real
|
||||
def get_error_page(load_balancer_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:path => "loadbalancers/#{load_balancer_id}/errorpage",
|
||||
:method => 'GET'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancers
|
||||
class Real
|
||||
def remove_error_page(load_balancer_id)
|
||||
request(
|
||||
:expects => [200, 202],
|
||||
:path => "loadbalancers/#{load_balancer_id}/errorpage",
|
||||
:method => 'DELETE'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
21
lib/fog/rackspace/requests/load_balancers/set_error_page.rb
Normal file
21
lib/fog/rackspace/requests/load_balancers/set_error_page.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancers
|
||||
class Real
|
||||
def set_error_page(load_balancer_id, content)
|
||||
data = {
|
||||
'errorpage' => {
|
||||
'content' => content
|
||||
}
|
||||
}
|
||||
request(
|
||||
:body => MultiJson.encode(data),
|
||||
:expects => [200, 202],
|
||||
:path => "loadbalancers/#{load_balancer_id}/errorpage",
|
||||
:method => 'PUT'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
31
tests/rackspace/requests/load_balancers/error_page_tests.rb
Normal file
31
tests/rackspace/requests/load_balancers/error_page_tests.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancers | error_page', ['rackspace', 'loadbalancers']) do
|
||||
|
||||
pending if Fog.mocking?
|
||||
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
tests('success') do
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_error_page(#{@lb.id})").formats(ERROR_PAGE_FORMAT) do
|
||||
@service.get_error_page(@lb.id).body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_error_page(#{@lb.id}, '<html><body>hi!</body></html>')").succeeds do
|
||||
@service.set_error_page(@lb.id, '<html><body>hi!</body></html>')
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_error_page(#{@lb.id})").formats(ERROR_PAGE_FORMAT) do
|
||||
@service.get_error_page(@lb.id).body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#remove_error_page()").succeeds do
|
||||
@service.remove_error_page(@lb.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -131,3 +131,9 @@ LOAD_BALANCER_FORMAT = {
|
|||
'updated' => { 'time' => String },
|
||||
}.merge(CONNECTION_LOGGING_FORMAT)
|
||||
}
|
||||
|
||||
ERROR_PAGE_FORMAT = {
|
||||
'errorpage' => {
|
||||
'content' => String
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue