megam_api 0.100 → 1.5.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -69
- data/lib/megam/api.rb +15 -37
- data/lib/megam/api/errors.rb +19 -19
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/account.rb +1 -1
- data/lib/megam/core/assemblies.rb +1 -1
- data/lib/megam/core/assemblies_collection.rb +7 -15
- data/lib/megam/core/assembly.rb +1 -1
- data/lib/megam/core/assembly_collection.rb +7 -15
- data/lib/megam/core/balances.rb +1 -1
- data/lib/megam/core/balances_collection.rb +8 -16
- data/lib/megam/core/billedhistories.rb +1 -1
- data/lib/megam/core/billedhistories_collection.rb +7 -15
- data/lib/megam/core/components.rb +1 -1
- data/lib/megam/core/components_collection.rb +103 -110
- data/lib/megam/core/domain_collection.rb +102 -109
- data/lib/megam/core/domains.rb +1 -1
- data/lib/megam/core/error.rb +1 -15
- data/lib/megam/core/json_compat.rb +170 -208
- data/lib/megam/core/marketplace.rb +1 -1
- data/lib/megam/core/marketplace_collection.rb +7 -16
- data/lib/megam/core/organizations.rb +1 -1
- data/lib/megam/core/organizations_collection.rb +8 -40
- data/lib/megam/core/promos.rb +1 -1
- data/lib/megam/core/request.rb +1 -1
- data/lib/megam/core/request_collection.rb +7 -16
- data/lib/megam/core/rest_adapter.rb +54 -0
- data/lib/megam/core/sensors.rb +1 -1
- data/lib/megam/core/sensors_collection.rb +7 -14
- data/lib/megam/core/sshkey.rb +1 -1
- data/lib/megam/core/sshkey_collection.rb +103 -110
- data/lib/megam/core/stuff.rb +2 -34
- data/lib/megam/core/text.rb +1 -0
- data/lib/megam/core/text_formatter.rb +2 -1
- data/megam_api.gemspec +2 -2
- metadata +10 -56
- data/lib/megam/api/availableunits.rb +0 -50
- data/lib/megam/api/billings.rb +0 -50
- data/lib/megam/api/credithistories.rb +0 -50
- data/lib/megam/api/csars.rb +0 -75
- data/lib/megam/api/discounts.rb +0 -50
- data/lib/megam/api/invoices.rb +0 -50
- data/lib/megam/api/login.rb +0 -29
- data/lib/megam/api/subscriptions.rb +0 -50
- data/lib/megam/core/auth.rb +0 -91
- data/lib/megam/core/availableunits.rb +0 -182
- data/lib/megam/core/availableunits_collection.rb +0 -144
- data/lib/megam/core/billings.rb +0 -242
- data/lib/megam/core/billings_collection.rb +0 -144
- data/lib/megam/core/config.rb +0 -41
- data/lib/megam/core/credithistories.rb +0 -191
- data/lib/megam/core/credithistories_collection.rb +0 -144
- data/lib/megam/core/csar.rb +0 -179
- data/lib/megam/core/csar_collection.rb +0 -148
- data/lib/megam/core/discounts.rb +0 -204
- data/lib/megam/core/discounts_collection.rb +0 -164
- data/lib/megam/core/invoices.rb +0 -231
- data/lib/megam/core/invoices_collection.rb +0 -144
- data/lib/megam/core/server_api.rb +0 -52
- data/lib/megam/core/subscriptions.rb +0 -191
- data/lib/megam/core/subscriptions_collection.rb +0 -144
- data/test/test_availableunits.rb +0 -28
- data/test/test_billings.rb +0 -33
- data/test/test_cat_requests.rb +0 -20
- data/test/test_credithistories.rb +0 -29
- data/test/test_csars.rb +0 -22
- data/test/test_discounts.rb +0 -31
- data/test/test_invoices.rb +0 -31
- data/test/test_login.rb +0 -10
- data/test/test_marketplaceaddons.rb +0 -46
- data/test/test_predefclouds.rb +0 -80
- data/test/test_subscriptions.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3c1c1f8eda74d69c6e721b36a1d4266a35c013b
|
4
|
+
data.tar.gz: e601f5d38a95771f9640f208c3b4978df0c4404d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fcb38fe7ddcd5df82f7dd441f24e000ed8df47ed946f09941aa3904631017d74174ea9c346b308dd662da5d72ed41773a5ac541ba4d9f2d3b376174e448136e
|
7
|
+
data.tar.gz: 292a610d1c3d11c95c20e05af0b9dde48f2f33b37ce4abdd0be76c6fc7bc6e236b74264cc243a42d26d55efe7b3280b31f4198b0f5316926c965480d52553cee
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Vertice api for ruby
|
2
|
+
=====================
|
3
3
|
|
4
4
|
[](http://badge.fury.io/rb/megam_api)
|
5
5
|
|
6
|
-
|
6
|
+
Vertice api is used to talk to the vertice gateway server.
|
7
7
|
|
8
|
-
For more about the REST API <http://docs.megam.io
|
8
|
+
For more about the REST API <http://docs.megam.io>
|
9
9
|
|
10
10
|
[](https://travis-ci.org/megamsys/megam_api)
|
11
11
|
|
@@ -19,70 +19,7 @@ gem install megam_api
|
|
19
19
|
|
20
20
|
```
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
```ruby
|
25
|
-
|
26
|
-
require 'megam_api'
|
27
|
-
|
28
|
-
require 'meggy/meg'
|
29
|
-
require 'megam/core/server_api'
|
30
|
-
require 'command_line_reporter'
|
31
|
-
|
32
|
-
class Meggy
|
33
|
-
class Meg
|
34
|
-
class AccountShow < Meg
|
35
|
-
include CommandLineReporter
|
36
|
-
|
37
|
-
banner "meg account show"
|
38
|
-
def run
|
39
|
-
begin
|
40
|
-
Megam::Config[:email] = Meggy::Config[:email]
|
41
|
-
Megam::Config[:api_key] = Meggy::Config[:api_key]
|
42
|
-
@excon_res = Megam::Account.show(Megam::Config[:email])
|
43
|
-
acct_res = @excon_res.data[:body]
|
44
|
-
report(acct_res)
|
45
|
-
rescue Megam::API::Errors::ErrorWithResponse => ewr
|
46
|
-
res = ewr.response.data[:body].some_msg
|
47
|
-
text.error(res[:msg])
|
48
|
-
text.msg("#{text.color("Retry Again", :white, :bold)}")
|
49
|
-
text.info(res[:links])
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def report(acct_res)
|
54
|
-
table :border => true do
|
55
|
-
row :header => true, :color => 'green' do
|
56
|
-
column 'Account', :width => 15
|
57
|
-
column 'Information', :width => 32, :align => 'left'
|
58
|
-
end
|
59
|
-
row do
|
60
|
-
column 'email'
|
61
|
-
column acct_res.email
|
62
|
-
end
|
63
|
-
row do
|
64
|
-
column 'api_key'
|
65
|
-
column acct_res.api_key
|
66
|
-
end
|
67
|
-
row do
|
68
|
-
column 'authority'
|
69
|
-
column acct_res.authority
|
70
|
-
end
|
71
|
-
row do
|
72
|
-
column 'created_at'
|
73
|
-
column acct_res.created_at
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
```
|
82
|
-
|
83
|
-
* See [meggy](https://github.com/megamsys/meggy.git) where the files like `Meg` are there.
|
84
|
-
|
85
|
-
For more implementation details [see meggy](https://github.com/megamsys/meggy.git)
|
22
|
+
For more implementation details [see nilavu](http://github.com/megamsys/nilavu.git)
|
86
23
|
|
87
24
|
We are glad to help if you have questions, or request for new features..
|
88
25
|
|
@@ -90,7 +27,6 @@ We are glad to help if you have questions, or request for new features..
|
|
90
27
|
|
91
28
|
|
92
29
|
|
93
|
-
|
94
30
|
# License
|
95
31
|
|
96
32
|
| | |
|
data/lib/megam/api.rb
CHANGED
@@ -23,28 +23,21 @@ require 'openssl'
|
|
23
23
|
__LIB_DIR__ = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
24
24
|
$LOAD_PATH.unshift(__LIB_DIR__) unless $LOAD_PATH.include?(__LIB_DIR__)
|
25
25
|
|
26
|
-
require 'megam/api/errors'
|
27
|
-
require 'megam/api/version'
|
28
26
|
require 'megam/api/accounts'
|
29
|
-
require 'megam/api/requests'
|
30
|
-
require 'megam/api/sshkeys'
|
31
|
-
require 'megam/api/marketplaces'
|
32
|
-
require 'megam/api/organizations'
|
33
|
-
require 'megam/api/domains'
|
34
|
-
require 'megam/api/csars'
|
35
27
|
require 'megam/api/assemblies'
|
36
28
|
require 'megam/api/assembly'
|
37
|
-
require 'megam/api/components'
|
38
|
-
require 'megam/api/sensors'
|
39
|
-
require 'megam/api/availableunits'
|
40
29
|
require 'megam/api/balances'
|
41
30
|
require 'megam/api/billedhistories'
|
42
|
-
require 'megam/api/
|
43
|
-
require 'megam/api/
|
44
|
-
require 'megam/api/
|
45
|
-
require 'megam/api/
|
31
|
+
require 'megam/api/components'
|
32
|
+
require 'megam/api/domains'
|
33
|
+
require 'megam/api/errors'
|
34
|
+
require 'megam/api/marketplaces'
|
35
|
+
require 'megam/api/organizations'
|
46
36
|
require 'megam/api/promos'
|
47
|
-
require 'megam/api/
|
37
|
+
require 'megam/api/requests'
|
38
|
+
require 'megam/api/sensors'
|
39
|
+
require 'megam/api/sshkeys'
|
40
|
+
require 'megam/api/version'
|
48
41
|
|
49
42
|
require 'megam/mixins/assemblies'
|
50
43
|
require 'megam/mixins/assembly'
|
@@ -54,13 +47,11 @@ require 'megam/mixins/megam_attributes'
|
|
54
47
|
require 'megam/mixins/outputs'
|
55
48
|
require 'megam/mixins/policies'
|
56
49
|
|
57
|
-
require 'megam/core/
|
58
|
-
require 'megam/core/config'
|
50
|
+
require 'megam/core/rest_adapter'
|
59
51
|
require 'megam/core/stuff'
|
60
52
|
require 'megam/core/text'
|
61
53
|
require 'megam/core/log'
|
62
54
|
require 'megam/core/json_compat'
|
63
|
-
require 'megam/core/auth'
|
64
55
|
require 'megam/core/error'
|
65
56
|
require 'megam/core/account'
|
66
57
|
require 'megam/core/request'
|
@@ -75,8 +66,6 @@ require 'megam/core/domains'
|
|
75
66
|
require 'megam/core/domain_collection'
|
76
67
|
require 'megam/core/assemblies'
|
77
68
|
require 'megam/core/assemblies_collection'
|
78
|
-
require 'megam/core/csar'
|
79
|
-
require 'megam/core/csar_collection'
|
80
69
|
require 'megam/core/konipai'
|
81
70
|
require 'megam/core/assembly'
|
82
71
|
require 'megam/core/assembly_collection'
|
@@ -84,26 +73,15 @@ require 'megam/core/components'
|
|
84
73
|
require 'megam/core/components_collection'
|
85
74
|
require 'megam/core/sensors'
|
86
75
|
require 'megam/core/sensors_collection'
|
87
|
-
require 'megam/core/availableunits_collection'
|
88
|
-
require 'megam/core/availableunits'
|
89
76
|
require 'megam/core/balances_collection'
|
90
77
|
require 'megam/core/balances'
|
91
78
|
require 'megam/core/billedhistories_collection'
|
92
79
|
require 'megam/core/billedhistories'
|
93
|
-
require 'megam/core/billings_collection'
|
94
|
-
require 'megam/core/billings'
|
95
|
-
require 'megam/core/credithistories_collection'
|
96
|
-
require 'megam/core/credithistories'
|
97
|
-
require 'megam/core/discounts_collection'
|
98
|
-
require 'megam/core/discounts'
|
99
|
-
require 'megam/core/subscriptions_collection'
|
100
|
-
require 'megam/core/subscriptions'
|
101
80
|
require 'megam/core/promos'
|
102
|
-
require 'megam/core/invoices_collection'
|
103
|
-
require 'megam/core/invoices'
|
104
81
|
|
105
82
|
module Megam
|
106
83
|
class API
|
84
|
+
|
107
85
|
# text is used to print stuff in the terminal (message, log, info, warn etc.)
|
108
86
|
attr_accessor :text
|
109
87
|
|
@@ -113,6 +91,7 @@ module Megam
|
|
113
91
|
X_Megam_HMAC = 'X-Megam-HMAC'.freeze
|
114
92
|
X_Megam_OTTAI = 'X-Megam-OTTAI'.freeze
|
115
93
|
X_Megam_ORG = 'X-Megam-ORG'.freeze
|
94
|
+
X_Megam_PUTTUSAVI = 'X-Megam-PUTTUSAVI'.freeze
|
116
95
|
|
117
96
|
HEADERS = {
|
118
97
|
'Accept' => 'application/json',
|
@@ -235,7 +214,7 @@ module Megam
|
|
235
214
|
@options[:headers] = HEADERS.merge(X_Megam_HMAC => encoded_api_header[:hmac],
|
236
215
|
X_Megam_DATE => encoded_api_header[:date], X_Megam_ORG => "#{@org_id}").merge(@options[:headers])
|
237
216
|
if (@api_key == "" || @api_key.nil?)
|
238
|
-
@options[:headers] = @options[:headers].merge(
|
217
|
+
@options[:headers] = @options[:headers].merge(X_Megam_PUTTUSAVI => "true") unless (@password == "" || @password.nil?)
|
239
218
|
end
|
240
219
|
|
241
220
|
Megam::Log.debug('HTTP Request Data:')
|
@@ -259,7 +238,6 @@ module Megam
|
|
259
238
|
# The output will have
|
260
239
|
# :hmac
|
261
240
|
# :date
|
262
|
-
# (Refer https://github.com/indykish/megamplay.git/test/AuthenticateSpec.scala)
|
263
241
|
def encode_header(cmd_parms)
|
264
242
|
header_params = {}
|
265
243
|
body_digest = OpenSSL::Digest::MD5.digest(cmd_parms[:body])
|
@@ -275,11 +253,11 @@ module Megam
|
|
275
253
|
hash = OpenSSL::HMAC.hexdigest(digest, Base64.strict_decode64(@password), movingFactor)
|
276
254
|
elsif !(@api_key.nil?)
|
277
255
|
hash = OpenSSL::HMAC.hexdigest(digest, @api_key, movingFactor)
|
278
|
-
else
|
256
|
+
else
|
279
257
|
hash = OpenSSL::HMAC.hexdigest(digest, "", movingFactor)
|
280
258
|
end
|
281
259
|
final_hmac = @email + ':' + hash
|
282
260
|
header_params = { hmac: final_hmac, date: current_date }
|
283
261
|
end
|
284
262
|
end
|
285
|
-
end
|
263
|
+
end
|
data/lib/megam/api/errors.rb
CHANGED
@@ -14,31 +14,31 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
module Megam
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
class API
|
18
|
+
module Errors
|
19
|
+
class Error < StandardError; end
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
class ErrorWithResponse < Error
|
22
|
+
attr_reader :response
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def initialize(message, response)
|
25
|
+
super message
|
26
|
+
@response = response
|
27
|
+
end
|
28
28
|
|
29
29
|
|
30
|
-
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
class Unauthorized < ErrorWithResponse; end
|
33
|
+
class Forbidden < ErrorWithResponse; end
|
34
|
+
class NotFound < ErrorWithResponse; end
|
35
|
+
class Timeout < ErrorWithResponse; end
|
36
|
+
class Locked < ErrorWithResponse; end
|
37
|
+
class Socket < ErrorWithResponse; end
|
38
|
+
class RequestFailed < ErrorWithResponse; end
|
39
39
|
|
40
|
-
|
40
|
+
class AuthKeysMissing < ArgumentError; end
|
41
41
|
|
42
|
+
end
|
42
43
|
end
|
43
|
-
end
|
44
44
|
end
|
data/lib/megam/api/version.rb
CHANGED
data/lib/megam/core/account.rb
CHANGED
@@ -101,19 +101,16 @@ module Megam
|
|
101
101
|
@assemblies[res]
|
102
102
|
end
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
index_hash
|
104
|
+
def to_s
|
105
|
+
@assemblies.join(", ")
|
106
|
+
end
|
107
|
+
|
108
|
+
def for_json
|
109
|
+
to_a.map { |item| item.to_s }
|
111
110
|
end
|
112
111
|
|
113
|
-
# Serialize this object as a hash: called from JsonCompat.
|
114
|
-
# Verify if this called from JsonCompat during testing.
|
115
112
|
def to_json(*a)
|
116
|
-
|
113
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
117
114
|
end
|
118
115
|
|
119
116
|
def self.json_create(o)
|
@@ -136,10 +133,5 @@ module Megam
|
|
136
133
|
end
|
137
134
|
true
|
138
135
|
end
|
139
|
-
|
140
|
-
def to_s
|
141
|
-
Megam::Stuff.styled_hash(to_hash)
|
142
|
-
end
|
143
|
-
|
144
136
|
end
|
145
137
|
end
|
data/lib/megam/core/assembly.rb
CHANGED
@@ -101,19 +101,16 @@ module Megam
|
|
101
101
|
@assemblys[res]
|
102
102
|
end
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
index_hash
|
104
|
+
def to_s
|
105
|
+
@assemblys.join(", ")
|
106
|
+
end
|
107
|
+
|
108
|
+
def for_json
|
109
|
+
to_a.map { |item| item.to_s }
|
111
110
|
end
|
112
111
|
|
113
|
-
# Serialize this object as a hash: called from JsonCompat.
|
114
|
-
# Verify if this called from JsonCompat during testing.
|
115
112
|
def to_json(*a)
|
116
|
-
|
113
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
117
114
|
end
|
118
115
|
|
119
116
|
def self.json_create(o)
|
@@ -136,10 +133,5 @@ module Megam
|
|
136
133
|
end
|
137
134
|
true
|
138
135
|
end
|
139
|
-
|
140
|
-
def to_s
|
141
|
-
Megam::Stuff.styled_hash(to_hash)
|
142
|
-
end
|
143
|
-
|
144
136
|
end
|
145
137
|
end
|
data/lib/megam/core/balances.rb
CHANGED
@@ -101,19 +101,16 @@ module Megam
|
|
101
101
|
@balance[res]
|
102
102
|
end
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
index_hash
|
104
|
+
def to_s
|
105
|
+
@balance.join(", ")
|
106
|
+
end
|
107
|
+
|
108
|
+
def for_json
|
109
|
+
to_a.map { |item| item.to_s }
|
111
110
|
end
|
112
111
|
|
113
|
-
# Serialize this object as a hash: called from JsonCompat.
|
114
|
-
# Verify if this called from JsonCompat during testing.
|
115
112
|
def to_json(*a)
|
116
|
-
|
113
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
117
114
|
end
|
118
115
|
|
119
116
|
def self.json_create(o)
|
@@ -135,10 +132,5 @@ module Megam
|
|
135
132
|
end
|
136
133
|
true
|
137
134
|
end
|
138
|
-
|
139
|
-
def to_s
|
140
|
-
Megam::Stuff.styled_hash(to_hash)
|
141
|
-
end
|
142
|
-
|
143
135
|
end
|
144
|
-
end
|
136
|
+
end
|