1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Rackspace LB: account usage request

This commit is contained in:
Brian Hartsock 2011-07-27 21:44:43 -04:00
parent 8eb7aaeb54
commit 994d5fa3e1
5 changed files with 68 additions and 0 deletions

View file

@ -83,6 +83,7 @@ module Fog
request :get_monitor
request :set_monitor
request :remove_monitor
request :get_usage
class Real
def initialize(options={})

View file

@ -0,0 +1,20 @@
module Fog
module Rackspace
class LoadBalancer
class Real
def get_usage(options = {})
if options.has_key? :start_time and options.has_key? :end_time
query = "?startTime=#{options[:start_time]}&endTime=#{options[:end_time]}"
else
query = ''
end
request(
:expects => 200,
:path => "loadbalancers/usage#{query}",
:method => 'GET'
)
end
end
end
end
end

View file

@ -8,6 +8,7 @@ module Fog
module Integer; end
module String; end
module Time; end
module Float; end
end
end
[FalseClass, TrueClass].each {|klass| klass.send(:include, Fog::Boolean)}
@ -15,6 +16,7 @@ end
[NilClass, String].each {|klass| klass.send(:include, Fog::Nullable::String)}
[NilClass, Time].each {|klass| klass.send(:include, Fog::Nullable::Time)}
[Integer, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Integer)}
[Float, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Float)}
module Shindo
class Tests

View file

@ -3,6 +3,36 @@ NODE_FORMAT = {'node' => SINGLE_NODE_FORMAT}
NODES_FORMAT = {'nodes' => [SINGLE_NODE_FORMAT]}
VIRTUAL_IP_FORMAT = {'type' => String, 'id' => Integer, 'type' => String, 'ipVersion' => String, 'address' => String}
VIRTUAL_IPS_FORMAT = { 'virtualIps' => [VIRTUAL_IP_FORMAT] }
USAGE_FORMAT = {
'accountId' => Integer,
'loadBalancerUsages' => [
{
'loadBalancerId' => Fog::Nullable::Integer,
'loadBalancerName' => Fog::Nullable::String,
'loadBalancerUsageRecords' => [
{
'id' => Fog::Nullable::Integer,
'eventType' => Fog::Nullable::String,
'averageNumConnections' => Fog::Nullable::Float,
'incomingTransfer' => Fog::Nullable::Integer,
'outgoingTransfer' => Fog::Nullable::Integer,
'numVips' => Fog::Nullable::Integer,
'numPolls' => Fog::Nullable::Integer,
'startTime' => Fog::Nullable::String,
'endTime' => Fog::Nullable::String
}
]
}
],
'accountUsage' => [
{
'startTime' => Fog::Nullable::String,
'numLoadBalancers' => Fog::Nullable::Integer,
'numPublicVips' => Fog::Nullable::Integer,
'numServicenetVips' => Fog::Nullable::Integer
}
]
}
CONNECTION_LOGGING_FORMAT = {
'connectionLogging' => {
'enabled' => Fog::Boolean

View file

@ -0,0 +1,15 @@
Shindo.tests('Fog::Rackspace::LoadBalancer | usage', ['rackspace']) do
@service = Fog::Rackspace::LoadBalancer.new
tests('success') do
tests("#get_usage()").formats(USAGE_FORMAT) do
@service.get_usage.body
end
tests("#get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11')").formats(USAGE_FORMAT) do
@service.get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11').body
end
end
end