megam_api 0.23 → 0.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed8e85c99104ae0dbc964b06fac754abeb9170e0
4
- data.tar.gz: 898bb08d102dfd8b7c893d58fcf0333b3583d089
3
+ metadata.gz: 8555abcfba66ec92bd932251a6e87e1d76b9fe86
4
+ data.tar.gz: 6ad271b618237e58e142eec627a7fb9a62ddf733
5
5
  SHA512:
6
- metadata.gz: 2a6e66718f6d8eb1c8a0c9092d97d1c40224f504793db9284eb3db638670762df74d9c6a7c3522881a27340ef025011eaa6b158579db07d1241ef6d924519c22
7
- data.tar.gz: be916ffcea604388b8fe46a7e367c7b723b73ccce0955d95f0ca3eec30dbfc62787f58595c7c5aac47453cfd5eea591005e4b5fcf2e46e9108ff8f15eeb4ab8e
6
+ metadata.gz: a22a9a8745fe9821084ec53969b92b4df1e78bb950c99b5d1694c5330d9c9b18729364c8e7b13529c6ed2e5e3e69b6c5ce4ae8eb9c142acca15ced561537fe5b
7
+ data.tar.gz: f90d1ba428e0ef6a33681ec9a335b2bc83ec211db18529bff33dbfd80e375d7df0070edd6ba1174cd9068e5adea6433a525e468c3ed968cf5d6daa9860428a0a
@@ -10,6 +10,17 @@ module Megam
10
10
  :body => @options[:body]
11
11
  )
12
12
  end
13
+
14
+ def update_assembly(new_asm)
15
+ @options = {:path => '/assembly/update',
16
+ :body => Megam::JSONCompat.to_json(new_asm)}.merge(@options)
17
+
18
+ request(
19
+ :expects => [200, 201],
20
+ :method => :post,
21
+ :body => @options[:body]
22
+ )
23
+ end
13
24
 
14
25
  end
15
26
  end
@@ -9,6 +9,17 @@ module Megam
9
9
  :body => @options[:body]
10
10
  )
11
11
  end
12
+
13
+ def update_component(new_asm)
14
+ @options = {:path => '/components/update',
15
+ :body => Megam::JSONCompat.to_json(new_asm)}.merge(@options)
16
+
17
+ request(
18
+ :expects => 200,
19
+ :method => :post,
20
+ :body => @options[:body]
21
+ )
22
+ end
12
23
 
13
24
  end
14
25
  end
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "0.23"
3
+ VERSION = "0.24"
4
4
  end
5
5
  end
@@ -20,7 +20,7 @@ module Megam
20
20
  @id = nil
21
21
  @name = nil
22
22
  @components = []
23
- @policies={}
23
+ @policies=[]
24
24
  @inputs = {}
25
25
  @operations = nil
26
26
  @created_at = nil
@@ -163,6 +163,16 @@ module Megam
163
163
  asm.megam_rest.get_one_assembly(assembly_id)
164
164
  end
165
165
 
166
+ def self.update(o,tmp_email=nil, tmp_api_key=nil)
167
+ asm = from_hash(o, tmp_email, tmp_api_key)
168
+ asm.update
169
+ end
170
+
171
+ # Create the node via the REST API
172
+
173
+ def update
174
+ megam_rest.update_assembly(to_hash)
175
+ end
166
176
 
167
177
  def to_s
168
178
  Megam::Stuff.styled_hash(to_hash)
@@ -47,8 +47,8 @@ module Megam
47
47
  @operations = {}
48
48
  @operation_type = nil
49
49
  @target_resource = nil
50
- @created_at = nil
51
-
50
+ @created_at = nil
51
+
52
52
  super(email, api_key)
53
53
  end
54
54
 
@@ -56,14 +56,14 @@ module Megam
56
56
  self
57
57
  end
58
58
 
59
- def id(arg=nil)
59
+ def id(arg=nil)
60
60
  if arg != nil
61
61
  @id = arg
62
62
  else
63
63
  @id
64
64
  end
65
- end
66
-
65
+ end
66
+
67
67
  def name(arg=nil)
68
68
  if arg != nil
