virtengine_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.travis.yml +11 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE +21 -0
  6. data/README.md +27 -0
  7. data/Rakefile +10 -0
  8. data/lib/megam/api.rb +329 -0
  9. data/lib/megam/api/accounts.rb +96 -0
  10. data/lib/megam/api/addons.rb +27 -0
  11. data/lib/megam/api/assemblies.rb +49 -0
  12. data/lib/megam/api/assembly.rb +56 -0
  13. data/lib/megam/api/backups.rb +57 -0
  14. data/lib/megam/api/balances.rb +45 -0
  15. data/lib/megam/api/billedhistories.rb +35 -0
  16. data/lib/megam/api/billingtransactions.rb +25 -0
  17. data/lib/megam/api/components.rb +24 -0
  18. data/lib/megam/api/credits.rb +34 -0
  19. data/lib/megam/api/disks.rb +44 -0
  20. data/lib/megam/api/domains.rb +25 -0
  21. data/lib/megam/api/errors.rb +29 -0
  22. data/lib/megam/api/eventsall.rb +36 -0
  23. data/lib/megam/api/eventsbilling.rb +35 -0
  24. data/lib/megam/api/eventscontainer.rb +35 -0
  25. data/lib/megam/api/eventsmarketplace.rb +35 -0
  26. data/lib/megam/api/eventsstorage.rb +24 -0
  27. data/lib/megam/api/eventsvm.rb +35 -0
  28. data/lib/megam/api/flavors.rb +56 -0
  29. data/lib/megam/api/license.rb +26 -0
  30. data/lib/megam/api/marketplaces.rb +68 -0
  31. data/lib/megam/api/organizations.rb +50 -0
  32. data/lib/megam/api/promos.rb +18 -0
  33. data/lib/megam/api/quotas.rb +47 -0
  34. data/lib/megam/api/rawimages.rb +36 -0
  35. data/lib/megam/api/reports.rb +24 -0
  36. data/lib/megam/api/requests.rb +36 -0
  37. data/lib/megam/api/sensors.rb +35 -0
  38. data/lib/megam/api/snapshots.rb +46 -0
  39. data/lib/megam/api/sshkeys.rb +35 -0
  40. data/lib/megam/api/subscriptions.rb +26 -0
  41. data/lib/megam/api/version.rb +6 -0
  42. data/lib/megam/core/account.rb +245 -0
  43. data/lib/megam/core/account_collection.rb +122 -0
  44. data/lib/megam/core/addons.rb +169 -0
  45. data/lib/megam/core/addons_collection.rb +121 -0
  46. data/lib/megam/core/assemblies.rb +191 -0
  47. data/lib/megam/core/assemblies_collection.rb +122 -0
  48. data/lib/megam/core/assembly.rb +226 -0
  49. data/lib/megam/core/assembly_collection.rb +122 -0
  50. data/lib/megam/core/backups.rb +259 -0
  51. data/lib/megam/core/backups_collection.rb +122 -0
  52. data/lib/megam/core/balances.rb +187 -0
  53. data/lib/megam/core/balances_collection.rb +121 -0
  54. data/lib/megam/core/billedhistories.rb +190 -0
  55. data/lib/megam/core/billedhistories_collection.rb +121 -0
  56. data/lib/megam/core/billingtransactions.rb +214 -0
  57. data/lib/megam/core/billingtransactions_collection.rb +122 -0
  58. data/lib/megam/core/components.rb +326 -0
  59. data/lib/megam/core/components_collection.rb +123 -0
  60. data/lib/megam/core/credits.rb +146 -0
  61. data/lib/megam/core/credits_collection.rb +121 -0
  62. data/lib/megam/core/disks.rb +199 -0
  63. data/lib/megam/core/disks_collection.rb +122 -0
  64. data/lib/megam/core/domain_collection.rb +122 -0
  65. data/lib/megam/core/domains.rb +118 -0
  66. data/lib/megam/core/error.rb +70 -0
  67. data/lib/megam/core/eventsall.rb +186 -0
  68. data/lib/megam/core/eventsall_collection.rb +122 -0
  69. data/lib/megam/core/eventsbilling.rb +174 -0
  70. data/lib/megam/core/eventsbilling_collection.rb +122 -0
  71. data/lib/megam/core/eventscontainer.rb +187 -0
  72. data/lib/megam/core/eventscontainer_collection.rb +122 -0
  73. data/lib/megam/core/eventsmarketplace.rb +187 -0
  74. data/lib/megam/core/eventsmarketplace_collection.rb +122 -0
  75. data/lib/megam/core/eventsstorage.rb +156 -0
  76. data/lib/megam/core/eventsstorage_collection.rb +122 -0
  77. data/lib/megam/core/eventsvm.rb +187 -0
  78. data/lib/megam/core/eventsvm_collection.rb +122 -0
  79. data/lib/megam/core/flavors.rb +294 -0
  80. data/lib/megam/core/flavors_collection.rb +121 -0
  81. data/lib/megam/core/json_compat.rb +289 -0
  82. data/lib/megam/core/konipai.rb +42 -0
  83. data/lib/megam/core/license.rb +101 -0
  84. data/lib/megam/core/license_collection.rb +122 -0
  85. data/lib/megam/core/log.rb +19 -0
  86. data/lib/megam/core/marketplace.rb +308 -0
  87. data/lib/megam/core/marketplace_collection.rb +123 -0
  88. data/lib/megam/core/monologger.rb +89 -0
  89. data/lib/megam/core/organizations.rb +142 -0
  90. data/lib/megam/core/organizations_collection.rb +121 -0
  91. data/lib/megam/core/promos.rb +145 -0
  92. data/lib/megam/core/quotas.rb +215 -0
  93. data/lib/megam/core/quotas_collection.rb +121 -0
  94. data/lib/megam/core/rawimages.rb +194 -0
  95. data/lib/megam/core/rawimages_collection.rb +121 -0
  96. data/lib/megam/core/reports.rb +176 -0
  97. data/lib/megam/core/reports_collection.rb +121 -0
  98. data/lib/megam/core/request.rb +197 -0
  99. data/lib/megam/core/request_collection.rb +121 -0
  100. data/lib/megam/core/rest_adapter.rb +44 -0
  101. data/lib/megam/core/sensors.rb +141 -0
  102. data/lib/megam/core/sensors_collection.rb +121 -0
  103. data/lib/megam/core/snapshots.rb +268 -0
  104. data/lib/megam/core/snapshots_collection.rb +122 -0
  105. data/lib/megam/core/sshkey.rb +173 -0
  106. data/lib/megam/core/sshkey_collection.rb +122 -0
  107. data/lib/megam/core/stuff.rb +22 -0
  108. data/lib/megam/core/subscriptions.rb +167 -0
  109. data/lib/megam/core/subscriptions_collection.rb +121 -0
  110. data/lib/megam/core/text.rb +87 -0
  111. data/lib/megam/core/text_formatter.rb +64 -0
  112. data/lib/megam/mixins/assemblies.rb +16 -0
  113. data/lib/megam/mixins/assembly.rb +59 -0
  114. data/lib/megam/mixins/common_deployable.rb +78 -0
  115. data/lib/megam/mixins/components.rb +182 -0
  116. data/lib/megam/mixins/megam_attributes.rb +30 -0
  117. data/lib/megam/mixins/outputs.rb +23 -0
  118. data/lib/megam/mixins/policies.rb +27 -0
  119. data/lib/megam_api.rb +1 -0
  120. data/megam_api.gemspec +26 -0
  121. data/test/mixins/test_assemblies.rb +113 -0
  122. data/test/mixins/test_assembly.rb +74 -0
  123. data/test/mixins/test_component.rb +19 -0
  124. data/test/test_accounts.rb +127 -0
  125. data/test/test_addons.rb +26 -0
  126. data/test/test_assemblies.rb +88 -0
  127. data/test/test_assembly.rb +37 -0
  128. data/test/test_backups.rb +29 -0
  129. data/test/test_balances.rb +38 -0
  130. data/test/test_billedhistories.rb +30 -0
  131. data/test/test_billingtranscations.rb +35 -0
  132. data/test/test_components.rb +42 -0
  133. data/test/test_credits.rb +28 -0
  134. data/test/test_disks.rb +25 -0
  135. data/test/test_domains.rb +29 -0
  136. data/test/test_eventsbilling.rb +30 -0
  137. data/test/test_eventscontainer.rb +26 -0
  138. data/test/test_eventsstorage.rb +12 -0
  139. data/test/test_eventsvm.rb +26 -0
  140. data/test/test_helper.rb +77 -0
  141. data/test/test_marketplaces.rb +38 -0
  142. data/test/test_organizations.rb +45 -0
  143. data/test/test_promos.rb +11 -0
  144. data/test/test_quotas.rb +33 -0
  145. data/test/test_reports.rb +32 -0
  146. data/test/test_requests.rb +95 -0
  147. data/test/test_sensors.rb +50 -0
  148. data/test/test_snapshots.rb +30 -0
  149. data/test/test_sshkeys.rb +50 -0
  150. data/test/test_subscriptions.rb +22 -0
  151. metadata +325 -0
