This is the API used by Supplier to provide resources to 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
API used to manage this resource
Create a resource on the OnApp Market.
resource OnappMarket::Resource.
Provides all information required.
pricing OnappMarket::Pricing.
Provides pricing information for the resource.
OnappMarket::API::Response - data will contain the supplied resource with resource_id populated if is_ok?
supplier, admin
# File lib/onapp_market/supply.rb, line 40 def create_resource(resource, pricing) # Create params for post as a Hash data = {"resource" => OnappMarket::API::Serialize.to_hash(resource), "pricing" => OnappMarket::API::Serialize.to_hash(pricing)} # Post - will de-serialize and return response @api.post("/resource", data) end
Get the billing statistics for an 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?
supplier, admin
# File lib/onapp_market/supply.rb, line 100 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 resource
resource_id - The resource id
OnappMarket::API::Response - data will contain OnappMarket::Base::Resource if is_ok?
supplier, admin
# File lib/onapp_market/supply.rb, line 70 def get_resource(resource_id) @api.get("/resource/#{resource_id.to_s.url_safe}") end
Get the billing statistics for a resource for a given time period
resource_id - resource id of resource 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?
supplier, admin
# File lib/onapp_market/supply.rb, line 85 def get_resource_billing_data(resource_id, start_date, end_date) @api.get("/resource/#{resource_id.to_s.url_safe}/billing", {:start => start_date.rfc3339, :end => end_date.rfc3339}) end
Get a list of resources from the market
filter - hash of exact attribute matches. In the future we may
add search_resources for more flexible access.
detail - List of ids (false) or objects (true)
OnappMarket::API::Response - data will contain an Array of Hashes containing resource_id and local_id of resource if is_ok?
supplier, admin
# File lib/onapp_market/supply.rb, line 57 def get_resources(filter = {}, detail = false) @api.get("/resource",{:filter => filter, :detail => detail}, detail) 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/supply.rb, line 115 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