megam_api 1.7.4 → 1.7.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 +43 -40
- data/lib/megam/api/eventsall.rb +36 -0
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/eventsall.rb +186 -0
- data/lib/megam/core/eventsall_collection.rb +122 -0
- data/lib/megam/core/json_compat.rb +7 -1
- data/lib/megam/core/snapshots.rb +14 -1
- data/test/test_helper.rb +1 -1
- data/test/test_snapshots.rb +5 -4
- metadata +6 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bb4513477944a7ee015fa5abcef0e5c16651a12
|
4
|
+
data.tar.gz: 09aa0c07ed4574ff12887812264e71496f4941f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3c08e2fcf873fa1b0f775c1d896fa3a2f5eb6e839c125c132c410750ef33242a8083b7e5c8faab42f1c16c4de987119dba5c304279250fb37c6ca27d2bd1abc
|
7
|
+
data.tar.gz: 272b3753a41d6d6b0eb4415d96749f8fec7a342162c1f1935517f11233fb43cc5d4d94b6baf72a7393e6e69152460acc2ab37f8b1afbe2b0eb76b269c4a10068
|
data/lib/megam/api.rb
CHANGED
@@ -23,6 +23,7 @@ require 'megam/api/promos'
|
|
23
23
|
require 'megam/api/requests'
|
24
24
|
require 'megam/api/sensors'
|
25
25
|
require 'megam/api/sshkeys'
|
26
|
+
require 'megam/api/eventsall'
|
26
27
|
require 'megam/api/eventsvm'
|
27
28
|
require 'megam/api/eventscontainer'
|
28
29
|
require 'megam/api/eventsbilling'
|
@@ -52,7 +53,9 @@ require 'megam/core/request'
|
|
52
53
|
require 'megam/core/request_collection'
|
53
54
|
require 'megam/core/sshkey'
|
54
55
|
require 'megam/core/sshkey_collection'
|
56
|
+
require 'megam/core/eventsall'
|
55
57
|
require 'megam/core/eventsvm'
|
58
|
+
require 'megam/core/eventsall_collection'
|
56
59
|
require 'megam/core/eventsvm_collection'
|
57
60
|
require 'megam/core/eventscontainer'
|
58
61
|
require 'megam/core/eventscontainer_collection'
|
@@ -97,7 +100,7 @@ module Megam
|
|
97
100
|
attr_accessor :email, :api_key, :password_hash, :org_id
|
98
101
|
attr_accessor :api_url, :api_version
|
99
102
|
attr_reader :last_response
|
100
|
-
|
103
|
+
|
101
104
|
API_VERSION2 = '/v2'.freeze
|
102
105
|
|
103
106
|
X_Megam_DATE = 'X-Megam-DATE'.freeze
|
@@ -121,15 +124,15 @@ module Megam
|
|
121
124
|
|
122
125
|
def initialize(options = {})
|
123
126
|
@options = OPTIONS.merge(options)
|
124
|
-
|
127
|
+
|
125
128
|
assign_credentials
|
126
|
-
|
129
|
+
|
127
130
|
ensure_host_is_flattened
|
128
|
-
|
131
|
+
|
129
132
|
turn_off_ssl_verify
|
130
133
|
end
|
131
|
-
|
132
|
-
|
134
|
+
|
135
|
+
|
133
136
|
def text
|
134
137
|
@text ||= Megam::Text.new(STDOUT, STDERR, STDIN, {})
|
135
138
|
end
|
@@ -138,7 +141,7 @@ module Megam
|
|
138
141
|
just_color_debug("#{@options[:path]}")
|
139
142
|
start = Time.now
|
140
143
|
Megam::Log.debug('START')
|
141
|
-
|
144
|
+
|
142
145
|
ensure_authkeys unless is_passthru?
|
143
146
|
|
144
147
|
begin
|
@@ -162,7 +165,7 @@ module Megam
|
|
162
165
|
end
|
163
166
|
|
164
167
|
@last_response = response
|
165
|
-
|
168
|
+
|
166
169
|
if response.body && !response.body.empty?
|
167
170
|
if response.headers['Content-Encoding'] == 'gzip'
|
168
171
|
response.body = Zlib::GzipReader.new(StringIO.new(response.body)).read
|
@@ -178,84 +181,84 @@ module Megam
|
|
178
181
|
raise(jsonerr)
|
179
182
|
end
|
180
183
|
end
|
181
|
-
|
184
|
+
|
182
185
|
Megam::Log.debug("END(#{(Time.now - start)}s)")
|
183
|
-
|
186
|
+
|
184
187
|
@connection.reset
|
185
188
|
response
|
186
189
|
end
|
187
190
|
|
188
191
|
private
|
189
|
-
|
192
|
+
|
190
193
|
def assign_credentials
|
191
194
|
@api_key = @options.delete(:api_key) || ENV['MEGAM_API_KEY']
|
192
195
|
@email = @options.delete(:email)
|
193
196
|
@password_hash = @options.delete(:password_hash)
|
194
197
|
@org_id = @options.delete(:org_id)
|
195
198
|
end
|
196
|
-
|
199
|
+
|
197
200
|
def ensure_host_is_flattened
|
198
201
|
uri = URI(@options.delete(:host)) if @options.has_key?(:host)
|
199
|
-
|
202
|
+
|
200
203
|
scheme = (uri && uri.scheme) ? uri.scheme : 'http'
|
201
|
-
|
204
|
+
|
202
205
|
host = (uri && uri.host) ? uri.host : '127.0.0.1'
|
203
|
-
|
206
|
+
|
204
207
|
port = (uri && uri.port) ? uri.port.to_s : '9000'
|
205
|
-
|
208
|
+
|
206
209
|
@api_version = (uri && uri.path) ? uri.path : API_VERSION2
|
207
|
-
|
210
|
+
|
208
211
|
@api_url = scheme + "://" + host + ":" + port + @api_version
|
209
212
|
end
|
210
|
-
|
213
|
+
|
211
214
|
def is_passthru?
|
212
215
|
@options[:passthru]
|
213
|
-
end
|
214
|
-
|
216
|
+
end
|
217
|
+
|
215
218
|
def ensure_authkeys
|
216
219
|
if !api_combo_missing? && !pw_combo_missing?
|
217
|
-
fail Megam::API::Errors::AuthKeysMissing
|
220
|
+
fail Megam::API::Errors::AuthKeysMissing
|
218
221
|
end
|
219
222
|
end
|
220
|
-
|
223
|
+
|
221
224
|
def api_combo_missing?
|
222
225
|
(!@email.nil? && !@api_key.nil?)
|
223
226
|
end
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
+
|
228
|
+
|
229
|
+
|
227
230
|
def pw_combo_missing?
|
228
231
|
(!@email.nil? && !@password_hash.nil?)
|
229
232
|
end
|
230
|
-
|
233
|
+
|
231
234
|
def turn_off_ssl_verify
|
232
235
|
Excon.defaults[:ssl_verify_peer] = false unless @api_url.include?("https")
|
233
236
|
|
234
237
|
end
|
235
238
|
|
236
239
|
def just_color_debug(path)
|
237
|
-
text.msg "--> #{text.color("(#{path})", :cyan, :bold)}"
|
240
|
+
text.msg "--> #{text.color("(#{path})", :cyan, :bold)}"
|
238
241
|
end
|
239
242
|
|
240
243
|
def connection
|
241
244
|
@options[:path] = @api_version + @options[:path]
|
242
|
-
|
245
|
+
|
243
246
|
build_headers
|
244
247
|
|
245
248
|
@connection = Excon.new(@api_url, @options)
|
246
249
|
end
|
247
|
-
|
248
|
-
|
250
|
+
|
251
|
+
|
249
252
|
def build_headers
|
250
253
|
encoded = encode_header
|
251
|
-
|
254
|
+
|
252
255
|
@options[:headers] = HEADERS.merge(X_Megam_HMAC => encoded[:hmac],
|
253
|
-
X_Megam_DATE => encoded[:date],
|
256
|
+
X_Megam_DATE => encoded[:date],
|
254
257
|
X_Megam_ORG => @org_id).merge(@options[:headers])
|
255
|
-
|
256
|
-
|
258
|
+
|
259
|
+
|
257
260
|
build_header_puttusavi
|
258
|
-
end
|
261
|
+
end
|
259
262
|
|
260
263
|
def encode_header
|
261
264
|
body_base64 = Base64.urlsafe_encode64(OpenSSL::Digest::MD5.digest(@options[:body]))
|
@@ -273,15 +276,15 @@ module Megam
|
|
273
276
|
else
|
274
277
|
hash = OpenSSL::HMAC.hexdigest(digest, "", movingFactor)
|
275
278
|
end
|
276
|
-
|
279
|
+
|
277
280
|
{ hmac: (@email + ':' + hash), date: current_date }
|
278
281
|
end
|
279
|
-
|
282
|
+
|
280
283
|
def build_header_puttusavi
|
281
284
|
if pw_combo_missing? && !is_passthru?
|
282
|
-
@options[:headers] = @options[:headers].merge(X_Megam_PUTTUSAVI => "true")
|
285
|
+
@options[:headers] = @options[:headers].merge(X_Megam_PUTTUSAVI => "true")
|
283
286
|
end
|
284
287
|
end
|
285
|
-
|
288
|
+
|
286
289
|
end
|
287
|
-
end
|
290
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Megam
|
2
|
+
class API
|
3
|
+
# GET /nodes
|
4
|
+
def list_eventsall(limit)
|
5
|
+
@options = {:path => "/eventsall/#{limit}",:body => ""}.merge(@options)
|
6
|
+
|
7
|
+
request(
|
8
|
+
:expects => 200,
|
9
|
+
:method => :get,
|
10
|
+
:body => @options[:body]
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def get_eventsall(limit, new_events)
|
16
|
+
@options = {:path => "/eventsall/show/#{limit}",
|
17
|
+
:body => Megam::JSONCompat.to_json(new_events)}.merge(@options)
|
18
|
+
request(
|
19
|
+
:expects => 200,
|
20
|
+
:method => :post,
|
21
|
+
:body => @options[:body]
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def index_eventsall
|
27
|
+
@options = {:path => "/eventsall",:body => ""}.merge(@options)
|
28
|
+
|
29
|
+
request(
|
30
|
+
:expects => 200,
|
31
|
+
:method => :get,
|
32
|
+
:body => @options[:body]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/megam/api/version.rb
CHANGED
@@ -0,0 +1,186 @@
|
|
1
|
+
module Megam
|
2
|
+
class EventsAll < Megam::RestAdapter
|
3
|
+
def initialize(o)
|
4
|
+
@account_id = nil
|
5
|
+
@assembly_id = nil
|
6
|
+
@event_type = nil
|
7
|
+
@data = []
|
8
|
+
@created_at = nil
|
9
|
+
@id = nil
|
10
|
+
@limit = nil
|
11
|
+
@some_msg = {}
|
12
|
+
super(o)
|
13
|
+
end
|
14
|
+
|
15
|
+
def eventsall
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def account_id(arg=nil)
|
20
|
+
if arg != nil
|
21
|
+
@account_id = arg
|
22
|
+
else
|
23
|
+
@account_id
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def id(arg=nil)
|
28
|
+
if arg != nil
|
29
|
+
@id = arg
|
30
|
+
else
|
31
|
+
@id
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def assembly_id(arg=nil)
|
36
|
+
if arg != nil
|
37
|
+
@assembly_id = arg
|
38
|
+
else
|
39
|
+
@assembly_id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def event_type(arg=nil)
|
44
|
+
if arg != nil
|
45
|
+
@event_type = arg
|
46
|
+
else
|
47
|
+
@event_type
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def data(arg=[])
|
53
|
+
if arg != []
|
54
|
+
@data = arg
|
55
|
+
else
|
56
|
+
@data
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def limit(arg=[])
|
61
|
+
if arg != []
|
62
|
+
@limit = arg
|
63
|
+
else
|
64
|
+
@limit
|
65
|
+
end
|
66
|
+
end
|
67
|
+
def created_at(arg=nil)
|
68
|
+
if arg != nil
|
69
|
+
@created_at = arg
|
70
|
+
else
|
71
|
+
@created_at
|
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
|
+
|
80
|
+
def some_msg(arg=nil)
|
81
|
+
if arg != nil
|
82
|
+
@some_msg = arg
|
83
|
+
else
|
84
|
+
@some_msg
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
# Transform the ruby obj -> to a Hash
|
90
|
+
def to_hash
|
91
|
+
index_hash = Hash.new
|
92
|
+
index_hash["json_claz"] = self.class.name
|
93
|
+
index_hash["account_id"] = account_id
|
94
|
+
index_hash["assembly_id"] = assembly_id
|
95
|
+
index_hash["event_type"] = event_type
|
96
|
+
index_hash["data"] = data
|
97
|
+
index_hash["limit"] = limit
|
98
|
+
index_hash["created_at"] = created_at
|
99
|
+
index_hash["id"] = id
|
100
|
+
index_hash["some_msg"] = some_msg
|
101
|
+
index_hash
|
102
|
+
end
|
103
|
+
|
104
|
+
# Serialize this object as a hash: called from JsonCompat.
|
105
|
+
# Verify if this called from JsonCompat during testing.
|
106
|
+
def to_json(*a)
|
107
|
+
for_json.to_json(*a)
|
108
|
+
end
|
109
|
+
|
110
|
+
def for_json
|
111
|
+
result = {
|
112
|
+
"account_id" => account_id,
|
113
|
+
"assembly_id" => assembly_id,
|
114
|
+
"event_type" => event_type,
|
115
|
+
"data" => data,
|
116
|
+
"limit" => limit,
|
117
|
+
"created_at" => created_at,
|
118
|
+
"id" => id
|
119
|
+
}
|
120
|
+
result
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.json_create(o)
|
124
|
+
evt = new({})
|
125
|
+
evt.account_id(o["account_id"]) if o.has_key?("account_id")
|
126
|
+
evt.id(o["id"]) if o.has_key?("id")
|
127
|
+
evt.assembly_id(o["assembly_id"]) if o.has_key?("assembly_id")
|
128
|
+
evt.event_type(o["event_type"]) if o.has_key?("event_type") #this will be an array? can hash store array?
|
129
|
+
evt.data(o["data"]) if o.has_key?("data")
|
130
|
+
evt.limit(o["limit"]) if o.has_key?("limit")
|
131
|
+
evt.created_at(o["created_at"]) if o.has_key?("created_at")
|
132
|
+
evt.some_msg[:code] = o["code"] if o.has_key?("code")
|
133
|
+
evt.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
134
|
+
evt.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
135
|
+
evt.some_msg[:links] = o["links"] if o.has_key?("links")
|
136
|
+
evt
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.from_hash(o)
|
140
|
+
evt = self.new(o)
|
141
|
+
evt.from_hash(o)
|
142
|
+
evt
|
143
|
+
end
|
144
|
+
|
145
|
+
def from_hash(o)
|
146
|
+
@account_id = o[:account_id] if o.has_key?(:account_id)
|
147
|
+
@assembly_id = o[:assembly_id] if o.has_key?(:assembly_id)
|
148
|
+
@event_type = o[:event_type] if o.has_key?(:event_type)
|
149
|
+
@data = o[:data] if o.has_key?(:data)
|
150
|
+
@limit = o[:limit] if o.has_key?(:limit)
|
151
|
+
@created_at = o[:created_at] if o.has_key?(:created_at)
|
152
|
+
@id = o[:id] if o.has_key?(:id)
|
153
|
+
self
|
154
|
+
end
|
155
|
+
|
156
|
+
def self.create(params)
|
157
|
+
evt = from_hash(params)
|
158
|
+
evt.create
|
159
|
+
end
|
160
|
+
|
161
|
+
# Create the node via the REST API
|
162
|
+
def create
|
163
|
+
megam_rest.post_events(to_hash)
|
164
|
+
end
|
165
|
+
|
166
|
+
def self.show(o)
|
167
|
+
evt = from_hash(o)
|
168
|
+
evt.megam_rest.get_eventsall(o[:limit], evt.from_hash(o).for_json)
|
169
|
+
end
|
170
|
+
|
171
|
+
def self.list(params)
|
172
|
+
asm = self.new(params)
|
173
|
+
asm.megam_rest.list_eventsall(params[:limit])
|
174
|
+
end
|
175
|
+
|
176
|
+
def self.index(params)
|
177
|
+
asm = self.new(params)
|
178
|
+
asm.megam_rest.index_eventsall
|
179
|
+
end
|
180
|
+
|
181
|
+
def to_s
|
182
|
+
Megam::Stuff.styled_hash(to_hash)
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module Megam
|
2
|
+
class EventsAllCollection
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :iterator
|
6
|
+
def initialize
|
7
|
+
@eventsall = Array.new
|
8
|
+
@eventsall_by_name = Hash.new
|
9
|
+
@insert_after_idx = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def all_eventsall
|
13
|
+
@eventsall
|
14
|
+
end
|
15
|
+
|
16
|
+
def [](index)
|
17
|
+
@eventsall[index]
|
18
|
+
end
|
19
|
+
|
20
|
+
def []=(index, arg)
|
21
|
+
is_megam_eventsall(arg)
|
22
|
+
@eventsall[index] = arg
|
23
|
+
@eventsall_by_name[arg.account_id] = index
|
24
|
+
end
|
25
|
+
|
26
|
+
def <<(*args)
|
27
|
+
args.flatten.each do |a|
|
28
|
+
is_megam_events(a)
|
29
|
+
@eventsall << a
|
30
|
+
@eventsall_by_name[a.account_id] = @eventsall.length - 1
|
31
|
+
end
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
# 'push' is an alias method to <<
|
36
|
+
alias_method :push, :<<
|
37
|
+
|
38
|
+
def insert(eventsall)
|
39
|
+
is_megam_eventsall(eventsall)
|
40
|
+
if @insert_after_idx
|
41
|
+
# in the middle of executing a run, so any nodes inserted now should
|
42
|
+
# be placed after the most recent addition done by the currently executing
|
43
|
+
# node
|
44
|
+
@eventsall.insert(@insert_after_idx + 1, eventsall)
|
45
|
+
# update name -> location mappings and register new node
|
46
|
+
@eventsall_by_name.each_key do |key|
|
47
|
+
@eventsall_by_name[key] += 1 if @eventsall_by_name[key] > @insert_after_idx
|
48
|
+
end
|
49
|
+
@eventsall_by_name[eventsall.account_id] = @insert_after_idx + 1
|
50
|
+
@insert_after_idx += 1
|
51
|
+
else
|
52
|
+
@eventsall << eventsall
|
53
|
+
@eventsall_by_name[eventsall.account_id] = @eventsall.length - 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def each
|
58
|
+
@eventsall.each do |eventsall|
|
59
|
+
yield eventsall
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def each_index
|
64
|
+
@eventsall.each_index do |i|
|
65
|
+
yield i
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def empty?
|
70
|
+
@eventsall.empty?
|
71
|
+
end
|
72
|
+
|
73
|
+
def lookup(eventsall)
|
74
|
+
lookup_by = nil
|
75
|
+
if events.kind_of?(Megam::EventsAll)
|
76
|
+
lookup_by = eventsall.account_id
|
77
|
+
elsif events.kind_of?(String)
|
78
|
+
lookup_by = eventsall
|
79
|
+
else
|
80
|
+
raise ArgumentError, "Must pass a Megam::EventsAll or String to lookup"
|
81
|
+
end
|
82
|
+
res = @eventsall_by_name[lookup_by]
|
83
|
+
unless res
|
84
|
+
raise ArgumentError, "Cannot find a node matching #{lookup_by} (did you define it first?)"
|
85
|
+
end
|
86
|
+
@eventsall[res]
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_s
|
90
|
+
@eventsall.join(", ")
|
91
|
+
end
|
92
|
+
|
93
|
+
def for_json
|
94
|
+
to_a.map { |item| item.to_s }
|
95
|
+
end
|
96
|
+
|
97
|
+
def to_json(*a)
|
98
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.json_create(o)
|
102
|
+
collection = self.new()
|
103
|
+
o["results"].each do |eventsall_list|
|
104
|
+
eventsall_array = eventsall_list.kind_of?(Array) ? eventsall_list : [ eventsall_list ]
|
105
|
+
eventsall_array.each do |eventsall|
|
106
|
+
collection.insert(eventsall)
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
collection
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def is_megam_eventsall(arg)
|
116
|
+
unless arg.kind_of?(Megam::EventsAll)
|
117
|
+
raise ArgumentError, "Members must be Megam::EventsAll's"
|
118
|
+
end
|
119
|
+
true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -6,7 +6,7 @@ require "json"
|
|
6
6
|
|
7
7
|
module Megam
|
8
8
|
class JSONCompat
|
9
|
-
|
9
|
+
|
10
10
|
JSON_MAX_NESTING = 1000
|
11
11
|
|
12
12
|
JSON_CLAZ = 'json_claz'.freeze
|
@@ -41,6 +41,8 @@ module Megam
|
|
41
41
|
MEGAM_DISKSCOLLECTION = 'Megam::DisksCollection'.freeze
|
42
42
|
MEGAM_SSHKEY = 'Megam::SshKey'.freeze
|
43
43
|
MEGAM_SSHKEYCOLLECTION = 'Megam::SshKeyCollection'.freeze
|
44
|
+
MEGAM_EVENTSALL = 'Megam::EventsAll'.freeze
|
45
|
+
MEGAM_EVENTSALLCOLLECTION = 'Megam::EventsAllCollection'.freeze
|
44
46
|
MEGAM_EVENTSVM = 'Megam::EventsVm'.freeze
|
45
47
|
MEGAM_EVENTSVMCOLLECTION = 'Megam::EventsVmCollection'.freeze
|
46
48
|
MEGAM_EVENTSCONTAINER = 'Megam::EventsContainer'.freeze
|
@@ -164,6 +166,10 @@ module Megam
|
|
164
166
|
Megam::EventsVm
|
165
167
|
when MEGAM_EVENTSVMCOLLECTION
|
166
168
|
Megam::EventsVmCollection
|
169
|
+
when MEGAM_EVENTSALL
|
170
|
+
Megam::EventsAll
|
171
|
+
when MEGAM_EVENTSALLCOLLECTION
|
172
|
+
Megam::EventsAllCollection
|
167
173
|
when MEGAM_EVENTSCONTAINER
|
168
174
|
Megam::EventsContainer
|
169
175
|
when MEGAM_EVENTSCONTAINERCOLLECTION
|
data/lib/megam/core/snapshots.rb
CHANGED
@@ -7,6 +7,7 @@ module Megam
|
|
7
7
|
@org_id = nil
|
8
8
|
@name= nil
|
9
9
|
@status=nil
|
10
|
+
@image_id=nil
|
10
11
|
@created_at = nil
|
11
12
|
@some_msg = {}
|
12
13
|
super(o)
|
@@ -63,6 +64,14 @@ module Megam
|
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
67
|
+
def image_id(arg=nil)
|
68
|
+
if arg != nil
|
69
|
+
@image_id = arg
|
70
|
+
else
|
71
|
+
@image_id
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
66
75
|
def created_at(arg=nil)
|
67
76
|
if arg != nil
|
68
77
|
@created_at = arg
|
@@ -95,6 +104,7 @@ module Megam
|
|
95
104
|
index_hash["org_id"] = org_id
|
96
105
|
index_hash["name"] = name
|
97
106
|
index_hash["status"] = status
|
107
|
+
index_hash["image_id"] = image_id
|
98
108
|
index_hash["created_at"] = created_at
|
99
109
|
index_hash["some_msg"] = some_msg
|
100
110
|
index_hash
|
@@ -114,6 +124,7 @@ module Megam
|
|
114
124
|
"org_id" => org_id,
|
115
125
|
"name" => name,
|
116
126
|
"status" => status,
|
127
|
+
"image_id" => image_id,
|
117
128
|
"created_at" => created_at
|
118
129
|
}
|
119
130
|
result
|
@@ -126,7 +137,8 @@ module Megam
|
|
126
137
|
sps.asm_id(o["asm_id"]) if o.has_key?("asm_id")
|
127
138
|
sps.org_id(o["org_id"]) if o.has_key?("org_id") #this will be an array? can hash store array?
|
128
139
|
sps.name(o["name"]) if o.has_key?("name")
|
129
|
-
sps.
|
140
|
+
sps.status(o["status"]) if o.has_key?("status")
|
141
|
+
sps.image_id(o["status"]) if o.has_key?("image_id")
|
130
142
|
sps.created_at(o["created_at"]) if o.has_key?("created_at")
|
131
143
|
sps.some_msg[:code] = o["code"] if o.has_key?("code")
|
132
144
|
sps.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
@@ -148,6 +160,7 @@ module Megam
|
|
148
160
|
@org_id = o[:org_id] if o.has_key?(:org_id)
|
149
161
|
@name = o[:name] if o.has_key?(:name)
|
150
162
|
@status = o[:status] if o.has_key?(:status)
|
163
|
+
@image_id = o[:image_id] if o.has_key?(:image_id)
|
151
164
|
@created_at = o[:created_at] if o.has_key?(:created_at)
|
152
165
|
self
|
153
166
|
end
|
data/test/test_helper.rb
CHANGED
data/test/test_snapshots.rb
CHANGED
@@ -5,7 +5,7 @@ class TestApps < MiniTest::Unit::TestCase
|
|
5
5
|
def test_post_snapshots
|
6
6
|
tmp_hash = {
|
7
7
|
:account_id => "test@megam.io",
|
8
|
-
:asm_id => "
|
8
|
+
:asm_id => "ASM535576423764486230",
|
9
9
|
:org_id => "ORG7879663326321337888",
|
10
10
|
:name => "pop.megambox.com",
|
11
11
|
:status => "progress",
|
@@ -15,14 +15,15 @@ class TestApps < MiniTest::Unit::TestCase
|
|
15
15
|
response = megams.post_snapshots(tmp_hash)
|
16
16
|
assert_equal(201, response.status)
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def test_get_snapshots
|
20
|
-
response = megams.get_snapshots("
|
20
|
+
response = megams.get_snapshots("ASM535576423764486230")
|
21
21
|
assert_equal(200, response.status)
|
22
22
|
end
|
23
|
+
=begin
|
23
24
|
def test_list_snapshots
|
24
25
|
response = megams.list_snapshots
|
25
26
|
assert_equal(200, response.status)
|
26
27
|
end
|
27
|
-
|
28
|
+
=end
|
28
29
|
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.7.
|
4
|
+
version: 1.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajthilak, Kishorekumar Neelamegam, Ranjitha R, Vinodhini V, Rathish VBR, Rajesh
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-09-
|
12
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: excon
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/megam/api/disks.rb
|
149
149
|
- lib/megam/api/domains.rb
|
150
150
|
- lib/megam/api/errors.rb
|
151
|
+
- lib/megam/api/eventsall.rb
|
151
152
|
- lib/megam/api/eventsbilling.rb
|
152
153
|
- lib/megam/api/eventscontainer.rb
|
153
154
|
- lib/megam/api/eventsstorage.rb
|
@@ -181,6 +182,8 @@ files:
|
|
181
182
|
- lib/megam/core/domain_collection.rb
|
182
183
|
- lib/megam/core/domains.rb
|
183
184
|
- lib/megam/core/error.rb
|
185
|
+
- lib/megam/core/eventsall.rb
|
186
|
+
- lib/megam/core/eventsall_collection.rb
|
184
187
|
- lib/megam/core/eventsbilling.rb
|
185
188
|
- lib/megam/core/eventsbilling_collection.rb
|
186
189
|
- lib/megam/core/eventscontainer.rb
|
@@ -271,30 +274,4 @@ rubygems_version: 2.5.1
|
|
271
274
|
signing_key:
|
272
275
|
specification_version: 4
|
273
276
|
summary: Ruby Client for the Megam Vertice
|
274
|
-
test_files:
|
275
|
-
- test/mixins/test_assemblies.rb
|
276
|
-
- test/mixins/test_assembly.rb
|
277
|
-
- test/mixins/test_component.rb
|
278
|
-
- test/test_accounts.rb
|
279
|
-
- test/test_addons.rb
|
280
|
-
- test/test_assemblies.rb
|
281
|
-
- test/test_assembly.rb
|
282
|
-
- test/test_balances.rb
|
283
|
-
- test/test_billedhistories.rb
|
284
|
-
- test/test_billingtranscations.rb
|
285
|
-
- test/test_components.rb
|
286
|
-
- test/test_disks.rb
|
287
|
-
- test/test_domains.rb
|
288
|
-
- test/test_eventsbilling.rb
|
289
|
-
- test/test_eventscontainer.rb
|
290
|
-
- test/test_eventsstorage.rb
|
291
|
-
- test/test_eventsvm.rb
|
292
|
-
- test/test_helper.rb
|
293
|
-
- test/test_marketplaces.rb
|
294
|
-
- test/test_organizations.rb
|
295
|
-
- test/test_promos.rb
|
296
|
-
- test/test_requests.rb
|
297
|
-
- test/test_sensors.rb
|
298
|
-
- test/test_snapshots.rb
|
299
|
-
- test/test_sshkeys.rb
|
300
|
-
- test/test_subscriptions.rb
|
277
|
+
test_files: []
|