69
69
  @name = arg
@@ -71,231 +71,231 @@ module Megam
71
71
  @name
72
72
  end
73
73
  end
74
-
75
- def tosca_type(arg=nil)
74
+
75
+ def tosca_type(arg=nil)
76
76
  if arg != nil
77
77
  @tosca_type = arg
78
78
  else
79
79
  @tosca_type
80
80
  end
81
81
  end
82
-
83
- def requirements(arg=nil)
82
+
83
+ def requirements(arg=nil)
84
84
  if arg != nil
85
85
  @requirements = arg
86
86
  else
87
87
  @requirements
88
88
  end
89
89
  end
90
-
91
- def host(arg=nil)
90
+
91
+ def host(arg=nil)
92
92
  if arg != nil
93
93
  @host = arg
94
94
  else
95
95
  @host
96
96
  end
97
97
  end
98
-
99
- def dummy(arg=nil)
98
+
99
+ def dummy(arg=nil)
100
100
  if arg != nil
101
101
  @dummy = arg
102
102
  else
103
103
  @dummy
104
104
  end
105
105
  end
106
-
107
- def inputs(arg=[])
106
+
107
+ def inputs(arg=[])
108
108
  if arg != []
109
109
  @inputs = arg
110
110
  else
111
111
  @inputs
112
112
  end
113
113
  end
114
-
115
- def domain(arg=nil)
114
+
115
+ def domain(arg=nil)
116
116
  if arg != nil
117
117
  @domain = arg
118
118
  else
119
119
  @domain
120
120
  end
121
121
  end
122
-
123
- def port(arg=nil)
122
+
123
+ def port(arg=nil)
124
124
  if arg != nil
125
125
  @port = arg
126
126
  else
127
127
  @port
128
128
  end
129
129
  end
130
-
131
- def username(arg=nil)
130
+
131
+ def username(arg=nil)
132
132
  if arg != nil
133
133
  @username = arg
134
134
  else
135
135
  @username
136
136
  end
137
137
  end
138
-
139
- def password(arg=nil)
138
+
139
+ def password(arg=nil)
140
140
  if arg != nil
141
141
  @password = arg
142
142
  else
143
143
  @password
144
144
  end
145
145
  end
146
-
147
- def version(arg=nil)
146
+
147
+ def version(arg=nil)
148
148
  if arg != nil
149
149
  @version = arg
150
150
  else
151
151
  @version
152
152
  end
153
153
  end
154
-
155
- def source(arg=nil)
154
+
155
+ def source(arg=nil)
156
156
  if arg != nil
157
157
  @source = arg
158
158
  else
159
159
  @source
160
160
  end
161
161
  end
162
-
163
- def design_inputs(arg=nil)
162
+
163
+ def design_inputs(arg=nil)
164
164
  if arg != nil
165
165
  @design_inputs = arg
166
166
  else
167
167
  @design_inputs
168
168
  end
169
169
  end
170
-
171
- def x(arg=nil)
170
+
171
+ def x(arg=nil)
172
172
  if arg != nil
173
173
  @x = arg
174
174
  else
175
175
  @x
176
176
  end
177
177
  end
178
-
179
- def y(arg=nil)
178
+
179
+ def y(arg=nil)
180
180
  if arg != nil
181
181
  @y = arg
182
182
  else
183
183
  @y
184
184
  end
185
185
  end
186
-
187
- def z(arg=nil)
186
+
187
+ def z(arg=nil)
188
188
  if arg != nil
189
189
  @z = arg
190
190
  else
191
191
  @z
192
192
  end
193
193
  end
194
-
195
- def wires(arg=nil)
194
+
195
+ def wires(arg=nil)
196
196
  if arg != nil
197
197
  @wires = arg
198
198
  else
199
199
  @wires
200
200
  end
201
201
  end
202
-
203
- def service_inputs(arg=nil)
202
+
203
+ def service_inputs(arg=nil)
204
204
  if arg != nil
205
205
  @service_inputs = arg
206
206
  else
207
207
  @service_inputs
208
208
  end
209
209
  end
210
-
211
- def dbname(arg=nil)
210
+
211
+ def dbname(arg=nil)
212
212
  if arg != nil