@@ -0,0 +1,27 @@
1
+
2
+ module Megam
3
+ class API
4
+
5
+ def get_addon(name)
6
+ @options = {:path => "/addons/#{name}",:body => ""}.merge(@options)
7
+
8
+ request(
9
+ :expects => 200,
10
+ :method => :get,
11
+ :body => @options[:body]
12
+ )
13
+ end
14
+
15
+ def post_addons(new_addon)
16
+ @options = {:path => '/addons/content',
17
+ :body => Megam::JSONCompat.to_json(new_addon)}.merge(@options)
18
+
19
+ request(
20
+ :expects => 201,
21
+ :method => :post,
22
+ :body => @options[:body]
23
+ )
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,49 @@
1
+ module Megam
2
+ class API
3
+ # GET /nodes
4
+ def get_assemblies
5
+ @options = {:path => '/assemblies',:body => ""}.merge(@options)
6
+
7
+ request(
8
+ :expects => 200,
9
+ :method => :get,
10
+ :body => @options[:body]
11
+ )
12
+ end
13
+
14
+ def get_one_assemblies(asm_id)
15
+ @options = {:path => "/assemblies/#{asm_id}",:body => ""}.merge(@options)
16
+
17
+ request(
18
+ :expects => 200,
19
+ :method => :get,
20
+ :body => @options[:body]
21
+ )
22
+ end
23
+
24
+ def post_assemblies(new_asm)
25
+ @options = {:path => '/assemblies/content',
26
+ :body => Megam::JSONCompat.to_json(new_asm)}.merge(@options)
27
+
28
+ request(
29
+ :expects => 201,
30
+ :method => :post,
31
+ :body => @options[:body]
32
+ )
33
+ end
34
+
35
+ #Yet to be tested
36
+ # DELETE /nodes/:node_id
37
+ def delete_assemblies(asm_id)
38
+ @options = {:path => '/nodes/#{asm_id}',
39
+ :body => ""}.merge(@options)
40
+
41
+ request(
42
+ :expects => 200,
43
+ :method => :delete,
44
+ :body => @options[:body]
45
+ )
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,56 @@
1
+ module Megam
2
+ class API
3
+ def get_one_assembly(asm_id)
4
+ @options = { path: "/assembly/#{asm_id}", body: '' }.merge(@options)
5
+
6
+ request(
7
+ expects: 200,
8
+ method: :get,
9
+ body: @options[:body]
10
+ )
11
+ end
12
+
13
+ def update_assembly(new_asm)
14
+ @options = { path: '/assembly/update',
15
+ body: Megam::JSONCompat.to_json(new_asm) }.merge(@options)
16
+
17
+ request(
18
+ expects: [200, 201],
19
+ method: :post,
20
+ body: @options[:body]
21
+ )
22
+ end
23
+
24
+ def upgrade_assembly(asm_id)
25
+ @options = { path: "/assembly/upgrade/#{asm_id}", body: '' }.merge(@options)
26
+
27
+ request(
28
+ expects: [200, 201],
29
+ method: :get,
30
+ body: @options[:body]
31
+ )
32
+ end
33
+
34
+ def list_assembly
35
+ @options = {:path => "/assembly",:body => ""}.merge(@options)
36
+
37
+ request(
38
+ :expects => 200,
39
+ :method => :get,
40
+ :body => @options[:body]
41
+ )
42
+ end
43
+
44
+ def delete_assembly(id, asms_id)
45
+ @options = {path: "/admin/assembly/#{asms_id}/#{id}",
46
+ :body => ''}.merge(@options)
47
+
48
+ request(
49
+ :expects => 200,
50
+ :method => :delete,
51
+ :body => @options[:body]
52
+ )
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,57 @@
1
+ module Megam
2
+ class API
3
+ # GET /nodes
4
+ def list_backups
5
+ @options = {:path => "/backups",:body => ""}.merge(@options)
6
+
7
+ request(
8
+ :expects => 200,
9
+ :method => :get,
10
+ :body => @options[:body]
11
+ )
12
+ end
13
+
14
+ def get_backups(asm_id)
15
+ @options = {:path => "/backups/#{asm_id}",:body => ""}.merge(@options)
16
+
17
+ request(
18
+ :expects => 200,
19
+ :method => :get,
20
+ :body => @options[:body]
21
+ )
22
+ end
23
+
24
+ def get_one_backup(backup_id)
25
+ @options = {:path => "/backups/show/#{backup_id}",:body => ""}.merge(@options)
26
+
27
+ request(
28
+ :expects => 200,
29
+ :method => :get,
30
+ :body => @options[:body]
31
+ )
32
+ end
33
+
34
+ def post_backups(new_sps)
35
+ @options = {:path => '/backups/content',
36
+ :body => Megam::JSONCompat.to_json(new_sps)}.merge(@options)
37
+
38
+ request(
39
+ :expects => 201,
40
+ :method => :post,
41
+ :body => @options[:body]
42
+ )
43
+ end
44
+
45
+ def update_backups(update_sps)
46
+ @options = {:path => '/backups/update',
47
+ :body => Megam::JSONCompat.to_json(update_sps)}.merge(@options)
48
+
49
+ request(
50
+ :expects => 201,
51
+ :method => :post,
52
+ :body => @options[:body]
53
+ )
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,45 @@
1
+ module Megam
2
+ class API
3
+ def get_balances
4
+ @options = {:path => '/balances',:body => ""}.merge(@options)
5
+
6
+ request(
7
+ :expects => 200,
8
+ :method => :get,
9
+ :body => @options[:body]
10
+ )
11
+ end
12
+
13
+ def get_balance(id)
14
+ @options = {:path => "/balances/#{id}",:body => Megam::JSONCompat.to_json(id)}.merge(@options)
15
+ request(
16
+ :expects => 200,
17
+ :method => :get,
18
+ :body => @options[:body]
19
+ )
20
+ end
21
+
22
+ def post_balances(new_balance)
23
+ @options = {:path => '/balances/content',
24
+ :body => Megam::JSONCompat.to_json(new_balance)}.merge(@options)
25
+
26
+ request(
27
+ :expects => 201,
28
+ :method => :post,
29
+ :body => @options[:body]
30
+ )
31
+ end
32
+
33
+ def update_balance(new_balance)
34
+ @options = {:path => '/admin/balances/update',
35
+ :body => Megam::JSONCompat.to_json(new_balance)}.merge(@options)
36
+
37
+ request(
38
+ :expects => 201,
39
+ :method => :post,
40
+ :body => @options[:body]
41
+ )
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,35 @@
1
+ module Megam
2
+ class API
3
+ def get_billedhistories
4
+ @options = {:path => '/billedhistories',:body => ""}.merge(@options)
5
+
6
+ request(
7
+ :expects => 200,
8
+ :method => :get,
9
+ :body => @options[:body]
10
+ )
11
+ end
12
+
13
+ def get_billedhistory(id)
14
+ @options = {:path => "/billedhistories/#{id}",:body => ""}.merge(@options)
15
+
16
+ request(
17
+ :expects => 200,
18
+ :method => :get,
19
+ :body => @options[:body]
20
+ )
21
+ end
22
+
23
+ def post_billedhistories(new_billedhistory)
24
+ @options = {:path => '/billedhistories/content',
25
+ :body => Megam::JSONCompat.to_json(new_billedhistory)}.merge(@options)
26
+
27
+ request(
28
+ :expects => 201,
29
+ :method => :post,
30
+ :body => @options[:body]
31
+ )
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,25 @@
1
+ module Megam
2
+ class API
3
+ def get_billingtransactions
4
+ @options = {:path => '/billingtransactions',:body => ""}.merge(@options)
5
+
6
+ request(
7
+ :expects => 200,
8
+ :method => :get,
9
+ :body => @options[:body]
10
+ )
11
+ end
12
+
13
+ def post_billingtransactions(new_billtransaction)
14
+ @options = {:path => '/billingtransactions/content',
15
+ :body => Megam::JSONCompat.to_json(new_billtransaction)}.merge(@options)
16
+
17
+ request(
18
+ :expects => 201,
19
+ :method => :post,
20
+ :body => @options[:body]
21
+ )
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ module Megam
2
+ class API
3
+ def get_components(comp_id)
4
+ @options = { path: "/components/#{comp_id}", body: '' }.merge(@options)
5
+
6
+ request(
7
+ expects: 200,
8
+ method: :get,
9
+ body: @options[:body]
10
+ )
11
+ end
12
+
13
+ def update_component(new_asm)
14
+ @options = { path: '/components/update',
15
+ body: Megam::JSONCompat.to_json(new_asm) }.merge(@options)
16
+
17
+ request(
18
+ expects: [200, 201],
19
+ method: :post,
20
+ body: @options[:body]
21
+ )
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ module Megam
2
+ class API
3
+ def list_credits
4
+ @options = {:path => '/credits',:body => ""}.merge(@options)
5
+
6
+ request(
7
+ :expects => 200,
8
+ :method => :get,
9
+ :body => @options[:body]
10
+ )
11
+ end
12
+
13
+ def get_credits(account_id)
14
+ @options = {:path => "/credits/#{account_id}",:body => Megam::JSONCompat.to_json(account_id)}.merge(@options)
15
+ request(
16
+ :expects => 200,
17
+ :method => :get,
18
+ :body => @options[:body]
19
+ )
20
+ end
21
+
22
+ def post_credits(new_credits)
23
+ @options = {:path => '/credits/content',
24
+ :body => Megam::JSONCompat.to_json(new_credits)}.merge(@options)
25
+
26
+ request(
27
+ :expects => 201,
28
+ :method => :post,
29
+ :body => @options[:body]
30
+ )
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,44 @@
1
+ module Megam
2
+ class API
3
+ # GET /nodes
4
+ def list_disks
5
+ @options = {:path => "/disks",:body => ""}.merge(@options)
6
+
7
+ request(
8
+ :expects => 200,
9
+ :method => :get,
10
+ :body => @options[:body]
11
+ )
12
+ end
13
+
14
+ def get_disks(asm_id)
15
+ @options = {:path => "/disks/#{asm_id}",:body => ""}.merge(@options)
16
+
17
+ request(
18
+ :expects => 200,
19
+ :method => :get,
20
+ :body => @options[:body]
21
+ )
22
+ end
23
+ def post_disks(new_dsk)
24
+ @options = {:path => '/disks/content',
25
+ :body => Megam::JSONCompat.to_json(new_dsk)}.merge(@options)
26
+ request(
27
+ :expects => 201,
28
+ :method => :post,
29
+ :body => @options[:body]
30
+ )
31
+ end
32
+ def remove_disks(asm_id, disk_id)
33
+
34
+ @options = {:path => "/disks/delete/#{asm_id}/#{disk_id}",
35
+ :body => ""}.merge(@options)
36
+ request(
37
+ :expects => 201,
38
+ :method => :get,
39
+ :body => @options[:body]
40
+ )
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,25 @@
1
+ module Megam
2
+ class API
3
+
4
+
5
+ def get_domains
6
+ @options = {:path => "/domains", :body => ''}.merge(@options)
7
+ request(
8
+ :expects => 200,
9
+ :method => :get,
10
+ :body => @options[:body]
11
+ )
12
+ end
13
+
14
+
15
+ def post_domains(new_domain)
16
+ @options = {:path => '/domains/content',
17
+ :body => Megam::JSONCompat.to_json(new_domain)}.merge(@options)
18
+ request(
19
+ :expects => 201,
20
+ :method => :post,
21
+ :body => @options[:body]
22
+ )
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ module Megam
2
+ class API
3
+ module Errors
4
+ class Error < StandardError; end
5
+
6
+ class ErrorWithResponse < Error
7
+ attr_reader :response
8
+
9
+ def initialize(message, response)
10
+ super message
11
+ @response = response
12
+ end
13
+
14
+
15
+ end
16
+
17
+ class Unauthorized < ErrorWithResponse; end
18
+ class Forbidden < ErrorWithResponse; end
19
+ class NotFound < ErrorWithResponse; end
20
+ class Timeout < ErrorWithResponse; end
21
+ class Locked < ErrorWithResponse; end
22
+ class Socket < ErrorWithResponse; end
23
+ class RequestFailed < ErrorWithResponse; end
24
+
25
+ class AuthKeysMissing < ArgumentError; end
26
+
27
+ end
28
+ end
29
+ end