megam_api 1.50.5 → 1.50.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fe61a1e56920aa8dd9aab819cf81be10135adca
4
- data.tar.gz: e09ade66b6031e9ac28ace557bffab0490fcb402
3
+ metadata.gz: 34c06c46af5e5bed95d65b68ead862211ba0e90a
4
+ data.tar.gz: 0137f6f56614622d70385cb6b331ecb6842b7bb5
5
5
  SHA512:
6
- metadata.gz: 03d4f43a56ef0947be289ac2e118684e87ed90cf19473f0cb95fcfa2133cb1ef152af96069bf7903b0b959fb1f206d46b0450add1444159701a1d4540401b999
7
- data.tar.gz: e7ae3edb04d94e609f8dfa65b3419470629ddaf4e80c074fa074364731921ae04e246f3e3d39b9d048a16ee96ffdd2062d8a5c34160e6b59b590b9177bce7928
6
+ metadata.gz: 6a17da822d8ea782a02b886aac4682fe8975a5bd37bb145c65d2dea495518e54ff62ace35d8cd4aa844eacf7ee36659c97de67399539cf4f8244b984296e9976
7
+ data.tar.gz: 2932dc22f13586a8bd33e25c757e0a4ce23f63533f9ec20f11619463a8528ecf7f71fc9edcb15d5f16ff1ebf3d3f1a525d29d89a1b1038ca3a8fd870dcde4f37
data/lib/megam/api.rb CHANGED
@@ -34,6 +34,7 @@ require 'megam/api/snapshots'
34
34
  require 'megam/api/backups'
35
35
  require 'megam/api/reports'
36
36
  require 'megam/api/quotas'
37
+ require 'megam/api/rawimages'
37
38
  require 'megam/api/disks'
38
39
  require 'megam/api/subscriptions'
39
40
  require 'megam/api/addons'
@@ -95,6 +96,8 @@ require 'megam/core/reports'
95
96
  require 'megam/core/reports_collection'
96
97
  require 'megam/core/quotas'
97
98
  require 'megam/core/quotas_collection'
99
+ require 'megam/core/rawimages'
100
+ require 'megam/core/rawimages_collection'
98
101
  require 'megam/core/disks'
99
102
  require 'megam/core/disks_collection'
100
103
  require 'megam/core/balances_collection'
@@ -21,6 +21,25 @@ module Megam
21
21
  )
22
22
  end
23
23
 
24
+ def get_marketplaceprovider(provider)
25
+ @options = {:path => "/marketplaces/p/#{provider}" ,:body => ""}.merge(@options)
26
+
27
+ request(
28
+ :expects => 200,
29
+ :method => :get,
30
+ :body => @options[:body]
31
+ )
32
+ end
33
+
34
+ def get_marketplaceflavor(flavor)
35
+ @options = {:path => "/marketplaces/f/#{flavor}",:body => ""}.merge(@options)
36
+ request(
37
+ :expects => 200,
38
+ :method => :get,
39
+ :body => @options[:body]
40
+ )
41
+ end
42
+
24
43
  def post_marketplaceapp(catitem)
25
44
  @options = {:path => '/marketplaces/content',
26
45
  :body => Megam::JSONCompat.to_json(catitem)}.merge(@options)
@@ -0,0 +1,36 @@
1
+ module Megam
2
+ class API
3
+
4
+ def get_one_rawimage(name)
5
+ @options = { path: "/rawimages/#{name}", body: '' }.merge(@options)
6
+
7
+ request(
8
+ expects: 200,
9
+ method: :get,
10
+ body: @options[:body]
11
+ )
12
+ end
13
+
14
+ def list_rawimages
15
+ @options = {:path => "/rawimages",:body => ""}.merge(@options)
16
+
17
+ request(
18
+ :expects => 200,
19
+ :method => :get,
20
+ :body => @options[:body]
21
+ )
22
+ end
23
+
24
+ def post_rawimages(rawimage_item)
25
+ @options = {:path => '/rawimages/content',
26
+ :body => Megam::JSONCompat.to_json(rawimage_item)}.merge(@options)
27
+
28
+ request(
29
+ :expects => 201,
30
+ :method => :post,
31
+ :body => @options[:body]
32
+ )
33
+ end
34
+
35
+ end
36
+ end
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "1.50.5"
3
+ VERSION = "1.50.6"
4
4
  end
5
5
  end
@@ -66,6 +66,8 @@ module Megam
66
66
  MEGAM_REPORTSCOLLECTION = 'Megam::ReportsCollection'.freeze
67
67
  MEGAM_QUOTAS = 'Megam::Quotas'.freeze
