diff --git a/lib/fog/storm_on_demand/compute.rb b/lib/fog/storm_on_demand/compute.rb index 284f89e66..150df3370 100644 --- a/lib/fog/storm_on_demand/compute.rb +++ b/lib/fog/storm_on_demand/compute.rb @@ -36,6 +36,8 @@ module Fog collection :stats model :template collection :templates + model :product + collection :products request_path 'fog/storm_on_demand/requests/compute' request :clone_server @@ -114,6 +116,12 @@ module Fog request :get_zone request :list_zones request :set_default_zone + + request :get_product + request :get_product_code + request :list_products + request :get_product_price + request :get_product_starting_price class Mock diff --git a/lib/fog/storm_on_demand/models/compute/product.rb b/lib/fog/storm_on_demand/models/compute/product.rb new file mode 100644 index 000000000..9535eb962 --- /dev/null +++ b/lib/fog/storm_on_demand/models/compute/product.rb @@ -0,0 +1,40 @@ +require 'fog/core/model' + +module Fog + module Compute + class StormOnDemand + + class Product < Fog::Model + identity :code + attribute :alias + attribute :capabilities + attribute :categories + attribute :cycle + attribute :default_price + attribute :description + attribute :features + attribute :options + attribute :parent_product + attribute :prices + attribute :related_product + attribute :series + + def initialize(attributes={}) + super + end + + def price(options) + requires :identity + service.get_product_price({:code => identity}.merge!(options)).body + end + + def starting_price + requires :identity + service.get_product_starting_price(:code => identity).body['items'] + end + + end + + end + end +end diff --git a/lib/fog/storm_on_demand/models/compute/products.rb b/lib/fog/storm_on_demand/models/compute/products.rb new file mode 100644 index 000000000..59bcfca8e --- /dev/null +++ b/lib/fog/storm_on_demand/models/compute/products.rb @@ -0,0 +1,28 @@ +require 'fog/core/collection' +require 'fog/storm_on_demand/models/compute/product' + +module Fog + module Compute + class StormOnDemand + + class Products < Fog::Collection + model Fog::Compute::StormOnDemand::Product + + def get(product_code) + prod = service.get_product(:code => product_code).body + new(prod) + end + + def get_product_code(options) + service.get_product_code(options).body + end + + def all(options={}) + service.list_products(options).body['items'] + end + + end + + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/get_product.rb b/lib/fog/storm_on_demand/requests/compute/get_product.rb new file mode 100644 index 000000000..72f97bbf8 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/get_product.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def get_product(options={}) + request( + :path => '/Product/details', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/get_product_code.rb b/lib/fog/storm_on_demand/requests/compute/get_product_code.rb new file mode 100644 index 000000000..f07e6bd2d --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/get_product_code.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def get_product_code(options={}) + request( + :path => '/Product/getProductCodeFromPath', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/get_product_price.rb b/lib/fog/storm_on_demand/requests/compute/get_product_price.rb new file mode 100644 index 000000000..5fab79797 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/get_product_price.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def get_product_price(options={}) + request( + :path => '/Product/price', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/get_product_starting_price.rb b/lib/fog/storm_on_demand/requests/compute/get_product_starting_price.rb new file mode 100644 index 000000000..2f6d3efcb --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/get_product_starting_price.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def get_product_starting_price(options={}) + request( + :path => '/Product/startingPrice', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/list_products.rb b/lib/fog/storm_on_demand/requests/compute/list_products.rb new file mode 100644 index 000000000..7e53e5484 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/list_products.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def list_products(options={}) + request( + :path => '/Product/list', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end