213
213
  @dbname = arg
214
214
  else
215
215
  @dbname
216
216
  end
217
217
  end
218
-
219
- def dbpassword(arg=nil)
218
+
219
+ def dbpassword(arg=nil)
220
220
  if arg != nil
221
221
  @dbpassword = arg
222
222
  else
223
223
  @dbpassword
224
224
  end
225
225
  end
226
-
227
- def external_management_resource(arg=nil)
226
+
227
+ def external_management_resource(arg=nil)
228
228
  if arg != nil
229
229
  @external_management_resource = arg
230
230
  else
231
231
  @external_management_resource
232
232
  end
233
233
  end
234
-
235
- def artifacts(arg=nil)
234
+
235
+ def artifacts(arg=nil)
236
236
  if arg != nil
237
237
  @artifacts = arg
238
238
  else
239
239
  @artifacts
240
240
  end
241
241
  end
242
-
243
- def artifact_type(arg=nil)
242
+
243
+ def artifact_type(arg=nil)
244
244
  if arg != nil
245
245
  @artifact_type = arg
246
246
  else
247
247
  @artifact_type
248
248
  end
249
249
  end
250
-
251
- def content(arg=nil)
250
+
251
+ def content(arg=nil)
252
252
  if arg != nil
253
253
  @content = arg
254
254
  else
255
255
  @content
256
256
  end
257
257
  end
258
-
259
- def artifact_requirements(arg=nil)
258
+
259
+ def artifact_requirements(arg=nil)
260
260
  if arg != nil
261
261
  @artifact_requirements = arg
262
262
  else
263
263
  @artifact_requirements
264
264
  end
265
265
  end
266
-
267
- def related_components(arg=nil)
266
+
267
+ def related_components(arg=nil)
268
268
  if arg != nil
269
269
  @related_components = arg
270
270
  else
271
271
  @related_components
272
272
  end
273
273
  end
274
-
275
- def operations(arg=nil)
274
+
275
+ def operations(arg=nil)
276
276
  if arg != nil
277
277
  @operations = arg
278
278
  else
279
279
  @operations
280
280
  end
281
281
  end
282
-
283
- def operation_type(arg=nil)
282
+
283
+ def operation_type(arg=nil)
284
284
  if arg != nil
285
285
  @operation_type = arg
286
286
  else
287
287
  @operation_type
288
288
  end
289
289
  end
290
-
291
- def target_resource(arg=nil)
290
+
291
+ def target_resource(arg=nil)
292
292
  if arg != nil
293
293
  @target_resource = arg
294
294
  else
295
295
  @target_resource
296
296
  end
297
297
  end
298
-
298
+
299
299
  def created_at(arg=nil)
300
300
  if arg != nil
301
301
  @created_at = arg
@@ -352,12 +352,12 @@ module Megam
352
352
  asm.id(o["id"]) if o.has_key?("id")
353
353
  asm.name(o["name"]) if o.has_key?("name")
354
354
  asm.tosca_type(o["tosca_type"]) if o.has_key?("tosca_type")
355
-
356
- oq = o["requirements"]
355
+
356
+ oq = o["requirements"]
357
357
  asm.requirements[:host] = oq["host"] if oq && oq.has_key?("host")
358
358
  asm.requirements[:dummy] = oq["dummy"] if oq && oq.has_key?("dummy")
359
359
 
360
- inp = o["inputs"]
360
+ inp = o["inputs"]
361
361
  asm.inputs[:domain] = inp["domain"] if inp && inp.has_key?("domain")
362
362
  asm.inputs[:port] = inp["port"] if inp && inp.has_key?("port")
363
363
  asm.inputs[:username] = inp["username"] if inp && inp.has_key?("username")
@@ -366,29 +366,29 @@ module Megam
366
366
  asm.inputs[:source] = inp["source"] if inp && inp.has_key?("source")
367
367
  asm.inputs[:design_inputs] = inp["design_inputs"] if inp && inp.has_key?("design_inputs")
368
368
  asm.inputs[:service_inputs] = inp["service_inputs"] if inp && inp.has_key?("service_inputs")
