This is the API used by Trader to provision and manage resources on the OnApp Market, and subsequently control those resources.
It is assumed that any user of this API will have
Been assigned an appropriate user ID / API key
Have been given a suitable role wihin the market
It is also assumed that each ‘control panel’ enabled for the market, will have had it’s IP address added as a white list entry for the given user ID
It is assumed billing data will be accessible through a different API
Get the flavors associated with the specified resource
resource_id - The resource_id of the Compute resource
OnappMarket::API::Response - data will contain Array of templates if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 131 def get_flavors(resource_id) @api.get("/compute/#{resource_id.url_safe}/flavors") end
Get a specific instance
instance_id - instance id we wish to retrieve
OnappMarket::API::Response - data will contain an OnappMarket::Instance if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 107 def get_instance(instance_id) @api.get("/instance/#{instance_id.url_safe}") end
Get the billing statistics for a resource instance for a given time period
instance_id - instance id of instance whose billing data we
require
start_date - Date - start date
end_date - Date - end date
period - Billing period: hourly|daily|monthly
OnappMarket::API::Response - object/hash of JSON billing data if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 67 def get_instance_billing_data(instance_id, start_date, end_date, period = :daily) @api.get("/instance/#{instance_id.url_safe}/billing", {:start => start_date.rfc3339, :end => end_date.rfc3339, :period => period.to_s}) end
Get a list of instances provisioned by this user
filter - hash of exact attributes mathces. In the future we
may add search_instances for more flexible access.
detail - List of ids (false) or objects (true)
OnappMarket::API::Response - data will contain an Array of instance_ids if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 95 def get_instances(filter = {}, detail = false) @api.get("/instance", {:filter => filter, :detail => detail}, detail) end
Get the pricing data for a specified resource
resource_id - the resource id
OnappMarket::API::Response - data will contain OnappMarket::Pricing if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 52 def get_pricing(resource_id) @api.get("/resource/#{resource_id.url_safe}/pricing") end
Get a resource
resource_id - The resource id
OnappMarket::API::Response - data will contain OnappMarket::Base::Resource if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 40 def get_resource(resource_id) @api.get("/resource/#{resource_id.to_s.url_safe}") end
Get the templates associated with the specified resource
resource_id - The resource_id of the Compute resource
OnappMarket::API::Response - data will contain Array of templates if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 119 def get_templates(resource_id) @api.get("/compute/#{resource_id.url_safe}/template") end
Get a user’s billing statistics
user_id - user id of user whose billing data we require
start_date - DateTime - start date
end_date - DateTime - end date
period - Billing period: hourly|daily|monthly
OnappMarket::API::Response - object/hash of JSON billing data if is_ok?
admin
# File lib/onapp_market/trader.rb, line 82 def get_user_billing_data(user_id, start_date, end_date, period = :daily) @api.get("/admin/user/#{user_id.url_safe}/billing", {:start => start_date.rfc3339, :end => end_date.rfc3339, :period => period.to_s}) end
Create a new resource on the market using a specified resource
resource_id - The id of the resource
instance - The instance to be created
OnappMarket::API::Response - data will contain the instance with the instance_id populated if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 144 def provision(resource_id, instance) @api.post("/instance", {:resource_id => resource_id, :instance => OnappMarket::API::Serialize.to_hash(instance)}) end
Get the notices for a resource for a given time period
resource_id - resource id of resource whose notices we require
start_date - Date - start date
end_date - Date - end date
OnappMarket::API::Response - Array of notices if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 196 def resource_get_notices(resource_id, start_date, end_date) @api.get("/resource/#{resource_id.to_s.url_safe}/notices", {:start_date => start_date.iso8601, :end_date => end_date.iso8601}) end
Submit a URL that will receive notifications, for example, a hypervisor zone has been ‘deactivated’
url - The url for the notifications
OnappMarket::API::Response - registered successfully if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 182 def resource_notification_url(url) @api.post("/resource/notification_url", {:url => url}) end
Request notifications are turned off for changes in a zone Assumes you have already set up a listener with notifications_url
+ resource_id - The id of the zone you are no longer interested in
OnappMarket::API::Response - set if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 170 def resource_notifications_off(resource_id) @api.get("/resource/#{resource_id.url_safe}/notifications_off") end
Request notifications as a trader for changes in a zone Assumes you have already set up a listener with notifications_url
+ resource_id - The id of the zone you are interested in
OnappMarket::API::Response - set if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 157 def resource_notifications_on(resource_id) @api.get("/resource/#{resource_id.url_safe}/notifications_on") end
Indicate desire to subscribe to the specified resource
+ resource_id - The id of the zone you are subscribing to
OnappMarket::API::Response - set if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 208 def resource_subscribe(resource_id) @api.get("/resource/#{resource_id.url_safe}/subscribe") end
Indicate desire to subscribe to the specified resource
+ resource_id - The id of the zone you are subscribing to
OnappMarket::API::Response - set if is_ok?
trader, admin
# File lib/onapp_market/trader.rb, line 220 def resource_unsubscribe(resource_id) @api.get("/resource/#{resource_id.url_safe}/unsubscribe") end