68
68
  MEGAM_QUOTASCOLLECTION = 'Megam::QuotasCollection'.freeze
69
+ MEGAM_RAWIMAGES = 'Megam::Rawimages'.freeze
70
+ MEGAM_RAWIMAGESCOLLECTION = 'Megam::RawimagesCollection'.freeze
69
71
  MEGAM_PROMOS = 'Megam::Promos'.freeze
70
72
 
71
73
 
@@ -260,6 +262,10 @@ module Megam
260
262
  Megam::Quotas
261
263
  when MEGAM_QUOTASCOLLECTION
262
264
  Megam::QuotasCollection
265
+ when MEGAM_RAWIMAGES
266
+ Megam::Rawimages
267
+ when MEGAM_RAWIMAGESCOLLECTION
268
+ Megam::RawimagesCollection
263
269
  when MEGAM_PROMOS
264
270
  Megam::Promos
265
271
  else
@@ -2,16 +2,21 @@ module Megam
2
2
  class MarketPlace < Megam::RestAdapter
3
3
  def initialize(o)
4
4
  @id = nil
5
- @settings_name = nil
5
+ @provided_by = nil
6
6
  @cattype = nil
7
+ @catorder = nil
8
+ @status = nil
7
9
  @flavor = nil
8
10
  @image = nil
9
- @catorder = nil
10
11
  @url = nil
11
12
  @envs = []
12
13
  @options = []
13
- @plans = nil
14
+ @inputs = []
15
+ @outputs = []
16
+ @acl_policies = []
17
+ @plans = []
14
18
  @created_at = nil
19
+ @updated_at = nil
15
20
  super(o)
16
21
  end
17
22
 
@@ -19,11 +24,11 @@ module Megam
19
24
  self
20
25
  end
21
26
 
22
- def settings_name(arg = nil)
27
+ def provided_by(arg = nil)
23
28
  if !arg.nil?
24
- @settings_name = arg
29
+ @provided_by = arg
25
30
  else
26
- @settings_name
31
+ @provided_by
27
32
  end
28
33
  end
29
34
 
@@ -35,8 +40,8 @@ module Megam
35
40
  end
36
41
  end
37
42
 
38
- def plans(arg = nil)
39
- if !arg.nil?
43
+ def plans(arg = [])
44
+ if arg != []
40
45
  @plans = arg
41
46
  else
42
47
  @plans
@@ -99,6 +104,38 @@ module Megam
99
104
  end
100
105
  end
101
106
 
107
+ def inputs(arg = [])
108
+ if arg != []
109
+ @inputs = arg
110
+ else
111
+ @inputs
112
+ end
113
+ end
114
+
115
+ def outputs(arg = [])
116
+ if arg != []
117
+ @outputs = arg
118
+ else
119
+ @outputs
120
+ end
121
+ end
122
+
123
+ def status(arg = [])
124
+ if arg != []
125
+ @status = arg
126
+ else
127
+ @status
128
+ end
129
+ end
130
+
131
+ def acl_policies(arg = [])
132
+ if arg != []
133
+ @acl_policies = arg
134
+ else
135
+ @acl_policies
136
+ end
137
+ end
138
+
102
139
  def created_at(arg = nil)
103
140
  if !arg.nil?
104
141
  @created_at = arg
@@ -107,6 +144,14 @@ module Megam
107
144
  end
108
145
  end
109
146
 
147
+ def updated_at(arg = nil)
148
+ if !arg.nil?
149
+ @updated_at = arg
150
+ else
151
+ @updated_at
152
+ end
153
+ end
154
+
110
155
  def some_msg(arg = nil)
111
156
  if !arg.nil?
112
157
  @some_msg = arg
@@ -124,7 +169,7 @@ module Megam
124
169
  index_hash = {}
125
170
  index_hash['json_claz'] = self.class.name
126
171
  index_hash['id'] = id
127
- index_hash['settings_name'] = settings_name
172
+ index_hash['provided_by'] = provided_by
128
173
  index_hash['cattype'] = cattype
129
174
  index_hash['flavor'] = flavor
130
175
  index_hash['image'] = image
@@ -134,6 +179,11 @@ module Megam
134
179
  index_hash['options'] = options
135
180
  index_hash['plans'] = plans
136
181
  index_hash['created_at'] = created_at
182
+ index_hash['updated_at'] = updated_at
183
+ index_hash['status'] = status
184
+ index_hash['inputs'] = inputs
185
+ index_hash['outputs'] = outputs
186
+ index_hash['acl_policies'] = acl_policies
137
187
  index_hash
138
188
  end
139
189
 
@@ -146,7 +196,7 @@ module Megam
146
196
  def for_json