369
- # ind = inp["design_inputs"]
370
- # asm.inputs["design_inputs"][:did] = ind["did"] if ind && ind.has_key?("did")
371
- # asm.inputs[:design_inputs][:x] = ind["x"] if ind && ind.has_key?("x")
372
- # asm.inputs[:design_inputs][:y] = ind["y"] if ind && ind.has_key?("y")
373
- # asm.inputs[:design_inputs][:z] = ind["z"] if ind && ind.has_key?("z")
374
- # asm.inputs[:design_inputs][:wires] = ind["wires"] if ind && ind.has_key?("wires")
375
- # ins = o["inputs"]["service_inputs"]
376
- # asm.inputs[:service_inputs][:dbname] = ins["dbname"] if ins && ins.has_key?("dbname")
377
- # asm.inputs[:service_inputs][:dbpassword] = ins["dbpassword"] if ins && ins.has_key?("dbpassword")
378
-
369
+ # ind = inp["design_inputs"]
370
+ # asm.inputs["design_inputs"][:did] = ind["did"] if ind && ind.has_key?("did")
371
+ # asm.inputs[:design_inputs][:x] = ind["x"] if ind && ind.has_key?("x")
372
+ # asm.inputs[:design_inputs][:y] = ind["y"] if ind && ind.has_key?("y")
373
+ # asm.inputs[:design_inputs][:z] = ind["z"] if ind && ind.has_key?("z")
374
+ # asm.inputs[:design_inputs][:wires] = ind["wires"] if ind && ind.has_key?("wires")
375
+ # ins = o["inputs"]["service_inputs"]
376
+ # asm.inputs[:service_inputs][:dbname] = ins["dbname"] if ins && ins.has_key?("dbname")
377
+ # asm.inputs[:service_inputs][:dbpassword] = ins["dbpassword"] if ins && ins.has_key?("dbpassword")
378
+
379
379
  asm.external_management_resource(o["external_management_resource"]) if o.has_key?("external_management_resource")
380
-
381
- ar = o["artifacts"]
380
+
381
+ ar = o["artifacts"]
382
382
  asm.artifacts[:artifact_type] = ar["artifact_type"] if ar && ar.has_key?("artifact_type")
383
383
  asm.artifacts[:content] = ar["content"] if ar && ar.has_key?("content")
384
384
  asm.artifacts[:artifact_requirements] = ar["artifact_requirements"] if ar && ar.has_key?("artifact_requirements")
385
-
385
+
386
386
  asm.related_components(o["related_components"]) if o.has_key?("related_components")
387
-
388
- ope = o["operations"]
387
+
388
+ ope = o["operations"]
389
389
  asm.operations[:operation_type] = ope["operation_type"] if ope && ope.has_key?("operation_type")
390
390
  asm.operations[:target_resource] = ope["target_resource"] if ope && ope.has_key?("target_resource")
391
-
391
+
392
392
  asm.created_at(o["created_at"]) if o.has_key?("created_at")
393
393
  asm
394
394
  end
@@ -399,10 +399,11 @@ module Megam
399
399
  asm
400
400
  end
401
401
 
402
- def from_hash(o)
402
+ def from_hash(o)
403
403
  @id = o["id"] if o.has_key?("id")
404
404
  @name = o["name"] if o.has_key?("name")
405
405
  @tosca_type = o["tosca_type"] if o.has_key?("tosca_type")
406
+ @requirements = o["requirements"] if o.has_key?("requirements")
406
407
  @inputs = o["inputs"] if o.has_key?("inputs")
407
408
  @external_management_resource = o["external_management_resource"] if o.has_key?("external_management_resource")
408
409
  @artifacts = o["artifacts"] if o.has_key?("artifacts")
@@ -416,15 +417,23 @@ module Megam
416
417
  asm = from_hash(o, tmp_email, tmp_api_key)
417
418
  asm.create
418
419
  end
419
-
420
420
 
421
421
  # Load a account by email_p
422
422
  def self.show(comp_id, tmp_email=nil, tmp_api_key=nil)
423
423
  asm = self.new(tmp_email, tmp_api_key)
