megam_api 1.51.4 → 1.52.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/megam/api.rb +6 -3
- data/lib/megam/api/{eventsmarketplaces.rb → eventsmarketplace.rb} +6 -6
- data/lib/megam/api/flavors.rb +56 -0
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/{eventsmarketplaces.rb → eventsmarketplace.rb} +13 -13
- data/lib/megam/core/eventsmarketplace_collection.rb +122 -0
- data/lib/megam/core/flavors.rb +276 -0
- data/lib/megam/core/flavors_collection.rb +122 -0
- data/lib/megam/core/json_compat.rb +12 -6
- metadata +8 -5
- data/lib/megam/core/eventsmarketplaces_collection.rb +0 -122
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82f4868b44b3471243d6f35f4b2773fb070b4af5
|
4
|
+
data.tar.gz: 7b8847bce125c0ce9c4be38fdf0e7e8c2315022d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1b17c64e80d7dbfc7e80f202c3f766d30ec63037fa951d39e7801f6882c147d4150137f9d6a9bd9600fda9f9c3245a75be0787210178194aa0ca5d7d062f03a
|
7
|
+
data.tar.gz: 197de5554d26ea8a291ed7c197f0edf5a49f671508ec4a0cdbd4264c17b67407ed26f789f1eb7d17d977c3da5b206f9195ca7b2e9b25f1209155e60c9a286e42
|
data/lib/megam/api.rb
CHANGED
@@ -26,8 +26,9 @@ require 'megam/api/sensors'
|
|
26
26
|
require 'megam/api/sshkeys'
|
27
27
|
require 'megam/api/eventsall'
|
28
28
|
require 'megam/api/eventsvm'
|
29
|
-
require 'megam/api/
|
29
|
+
require 'megam/api/eventsmarketplace'
|
30
30
|
require 'megam/api/license'
|
31
|
+
require 'megam/api/flavors'
|
31
32
|
require 'megam/api/eventscontainer'
|
32
33
|
require 'megam/api/eventsbilling'
|
33
34
|
require 'megam/api/eventsstorage'
|
@@ -62,14 +63,16 @@ require 'megam/core/request'
|
|
62
63
|
require 'megam/core/request_collection'
|
63
64
|
require 'megam/core/license'
|
64
65
|
require 'megam/core/license_collection'
|
66
|
+
require 'megam/core/flavors'
|
67
|
+
require 'megam/core/flavors_collection'
|
65
68
|
require 'megam/core/sshkey'
|
66
69
|
require 'megam/core/sshkey_collection'
|
67
70
|
require 'megam/core/eventsall'
|
68
71
|
require 'megam/core/eventsall_collection'
|
69
72
|
require 'megam/core/eventsvm'
|
70
73
|
require 'megam/core/eventsvm_collection'
|
71
|
-
require 'megam/core/
|
72
|
-
require 'megam/core/
|
74
|
+
require 'megam/core/eventsmarketplace'
|
75
|
+
require 'megam/core/eventsmarketplace_collection'
|
73
76
|
require 'megam/core/eventscontainer'
|
74
77
|
require 'megam/core/eventscontainer_collection'
|
75
78
|
require 'megam/core/eventsbilling'
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Megam
|
2
2
|
class API
|
3
3
|
# GET /nodes
|
4
|
-
def
|
5
|
-
@options = {:path => "/
|
4
|
+
def list_eventsMarketplace(limit)
|
5
|
+
@options = {:path => "/eventsmarketplace/#{limit}",:body => ""}.merge(@options)
|
6
6
|
|
7
7
|
request(
|
8
8
|
:expects => 200,
|
@@ -12,8 +12,8 @@ module Megam
|
|
12
12
|
end
|
13
13
|
|
14
14
|
|
15
|
-
def
|
16
|
-
@options = {:path => "/
|
15
|
+
def get_eventsMarketplace(limit, new_events)
|
16
|
+
@options = {:path => "/eventsmarketplace/show/#{limit}",
|
17
17
|
:body => Megam::JSONCompat.to_json(new_events)}.merge(@options)
|
18
18
|
request(
|
19
19
|
:expects => 200,
|
@@ -22,8 +22,8 @@ module Megam
|
|
22
22
|
)
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
@options = {:path => "/
|
25
|
+
def index_eventsMarketplace
|
26
|
+
@options = {:path => "/eventsmarketplace",:body => ""}.merge(@options)
|
27
27
|
|
28
28
|
request(
|
29
29
|
:expects => 200,
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Megam
|
2
|
+
class API
|
3
|
+
|
4
|
+
def get_flavors()
|
5
|
+
@options = {:path => "/flavors",:body => ""}.merge(@options)
|
6
|
+
request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => :get,
|
9
|
+
:body => @options[:body]
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_one_flavor(name)
|
14
|
+
@options = { path: "/flavors/#{name}", body: '' }.merge(@options)
|
15
|
+
|
16
|
+
request(
|
17
|
+
expects: 200,
|
18
|
+
method: :get,
|
19
|
+
body: @options[:body]
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def post_flavors(new_flavors)
|
24
|
+
@options = {:path => "/flavors/content",
|
25
|
+
:body => Megam::JSONCompat.to_json(new_flavors)}.merge(@options)
|
26
|
+
request(
|
27
|
+
:expects => 201,
|
28
|
+
:method => :post,
|
29
|
+
:body => @options[:body]
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def update_flavors(update_flavors)
|
34
|
+
@options = {:path => '/flavors/update',
|
35
|
+
:body => Megam::JSONCompat.to_json(update_flavors)}.merge(@options)
|
36
|
+
|
37
|
+
request(
|
38
|
+
:expects => 201,
|
39
|
+
:method => :post,
|
40
|
+
:body => @options[:body]
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def delete_flavors(delete_flavors)
|
45
|
+
@options = {path: "/flavors/#{delete_flavors["name"]}",
|
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
|
data/lib/megam/api/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Megam
|
2
|
-
class
|
2
|
+
class EventsMarketplace < Megam::RestAdapter
|
3
3
|
def initialize(o)
|
4
4
|
@account_id = nil
|
5
|
-
@
|
5
|
+
@marketplace_id = nil
|
6
6
|
@event_type = nil
|
7
7
|
@data = []
|
8
8
|
@created_at = nil
|
@@ -12,7 +12,7 @@ module Megam
|
|
12
12
|
super(o)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def eventsmarketplace
|
16
16
|
self
|
17
17
|
end
|
18
18
|
|
@@ -32,11 +32,11 @@ module Megam
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def marketplace_id(arg=nil)
|
36
36
|
if arg != nil
|
37
|
-
@
|
37
|
+
@marketplace_id = arg
|
38
38
|
else
|
39
|
-
@
|
39
|
+
@marketplace_id
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -91,7 +91,7 @@ module Megam
|
|
91
91
|
index_hash = Hash.new
|
92
92
|
index_hash["json_claz"] = self.class.name
|
93
93
|
index_hash["account_id"] = account_id
|
94
|
-
index_hash["
|
94
|
+
index_hash["marketplace_id"] = marketplace_id
|
95
95
|
index_hash["event_type"] = event_type
|
96
96
|
index_hash["data"] = data
|
97
97
|
index_hash["limit"] = limit
|
@@ -110,7 +110,7 @@ module Megam
|
|
110
110
|
def for_json
|
111
111
|
result = {
|
112
112
|
"account_id" => account_id,
|
113
|
-
"
|
113
|
+
"marketplace_id" => marketplace_id,
|
114
114
|
"event_type" => event_type,
|
115
115
|
"data" => data,
|
116
116
|
"limit" => limit,
|
@@ -123,7 +123,7 @@ module Megam
|
|
123
123
|
def self.json_create(o)
|
124
124
|
evt = new({})
|
125
125
|
evt.account_id(o["account_id"]) if o.has_key?("account_id")
|
126
|
-
evt.
|
126
|
+
evt.marketplace_id(o["marketplace_id"]) if o.has_key?("marketplace_id")
|
127
127
|
evt.id(o["id"]) if o.has_key?("id")
|
128
128
|
evt.event_type(o["event_type"]) if o.has_key?("event_type") #this will be an array? can hash store array?
|
129
129
|
evt.data(o["data"]) if o.has_key?("data")
|
@@ -144,7 +144,7 @@ module Megam
|
|
144
144
|
|
145
145
|
def from_hash(o)
|
146
146
|
@account_id = o[:account_id] if o.has_key?(:account_id)
|
147
|
-
@
|
147
|
+
@marketplace_id = o[:marketplace_id] if o.has_key?(:marketplace_id)
|
148
148
|
@event_type = o[:event_type] if o.has_key?(:event_type)
|
149
149
|
@data = o[:data] if o.has_key?(:data)
|
150
150
|
@limit = o[:limit] if o.has_key?(:limit)
|
@@ -166,17 +166,17 @@ module Megam
|
|
166
166
|
# Load a account by email_p
|
167
167
|
def self.show(o)
|
168
168
|
evt = from_hash(o)
|
169
|
-
evt.megam_rest.
|
169
|
+
evt.megam_rest.get_eventsMarketplace(o[:limit], evt.from_hash(o).for_json)
|
170
170
|
end
|
171
171
|
|
172
172
|
def self.list(params)
|
173
173
|
asm = self.new(params)
|
174
|
-
asm.megam_rest.
|
174
|
+
asm.megam_rest.list_eventsMarketplace(params[:limit])
|
175
175
|
end
|
176
176
|
|
177
177
|
def self.index(params)
|
178
178
|
asm = self.new(params)
|
179
|
-
asm.megam_rest.
|
179
|
+
asm.megam_rest.index_eventsMarketplace
|
180
180
|
end
|
181
181
|
|
182
182
|
def to_s
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module Megam
|
2
|
+
class EventsMarketplaceCollection
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :iterator
|
6
|
+
def initialize
|
7
|
+
@eventsmarketplace = Array.new
|
8
|
+
@eventsmarketplace_by_name = Hash.new
|
9
|
+
@insert_after_idx = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def all_eventsmarketplace
|
13
|
+
@eventsmarketplace
|
14
|
+
end
|
15
|
+
|
16
|
+
def [](index)
|
17
|
+
@eventsmarketplace[index]
|
18
|
+
end
|
19
|
+
|
20
|
+
def []=(index, arg)
|
21
|
+
is_megam_eventsvm(arg)
|
22
|
+
@eventsmarketplace[index] = arg
|
23
|
+
@eventsmarketplace_by_name[arg.account_id] = index
|
24
|
+
end
|
25
|
+
|
26
|
+
def <<(*args)
|
27
|
+
args.flatten.each do |a|
|
28
|
+
is_megam_events(a)
|
29
|
+
@eventsmarketplace << a
|
30
|
+
@eventsmarketplace_by_name[a.account_id] = @eventsmarketplace.length - 1
|
31
|
+
end
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
# 'push' is an alias method to <<
|
36
|
+
alias_method :push, :<<
|
37
|
+
|
38
|
+
def insert(eventsmarketplace)
|
39
|
+
is_megam_eventsmarketplace(eventsmarketplace)
|
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
|
+
@eventsmarketplace.insert(@insert_after_idx + 1, eventsmarketplace)
|
45
|
+
# update name -> location mappings and register new node
|
46
|
+
@eventsmarketplace_by_name.each_key do |key|
|
47
|
+
@eventsmarketplace_by_name[key] += 1 if @eventsmarketplace_by_name[key] > @insert_after_idx
|
48
|
+
end
|
49
|
+
@eventsmarketplace_by_name[eventsmarketplace.account_id] = @insert_after_idx + 1
|
50
|
+
@insert_after_idx += 1
|
51
|
+
else
|
52
|
+
@eventsmarketplace << eventsmarketplace
|
53
|
+
@eventsmarketplace_by_name[eventsmarketplace.account_id] = @eventsmarketplace.length - 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def each
|
58
|
+
@eventsmarketplace.each do |eventsmarketplace|
|
59
|
+
yield eventsmarketplace
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def each_index
|
64
|
+
@eventsmarketplace.each_index do |i|
|
65
|
+
yield i
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def empty?
|
70
|
+
@eventsmarketplace.empty?
|
71
|
+
end
|
72
|
+
|
73
|
+
def lookup(eventsmarketplace)
|
74
|
+
lookup_by = nil
|
75
|
+
if events.kind_of?(Megam::EventsMarketplace)
|
76
|
+
lookup_by = eventsmarketplace.account_id
|
77
|
+
elsif eventsmarketplace.kind_of?(String)
|
78
|
+
lookup_by = eventsmarketplace
|
79
|
+
else
|
80
|
+
raise ArgumentError, "Must pass a Megam::EventsMarketplace or String to lookup"
|
81
|
+
end
|
82
|
+
res = @eventsmarketplace_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
|
+
@eventsmarketplace[res]
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_s
|
90
|
+
@eventsmarketplace.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 |eventsmarketplace_list|
|
104
|
+
eventsmarketplace_array = eventsmarketplace_list.kind_of?(Array) ? eventsmarketplace_list : [ eventsmarketplace_list ]
|
105
|
+
eventsmarketplace_array.each do |eventsmarketplace|
|
106
|
+
collection.insert(eventsmarketplace)
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
collection
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def is_megam_eventsmarketplace(arg)
|
116
|
+
unless arg.kind_of?(Megam::EventsMarketplace)
|
117
|
+
raise ArgumentError, "Members must be Megam::EventsMarketplace's"
|
118
|
+
end
|
119
|
+
true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,276 @@
|
|
1
|
+
module Megam
|
2
|
+
class Flavors < Megam::RestAdapter
|
3
|
+
def initialize(o)
|
4
|
+
@id = nil
|
5
|
+
@org_id = nil
|
6
|
+
@account_id = nil
|
7
|
+
@name = nil
|
8
|
+
@cpu = nil
|
9
|
+
@ram = nil
|
10
|
+
@disk = nil
|
11
|
+
@regions = []
|
12
|
+
@price = []
|
13
|
+
@properties = []
|
14
|
+
@status = nil
|
15
|
+
@created_at = nil
|
16
|
+
@updated_at = nil
|
17
|
+
@some_msg = {}
|
18
|
+
super(o)
|
19
|
+
end
|
20
|
+
|
21
|
+
def flavors
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
def id(arg = nil)
|
26
|
+
if arg != nil
|
27
|
+
@id = arg
|
28
|
+
else
|
29
|
+
@id
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def org_id(arg = nil)
|
34
|
+
if arg != nil
|
35
|
+
@org_id = arg
|
36
|
+
else
|
37
|
+
@org_id
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def account_id(arg=nil)
|
42
|
+
if arg != nil
|
43
|
+
@account_id = arg
|
44
|
+
else
|
45
|
+
@account_id
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def name(arg = nil)
|
50
|
+
if arg != nil
|
51
|
+
@name = arg
|
52
|
+
else
|
53
|
+
@name
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def cpu(arg = nil)
|
59
|
+
if arg != nil
|
60
|
+
@cpu = arg
|
61
|
+
else
|
62
|
+
@cpu
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def ram(arg = nil)
|
67
|
+
if arg != nil
|
68
|
+
@ram = arg
|
69
|
+
else
|
70
|
+
@ram
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def disk(arg = nil)
|
75
|
+
if arg != nil
|
76
|
+
@disk = arg
|
77
|
+
else
|
78
|
+
@disk
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def regions(arg = [])
|
83
|
+
if arg != []
|
84
|
+
@regions = arg
|
85
|
+
else
|
86
|
+
@regions
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def price(arg = [])
|
91
|
+
if arg != []
|
92
|
+
@price = arg
|
93
|
+
else
|
94
|
+
@price
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def properties(arg = [])
|
99
|
+
if arg != []
|
100
|
+
@properties = arg
|
101
|
+
else
|
102
|
+
@properties
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def status(arg=nil)
|
107
|
+
if arg != nil
|
108
|
+
@status = arg
|
109
|
+
else
|
110
|
+
@status
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def created_at(arg=nil)
|
115
|
+
if arg != nil
|
116
|
+
@created_at = arg
|
117
|
+
else
|
118
|
+
@created_at
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def updated_at(arg=nil)
|
123
|
+
if arg != nil
|
124
|
+
@updated_at = arg
|
125
|
+
else
|
126
|
+
@updated_at
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def error?
|
131
|
+
crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
|
132
|
+
end
|
133
|
+
|
134
|
+
def some_msg(arg=nil)
|
135
|
+
if arg != nil
|
136
|
+
@some_msg = arg
|
137
|
+
else
|
138
|
+
@some_msg
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Transform the ruby obj -> to a Hash
|
143
|
+
def to_hash
|
144
|
+
index_hash = Hash.new
|
145
|
+
index_hash['json_claz'] = self.class.name
|
146
|
+
index_hash['id'] = id
|
147
|
+
index_hash['org_id'] = org_id
|
148
|
+
index_hash["account_id"] = account_id
|
149
|
+
index_hash['name'] = name
|
150
|
+
index_hash['cpu'] = cpu
|
151
|
+
index_hash['ram'] = ram
|
152
|
+
index_hash['disk'] = disk
|
153
|
+
index_hash['regions'] = regions
|
154
|
+
index_hash['price'] = price
|
155
|
+
index_hash['properties'] = properties
|
156
|
+
index_hash['status'] = status
|
157
|
+
index_hash['created_at'] = created_at
|
158
|
+
index_hash['updated_at'] = updated_at
|
159
|
+
index_hash["some_msg"] = some_msg
|
160
|
+
index_hash
|
161
|
+
end
|
162
|
+
|
163
|
+
# Serialize this object as a hash: called from JsonCompat.
|
164
|
+
# Verify if this called from JsonCompat during testing.
|
165
|
+
def to_json(*a)
|
166
|
+
for_json.to_json(*a)
|
167
|
+
end
|
168
|
+
|
169
|
+
def for_json
|
170
|
+
result = {
|
171
|
+
'id' => id,
|
172
|
+
'account_id' => account_id,
|
173
|
+
'name' => name,
|
174
|
+
'org_id' => org_id,
|
175
|
+
'cpu' => cpu,
|
176
|
+
'ram' => ram,
|
177
|
+
'disk' => disk,
|
178
|
+
'regions' => regions,
|
179
|
+
'price' => price,
|
180
|
+
'properties' => properties,
|
181
|
+
'status' => status,
|
182
|
+
'created_at' => created_at,
|
183
|
+
'updated_at' => updated_at
|
184
|
+
}
|
185
|
+
|
186
|
+
result
|
187
|
+
end
|
188
|
+
|
189
|
+
def self.json_create(o)
|
190
|
+
fav = new({})
|
191
|
+
fav.id(o['id']) if o.key?('id')
|
192
|
+
fav.org_id(o['org_id']) if o.key?('org_id')
|
193
|
+
fav.account_id(o["account_id"]) if o.has_key?("account_id")
|
194
|
+
fav.name(o['name']) if o.key?('name')
|
195
|
+
fav.cpu(o['cpu']) if o.key?('cpu')
|
196
|
+
fav.ram(o['ram']) if o.key?('ram')
|
197
|
+
fav.disk(o['disk']) if o.key?('disk')
|
198
|
+
fav.regions(o['regions']) if o.key?('regions')
|
199
|
+
fav.price(o['price']) if o.key?('price')
|
200
|
+
fav.properties(o['properties']) if o.key?('properties')
|
201
|
+
fav.status(o['status']) if o.key?('status')
|
202
|
+
fav.created_at(o['created_at']) if o.key?('created_at')
|
203
|
+
fav.updated_at(o['updated_at']) if o.key?('updated_at')
|
204
|
+
fav.some_msg[:code] = o["code"] if o.has_key?("code")
|
205
|
+
fav.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
206
|
+
fav.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
207
|
+
fav.some_msg[:links] = o["links"] if o.has_key?("links")
|
208
|
+
fav
|
209
|
+
end
|
210
|
+
|
211
|
+
def self.from_hash(o)
|
212
|
+
fav = self.new(o)
|
213
|
+
fav.from_hash(o)
|
214
|
+
fav
|
215
|
+
end
|
216
|
+
|
217
|
+
def from_hash(o)
|
218
|
+
@id = o[:id] if o.has_key?(:id)
|
219
|
+
@org_id = o[:org_id] if o.has_key?(:org_id)
|
220
|
+
@account_id = o[:account_id] if o.has_key?(:account_id)
|
221
|
+
@name = o[:name] if o.has_key?(:name)
|
222
|
+
@cpu = o[:cpu] if o.has_key?(:cpu)
|
223
|
+
@ram = o[:ram] if o.has_key?(:ram)
|
224
|
+
@disk = o[:disk] if o.has_key?(:disk)
|
225
|
+
@regions = o[:regions] if o.has_key?(:regions)
|
226
|
+
@price = o[:price] if o.has_key?(:price)
|
227
|
+
@properties = o[:properties] if o.has_key?(:properties)
|
228
|
+
@status = o[:status] if o.has_key?(:status)
|
229
|
+
@created_at = o[:created_at] if o.has_key?(:created_at)
|
230
|
+
@updated_at = o[:updated_at] if o.has_key?(:updated_at)
|
231
|
+
self
|
232
|
+
end
|
233
|
+
|
234
|
+
|
235
|
+
def self.show(params)
|
236
|
+
fav = self.new(params)
|
237
|
+
fav.megam_rest.get_one_flavor(params[:name])
|
238
|
+
end
|
239
|
+
|
240
|
+
def self.list(params)
|
241
|
+
fav = self.new(params)
|
242
|
+
fav.megam_rest.get_flavors
|
243
|
+
end
|
244
|
+
|
245
|
+
def self.create(params)
|
246
|
+
fav = from_hash(params)
|
247
|
+
fav.create
|
248
|
+
end
|
249
|
+
|
250
|
+
def create
|
251
|
+
megam_rest.post_flavors(to_hash)
|
252
|
+
end
|
253
|
+
|
254
|
+
def update
|
255
|
+
megam_rest.update_flavors(to_hash)
|
256
|
+
end
|
257
|
+
|
258
|
+
def self.update(params)
|
259
|
+
fav = from_hash(params)
|
260
|
+
fav.update
|
261
|
+
end
|
262
|
+
|
263
|
+
def self.remove(o)
|
264
|
+
fav = from_hash(o)
|
265
|
+
fav.remove
|
266
|
+
end
|
267
|
+
|
268
|
+
def remove
|
269
|
+
megam_rest.delete_flavors(to_hash)
|
270
|
+
end
|
271
|
+
|
272
|
+
def to_s
|
273
|
+
Megam::Stuff.styled_hash(to_hash)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module Megam
|
2
|
+
class FlavorsCollection
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :iterator
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@flavors = Array.new
|
9
|
+
@flavors_by_name = Hash.new
|
10
|
+
@insert_after_idx = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def all_flavors
|
14
|
+
@flavors
|
15
|
+
end
|
16
|
+
|
17
|
+
def [](index)
|
18
|
+
@flavors[index]
|
19
|
+
end
|
20
|
+
|
21
|
+
def []=(index, arg)
|
22
|
+
is_megam_flavors(arg)
|
23
|
+
@flavors[index] = arg
|
24
|
+
@flavors_by_name[arg.name] = index
|
25
|
+
end
|
26
|
+
|
27
|
+
def <<(*args)
|
28
|
+
args.flatten.each do |a|
|
29
|
+
is_megam_flavors(a)
|
30
|
+
@flavors << a
|
31
|
+
@flavors_by_name[a.name] =@flavors.length - 1
|
32
|
+
end
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
# 'push' is an alias method to <<
|
37
|
+
alias_method :push, :<<
|
38
|
+
|
39
|
+
def insert(flavors)
|
40
|
+
is_megam_flavors(flavors)
|
41
|
+
if @insert_after_idx
|
42
|
+
# in the middle of executing a run, so any flavors inserted now should
|
43
|
+
# be placed after the most recent addition done by the currently executing
|
44
|
+
# flavors
|
45
|
+
@flavors.insert(@insert_after_idx + 1, flavors)
|
46
|
+
# update name -> location mappings and register new flavors
|
47
|
+
@flavors_by_name.each_key do |key|
|
48
|
+
@flavors_by_name[key] += 1 if@flavors_by_name[key] > @insert_after_idx
|
49
|
+
end
|
50
|
+
@flavors_by_name[flavors.name] = @insert_after_idx + 1
|
51
|
+
@insert_after_idx += 1
|
52
|
+
else
|
53
|
+
@flavors << flavors
|
54
|
+
@flavors_by_name[flavors.name] =@flavors.length - 1
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def each
|
59
|
+
@flavors.each do |flavors|
|
60
|
+
yield flavors
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def each_index
|
65
|
+
@flavors.each_index do |i|
|
66
|
+
yield i
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def empty?
|
71
|
+
@flavors.empty?
|
72
|
+
end
|
73
|
+
|
74
|
+
def lookup(flavors)
|
75
|
+
lookup_by = nil
|
76
|
+
if flavors.kind_of?(Megam::Flavors)
|
77
|
+
lookup_by = flavors.name
|
78
|
+
elsif flavors.kind_of?(String)
|
79
|
+
lookup_by = flavors
|
80
|
+
else
|
81
|
+
raise ArgumentError, "Must pass a Megam::flavors or String to lookup"
|
82
|
+
end
|
83
|
+
res =@flavors_by_name[lookup_by]
|
84
|
+
unless res
|
85
|
+
raise ArgumentError, "Cannot find a flavors matching #{lookup_by} (did you define it first?)"
|
86
|
+
end
|
87
|
+
@flavors[res]
|
88
|
+
end
|
89
|
+
|
90
|
+
def to_s
|
91
|
+
@flavors.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 |flavors_list|
|
105
|
+
flavors_array = flavors_list.kind_of?(Array) ? flavors_list : [ flavors_list ]
|
106
|
+
flavors_array.each do |flavors|
|
107
|
+
collection.insert(flavors)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
collection
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def is_megam_flavors(arg)
|
116
|
+
unless arg.kind_of?(Megam::Flavors)
|
117
|
+
raise ArgumentError, "Members must be Megam::Flavors's"
|
118
|
+
end
|
119
|
+
true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -54,8 +54,8 @@ module Megam
|
|
54
54
|
MEGAM_EVENTSVMCOLLECTION = 'Megam::EventsVmCollection'.freeze
|
55
55
|
MEGAM_EVENTSCONTAINER = 'Megam::EventsContainer'.freeze
|
56
56
|
MEGAM_EVENTSCONTAINERCOLLECTION = 'Megam::EventsContainerCollection'.freeze
|
57
|
-
|
58
|
-
|
57
|
+
MEGAM_EVENTSMARKETPLACE = 'Megam::EventsMarketplace'.freeze
|
58
|
+
MEGAM_EventsMarketplaceCollection = 'Megam::EventsMarketplaceCollection'.freeze
|
59
59
|
MEGAM_EVENTSBILLING = 'Megam::EventsBilling'.freeze
|
60
60
|
MEGAM_EVENTSBILLINGCOLLECTION = 'Megam::EventsBillingCollection'.freeze
|
61
61
|
MEGAM_EVENTSSTORAGE = 'Megam::EventsStorage'.freeze
|
@@ -68,6 +68,8 @@ module Megam
|
|
68
68
|
MEGAM_REPORTSCOLLECTION = 'Megam::ReportsCollection'.freeze
|
69
69
|
MEGAM_QUOTAS = 'Megam::Quotas'.freeze
|
70
70
|
MEGAM_QUOTASCOLLECTION = 'Megam::QuotasCollection'.freeze
|
71
|
+
MEGAM_FLAVORS = 'Megam::Flavors'.freeze
|
72
|
+
MEGAM_FLAVORSCOLLECTION = 'Megam::FlavorsCollection'.freeze
|
71
73
|
MEGAM_RAWIMAGES = 'Megam::Rawimages'.freeze
|
72
74
|
MEGAM_RAWIMAGESCOLLECTION = 'Megam::RawimagesCollection'.freeze
|
73
75
|
MEGAM_PROMOS = 'Megam::Promos'.freeze
|
@@ -184,14 +186,18 @@ module Megam
|
|
184
186
|
Megam::EventsVm
|
185
187
|
when MEGAM_EVENTSVMCOLLECTION
|
186
188
|
Megam::EventsVmCollection
|
187
|
-
when
|
188
|
-
Megam::
|
189
|
-
when
|
190
|
-
Megam::
|
189
|
+
when MEGAM_EVENTSMARKETPLACE
|
190
|
+
Megam::EventsMarketplace
|
191
|
+
when MEGAM_EventsMarketplaceCollection
|
192
|
+
Megam::EventsMarketplaceCollection
|
191
193
|
when MEGAM_LICENSE
|
192
194
|
Megam::License
|
193
195
|
when MEGAM_LICENSECOLLECTION
|
194
196
|
Megam::LicenseCollection
|
197
|
+
when MEGAM_FLAVORS
|
198
|
+
Megam::Flavors
|
199
|
+
when MEGAM_FLAVORSCOLLECTION
|
200
|
+
Megam::FlavorsCollection
|
195
201
|
when MEGAM_EVENTSALL
|
196
202
|
Megam::EventsAll
|
197
203
|
when MEGAM_EVENTSALLCOLLECTION
|
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.
|
4
|
+
version: 1.52.1
|
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: 2017-03-
|
12
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: excon
|
@@ -152,9 +152,10 @@ files:
|
|
152
152
|
- lib/megam/api/eventsall.rb
|
153
153
|
- lib/megam/api/eventsbilling.rb
|
154
154
|
- lib/megam/api/eventscontainer.rb
|
155
|
-
- lib/megam/api/
|
155
|
+
- lib/megam/api/eventsmarketplace.rb
|
156
156
|
- lib/megam/api/eventsstorage.rb
|
157
157
|
- lib/megam/api/eventsvm.rb
|
158
|
+
- lib/megam/api/flavors.rb
|
158
159
|
- lib/megam/api/license.rb
|
159
160
|
- lib/megam/api/marketplaces.rb
|
160
161
|
- lib/megam/api/organizations.rb
|
@@ -199,12 +200,14 @@ files:
|
|
199
200
|
- lib/megam/core/eventsbilling_collection.rb
|
200
201
|
- lib/megam/core/eventscontainer.rb
|
201
202
|
- lib/megam/core/eventscontainer_collection.rb
|
202
|
-
- lib/megam/core/
|
203
|
-
- lib/megam/core/
|
203
|
+
- lib/megam/core/eventsmarketplace.rb
|
204
|
+
- lib/megam/core/eventsmarketplace_collection.rb
|
204
205
|
- lib/megam/core/eventsstorage.rb
|
205
206
|
- lib/megam/core/eventsstorage_collection.rb
|
206
207
|
- lib/megam/core/eventsvm.rb
|
207
208
|
- lib/megam/core/eventsvm_collection.rb
|
209
|
+
- lib/megam/core/flavors.rb
|
210
|
+
- lib/megam/core/flavors_collection.rb
|
208
211
|
- lib/megam/core/json_compat.rb
|
209
212
|
- lib/megam/core/konipai.rb
|
210
213
|
- lib/megam/core/license.rb
|
@@ -1,122 +0,0 @@
|
|
1
|
-
module Megam
|
2
|
-
class EventsMarketplacesCollection
|
3
|
-
include Enumerable
|
4
|
-
|
5
|
-
attr_reader :iterator
|
6
|
-
def initialize
|
7
|
-
@eventsmarketplaces = Array.new
|
8
|
-
@eventsmarketplaces_by_name = Hash.new
|
9
|
-
@insert_after_idx = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def all_eventsmarketplaces
|
13
|
-
@eventsmarketplaces
|
14
|
-
end
|
15
|
-
|
16
|
-
def [](index)
|
17
|
-
@eventsmarketplaces[index]
|
18
|
-
end
|
19
|
-
|
20
|
-
def []=(index, arg)
|
21
|
-
is_megam_eventsvm(arg)
|
22
|
-
@eventsmarketplaces[index] = arg
|
23
|
-
@eventsmarketplaces_by_name[arg.account_id] = index
|
24
|
-
end
|
25
|
-
|
26
|
-
def <<(*args)
|
27
|
-
args.flatten.each do |a|
|
28
|
-
is_megam_events(a)
|
29
|
-
@eventsmarketplaces << a
|
30
|
-
@eventsmarketplaces_by_name[a.account_id] = @eventsmarketplaces.length - 1
|
31
|
-
end
|
32
|
-
self
|
33
|
-
end
|
34
|
-
|
35
|
-
# 'push' is an alias method to <<
|
36
|
-
alias_method :push, :<<
|
37
|
-
|
38
|
-
def insert(eventsmarketplaces)
|
39
|
-
is_megam_eventsmarketplaces(eventsmarketplaces)
|
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
|
-
@eventsmarketplaces.insert(@insert_after_idx + 1, eventsmarketplaces)
|
45
|
-
# update name -> location mappings and register new node
|
46
|
-
@eventsmarketplaces_by_name.each_key do |key|
|
47
|
-
@eventsmarketplaces_by_name[key] += 1 if @eventsmarketplaces_by_name[key] > @insert_after_idx
|
48
|
-
end
|
49
|
-
@eventsmarketplaces_by_name[eventsmarketplaces.account_id] = @insert_after_idx + 1
|
50
|
-
@insert_after_idx += 1
|
51
|
-
else
|
52
|
-
@eventsmarketplaces << eventsmarketplaces
|
53
|
-
@eventsmarketplaces_by_name[eventsmarketplaces.account_id] = @eventsmarketplaces.length - 1
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def each
|
58
|
-
@eventsmarketplaces.each do |eventsmarketplaces|
|
59
|
-
yield eventsmarketplaces
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def each_index
|
64
|
-
@eventsmarketplaces.each_index do |i|
|
65
|
-
yield i
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def empty?
|
70
|
-
@eventsmarketplaces.empty?
|
71
|
-
end
|
72
|
-
|
73
|
-
def lookup(eventsmarketplaces)
|
74
|
-
lookup_by = nil
|
75
|
-
if events.kind_of?(Megam::EventsMarketplaces)
|
76
|
-
lookup_by = eventsmarketplaces.account_id
|
77
|
-
elsif eventsmarketplaces.kind_of?(String)
|
78
|
-
lookup_by = eventsmarketplaces
|
79
|
-
else
|
80
|
-
raise ArgumentError, "Must pass a Megam::EventsMarketplaces or String to lookup"
|
81
|
-
end
|
82
|
-
res = @eventsmarketplaces_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
|
-
@eventsmarketplaces[res]
|
87
|
-
end
|
88
|
-
|
89
|
-
def to_s
|
90
|
-
@eventsmarketplaces.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 |eventsmarketplaces_list|
|
104
|
-
eventsmarketplaces_array = eventsmarketplaces_list.kind_of?(Array) ? eventsmarketplaces_list : [ eventsmarketplaces_list ]
|
105
|
-
eventsmarketplaces_array.each do |eventsmarketplaces|
|
106
|
-
collection.insert(eventsmarketplaces)
|
107
|
-
|
108
|
-
end
|
109
|
-
end
|
110
|
-
collection
|
111
|
-
end
|
112
|
-
|
113
|
-
private
|
114
|
-
|
115
|
-
def is_megam_eventsmarketplaces(arg)
|
116
|
-
unless arg.kind_of?(Megam::EventsMarketplaces)
|
117
|
-
raise ArgumentError, "Members must be Megam::EventsMarketplaces's"
|
118
|
-
end
|
119
|
-
true
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|