147
197
  result = {
148
198
  'id' => id,
149
- 'settings_name' => settings_name,
199
+ 'provided_by' => provided_by,
150
200
  'cattype' => cattype,
151
201
  'flavor' => flavor,
152
202
  'image' => image,
@@ -155,7 +205,12 @@ module Megam
155
205
  'envs' => envs,
156
206
  'options' => options,
157
207
  'plans' => plans,
158
- 'created_at' => created_at
208
+ 'created_at' => created_at,
209
+ 'updated_at' => updated_at,
210
+ 'status' => status,
211
+ 'inputs' => inputs,
212
+ 'outputs' => outputs,
213
+ 'acl_policies' => acl_policies
159
214
  }
160
215
  result
161
216
  end
@@ -163,7 +218,7 @@ module Megam
163
218
  def self.json_create(o)
164
219
  app = new({})
165
220
  app.id(o['id']) if o.key?('id')
166
- app.settings_name(o['settings_name']) if o.key?('settings_name')
221
+ app.provided_by(o['provided_by']) if o.key?('provided_by')
167
222
  app.cattype(o['cattype']) if o.key?('cattype')
168
223
  app.flavor(o['flavor']) if o.key?('flavor')
169
224
  app.image(o['image']) if o.key?('image')
@@ -173,7 +228,11 @@ module Megam
173
228
  app.options(o['options']) if o.key?('options')
174
229
  app.plans(o['plans']) if o.key?('plans')
175
230
  app.created_at(o['created_at']) if o.key?('created_at')
176
-
231
+ app.updated_at(o['updated_at']) if o.key?('updated_at')
232
+ app.inputs(o['inputs']) if o.key?('inputs')
233
+ app.outputs(o['outputs']) if o.key?('outputs')
234
+ app.status(o['status']) if o.key?('status')
235
+ app.acl_policies(o['acl_policies']) if o.key?('acl_policies')
177
236
  app
178
237
  end
179
238
 
@@ -184,17 +243,22 @@ module Megam
184
243
  end
185
244
 
186
245
  def from_hash(o)
187
- @settings_name = o['settings_name'] if o.key?('settings_name')
246
+ @provided_by = o['provided_by'] if o.key?('provided_by')
188
247
  @id = o['id'] if o.key?('id')
189
248
  @cattype = o['cattype'] if o.key?('cattype')
190
249
  @flavor = o['flavor'] if o.key?('flavor')
191
250
  @image = o['image'] if o.key?('image')
192
- @catorder = o['catorder'] if o.key?('catorder')
251
+ @catorder = o['catorder'] if o.key?('catorder')
193
252
  @url = o['url'] if o.key?('url')
194
253
  @envs = o['envs'] if o.key?('envs')
195
254
  @options = o['options'] if o.key?('options')
196
255
  @plans = o['plans'] if o.key?('plans')
197
256
  @created_at = o['created_at'] if o.key?('created_at')
257
+ @updated_at = o['updated_at'] if o.key?('updated_at')
258
+ @status = o['status'] if o.key?('status')
259
+ @inputs = o['inputs'] if o.key?('inputs')
260
+ @outputs = o['outputs'] if o.key?('outputs')
261
+ @acl_policies = o['acl_policies'] if o.key?('acl_policies')
198
262
  self
199
263
  end
200
264
 
@@ -219,6 +283,16 @@ module Megam
219
283
  app.megam_rest.get_marketplaceapps
220
284
  end
221
285
 
286
+ def self.list_provider(params)
287
+ app = new(params)
288
+ app.megam_rest.get_marketplaceprovider(params['provider'])
289
+ end
290
+
291
+ def self.list_flavor(params)
292
+ app = new(params)
293
+ app.megam_rest.get_marketplaceflavor(params['flavor'])
294
+ end
295
+
222
296
  def to_s
223
297
  Megam::Stuff.styled_hash(to_hash)
224
298
  # "---> Megam::Account:[error=#{error?}]\n"+
