class Megam::API
Constants
- API_VERSION2
- HEADERS
- OPTIONS
- VERSION
- X_Megam_DATE
- X_Megam_HMAC
- X_Megam_MASTERKEY
- X_Megam_ORG
- X_Megam_OTTAI
- X_Megam_PUTTUSAVI
Attributes
api_key[RW]
api_url[RW]
api_version[RW]
email[RW]
last_response[R]
master_key[RW]
org_id[RW]
password_hash[RW]
text[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/megam/api.rb, line 153 def initialize(options = {}) @options = OPTIONS.merge(options) assign_credentials ensure_host_is_flattened turn_off_ssl_verify end
Public Instance Methods
delete_accounts(delete_account)
click to toggle source
# File lib/megam/api/accounts.rb, line 61 def delete_accounts(delete_account) @options = {path: "/admin/accounts/#{delete_account["user_email"]}", :body => ''}.merge(@options) request( :expects => 200, :method => :delete, :body => @options[:body] ) end
delete_assemblies(asm_id)
click to toggle source
Yet to be tested
DELETE /nodes/:node_id
# File lib/megam/api/assemblies.rb, line 37 def delete_assemblies(asm_id) @options = {:path => '/nodes/#{asm_id}', :body => ""}.merge(@options) request( :expects => 200, :method => :delete, :body => @options[:body] ) end
delete_assembly(id, asms_id)
click to toggle source
# File lib/megam/api/assembly.rb, line 44 def delete_assembly(id, asms_id) @options = {path: "/admin/assembly/#{asms_id}/#{id}", :body => ''}.merge(@options) request( :expects => 200, :method => :delete, :body => @options[:body] ) end
delete_flavors(delete_flavors)
click to toggle source
# File lib/megam/api/flavors.rb, line 44 def delete_flavors(delete_flavors) @options = {path: "/flavors/#{delete_flavors["name"]}", :body => ''}.merge(@options) request( :expects => 201, :method => :delete, :body => @options[:body] ) end
delete_marketplaceapp(catitem_id)
click to toggle source
Yet to be tested
DELETE /marketplacess/:node_id
# File lib/megam/api/marketplaces.rb, line 56 def delete_marketplaceapp(catitem_id) @options = {:path => '/marketplaces/#{catitem_id}', :body => ""}.merge(@options) request( :expects => 200, :method => :delete, :body => @options[:body] ) end
forgot(account)
click to toggle source
# File lib/megam/api/accounts.rb, line 50 def forgot(account) @options = { path: "/accounts/forgot/#{account["email"]}", passthru: true, body: ''}.merge(@options) request( :expects => 201, :method => :get, :body => @options[:body] ) end
get_accounts(email)
click to toggle source
GET /accounts
# File lib/megam/api/accounts.rb, line 4 def get_accounts(email) @options = {:path => "/accounts/#{email}", :body => ''}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_addon(name)
click to toggle source
# File lib/megam/api/addons.rb, line 5 def get_addon(name) @options = {:path => "/addons/#{name}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_assemblies()
click to toggle source
GET /nodes
# File lib/megam/api/assemblies.rb, line 4 def get_assemblies @options = {:path => '/assemblies',:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_backups(asm_id)
click to toggle source
# File lib/megam/api/backups.rb, line 14 def get_backups(asm_id) @options = {:path => "/backups/#{asm_id}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_balance(id)
click to toggle source
# File lib/megam/api/balances.rb, line 13 def get_balance(id) @options = {:path => "/balances/#{id}",:body => Megam::JSONCompat.to_json(id)}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_balances()
click to toggle source
# File lib/megam/api/balances.rb, line 3 def get_balances @options = {:path => '/balances',:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_billedhistories()
click to toggle source
# File lib/megam/api/billedhistories.rb, line 3 def get_billedhistories @options = {:path => '/billedhistories',:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_billedhistory(id)
click to toggle source
# File lib/megam/api/billedhistories.rb, line 13 def get_billedhistory(id) @options = {:path => "/billedhistories/#{id}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_billingtransactions()
click to toggle source
# File lib/megam/api/billingtransactions.rb, line 3 def get_billingtransactions @options = {:path => '/billingtransactions',:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_components(comp_id)
click to toggle source
# File lib/megam/api/components.rb, line 3 def get_components(comp_id) @options = { path: "/components/#{comp_id}", body: '' }.merge(@options) request( expects: 200, method: :get, body: @options[:body] ) end
get_credits(account_id)
click to toggle source
# File lib/megam/api/credits.rb, line 13 def get_credits(account_id) @options = {:path => "/credits/#{account_id}",:body => Megam::JSONCompat.to_json(account_id)}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_disks(asm_id)
click to toggle source
# File lib/megam/api/disks.rb, line 14 def get_disks(asm_id) @options = {:path => "/disks/#{asm_id}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_domains()
click to toggle source
# File lib/megam/api/domains.rb, line 5 def get_domains @options = {:path => "/domains", :body => ''}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_eventsMarketplace(limit, new_events)
click to toggle source
# File lib/megam/api/eventsmarketplace.rb, line 15 def get_eventsMarketplace(limit, new_events) @options = {:path => "/eventsmarketplace/show/#{limit}", :body => Megam::JSONCompat.to_json(new_events)}.merge(@options) request( :expects => 200, :method => :post, :body => @options[:body] ) end
get_eventsall(limit, new_events)
click to toggle source
# File lib/megam/api/eventsall.rb, line 15 def get_eventsall(limit, new_events) @options = {:path => "/eventsall/show/#{limit}", :body => Megam::JSONCompat.to_json(new_events)}.merge(@options) request( :expects => 200, :method => :post, :body => @options[:body] ) end
get_eventsbilling(limit, new_events)
click to toggle source
# File lib/megam/api/eventsbilling.rb, line 15 def get_eventsbilling(limit, new_events) @options = {:path => "/eventsbilling/show/#{limit}", :body => Megam::JSONCompat.to_json(new_events)}.merge(@options) request( :expects => 200, :method => :post, :body => @options[:body] ) end
get_eventscontainer(limit, new_events)
click to toggle source
# File lib/megam/api/eventscontainer.rb, line 15 def get_eventscontainer(limit, new_events) @options = {:path => "/eventscontainer/show/#{limit}", :body => Megam::JSONCompat.to_json(new_events)}.merge(@options) request( :expects => 200, :method => :post, :body => @options[:body] ) end
get_eventsvm(limit, new_events)
click to toggle source
# File lib/megam/api/eventsvm.rb, line 15 def get_eventsvm(limit, new_events) @options = {:path => "/eventsvm/show/#{limit}", :body => Megam::JSONCompat.to_json(new_events)}.merge(@options) request( :expects => 200, :method => :post, :body => @options[:body] ) end
get_flavors()
click to toggle source
# File lib/megam/api/flavors.rb, line 4 def get_flavors() @options = {:path => "/flavors",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_license(license_id)
click to toggle source
# File lib/megam/api/license.rb, line 4 def get_license(license_id) @options = {:path => "/admin/licenses/#{license_id}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_marketplaceapp(id)
click to toggle source
# File lib/megam/api/marketplaces.rb, line 14 def get_marketplaceapp(id) @options = {:path => "/marketplaces/#{id}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_marketplaceapps()
click to toggle source
# File lib/megam/api/marketplaces.rb, line 4 def get_marketplaceapps @options = {:path => '/marketplaces',:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_marketplaceflavor(flavor)
click to toggle source
# File lib/megam/api/marketplaces.rb, line 34 def get_marketplaceflavor(flavor) @options = {:path => "/marketplaces/f/#{flavor}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_marketplaceprovider(provider)
click to toggle source
# File lib/megam/api/marketplaces.rb, line 24 def get_marketplaceprovider(provider) @options = {:path => "/marketplaces/p/#{provider}" ,:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_one_assemblies(asm_id)
click to toggle source
# File lib/megam/api/assemblies.rb, line 14 def get_one_assemblies(asm_id) @options = {:path => "/assemblies/#{asm_id}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_one_assembly(asm_id)
click to toggle source
# File lib/megam/api/assembly.rb, line 3 def get_one_assembly(asm_id) @options = { path: "/assembly/#{asm_id}", body: '' }.merge(@options) request( expects: 200, method: :get, body: @options[:body] ) end
get_one_backup(backup_id)
click to toggle source
# File lib/megam/api/backups.rb, line 24 def get_one_backup(backup_id) @options = {:path => "/backups/show/#{backup_id}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_one_flavor(id)
click to toggle source
# File lib/megam/api/flavors.rb, line 13 def get_one_flavor(id) @options = { path: "/flavors/#{id}", body: '' }.merge(@options) request( expects: 200, method: :get, body: @options[:body] ) end
get_one_quota(name)
click to toggle source
# File lib/megam/api/quotas.rb, line 4 def get_one_quota(name) @options = { path: "/quotas/#{name}", body: '' }.merge(@options) request( expects: 200, method: :get, body: @options[:body] ) end
get_one_rawimage(name)
click to toggle source
# File lib/megam/api/rawimages.rb, line 4 def get_one_rawimage(name) @options = { path: "/rawimages/#{name}", body: '' }.merge(@options) request( expects: 200, method: :get, body: @options[:body] ) end
get_organization(id)
click to toggle source
# File lib/megam/api/organizations.rb, line 14 def get_organization(id) @options = {:path => "/organizations/#{id}", :body => ''}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_organizations()
click to toggle source
# File lib/megam/api/organizations.rb, line 3 def get_organizations @options = {:path => '/organizations',:body => ''}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_promos(id)
click to toggle source
# File lib/megam/api/promos.rb, line 5 def get_promos(id) @options = {:path => "/promos/#{id}", :body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_reports(new_sps)
click to toggle source
# File lib/megam/api/reports.rb, line 15 def get_reports(new_sps) @options = {:path => '/accounts/reports/content', :body => Megam::JSONCompat.to_json(new_sps)}.merge(@options) request( :expects => 200, :method => :post, :body => @options[:body] ) end
get_request(node_name)
click to toggle source
# File lib/megam/api/requests.rb, line 15 def get_request(node_name) @options = {:path => "/requests/#{node_name}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_requests()
click to toggle source
GET /requests
# File lib/megam/api/requests.rb, line 5 def get_requests @options = {:path => '/requests',:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_sensor(id)
click to toggle source
# File lib/megam/api/sensors.rb, line 13 def get_sensor(id) @options = {:path => "/sensors/#{id}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_sensors()
click to toggle source
# File lib/megam/api/sensors.rb, line 3 def get_sensors @options = {:path => '/sensors',:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_snapshots(asm_id)
click to toggle source
# File lib/megam/api/snapshots.rb, line 14 def get_snapshots(asm_id) @options = {:path => "/snapshots/#{asm_id}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_sshkey(sshkey_name)
click to toggle source
# File lib/megam/api/sshkeys.rb, line 13 def get_sshkey(sshkey_name) @options = {:path => "/sshkeys/#{sshkey_name}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_sshkeys()
click to toggle source
# File lib/megam/api/sshkeys.rb, line 3 def get_sshkeys @options = {:path => '/sshkeys',:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
get_subscription()
click to toggle source
# File lib/megam/api/subscriptions.rb, line 4 def get_subscription @options = {:path => "/subscriptions",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
index_eventsMarketplace()
click to toggle source
# File lib/megam/api/eventsmarketplace.rb, line 25 def index_eventsMarketplace @options = {:path => "/eventsmarketplace",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
index_eventsall()
click to toggle source
# File lib/megam/api/eventsall.rb, line 26 def index_eventsall @options = {:path => "/eventsall",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
index_eventsbilling()
click to toggle source
# File lib/megam/api/eventsbilling.rb, line 25 def index_eventsbilling @options = {:path => "/eventsbilling",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
index_eventscontainer()
click to toggle source
# File lib/megam/api/eventscontainer.rb, line 25 def index_eventscontainer @options = {:path => "/eventscontainer",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
index_eventsstorage()
click to toggle source
# File lib/megam/api/eventsstorage.rb, line 14 def index_eventsstorage @options = {:path => "/eventsstorage",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
index_eventsvm()
click to toggle source
# File lib/megam/api/eventsvm.rb, line 25 def index_eventsvm @options = {:path => "/eventsvm",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_accounts()
click to toggle source
ADMIN: LIST /accounts
# File lib/megam/api/accounts.rb, line 84 def list_accounts @options = {:path => "/admin/accounts", :body => ''}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_assembly()
click to toggle source
# File lib/megam/api/assembly.rb, line 34 def list_assembly @options = {:path => "/assembly",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_backups()
click to toggle source
GET /nodes
# File lib/megam/api/backups.rb, line 4 def list_backups @options = {:path => "/backups",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_credits()
click to toggle source
# File lib/megam/api/credits.rb, line 3 def list_credits @options = {:path => '/credits',:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_disks()
click to toggle source
GET /nodes
# File lib/megam/api/disks.rb, line 4 def list_disks @options = {:path => "/disks",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_eventsMarketplace(limit)
click to toggle source
GET /nodes
# File lib/megam/api/eventsmarketplace.rb, line 4 def list_eventsMarketplace(limit) @options = {:path => "/eventsmarketplace/#{limit}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_eventsall(limit)
click to toggle source
GET /nodes
# File lib/megam/api/eventsall.rb, line 4 def list_eventsall(limit) @options = {:path => "/eventsvm/#{limit}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_eventsbilling(limit)
click to toggle source
GET /nodes
# File lib/megam/api/eventsbilling.rb, line 4 def list_eventsbilling(limit) @options = {:path => "/eventsbilling/#{limit}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_eventscontainer(limit)
click to toggle source
GET /nodes
# File lib/megam/api/eventscontainer.rb, line 4 def list_eventscontainer(limit) @options = {:path => "/eventscontainer/#{limit}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_eventsstorage(limit)
click to toggle source
GET /nodes
# File lib/megam/api/eventsstorage.rb, line 4 def list_eventsstorage(limit) @options = {:path => "/eventsstorage/#{limit}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_eventsvm(limit)
click to toggle source
GET /nodes
# File lib/megam/api/eventsvm.rb, line 4 def list_eventsvm(limit) @options = {:path => "/eventsvm/#{limit}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_quotas()
click to toggle source
# File lib/megam/api/quotas.rb, line 25 def list_quotas @options = {:path => "/quotas",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_rawimages()
click to toggle source
# File lib/megam/api/rawimages.rb, line 14 def list_rawimages @options = {:path => "/rawimages",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
list_snapshots()
click to toggle source
GET /nodes
# File lib/megam/api/snapshots.rb, line 4 def list_snapshots @options = {:path => "/snapshots",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end
login(new_account)
click to toggle source
The body content needs to be a json.
# File lib/megam/api/accounts.rb, line 16 def login(new_account) @options = {:path => '/accounts/login', :body => Megam::JSONCompat.to_json(new_account)}.merge(@options) request( :expects => 302, :method => :post, :body => @options[:body] ) end
password_reset(account)
click to toggle source
# File lib/megam/api/accounts.rb, line 72 def password_reset(account) @options = {:path => "/accounts/password_reset", passthru: true, body: Megam::JSONCompat.to_json(account)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_accounts(new_account)
click to toggle source
The body content needs to be a json.
# File lib/megam/api/accounts.rb, line 28 def post_accounts(new_account) @options = {path: '/accounts/content', body: Megam::JSONCompat.to_json(new_account)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_addons(new_addon)
click to toggle source
# File lib/megam/api/addons.rb, line 15 def post_addons(new_addon) @options = {:path => '/addons/content', :body => Megam::JSONCompat.to_json(new_addon)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_assemblies(new_asm)
click to toggle source
# File lib/megam/api/assemblies.rb, line 24 def post_assemblies(new_asm) @options = {:path => '/assemblies/content', :body => Megam::JSONCompat.to_json(new_asm)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_backups(new_sps)
click to toggle source
# File lib/megam/api/backups.rb, line 34 def post_backups(new_sps) @options = {:path => '/backups/content', :body => Megam::JSONCompat.to_json(new_sps)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_balances(new_balance)
click to toggle source
# File lib/megam/api/balances.rb, line 22 def post_balances(new_balance) @options = {:path => '/balances/content', :body => Megam::JSONCompat.to_json(new_balance)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_billedhistories(new_billedhistory)
click to toggle source
# File lib/megam/api/billedhistories.rb, line 23 def post_billedhistories(new_billedhistory) @options = {:path => '/billedhistories/content', :body => Megam::JSONCompat.to_json(new_billedhistory)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_billingtransactions(new_billtransaction)
click to toggle source
# File lib/megam/api/billingtransactions.rb, line 13 def post_billingtransactions(new_billtransaction) @options = {:path => '/billingtransactions/content', :body => Megam::JSONCompat.to_json(new_billtransaction)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_credits(new_credits)
click to toggle source
# File lib/megam/api/credits.rb, line 22 def post_credits(new_credits) @options = {:path => '/credits/content', :body => Megam::JSONCompat.to_json(new_credits)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_disks(new_dsk)
click to toggle source
# File lib/megam/api/disks.rb, line 23 def post_disks(new_dsk) @options = {:path => '/disks/content', :body => Megam::JSONCompat.to_json(new_dsk)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_domains(new_domain)
click to toggle source
# File lib/megam/api/domains.rb, line 15 def post_domains(new_domain) @options = {:path => '/domains/content', :body => Megam::JSONCompat.to_json(new_domain)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_flavors(new_flavors)
click to toggle source
# File lib/megam/api/flavors.rb, line 23 def post_flavors(new_flavors) @options = {:path => "/flavors/content", :body => Megam::JSONCompat.to_json(new_flavors)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_license(new_license)
click to toggle source
# File lib/megam/api/license.rb, line 14 def post_license(new_license) @options = {:path => '/admin/licenses/content', :body => Megam::JSONCompat.to_json(new_license)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_marketplaceapp(catitem)
click to toggle source
# File lib/megam/api/marketplaces.rb, line 43 def post_marketplaceapp(catitem) @options = {:path => '/marketplaces/content', :body => Megam::JSONCompat.to_json(catitem)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_organization(new_organization)
click to toggle source
# File lib/megam/api/organizations.rb, line 26 def post_organization(new_organization) @options = {:path => '/organizations/content', :body => Megam::JSONCompat.to_json(new_organization)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_quotas(new_sps)
click to toggle source
# File lib/megam/api/quotas.rb, line 35 def post_quotas(new_sps) @options = {:path => '/quotas/content', :body => Megam::JSONCompat.to_json(new_sps)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_rawimages(rawimage_item)
click to toggle source
# File lib/megam/api/rawimages.rb, line 24 def post_rawimages(rawimage_item) @options = {:path => '/rawimages/content', :body => Megam::JSONCompat.to_json(rawimage_item)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_reports(new_sps)
click to toggle source
# File lib/megam/api/reports.rb, line 4 def post_reports(new_sps) @options = {:path => '/admin/reports/content', :body => Megam::JSONCompat.to_json(new_sps)}.merge(@options) request( :expects => 200, :method => :post, :body => @options[:body] ) end
post_request(new_req)
click to toggle source
# File lib/megam/api/requests.rb, line 25 def post_request(new_req) @options = {:path => '/requests/content', :body => Megam::JSONCompat.to_json(new_req)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_sensors(new_sensors)
click to toggle source
# File lib/megam/api/sensors.rb, line 23 def post_sensors(new_sensors) @options = {:path => '/sensors/content', :body => Megam::JSONCompat.to_json(new_sensors)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_snapshots(new_sps)
click to toggle source
# File lib/megam/api/snapshots.rb, line 23 def post_snapshots(new_sps) @options = {:path => '/snapshots/content', :body => Megam::JSONCompat.to_json(new_sps)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_sshkey(new_sshkey)
click to toggle source
# File lib/megam/api/sshkeys.rb, line 23 def post_sshkey(new_sshkey) @options = {:path => '/sshkeys/content', :body => Megam::JSONCompat.to_json(new_sshkey)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
post_subscriptions(new_subscription)
click to toggle source
# File lib/megam/api/subscriptions.rb, line 14 def post_subscriptions(new_subscription) @options = {:path => '/subscriptions/content', :body => Megam::JSONCompat.to_json(new_subscription)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
remove_disks(asm_id, disk_id)
click to toggle source
# File lib/megam/api/disks.rb, line 32 def remove_disks(asm_id, disk_id) @options = {:path => "/disks/delete/#{asm_id}/#{disk_id}", :body => ""}.merge(@options) request( :expects => 201, :method => :get, :body => @options[:body] ) end
request(params, &block)
click to toggle source
# File lib/megam/api.rb, line 168 def request(params, &block) just_color_debug("#{@options[:path]}") start = Time.now Megam::Log.debug('START') ensure_authkeys unless is_passthru? begin response = connection.request(params, &block) rescue Excon::Errors::HTTPStatusError => error klass = case error.response.status when 401 then Megam::API::Errors::Unauthorized when 403 then Megam::API::Errors::Forbidden when 404 then Megam::API::Errors::NotFound when 408 then Megam::API::Errors::Timeout when 422 then Megam::API::Errors::RequestFailed when 423 then Megam::API::Errors::Locked when /50./ then Megam::API::Errors::RequestFailed else Megam::API::Errors::ErrorWithResponse end reerror = klass.new(error.message, error.response) reerror.set_backtrace(error.backtrace) reerror.response.body = Megam::JSONCompat.from_json(reerror.response.body.chomp) raise(reerror) end @last_response = response if response.body && !response.body.empty? if response.headers['Content-Encoding'] == 'gzip' response.body = Zlib::GzipReader.new(StringIO.new(response.body)).read end begin unless response.headers[X_Megam_OTTAI] response.body = Megam::JSONCompat.from_json(response.body.chomp) else response.body = Megam::KoniPai.new.koni(response.body.chomp) end rescue Exception => jsonerr raise(jsonerr) end end Megam::Log.debug("END(#{(Time.now - start)}s)") @connection.reset response end
update_accounts(update_account)
click to toggle source
# File lib/megam/api/accounts.rb, line 39 def update_accounts(update_account) @options = {path: '/accounts/update', passthru: true, body: Megam::JSONCompat.to_json(update_account)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
update_assembly(new_asm)
click to toggle source
# File lib/megam/api/assembly.rb, line 13 def update_assembly(new_asm) @options = { path: '/assembly/update', body: Megam::JSONCompat.to_json(new_asm) }.merge(@options) request( expects: [200, 201], method: :post, body: @options[:body] ) end
update_backups(update_sps)
click to toggle source
# File lib/megam/api/backups.rb, line 45 def update_backups(update_sps) @options = {:path => '/backups/update', :body => Megam::JSONCompat.to_json(update_sps)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
update_balance(new_balance)
click to toggle source
# File lib/megam/api/balances.rb, line 33 def update_balance(new_balance) @options = {:path => '/admin/balances/update', :body => Megam::JSONCompat.to_json(new_balance)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
update_component(new_asm)
click to toggle source
# File lib/megam/api/components.rb, line 13 def update_component(new_asm) @options = { path: '/components/update', body: Megam::JSONCompat.to_json(new_asm) }.merge(@options) request( expects: [200, 201], method: :post, body: @options[:body] ) end
update_flavors(update_flavors)
click to toggle source
# File lib/megam/api/flavors.rb, line 33 def update_flavors(update_flavors) @options = {:path => '/flavors/update', :body => Megam::JSONCompat.to_json(update_flavors)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
update_organization(new_organization)
click to toggle source
# File lib/megam/api/organizations.rb, line 38 def update_organization(new_organization) @options = {:path => '/organizations/update', :body => Megam::JSONCompat.to_json(new_organization)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
update_quotas(new_asm)
click to toggle source
# File lib/megam/api/quotas.rb, line 14 def update_quotas(new_asm) @options = { path: '/quotas/update', body: Megam::JSONCompat.to_json(new_asm) }.merge(@options) request( expects: [200, 201], method: :post, body: @options[:body] ) end
update_snapshots(update_sps)
click to toggle source
# File lib/megam/api/snapshots.rb, line 34 def update_snapshots(update_sps) @options = {:path => '/snapshots/update', :body => Megam::JSONCompat.to_json(update_sps)}.merge(@options) request( :expects => 201, :method => :post, :body => @options[:body] ) end
upgrade_assembly(asm_id)
click to toggle source
# File lib/megam/api/assembly.rb, line 24 def upgrade_assembly(asm_id) @options = { path: "/assembly/upgrade/#{asm_id}", body: '' }.merge(@options) request( expects: [200, 201], method: :get, body: @options[:body] ) end
Private Instance Methods
api_combo_missing?()
click to toggle source
# File lib/megam/api.rb, line 254 def api_combo_missing? (!@email.nil? && !@api_key.nil?) end
assign_credentials()
click to toggle source
# File lib/megam/api.rb, line 221 def assign_credentials @api_key = @options.delete(:api_key) || ENV['VERTICE_API_KEY'] @email = @options.delete(:email) || ENV['VERTICE_EMAIL'] @password_hash = @options.delete(:password_hash) @org_id = @options.delete(:org_id) @master_key = @options.delete(:master_key) || ENV['VERTICE_MASTER_KEY'] end
build_header_masterkey()
click to toggle source
# File lib/megam/api.rb, line 322 def build_header_masterkey if masterkey_combo_missing? && !is_passthru? @options[:headers] = @options[:headers].merge(X_Megam_MASTERKEY => "true") end end
build_header_puttusavi()
click to toggle source
# File lib/megam/api.rb, line 316 def build_header_puttusavi if pw_combo_missing? && !is_passthru? @options[:headers] = @options[:headers].merge(X_Megam_PUTTUSAVI => "true") end end
build_headers()
click to toggle source
# File lib/megam/api.rb, line 283 def build_headers encoded = encode_header @options[:headers] = HEADERS.merge(X_Megam_HMAC => encoded[:hmac], X_Megam_DATE => encoded[:date], X_Megam_ORG => @org_id).merge(@options[:headers]) build_header_puttusavi build_header_masterkey end
connection()
click to toggle source
# File lib/megam/api.rb, line 274 def connection @options[:path] = @api_version + @options[:path] build_headers @connection = Excon.new(@api_url, @options) end
encode_header()
click to toggle source
# File lib/megam/api.rb, line 296 def encode_header body_base64 = Base64.urlsafe_encode64(OpenSSL::Digest::MD5.digest(@options[:body])) current_date = Time.now.strftime('%Y-%m-%d %H:%M') movingFactor = "#{current_date}" + "\n" + "#{@options[:path]}" + "\n" + "#{body_base64}" digest = OpenSSL::Digest.new('sha256') if pw_combo_missing? && !is_passthru? hash = OpenSSL::HMAC.hexdigest(digest, Base64.strict_decode64(@password_hash), movingFactor) elsif api_combo_missing? hash = OpenSSL::HMAC.hexdigest(digest, @api_key, movingFactor) elsif masterkey_combo_missing? hash = OpenSSL::HMAC.hexdigest(digest, @master_key, movingFactor) else hash = "" end { hmac: (@email + ':' + hash), date: current_date } end
ensure_authkeys()
click to toggle source
# File lib/megam/api.rb, line 248 def ensure_authkeys if !api_combo_missing? && !pw_combo_missing? && !masterkey_combo_missing? fail Megam::API::Errors::AuthKeysMissing end end
ensure_host_is_flattened()
click to toggle source
# File lib/megam/api.rb, line 229 def ensure_host_is_flattened uri = URI(@options.delete(:host)) if @options.has_key?(:host) scheme = (uri && uri.scheme) ? uri.scheme : 'http' host = (uri && uri.host) ? uri.host : 'localhost' port = (uri && uri.port) ? uri.port.to_s : '9000' @api_version = (uri && uri.path) ? uri.path : API_VERSION2 @api_url = scheme + "://" + host + ":" + port + @api_version end
is_passthru?()
click to toggle source
# File lib/megam/api.rb, line 244 def is_passthru? @options[:passthru] end
just_color_debug(path)
click to toggle source
# File lib/megam/api.rb, line 270 def just_color_debug(path) text.msg "--> #{text.color("(#{path})", :cyan, :bold)}" end
masterkey_combo_missing?()
click to toggle source
# File lib/megam/api.rb, line 262 def masterkey_combo_missing? (!@email.nil? && !@master_key.nil?) end
pw_combo_missing?()
click to toggle source
# File lib/megam/api.rb, line 258 def pw_combo_missing? (!@email.nil? && !@password_hash.nil?) end
turn_off_ssl_verify()
click to toggle source
# File lib/megam/api.rb, line 266 def turn_off_ssl_verify Excon.defaults[:ssl_verify_peer] = false unless @api_url.include?("https") end