class OnappMarket::OnApp::Trader

OnApp specific supply functions.

Public Class Methods

new(api) click to toggle source

Create a new instance of the Trader API

Attributes

  • api - The api which manages this resource

# File lib/onapp_market/onapp/trader.rb, line 16
def initialize(api)
  super(api)
end

Public Instance Methods

cp_control(resource_id, method, url, content = "", content_type = "") click to toggle source

Invoke a CP API call via the market. Note the call may not be supported or blacklisted for a specific market user.

Attributes

  • resource_id - the resource (HypervisroZone) we wish to control

  • method - :post, :get, :put or :delete

  • url - CP Market URL e.g. /virtual_machines/:virtual_machine_id/stop.xml

  • content - content as a string, for example XML or JSON

  • content_type

Returns

OnappMarket::API::Response - data will contain String of response (XML or JSON) if is_ok?

Roles

trader, admin

# File lib/onapp_market/onapp/trader.rb, line 33
def cp_control(resource_id, method, url, content = "", content_type = "")
  res = @api.post("/onapp/hypervisor_zone/#{resource_id.url_safe}/cp_control", {:method => method, :url => url, :content => content, :content_type => content_type})
  return OnappMarket::API::Response.new(true, JSON.parse(res.data), res.errors, res.http_code) if res.is_ok?
  res
end