424
- asm.megam_rest.get_components(comp_id)
424
+ asm.megam_rest.get_components(comp_id)
425
+ end
426
+
427
+ def self.update(o,tmp_email=nil, tmp_api_key=nil)
428
+ asm = from_hash(o, tmp_email, tmp_api_key)
429
+ asm.update
430
+ end
431
+
432
+ # Create the node via the REST API
433
+ def update
434
+ megam_rest.update_component(to_hash)
425
435
  end
426
436
 
427
-
428
437
  def to_s
429
438
  Megam::Stuff.styled_hash(to_hash)
430
439
  end
@@ -1,10 +1,29 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
+ def test_get_assembly
5
+ response = megams.get_one_assembly("ASM1133747830209511424")
6
+ assert_equal(200, response.status)
7
+ end
4
8
 
9
+ def test_update_assembly
10
+ tmp_hash = {
11
+ "id" => "ASM1139235178976247808",
12
+ "json_claz" => "Megam::Assembly",
13
+ "name" => "calcines",
14
+ "components" => ["COM1139235178934304768",""],
15
+ "policies" => [{
16
+ "name" => "bind policy",
17
+ "ptype" => "colocated",
18
+ "members" => ["calcines.megam.co/MattieGarcia","calcines.megam.co/parsnip"]
19
+ }],
20
+ "inputs" => "",
21
+ "operations" => "",
22
+ "created_at" => "2014-10-29 13:24:06 +0000"
23
+ }
24
+
25
+ response = megams.update_assembly(tmp_hash)
26
+ assert_equal(201, response.status)
27
+ end
5
28
 
6
- def test_get_assembly
7
- response = megams.get_one_assembly("ASM1133747830209511424")
8
- assert_equal(200, response.status)
9
- end
10
29
  end
@@ -1,8 +1,54 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
- def test_get_component
5
- response = megams.get_components("COM519839138036318208")
6
- assert_equal(200, response.status)
7
- end
4
+ def test_get_component
5
+ response = megams.get_components("COM519839138036318208")
6
+ assert_equal(200, response.status)
7
+ end
8
+
9
+ def test_update_component
10
+ tmp_hash = {
11
+ "id" => "COM1139245887592202240",
12
+ "name" => "NettieMoore",
13
+ "tosca_type" => "tosca.web.redis",
14
+ "requirements" => {
15
+ "host" => "clouddefault1139222212843274240",
16
+ "dummy" => ""
17
+ },
18
+ "inputs" => {
19
+ "domain" => "megam.co",
20
+ "port" => "6379",
21
+ "username" => "",
22
+ "password" => "",
23
+ "version" => "",
24
+ "source" => "",
25
+ "design_inputs" => {
26
+ "id" => "39bb18e7.c644e8",
27
+ "x" => "802",
28
+ "y" => "331",
29
+ "z" => "3f43bde9.c0bc42",
30
+ "wires" => ["cae50d7.f351af"]
31
+ },
32
+ "service_inputs" => {
33
+ "dbname" => "",
34
+ "dbpassword" => ""
35
+ }
36
+ },
37
+ "external_management_resource" => "",
38
+ "artifacts" => {
39
+ "artifact_type" => "tosca type",
40
+ "content" => "",
41
+ "artifact_requirements" => ""
42
+ },
43
+ "related_components" => "AntonioMcCormick.megam.co/TimothyHenderson",
44
+ "operations" => {
45
+ "operation_type" => "",
46
+ "target_resource" => ""
47
+ },
48
+ "created_at" => "2014-10-29 14:06:39 +0000"
49
+ }
50
+ response = megams.update_component(tmp_hash)
51
+ assert_equal(201, response.status)
52
+ end
53
+
8
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: megam_api
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.23'
4
+ version: '0.24'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kishorekumar Neelamegam, Thomas Alrin, Subash Sethurajan, Rajthilak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-26 00:00:00.000000000 Z
11
+ date: 2014-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  version: '0'
223
223
  requirements: []
224
224
  rubyforge_project:
225
- rubygems_version: 2.2.2
225
+ rubygems_version: 2.4.2
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: Ruby Client for the Megam