megam_api 1.8.4 → 1.8.5
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/lib/megam/api.rb +2 -0
- data/lib/megam/api/license.rb +35 -0
- data/lib/megam/api/version.rb +1 -2
- data/lib/megam/core/json_compat.rb +4 -0
- data/lib/megam/core/license-collection.rb +122 -0
- data/lib/megam/core/license.rb +173 -0
- metadata +5 -28
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55dd30f7d335322e02a1d7fb0fb068448d5cf2a0
|
|
4
|
+
data.tar.gz: b787907129fb100ad91c2dc86b2d0a0036f9a349
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc98d217f97652c5e5c5050c285d37ba4ada6b7b3f54538d53c96813bc5ca2319936dbd3a5fc714e45d55ce8f423ef3f1064571d6aa12a94a59d3e7f9827f13b
|
|
7
|
+
data.tar.gz: ac36e15c98f7396df1637392ab2252ed9b0e051afabc8cdf903091526f42b9c7c136a78d330886944abccaed3c10afdde30d4f211565829e5ecf9a70fe6095d5
|
data/lib/megam/api.rb
CHANGED
|
@@ -52,6 +52,8 @@ require 'megam/core/account'
|
|
|
52
52
|
require 'megam/core/account_collection'
|
|
53
53
|
require 'megam/core/request'
|
|
54
54
|
require 'megam/core/request_collection'
|
|
55
|
+
require 'megam/core/license'
|
|
56
|
+
require 'megam/core/license_collection'
|
|
55
57
|
require 'megam/core/sshkey'
|
|
56
58
|
require 'megam/core/sshkey_collection'
|
|
57
59
|
require 'megam/core/eventsall'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Megam
|
|
2
|
+
class API
|
|
3
|
+
def get_licenses
|
|
4
|
+
@options = {:path => '/license',:body => ""}.merge(@options)
|
|
5
|
+
|
|
6
|
+
request(
|
|
7
|
+
:expects => 200,
|
|
8
|
+
:method => :get,
|
|
9
|
+
:body => @options[:body]
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get_license(license_name)
|
|
14
|
+
@options = {:path => "/license/#{license_name}",:body => ""}.merge(@options)
|
|
15
|
+
|
|
16
|
+
request(
|
|
17
|
+
:expects => 200,
|
|
18
|
+
:method => :get,
|
|
19
|
+
:body => @options[:body]
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def post_license(new_license)
|
|
24
|
+
@options = {:path => '/license/content',
|
|
25
|
+
:body => Megam::JSONCompat.to_json(new_license)}.merge(@options)
|
|
26
|
+
|
|
27
|
+
request(
|
|
28
|
+
:expects => 201,
|
|
29
|
+
:method => :post,
|
|
30
|
+
:body => @options[:body]
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/megam/api/version.rb
CHANGED
|
@@ -40,6 +40,8 @@ module Megam
|
|
|
40
40
|
MEGAM_SNAPSHOTSCOLLECTION = 'Megam::SnapshotsCollection'.freeze
|
|
41
41
|
MEGAM_DISKS = 'Megam::Disks'.freeze
|
|
42
42
|
MEGAM_DISKSCOLLECTION = 'Megam::DisksCollection'.freeze
|
|
43
|
+
MEGAM_LICENSE = 'Megam::License'.freeze
|
|
44
|
+
MEGAM_LICENSECOLLECTION = 'Megam::LicenseCollection'.freeze
|
|
43
45
|
MEGAM_SSHKEY = 'Megam::SshKey'.freeze
|
|
44
46
|
MEGAM_SSHKEYCOLLECTION = 'Megam::SshKeyCollection'.freeze
|
|
45
47
|
MEGAM_EVENTSALL = 'Megam::EventsAll'.freeze
|
|
@@ -169,6 +171,8 @@ module Megam
|
|
|
169
171
|
Megam::EventsVm
|
|
170
172
|
when MEGAM_EVENTSVMCOLLECTION
|
|
171
173
|
Megam::EventsVmCollection
|
|
174
|
+
when MEGAM_LICENSECOLLECTION
|
|
175
|
+
Megam::LicenseCollection
|
|
172
176
|
when MEGAM_EVENTSALL
|
|
173
177
|
Megam::EventsAll
|
|
174
178
|
when MEGAM_EVENTSALLCOLLECTION
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
module Megam
|
|
2
|
+
class LicenseCollection
|
|
3
|
+
include Enumerable
|
|
4
|
+
|
|
5
|
+
attr_reader :iterator
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
@license = Array.new
|
|
9
|
+
@license_by_name = Hash.new
|
|
10
|
+
@insert_after_idx = nil
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def all_license
|
|
14
|
+
@license
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def [](index)
|
|
18
|
+
@license[index]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def []=(index, arg)
|
|
22
|
+
is_megam_license(arg)
|
|
23
|
+
@license[index] = arg
|
|
24
|
+
@license_by_name[arg.name] = index
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def <<(*args)
|
|
28
|
+
args.flatten.each do |a|
|
|
29
|
+
is_megam_license(a)
|
|
30
|
+
@license << a
|
|
31
|
+
@license_by_name[a.name] =@license.length - 1
|
|
32
|
+
end
|
|
33
|
+
self
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# 'push' is an alias method to <<
|
|
37
|
+
alias_method :push, :<<
|
|
38
|
+
|
|
39
|
+
def insert(license)
|
|
40
|
+
is_megam_license(license)
|
|
41
|
+
if @insert_after_idx
|
|
42
|
+
# in the middle of executing a run, so any license inserted now should
|
|
43
|
+
# be placed after the most recent addition done by the currently executing
|
|
44
|
+
# license
|
|
45
|
+
@license.insert(@insert_after_idx + 1, license)
|
|
46
|
+
# update name -> location mappings and register new license
|
|
47
|
+
@license_by_name.each_key do |key|
|
|
48
|
+
@license_by_name[key] += 1 if@license_by_name[key] > @insert_after_idx
|
|
49
|
+
end
|
|
50
|
+
@license_by_name[license.name] = @insert_after_idx + 1
|
|
51
|
+
@insert_after_idx += 1
|
|
52
|
+
else
|
|
53
|
+
@license << license
|
|
54
|
+
@license_by_name[license.name] =@license.length - 1
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def each
|
|
59
|
+
@license.each do |license|
|
|
60
|
+
yield license
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def each_index
|
|
65
|
+
@license.each_index do |i|
|
|
66
|
+
yield i
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def empty?
|
|
71
|
+
@license.empty?
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def lookup(license)
|
|
75
|
+
lookup_by = nil
|
|
76
|
+
if license.kind_of?(Megam::License)
|
|
77
|
+
lookup_by = license.name
|
|
78
|
+
elsif license.kind_of?(String)
|
|
79
|
+
lookup_by = license
|
|
80
|
+
else
|
|
81
|
+
raise ArgumentError, "Must pass a Megam::license or String to lookup"
|
|
82
|
+
end
|
|
83
|
+
res =@license_by_name[lookup_by]
|
|
84
|
+
unless res
|
|
85
|
+
raise ArgumentError, "Cannot find a license matching #{lookup_by} (did you define it first?)"
|
|
86
|
+
end
|
|
87
|
+
@license[res]
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def to_s
|
|
91
|
+
@license.join(", ")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def for_json
|
|
95
|
+
to_a.map { |item| item.to_s }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def to_json(*a)
|
|
99
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def self.json_create(o)
|
|
103
|
+
collection = self.new()
|
|
104
|
+
o["results"].each do |license_list|
|
|
105
|
+
license_array = license_list.kind_of?(Array) ? license_list : [ license_list ]
|
|
106
|
+
license_array.each do |license|
|
|
107
|
+
collection.insert(license)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
collection
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
private
|
|
114
|
+
|
|
115
|
+
def is_megam_license(arg)
|
|
116
|
+
unless arg.kind_of?(Megam::License)
|
|
117
|
+
raise ArgumentError, "Members must be Megam::License's"
|
|
118
|
+
end
|
|
119
|
+
true
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
module Megam
|
|
2
|
+
class License < Megam::RestAdapter
|
|
3
|
+
def initialize(o)
|
|
4
|
+
@id = nil
|
|
5
|
+
@name = nil
|
|
6
|
+
@org_id = nil
|
|
7
|
+
@privatekey=nil
|
|
8
|
+
@publickey=nil
|
|
9
|
+
@created_at = nil
|
|
10
|
+
@some_msg = {}
|
|
11
|
+
super(o)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def license
|
|
15
|
+
self
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def id(arg=nil)
|
|
19
|
+
if arg != nil
|
|
20
|
+
@id = arg
|
|
21
|
+
else
|
|
22
|
+
@id
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def name(arg=nil)
|
|
27
|
+
if arg != nil
|
|
28
|
+
@name = arg
|
|
29
|
+
else
|
|
30
|
+
@name
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def org_id(arg=nil)
|
|
35
|
+
if arg != nil
|
|
36
|
+
@org_id= arg
|
|
37
|
+
else
|
|
38
|
+
@org_id
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def privatekey(arg=nil)
|
|
43
|
+
if arg != nil
|
|
44
|
+
@privatekey = arg
|
|
45
|
+
else
|
|
46
|
+
@privatekey
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def publickey(arg=nil)
|
|
51
|
+
if arg != nil
|
|
52
|
+
@publickey = arg
|
|
53
|
+
else
|
|
54
|
+
@publickey
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def created_at(arg=nil)
|
|
60
|
+
if arg != nil
|
|
61
|
+
@created_at = arg
|
|
62
|
+
else
|
|
63
|
+
@created_at
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def some_msg(arg=nil)
|
|
68
|
+
if arg != nil
|
|
69
|
+
@some_msg = arg
|
|
70
|
+
else
|
|
71
|
+
@some_msg
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def error?
|
|
76
|
+
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Transform the ruby obj -> to a Hash
|
|
80
|
+
def to_hash
|
|
81
|
+
index_hash = Hash.new
|
|
82
|
+
index_hash["json_claz"] = self.class.name
|
|
83
|
+
index_hash["id"] = id
|
|
84
|
+
index_hash["name"] = name
|
|
85
|
+
index_hash["org_id"] = org_id
|
|
86
|
+
index_hash["privatekey"] = privatekey
|
|
87
|
+
index_hash["publickey"] = publickey
|
|
88
|
+
index_hash["created_at"] = created_at
|
|
89
|
+
index_hash
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Serialize this object as a hash: called from JsonCompat.
|
|
93
|
+
# Verify if this called from JsonCompat during testing.
|
|
94
|
+
def to_json(*a)
|
|
95
|
+
for_json.to_json(*a)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def for_json
|
|
99
|
+
result = {
|
|
100
|
+
"id" => id,
|
|
101
|
+
"name" => name,
|
|
102
|
+
"org_id" => org_id,
|
|
103
|
+
"privatekey" => privatekey,
|
|
104
|
+
"publickey" => publickey,
|
|
105
|
+
"created_at" => created_at
|
|
106
|
+
}
|
|
107
|
+
result
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
#
|
|
111
|
+
def self.json_create(o)
|
|
112
|
+
license = new({})
|
|
113
|
+
license.id(o["id"]) if o.has_key?("id")
|
|
114
|
+
license.name(o["name"]) if o.has_key?("name")
|
|
115
|
+
license.privatekey(o["privatekey"]) if o.has_key?("privatekey")
|
|
116
|
+
license.publickey(o["publickey"]) if o.has_key?("publickey")
|
|
117
|
+
license.created_at(o["created_at"]) if o.has_key?("created_at")
|
|
118
|
+
#success or error
|
|
119
|
+
license.some_msg[:code] = o["code"] if o.has_key?("code")
|
|
120
|
+
license.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
|
121
|
+
license.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
|
122
|
+
license.some_msg[:links] = o["links"] if o.has_key?("links")
|
|
123
|
+
license
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def self.from_hash(o)
|
|
127
|
+
license = self.new(o)
|
|
128
|
+
license.from_hash(o)
|
|
129
|
+
license
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def from_hash(o)
|
|
133
|
+
@id = o[:id] if o.has_key?(:id)
|
|
134
|
+
@name = o[:name] if o.has_key?(:name)
|
|
135
|
+
@org_id = o[:org_id] if o.has_key?(:org_id)
|
|
136
|
+
@privatekey = o[:privatekey] if o.has_key?(:privatekey)
|
|
137
|
+
@publickey = o[:publickey] if o.has_key?(:publickey)
|
|
138
|
+
@created_at = o[:created_at] if o.has_key?(:created_at)
|
|
139
|
+
self
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def self.create(params)
|
|
143
|
+
acct = from_hash(params)
|
|
144
|
+
acct.create
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Create the predef via the REST API
|
|
148
|
+
def create
|
|
149
|
+
megam_rest.post_license(to_hash)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Load all license -
|
|
153
|
+
# returns a LicensesCollection
|
|
154
|
+
# don't return self. check if the Megam::LicenseCollection is returned.
|
|
155
|
+
def self.list(params)
|
|
156
|
+
license = self.new(params)
|
|
157
|
+
license.megam_rest.get_license
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Show a particular License by name,
|
|
161
|
+
# Megam::License
|
|
162
|
+
def self.show(params)
|
|
163
|
+
pre = self.new(params)
|
|
164
|
+
pre.megam_rest.get_license(params["name"])
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def to_s
|
|
168
|
+
Megam::Stuff.styled_hash(to_hash)
|
|
169
|
+
#"---> Megam::Account:[error=#{error?}]\n"+
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
end
|
|
173
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: megam_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.8.
|
|
4
|
+
version: 1.8.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rajthilak, Kishorekumar Neelamegam, Ranjitha R, Vinodhini V, Rathish VBR, Rajesh
|
|
@@ -153,6 +153,7 @@ files:
|
|
|
153
153
|
- lib/megam/api/eventscontainer.rb
|
|
154
154
|
- lib/megam/api/eventsstorage.rb
|
|
155
155
|
- lib/megam/api/eventsvm.rb
|
|
156
|
+
- lib/megam/api/license.rb
|
|
156
157
|
- lib/megam/api/marketplaces.rb
|
|
157
158
|
- lib/megam/api/organizations.rb
|
|
158
159
|
- lib/megam/api/promos.rb
|
|
@@ -195,6 +196,8 @@ files:
|
|
|
195
196
|
- lib/megam/core/eventsvm_collection.rb
|
|
196
197
|
- lib/megam/core/json_compat.rb
|
|
197
198
|
- lib/megam/core/konipai.rb
|
|
199
|
+
- lib/megam/core/license-collection.rb
|
|
200
|
+
- lib/megam/core/license.rb
|
|
198
201
|
- lib/megam/core/log.rb
|
|
199
202
|
- lib/megam/core/marketplace.rb
|
|
200
203
|
- lib/megam/core/marketplace_collection.rb
|
|
@@ -275,30 +278,4 @@ rubygems_version: 2.5.1
|
|
|
275
278
|
signing_key:
|
|
276
279
|
specification_version: 4
|
|
277
280
|
summary: Ruby Client for the Megam Vertice
|
|
278
|
-
test_files:
|
|
279
|
-
- test/mixins/test_assemblies.rb
|
|
280
|
-
- test/mixins/test_assembly.rb
|
|
281
|
-
- test/mixins/test_component.rb
|
|
282
|
-
- test/test_accounts.rb
|
|
283
|
-
- test/test_addons.rb
|
|
284
|
-
- test/test_assemblies.rb
|
|
285
|
-
- test/test_assembly.rb
|
|
286
|
-
- test/test_balances.rb
|
|
287
|
-
- test/test_billedhistories.rb
|
|
288
|
-
- test/test_billingtranscations.rb
|
|
289
|
-
- test/test_components.rb
|
|
290
|
-
- test/test_disks.rb
|
|
291
|
-
- test/test_domains.rb
|
|
292
|
-
- test/test_eventsbilling.rb
|
|
293
|
-
- test/test_eventscontainer.rb
|
|
294
|
-
- test/test_eventsstorage.rb
|
|
295
|
-
- test/test_eventsvm.rb
|
|
296
|
-
- test/test_helper.rb
|
|
297
|
-
- test/test_marketplaces.rb
|
|
298
|
-
- test/test_organizations.rb
|
|
299
|
-
- test/test_promos.rb
|
|
300
|
-
- test/test_requests.rb
|
|
301
|
-
- test/test_sensors.rb
|
|
302
|
-
- test/test_snapshots.rb
|
|
303
|
-
- test/test_sshkeys.rb
|
|
304
|
-
- test/test_subscriptions.rb
|
|
281
|
+
test_files: []
|