@@ -0,0 +1,194 @@
1
+ module Megam
2
+ class Rawimages < Megam::RestAdapter
3
+ def initialize(o)
4
+ @id = nil
5
+ @account_id = nil
6
+ @name = nil
7
+ @repos = nil
8
+ @status = nil
9
+ @inputs = []
10
+ @created_at = nil
11
+ @updated_at = nil
12
+ @org_id = nil
13
+ super(o)
14
+ end
15
+
16
+ def rawimages
17
+ self
18
+ end
19
+
20
+ def id(arg = nil)
21
+ if !arg.nil?
22
+ @id = arg
23
+ else
24
+ @id
25
+ end
26
+ end
27
+
28
+ def name(arg = nil)
29
+ if !arg.nil?
30
+ @name = arg
31
+ else
32
+ @name
33
+ end
34
+ end
35
+
36
+ def account_id(arg=nil)
37
+ if arg != nil
38
+ @account_id = arg
39
+ else
40
+ @account_id
41
+ end
42
+ end
43
+
44
+ def repos(arg = nil)
45
+ if !arg.nil?
46
+ @repos = arg
47
+ else
48
+ @repos
49
+ end
50
+ end
51
+
52
+ def inputs(arg = [])
53
+ if arg != []
54
+ @inputs = arg
55
+ else
56
+ @inputs
57
+ end
58
+ end
59
+
60
+ def status(arg = nil)
61
+ if !arg.nil?
62
+ @status = arg
63
+ else
64
+ @status
65
+ end
66
+ end
67
+
68
+ def created_at(arg = nil)
69
+ if !arg.nil?
70
+ @created_at = arg
71
+ else
72
+ @created_at
73
+ end
74
+ end
75
+
76
+ def updated_at(arg = nil)
77
+ if !arg.nil?
78
+ @updated_at = arg
79
+ else
80
+ @updated_at
81
+ end
82
+ end
83
+
84
+ def org_id(arg = nil)
85
+ if !arg.nil?
86
+ @org_id = arg
87
+ else
88
+ @org_id
89
+ end
90
+ end
91
+
92
+ def error?
93
+ crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
94
+ end
95
+
96
+ # Transform the ruby obj -> to a Hash
97
+ def to_hash
98
+ index_hash = {}
99
+ index_hash['json_claz'] = self.class.name
100
+ index_hash['id'] = id
101
+ index_hash['org_id'] = org_id
102
+ index_hash["account_id"] = account_id
103
+ index_hash['name'] = name
104
+ index_hash['repos'] = repos
105
+ index_hash['status'] = status
106
+ index_hash['inputs'] = inputs
107
+ index_hash['created_at'] = created_at
108
+ index_hash['updated_at'] = updated_at
109
+ index_hash
110
+ end
111
+
112
+ # Serialize this object as a hash: called from JsonCompat.
113
+ # Verify if this called from JsonCompat during testing.
114
+ def to_json(*a)
115
+ for_json.to_json(*a)
116
+ end
117
+
118
+ def for_json
119
+ result = {
120
+ 'id' => id,
121
+ 'account_id' => account_id,
122
+ 'name' => name,
123
+ 'org_id' => org_id,
124
+ 'repos' => repos,
125
+ 'inputs' => inputs,
126
+ 'status' => status,
127
+ 'created_at' => created_at,
128
+ 'updated_at' => updated_at
129
+ }
130
+
131
+ result
132
+ end
133
+
134
+ def self.json_create(o)
135
+ quo = new({})
136
+ quo.id(o['id']) if o.key?('id')
137
+ quo.org_id(o['org_id']) if o.key?('org_id')
138
+ quo.account_id(o["account_id"]) if o.has_key?("account_id")
139
+ quo.name(o['name']) if o.key?('name')
140
+ quo.repos(o['repos']) if o.key?('repos')
141
+ quo.inputs(o['inputs']) if o.key?('inputs')
142
+ quo.status(o['status']) if o.key?('status')
143
+ quo.created_at(o['created_at']) if o.key?('created_at')
144
+ quo.updated_at(o['updated_at']) if o.key?('updated_at')
145
+ quo
146
+ end
147
+
148
+ def self.from_hash(o)
149
+ quo = new(o)
150
+ quo.from_hash(o)
151
+ quo
152
+ end
153
+
154
+ def from_hash(o)
155
+ @id = o['id'] if o.key?('id')
156
+ @org_id = o['org_id'] if o.key?('org_id')
157
+ @account_id = o["account_id"] if o.has_key?("account_id")
158
+ @name = o['name'] if o.key?('name')
159
+ @region = o['region'] if o.key?('region')
160
+ @repos = o['repos'] if o.key?('repos')
161
+ @inputs = o['inputs'] if o.key?('inputs')
162
+ @status = o['status'] if o.key?('status')
163
+ @created_at = o['created_at'] if o.key?('created_at')
164
+ @updated_at = o['updated_at'] if o.key?('updated_at')
165
+ self
166
+ end
167
+
168
+
169
+ def self.show(params)
170
+ quo = new(params)
171
+ quo.megam_rest.get_one_rawimage(params['id'])
172
+ end
173
+
174
+ def self.list(params)
175
+ quo = self.new(params)
176
+ quo.megam_rest.list_rawimages
177
+ end
178
+
179
+ def self.create(params)
180
+ quo = from_hash(params)
181
+ quo.create
182
+ end
183
+
184
+ def create
185
+ megam_rest.post_rawimages(to_hash)
186
+ end
187
+
188
+ # Create the node via the REST API
189
+
190
+ def to_s
191
+ Megam::Stuff.styled_hash(to_hash)
192
+ end
193
+ end
194
+ end
@@ -0,0 +1,121 @@
1
+ module Megam
2
+ class RawimagesCollection
3
+ include Enumerable
4
+
5
+ attr_reader :iterator
6
+ def initialize
7
+ @rawimages = Array.new
8
+ @rawimages_by_name = Hash.new
9
+ @insert_after_idx = nil
10
+ end
11
+
12
+ def all_rawimages
13
+ @rawimages
14
+ end
15
+
16
+ def [](index)
17
+ @rawimages[index]
18
+ end
19
+
20
+ def []=(index, arg)
21
+ is_megam_rawimages(arg)
22
+ @rawimages[index] = arg
23
+ @rawimages_by_name[arg.id] = index
24
+ end
25
+
26
+ def <<(*args)
27
+ args.flatten.each do |a|
28
+ is_megam_rawimages(a)
29
+ @rawimages << a
30
+ @rawimages_by_name[a.id] = @rawimages.length - 1
31
+ end
32
+ self
33
+ end
34
+
35
+ # 'push' is an alias method to <<
36
+ alias_method :push, :<<
37
+
38
+ def insert(rawimages)
39
+ is_megam_rawimages(rawimages)
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
+ @rawimages.insert(@insert_after_idx + 1, rawimages)
45
+ # update name -> location mappings and register new node
46
+ @rawimages_by_name.each_key do |key|
47
+ @rawimages_by_name[key] += 1 if @rawimages_by_name[key] > @insert_after_idx
48
+ end
49
+ @rawimages_by_name[rawimages.id] = @insert_after_idx + 1
50
+ @insert_after_idx += 1
51
+ else
52
+ @rawimages << rawimages
53
+ @rawimages_by_name[rawimages.id] = @rawimages.length - 1
54
+ end
55
+ end
56
+
57
+ def each
58
+ @rawimages.each do |rawimages|
59
+ yield rawimages
60
+ end
61
+ end
62
+
63
+ def each_index
64
+ @rawimages.each_index do |i|
65
+ yield i
66
+ end
67
+ end
68
+
69
+ def empty?
70
+ @rawimages.empty?
71
+ end
72
+
73
+ def lookup(rawimages)
74
+ lookup_by = nil
75
+ if rawimages.kind_of?(Megam::Rawimages)
76
+ lookup_by = rawimages.id
77
+ elsif rawimages.kind_of?(String)
78
+ lookup_by = rawimages
79
+ else
80
+ raise ArgumentError, "Must pass a Megam::Rawimages or String to lookup"
81
+ end
82
+ res = @rawimages_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
+ @rawimages[res]
87
+ end
88
+
89
+ def to_s
90
+ @rawimages.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 |rawimages_list|
104
+ rawimages_array = rawimages_list.kind_of?(Array) ? rawimages_list : [ rawimages_list ]
105
+ rawimages_array.each do |rawimages|
106
+ collection.insert(rawimages)
107
+ end
108
+ end
109
+ collection
110
+ end
111
+
112
+ private
113
+
114
+ def is_megam_rawimages(arg)
115
+ unless arg.kind_of?(Megam::Rawimages)
116
+ raise ArgumentError, "Members must be Megam::Rawimages's"
117
+ end
118
+ true
119
+ end
120
+ end
121
+ 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.50.5
4
+ version: 1.50.6
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-02-13 00:00:00.000000000 Z
12
+ date: 2017-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: excon
@@ -159,6 +159,7 @@ files:
159
159
  - lib/megam/api/organizations.rb
160
160
  - lib/megam/api/promos.rb
161
161
  - lib/megam/api/quotas.rb
162
+ - lib/megam/api/rawimages.rb
162
163
  - lib/megam/api/reports.rb
163
164
  - lib/megam/api/requests.rb
164
165
  - lib/megam/api/sensors.rb
@@ -214,6 +215,8 @@ files:
214
215
  - lib/megam/core/promos.rb
215
216
  - lib/megam/core/quotas.rb
216
217
  - lib/megam/core/quotas_collection.rb
218
+ - lib/megam/core/rawimages.rb
219
+ - lib/megam/core/rawimages_collection.rb
217
220
  - lib/megam/core/reports.rb
218
221
  - lib/megam/core/reports_collection.rb
219
222
  - lib/megam/core/request.rb