Class: Megam::API
- Inherits:
-
Object
- Object
- Megam::API
- Defined in:
- lib/megam/api.rb,
lib/megam/api/disks.rb,
lib/megam/api/addons.rb,
lib/megam/api/errors.rb,
lib/megam/api/promos.rb,
lib/megam/api/quotas.rb,
lib/megam/api/backups.rb,
lib/megam/api/credits.rb,
lib/megam/api/domains.rb,
lib/megam/api/license.rb,
lib/megam/api/reports.rb,
lib/megam/api/sensors.rb,
lib/megam/api/sshkeys.rb,
lib/megam/api/version.rb,
lib/megam/api/accounts.rb,
lib/megam/api/assembly.rb,
lib/megam/api/balances.rb,
lib/megam/api/eventsvm.rb,
lib/megam/api/requests.rb,
lib/megam/api/eventsall.rb,
lib/megam/api/rawimages.rb,
lib/megam/api/snapshots.rb,
lib/megam/api/assemblies.rb,
lib/megam/api/components.rb,
lib/megam/api/marketplaces.rb,
lib/megam/api/eventsbilling.rb,
lib/megam/api/eventsstorage.rb,
lib/megam/api/organizations.rb,
lib/megam/api/subscriptions.rb,
lib/megam/api/billedhistories.rb,
lib/megam/api/eventscontainer.rb,
lib/megam/api/eventsmarketplaces.rb,
lib/megam/api/billingtransactions.rb
Defined Under Namespace
Modules: Errors
Constant Summary collapse
- API_VERSION2 =
'/v2'.freeze
- X_Megam_DATE =
'X-Megam-DATE'.freeze
- X_Megam_HMAC =
'X-Megam-HMAC'.freeze
- X_Megam_OTTAI =
'X-Megam-OTTAI'.freeze
- X_Megam_ORG =
'X-Megam-ORG'.freeze
- X_Megam_PUTTUSAVI =
'X-Megam-PUTTUSAVI'.freeze
- X_Megam_MASTERKEY =
'X-Megam-MASTERKEY'.freeze
- HEADERS =
{ 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip', 'User-Agent' => "megam-api/#{Megam::API::VERSION}", 'X-Ruby-Version' => RUBY_VERSION, 'X-Ruby-Platform' => RUBY_PLATFORM }
- OPTIONS =
{ headers: {}, nonblock: false }
- VERSION =
"1.51.2"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#email ⇒ Object
Returns the value of attribute email.
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
-
#master_key ⇒ Object
Returns the value of attribute master_key.
-
#org_id ⇒ Object
Returns the value of attribute org_id.
-
#password_hash ⇒ Object
Returns the value of attribute password_hash.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #delete_accounts(delete_account) ⇒ Object
-
#delete_assemblies(asm_id) ⇒ Object
Yet to be tested DELETE /nodes/:node_id.
- #delete_assembly(id, asms_id) ⇒ Object
-
#delete_marketplaceapp(catitem_id) ⇒ Object
Yet to be tested DELETE /marketplacess/:node_id.
- #forgot(account) ⇒ Object
-
#get_accounts(email) ⇒ Object
GET /accounts.
- #get_addon(name) ⇒ Object
-
#get_assemblies ⇒ Object
GET /nodes.
- #get_backups(asm_id) ⇒ Object
- #get_balance(id) ⇒ Object
- #get_balances ⇒ Object
- #get_billedhistories ⇒ Object
- #get_billedhistory(id) ⇒ Object
- #get_billingtransactions ⇒ Object
- #get_components(comp_id) ⇒ Object
- #get_credits(account_id) ⇒ Object
- #get_disks(asm_id) ⇒ Object
- #get_domains ⇒ Object
- #get_eventsall(limit, new_events) ⇒ Object
- #get_eventsbilling(limit, new_events) ⇒ Object
- #get_eventscontainer(limit, new_events) ⇒ Object
- #get_eventsMarketplaces(limit, new_events) ⇒ Object
- #get_eventsvm(limit, new_events) ⇒ Object
- #get_license(license_id) ⇒ Object
- #get_marketplaceapp(id) ⇒ Object
- #get_marketplaceapps ⇒ Object
- #get_marketplaceflavor(flavor) ⇒ Object
- #get_marketplaceprovider(provider) ⇒ Object
- #get_one_assemblies(asm_id) ⇒ Object
- #get_one_assembly(asm_id) ⇒ Object
- #get_one_quota(name) ⇒ Object
- #get_one_rawimage(name) ⇒ Object
- #get_organization(id) ⇒ Object
- #get_organizations ⇒ Object
- #get_promos(id) ⇒ Object
- #get_reports(new_sps) ⇒ Object
- #get_request(node_name) ⇒ Object
-
#get_requests ⇒ Object
GET /requests.
- #get_sensor(id) ⇒ Object
- #get_sensors ⇒ Object
- #get_snapshots(asm_id) ⇒ Object
- #get_sshkey(sshkey_name) ⇒ Object
- #get_sshkeys ⇒ Object
- #get_subscription ⇒ Object
- #index_eventsall ⇒ Object
- #index_eventsbilling ⇒ Object
- #index_eventscontainer ⇒ Object
- #index_eventsMarketplaces ⇒ Object
- #index_eventsstorage ⇒ Object
- #index_eventsvm ⇒ Object
-
#initialize(options = {}) ⇒ API
constructor
A new instance of API.
-
#list_accounts ⇒ Object
ADMIN: LIST /accounts.
- #list_assembly ⇒ Object
-
#list_backups ⇒ Object
GET /nodes.
- #list_credits ⇒ Object
-
#list_disks ⇒ Object
GET /nodes.
-
#list_eventsall(limit) ⇒ Object
GET /nodes.
-
#list_eventsbilling(limit) ⇒ Object
GET /nodes.
-
#list_eventscontainer(limit) ⇒ Object
GET /nodes.
-
#list_eventsMarketplaces(limit) ⇒ Object
GET /nodes.
-
#list_eventsstorage(limit) ⇒ Object
GET /nodes.
-
#list_eventsvm(limit) ⇒ Object
GET /nodes.
- #list_quotas ⇒ Object
- #list_rawimages ⇒ Object
-
#list_snapshots ⇒ Object
GET /nodes.
-
#login(new_account) ⇒ Object
The body content needs to be a json.
- #password_reset(account) ⇒ Object
-
#post_accounts(new_account) ⇒ Object
The body content needs to be a json.
- #post_addons(new_addon) ⇒ Object
- #post_assemblies(new_asm) ⇒ Object
- #post_backups(new_sps) ⇒ Object
- #post_balances(new_balance) ⇒ Object
- #post_billedhistories(new_billedhistory) ⇒ Object
- #post_billingtransactions(new_billtransaction) ⇒ Object
- #post_credits(new_credits) ⇒ Object
- #post_disks(new_dsk) ⇒ Object
- #post_domains(new_domain) ⇒ Object
- #post_license(new_license) ⇒ Object
- #post_marketplaceapp(catitem) ⇒ Object
- #post_organization(new_organization) ⇒ Object
- #post_quotas(new_sps) ⇒ Object
- #post_rawimages(rawimage_item) ⇒ Object
- #post_reports(new_sps) ⇒ Object
- #post_request(new_req) ⇒ Object
- #post_sensors(new_sensors) ⇒ Object
- #post_snapshots(new_sps) ⇒ Object
- #post_sshkey(new_sshkey) ⇒ Object
- #post_subscriptions(new_subscription) ⇒ Object
- #remove_disks(asm_id, disk_id) ⇒ Object
- #request(params, &block) ⇒ Object
- #update_accounts(update_account) ⇒ Object
- #update_assembly(new_asm) ⇒ Object
- #update_backups(update_sps) ⇒ Object
- #update_balance(new_balance) ⇒ Object
- #update_component(new_asm) ⇒ Object
- #update_organization(new_organization) ⇒ Object
- #update_quotas(new_asm) ⇒ Object
- #update_snapshots(update_sps) ⇒ Object
- #upgrade_assembly(asm_id) ⇒ Object
Constructor Details
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
123 124 125 |
# File 'lib/megam/api.rb', line 123 def api_key @api_key end |
#api_url ⇒ Object
Returns the value of attribute api_url.
124 125 126 |
# File 'lib/megam/api.rb', line 124 def api_url @api_url end |
#api_version ⇒ Object
Returns the value of attribute api_version.
124 125 126 |
# File 'lib/megam/api.rb', line 124 def api_version @api_version end |
#email ⇒ Object
Returns the value of attribute email.
123 124 125 |
# File 'lib/megam/api.rb', line 123 def email @email end |
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
126 127 128 |
# File 'lib/megam/api.rb', line 126 def last_response @last_response end |
#master_key ⇒ Object
Returns the value of attribute master_key.
125 126 127 |
# File 'lib/megam/api.rb', line 125 def master_key @master_key end |
#org_id ⇒ Object
Returns the value of attribute org_id.
123 124 125 |
# File 'lib/megam/api.rb', line 123 def org_id @org_id end |
#password_hash ⇒ Object
Returns the value of attribute password_hash.
123 124 125 |
# File 'lib/megam/api.rb', line 123 def password_hash @password_hash end |
#text ⇒ Object
Returns the value of attribute text.
122 123 124 |
# File 'lib/megam/api.rb', line 122 def text @text end |
Instance Method Details
#delete_accounts(delete_account) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# 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) ⇒ Object
Yet to be tested DELETE /nodes/:node_id
37 38 39 40 41 42 43 44 45 46 |
# 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) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# 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_marketplaceapp(catitem_id) ⇒ Object
Yet to be tested DELETE /marketplacess/:node_id
56 57 58 59 60 61 62 63 64 65 |
# 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) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# 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) ⇒ Object
GET /accounts
4 5 6 7 8 9 10 11 12 13 |
# 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) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# 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 ⇒ Object
GET /nodes
4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
13 14 15 16 17 18 19 20 |
# 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 ⇒ Object
3 4 5 6 7 8 9 10 11 |
# 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 ⇒ Object
3 4 5 6 7 8 9 10 11 |
# 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) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# 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 ⇒ Object
3 4 5 6 7 8 9 10 11 |
# 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) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# 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) ⇒ Object
13 14 15 16 17 18 19 20 |
# 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) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# 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 ⇒ Object
5 6 7 8 9 10 11 12 |
# 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_eventsall(limit, new_events) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# 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) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# 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) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# 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_eventsMarketplaces(limit, new_events) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/megam/api/eventsmarketplaces.rb', line 15 def get_eventsMarketplaces(limit, new_events) @options = {:path => "/eventsmarketplaces/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) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# 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_license(license_id) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# 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 ⇒ Object
4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
34 35 36 37 38 39 40 41 |
# 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) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# 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) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# 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_quota(name) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# 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 ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# 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) ⇒ Object
15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# 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 ⇒ Object
GET /requests
5 6 7 8 9 10 11 12 13 |
# 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) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# 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 ⇒ Object
3 4 5 6 7 8 9 10 11 |
# 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) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# 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 ⇒ Object
3 4 5 6 7 8 9 10 11 |
# 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 ⇒ Object
4 5 6 7 8 9 10 11 12 |
# 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_eventsall ⇒ Object
26 27 28 29 30 31 32 33 34 |
# 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 ⇒ Object
25 26 27 28 29 30 31 32 33 |
# 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 ⇒ Object
25 26 27 28 29 30 31 32 33 |
# 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_eventsMarketplaces ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/megam/api/eventsmarketplaces.rb', line 25 def index_eventsMarketplaces @options = {:path => "/eventsmarketplaces",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end |
#index_eventsstorage ⇒ Object
14 15 16 17 18 19 20 21 22 |
# 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 ⇒ Object
25 26 27 28 29 30 31 32 33 |
# 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 ⇒ Object
ADMIN: LIST /accounts
84 85 86 87 88 89 90 91 92 93 |
# 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 ⇒ Object
34 35 36 37 38 39 40 41 42 |
# 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 ⇒ Object
GET /nodes
4 5 6 7 8 9 10 11 12 |
# 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 ⇒ Object
3 4 5 6 7 8 9 10 11 |
# 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 ⇒ Object
GET /nodes
4 5 6 7 8 9 10 11 12 |
# 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_eventsall(limit) ⇒ Object
GET /nodes
4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
GET /nodes
4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
GET /nodes
4 5 6 7 8 9 10 11 12 |
# 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_eventsMarketplaces(limit) ⇒ Object
GET /nodes
4 5 6 7 8 9 10 11 12 |
# File 'lib/megam/api/eventsmarketplaces.rb', line 4 def list_eventsMarketplaces(limit) @options = {:path => "/eventsmarketplaces/#{limit}",:body => ""}.merge(@options) request( :expects => 200, :method => :get, :body => @options[:body] ) end |
#list_eventsstorage(limit) ⇒ Object
GET /nodes
4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
GET /nodes
4 5 6 7 8 9 10 11 12 |
# 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 ⇒ Object
25 26 27 28 29 30 31 32 33 |
# 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 ⇒ Object
14 15 16 17 18 19 20 21 22 |
# 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 ⇒ Object
GET /nodes
4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
The body content needs to be a json.
16 17 18 19 20 21 22 23 24 25 |
# 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) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# 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) ⇒ Object
The body content needs to be a json.
28 29 30 31 32 33 34 35 36 37 |
# 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) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# 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) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/megam/api/backups.rb', line 23 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) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# 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) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# 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) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# 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_license(new_license) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# 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) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# 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) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# 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) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# 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) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# 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) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# 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) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# 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) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# 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) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# 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) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/megam/api.rb', line 165 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., 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) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# 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) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/megam/api/backups.rb', line 34 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) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# 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) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# 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_organization(new_organization) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# 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) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# 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) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# 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) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# 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 |