ruby_aem 0.9.0 → 1.0.0

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: 4d453de388f2dc00342d36f11040e2dff294a4dc
4
- data.tar.gz: b60ea29a13c060f5ff2cb4d7dfa6d2c774bfe68b
3
+ metadata.gz: d0f1ce4ed2a578ad6207b8ee2084a68fc33add63
4
+ data.tar.gz: 40234461975d56d98f46114379bfdce1db25bae1
5
5
  SHA512:
6
- metadata.gz: 1e3f54abe4d1764f61a1eddb6dc8450f6b907b264c4bb23a62b077a7f30ccd4720c8e2438edfa748854ed6305a4be7127d55e6e54caf8b5b6a33c7aa1d93ec68
7
- data.tar.gz: 0147ebd982bb243ba129958f588d4a9ddc89c788c2591f2750416b1152f6818566d8d54ab6e42f5709166dd1a15e8c632af23d259887e47b801dae98e5afb047
6
+ metadata.gz: 3fe281388b41b35867c105caa54eb8904d0e77f9287c13e021ebf3437fe09e70f090aae218deea7ffc9efac332b3995f698668b02e3f472b2896c75b75480e9f
7
+ data.tar.gz: e1068b423cd27d207b10be4ec13e082869c7e159dc7df892c49d3a7b47bd66fa5154aeeb251e0be668c150f4feb1435cf796703421e9cf156ed5a33baef5b79b
data/conf/spec.yaml CHANGED
@@ -1,8 +1,7 @@
1
1
  bundle:
2
2
  responses:
3
3
  404:
4
- status: failure
5
- handler: simple
4
+ handler: simple_error
6
5
  message: 'Bundle %{name} not found'
7
6
  actions:
8
7
  start:
@@ -14,7 +13,6 @@ bundle:
14
13
  action: start
15
14
  responses:
16
15
  200:
17
- status: success
18
16
  handler: simple
19
17
  message: 'Bundle %{name} started'
20
18
  stop:
@@ -26,14 +24,12 @@ bundle:
26
24
  action: stop
27
25
  responses:
28
26
  200:
29
- status: success
30
27
  handler: simple
31
28
  message: 'Bundle %{name} stopped'
32
29
  flushagent:
33
30
  responses:
34
31
  404:
35
- status: failure
36
- handler: simple
32
+ handler: simple_error
37
33
  message: 'Flush agent %{name} not found on %{run_mode}'
38
34
  actions:
39
35
  create_update:
@@ -50,7 +46,7 @@ flushagent:
50
46
  jcrcontentjcrdescription: '%{description}'
51
47
  jcrcontentslingresource_type: /libs/cq/replication/components/agent
52
48
  jcrcontenttransport_uri: '%{dest_base_url}/dispatcher/invalidate.cache'
53
- jcrcontentlog_level: error
49
+ jcrcontentlog_level: '%{log_level}'
54
50
  jcrcontentno_versioning: true
55
51
  jcrcontentprotocol_http_headers:
56
52
  - 'CQ-Action:{action}'
@@ -58,7 +54,7 @@ flushagent:
58
54
  - 'CQ-Path:{path}'
59
55
  jcrcontentprotocol_http_headers_type_hint: String[]
60
56
  jcrcontentprotocol_http_method: GET
61
- jcrcontentretry_delay: 30000
57
+ jcrcontentretry_delay: '%{retry_delay}'
62
58
  jcrcontentserialization_type: flush
63
59
  jcrcontentjcrmixin_types: cq:ReplicationStatus
64
60
  jcrcontenttrigger_receive: true
@@ -67,11 +63,9 @@ flushagent:
67
63
  jcrcontentenabled: true
68
64
  responses:
69
65
  200:
70
- status: success
71
66
  handler: simple
72
67
  message: 'Flush agent %{name} updated on %{run_mode}'
73
68
  201:
74
- status: success
75
69
  handler: simple
76
70
  message: 'Flush agent %{name} created on %{run_mode}'
77
71
  delete:
@@ -83,7 +77,6 @@ flushagent:
83
77
  name: '%{name}'
84
78
  responses:
85
79
  204:
86
- status: success
87
80
  handler: simple
88
81
  message: 'Flush agent %{name} deleted on %{run_mode}'
89
82
  exists:
@@ -95,14 +88,15 @@ flushagent:
95
88
  name: '%{name}'
96
89
  responses:
97
90
  302:
98
- status: success
99
- handler: simple
91
+ handler: simple_true
100
92
  message: 'Flush agent %{name} exists on %{run_mode}'
93
+ 404:
94
+ handler: simple_false
95
+ message: 'Flush agent %{name} not found on %{run_mode}'
101
96
  group:
102
97
  responses:
103
98
  404:
104
- status: failure
105
- handler: simple
99
+ handler: simple_error
106
100
  message: 'Group %{name} not found'
107
101
  actions:
108
102
  create:
@@ -117,7 +111,6 @@ group:
117
111
  profilegiven_name: '%{name}'
118
112
  responses:
119
113
  201:
120
- status: success
121
114
  handler: html_authorizable_id
122
115
  message: 'Group %{name} created at %{path}/%{authorizable_id}'
123
116
  find_authorizable_id:
@@ -131,9 +124,11 @@ group:
131
124
  _1_property_value: '%{name}'
132
125
  responses:
133
126
  200:
134
- status: success
135
127
  handler: json_authorizable_id
136
128
  message: 'Found group %{name} authorizable ID %{authorizable_id}'
129
+ 404:
130
+ handler: simple_nil
131
+ message: 'Group %{name} not found'
137
132
  delete:
138
133
  api: sling
139
134
  operation: deleteNode
@@ -143,7 +138,6 @@ group:
143
138
  name: '%{authorizable_id}'
144
139
  responses:
145
140
  204:
146
- status: success
147
141
  handler: simple
148
142
  message: 'Group %{name} deleted at /%{path}/%{authorizable_id}'
149
143
  exists:
@@ -155,9 +149,11 @@ group:
155
149
  name: '%{authorizable_id}'
156
150
  responses:
157
151
  302:
158
- status: success
159
- handler: simple
152
+ handler: simple_true
160
153
  message: 'Group %{name} exists at /%{path}/%{authorizable_id}'
154
+ 404:
155
+ handler: simple_false
156
+ message: 'Group %{name} not found'
161
157
  set_permission:
162
158
  api: cq
163
159
  operation: postCqActions
@@ -167,7 +163,6 @@ group:
167
163
  changelog: 'path:%{permission_path},%{permission_csv}'
168
164
  responses:
169
165
  200:
170
- status: success
171
166
  handler: simple
172
167
  message: 'Permission %{permission_csv} on path %{permission_path} set for group %{name}'
173
168
  add_member:
@@ -181,14 +176,12 @@ group:
181
176
  add_members: '%{member}'
182
177
  responses:
183
178
  200:
184
- status: success
185
179
  handler: simple
186
180
  message: 'User/group %{member} added to group %{name}'
187
181
  node:
188
182
  responses:
189
183
  404:
190
- status: failure
191
- handler: simple
184
+ handler: simple_error
192
185
  message: 'Node %{path}/%{name} not found'
193
186
  actions:
194
187
  create:
@@ -201,7 +194,6 @@ node:
201
194
  name: '%{name}'
202
195
  responses:
203
196
  201:
204
- status: success
205
197
  handler: simple
206
198
  message: 'Node %{path}/%{name} created'
207
199
  delete:
@@ -213,7 +205,6 @@ node:
213
205
  name: '%{name}'
214
206
  responses:
215
207
  204:
216
- status: success
217
208
  handler: simple
218
209
  message: 'Node %{path}/%{name} deleted'
219
210
  exists:
@@ -225,9 +216,11 @@ node:
225
216
  name: '%{name}'
226
217
  responses:
227
218
  302:
228
- status: success
229
- handler: simple
219
+ handler: simple_true
230
220
  message: 'Node %{path}/%{name} exists'
221
+ 404:
222
+ handler: simple_false
223
+ message: 'Node %{path}/%{name} not found'
231
224
  package:
232
225
  actions:
233
226
  create:
@@ -244,7 +237,6 @@ package:
244
237
  charset: utf-8
245
238
  responses:
246
239
  200:
247
- status: success
248
240
  handler: json_package_service
249
241
  update:
250
242
  api: crx
@@ -260,7 +252,6 @@ package:
260
252
  charset: utf-8
261
253
  responses:
262
254
  200:
263
- status: success
264
255
  handler: json_package_service
265
256
  delete:
266
257
  api: crx
@@ -271,7 +262,6 @@ package:
271
262
  cmd: delete
272
263
  responses:
273
264
  200:
274
- status: success
275
265
  handler: json_package_service
276
266
  build:
277
267
  api: crx
@@ -282,7 +272,6 @@ package:
282
272
  cmd: build
283
273
  responses:
284
274
  200:
285
- status: success
286
275
  handler: json_package_service
287
276
  install:
288
277
  api: crx
@@ -293,7 +282,6 @@ package:
293
282
  cmd: install
294
283
  responses:
295
284
  200:
296
- status: success
297
285
  handler: json_package_service
298
286
  replicate:
299
287
  api: crx
@@ -304,7 +292,6 @@ package:
304
292
  cmd: replicate
305
293
  responses:
306
294
  200:
307
- status: success
308
295
  handler: json_package_service
309
296
  download:
310
297
  api: sling
@@ -316,7 +303,6 @@ package:
316
303
  version: '%{package_version}'
317
304
  responses:
318
305
  200:
319
- status: success
320
306
  handler: file_download
321
307
  message: 'Package downloaded to %{file_path}/%{package_name}-%{package_version}.zip'
322
308
  upload:
@@ -331,7 +317,6 @@ package:
331
317
  package: __FILE__
332
318
  responses:
333
319
  200:
334
- status: success
335
320
  handler: json_package_service
336
321
  get_filter:
337
322
  api: sling
@@ -343,7 +328,6 @@ package:
343
328
  version: '%{package_version}'
344
329
  responses:
345
330
  200:
346
- status: success
347
331
  handler: json_package_filter
348
332
  message: 'Filter retrieved successfully'
349
333
  list_all:
@@ -354,7 +338,6 @@ package:
354
338
  cmd: ls
355
339
  responses:
356
340
  200:
357
- status: success
358
341
  handler: xml_package_list
359
342
  message: 'Package list retrieved successfully'
360
343
  path:
@@ -369,7 +352,6 @@ path:
369
352
  path: '%{name}'
370
353
  responses:
371
354
  200:
372
- status: success
373
355
  handler: simple
374
356
  message: 'Path %{name} activated'
375
357
  configproperty:
@@ -404,18 +386,15 @@ configproperty:
404
386
  - org_osgi_service_http_port_secure_type_hint
405
387
  responses:
406
388
  200:
407
- status: success
408
389
  handler: simple
409
390
  message: 'Set %{run_mode} config %{type} property %{name}=%{value}'
410
391
  201:
411
- status: success
412
392
  handler: simple
413
393
  message: 'Set %{run_mode} config %{type} property %{name}=%{value}'
414
394
  replicationagent:
415
395
  responses:
416
396
  404:
417
- status: failure
418
- handler: simple
397
+ handler: simple_error
419
398
  message: 'Replication agent %{name} not found on %{run_mode}'
420
399
  actions:
421
400
  create_update:
@@ -426,24 +405,24 @@ replicationagent:
426
405
  runmode: '%{run_mode}'
427
406
  name: '%{name}'
428
407
  optional:
429
- jcrprimary_type: cq:Page
430
- jcrcontentcqname: '%{name}'
431
- jcrcontentjcrtitle: '%{title}'
432
- jcrcontentjcrdescription: '%{description}'
433
- jcrcontentslingresource_type: /libs/cq/replication/components/agent
434
- jcrcontentserialization_type: durbo
435
- jcrcontenttransport_uri: '%{dest_base_url}/bin/receive?sling:authRequestLogin=1'
436
- jcrcontentlog_level: error
437
- jcrcontentretry_delay: 30000
438
- jcrcontentcqtemplate: /libs/cq/replication/templates/agent
439
- jcrcontentenabled: true
408
+ jcrprimary_type: cq:Page
409
+ jcrcontentcqname: '%{name}'
410
+ jcrcontentjcrtitle: '%{title}'
411
+ jcrcontentjcrdescription: '%{description}'
412
+ jcrcontentslingresource_type: /libs/cq/replication/components/agent
413
+ jcrcontentserialization_type: durbo
414
+ jcrcontenttransport_uri: '%{dest_base_url}/bin/receive?sling:authRequestLogin=1'
415
+ jcrcontenttransport_user: '%{transport_user}'
416
+ jcrcontenttransport_password: '%{transport_password}'
417
+ jcrcontentlog_level: '%{log_level}'
418
+ jcrcontentretry_delay: '%{retry_delay}'
419
+ jcrcontentcqtemplate: /libs/cq/replication/templates/agent
420
+ jcrcontentenabled: true
440
421
  responses:
441
422
  200:
442
- status: success
443
423
  handler: simple
444
424
  message: 'Replication agent %{name} updated on %{run_mode}'
445
425
  201:
446
- status: success
447
426
  handler: simple
448
427
  message: 'Replication agent %{name} created on %{run_mode}'
449
428
  delete:
@@ -455,7 +434,6 @@ replicationagent:
455
434
  name: '%{name}'
456
435
  responses:
457
436
  204:
458
- status: success
459
437
  handler: simple
460
438
  message: 'Replication agent %{name} deleted on %{run_mode}'
461
439
  exists:
@@ -467,9 +445,11 @@ replicationagent:
467
445
  name: '%{name}'
468
446
  responses:
469
447
  302:
470
- status: success
471
- handler: simple
448
+ handler: simple_true
472
449
  message: 'Replication agent %{name} exists on %{run_mode}'
450
+ 404:
451
+ handler: simple_false
452
+ message: 'Replication agent %{name} not found on %{run_mode}'
473
453
  repository:
474
454
  actions:
475
455
  block_writes:
@@ -480,7 +460,6 @@ repository:
480
460
  action: blockRepositoryWrites
481
461
  responses:
482
462
  200:
483
- status: success
484
463
  handler: simple
485
464
  message: 'Repository writes blocked'
486
465
  unblock_writes:
@@ -491,14 +470,12 @@ repository:
491
470
  action: unblockRepositoryWrites
492
471
  responses:
493
472
  200:
494
- status: success
495
473
  handler: simple
496
474
  message: 'Repository writes unblocked'
497
475
  user:
498
476
  responses:
499
477
  404:
500
- status: failure
501
- handler: simple
478
+ handler: simple_error
502
479
  message: 'User %{name} not found'
503
480
  actions:
504
481
  create:
@@ -513,7 +490,6 @@ user:
513
490
  reppassword: '%{password}'
514
491
  responses:
515
492
  201:
516
- status: success
517
493
  handler: html_authorizable_id
518
494
  message: 'User %{name} created at %{path}/%{authorizable_id}'
519
495
  find_authorizable_id:
@@ -527,9 +503,11 @@ user:
527
503
  _1_property_value: '%{name}'
528
504
  responses:
529
505
  200:
530
- status: success
531
506
  handler: json_authorizable_id
532
507
  message: 'Found user %{name} authorizable ID %{authorizable_id}'
508
+ 404:
509
+ handler: simple_nil
510
+ message: 'User %{name} not found'
533
511
  delete:
534
512
  api: sling
535
513
  operation: deleteNode
@@ -539,7 +517,6 @@ user:
539
517
  name: '%{authorizable_id}'
540
518
  responses:
541
519
  204:
542
- status: success
543
520
  handler: simple
544
521
  message: 'User %{name} deleted at /%{path}/%{authorizable_id}'
545
522
  exists:
@@ -551,9 +528,11 @@ user:
551
528
  name: '%{authorizable_id}'
552
529
  responses:
553
530
  302:
554
- status: success
555
- handler: simple
531
+ handler: simple_true
556
532
  message: 'User %{name} exists at /%{path}/%{authorizable_id}'
533
+ 404:
534
+ handler: simple_false
535
+ message: 'User %{name} not found'
557
536
  set_permission:
558
537
  api: cq
559
538
  operation: postCqActions
@@ -563,7 +542,6 @@ user:
563
542
  changelog: 'path:%{permission_path},%{permission_csv}'
564
543
  responses:
565
544
  200:
566
- status: success
567
545
  handler: simple
568
546
  message: 'Permission %{permission_csv} on path %{permission_path} set for user %{name}'
569
547
  change_password:
@@ -576,6 +554,5 @@ user:
576
554
  verify: '%{new_password}'
577
555
  responses:
578
556
  200:
579
- status: success
580
557
  handler: simple
581
558
  message: 'Logged in user password changed'
@@ -14,11 +14,13 @@ See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  =end
16
16
 
17
+ require 'ruby_aem/error'
17
18
  require 'ruby_aem/handlers/file'
18
19
  require 'ruby_aem/handlers/html'
19
20
  require 'ruby_aem/handlers/json'
20
21
  require 'ruby_aem/handlers/simple'
21
22
  require 'ruby_aem/handlers/xml'
23
+ require 'ruby_aem/response'
22
24
  require 'ruby_aem/swagger'
23
25
  require 'swagger_aem'
24
26
 
@@ -40,15 +42,18 @@ module RubyAem
40
42
  # Make an API call using the relevant Swagger AEM API client.
41
43
  # Clazz and action parameters are used to identify the action, API, and params
42
44
  # from ruby_aem specification, alongside the response handlers.
45
+ # Call parameters are used to construct HTTP request parameters based on the
46
+ # specification.
43
47
  #
44
48
  # @param clazz the class name of the caller resource
45
49
  # @param action the action of the API call
46
- # @param info additional information of the API call
50
+ # @param call_params API call parameters
47
51
  # @return RubyAem::Result
48
- def call(clazz, action, info)
52
+ def call(clazz, action, call_params)
49
53
 
50
- component = clazz.name.downcase.sub('rubyaem::', '')
51
- action_spec = @spec[component]['actions'][action]
54
+ resource_name = clazz.name.downcase.sub('rubyaem::resources::', '')
55
+ resource = @spec[resource_name]
56
+ action_spec = resource['actions'][action]
52
57
 
53
58
  api = @apis[action_spec['api'].to_sym]
54
59
  operation = action_spec['operation']
@@ -56,25 +61,26 @@ module RubyAem
56
61
  params = []
57
62
  required_params = action_spec['params']['required'] || {}
58
63
  required_params.each { |key, value|
59
- params.push(value % info)
64
+ params.push(value % call_params)
60
65
  }
61
66
  params.push({})
62
67
  optional_params = action_spec['params']['optional'] || {}
63
68
  optional_params.each { |key, value|
64
- add_optional_param(key, value, params, info)
69
+ add_optional_param(key, value, params, call_params)
65
70
  }
66
71
 
67
- base_responses = @spec[component]['responses'] || {}
68
- action_responses = action_spec['responses'] || {}
69
- responses = base_responses.merge(action_responses)
72
+ base_responses_spec = resource['responses'] || {}
73
+ action_responses_spec = action_spec['responses'] || {}
74
+ responses_spec = base_responses_spec.merge(action_responses_spec)
70
75
 
71
76
  begin
72
77
  method = RubyAem::Swagger.operation_to_method(operation)
73
78
  data, status_code, headers = api.send("#{method}_with_http_info", *params)
74
- handle(data, status_code, headers, responses, info)
79
+ response = RubyAem::Response.new(status_code, data, headers)
75
80
  rescue SwaggerAemClient::ApiError => err
76
- handle(err.response_body, err.code, err.response_headers, responses, info)
81
+ response = RubyAem::Response.new(err.code, err.response_body, err.response_headers)
77
82
  end
83
+ handle(response, responses_spec, call_params)
78
84
  end
79
85
 
80
86
  # Add optional param into params list.
@@ -82,24 +88,24 @@ module RubyAem
82
88
  # @param key optional param key
83
89
  # @param value optional param value
84
90
  # @param params combined list of required and optional parameters
85
- # @param info additional information
86
- def add_optional_param(key, value, params, info)
91
+ # @param call_params API call parameters
92
+ def add_optional_param(key, value, params, call_params)
87
93
  # if there is no value in optional param spec,
88
- # then only add optional param that is set in info
94
+ # then only add optional param that is set in call parameters
89
95
  if !value
90
- if info.key? key.to_sym
91
- params[-1][key.to_sym] = info[key.to_sym]
96
+ if call_params.key? key.to_sym
97
+ params[-1][key.to_sym] = call_params[key.to_sym]
92
98
  end
93
99
  # if value is provided in optional param spec,
94
100
  # then apply variable interpolation the same way as required param
95
101
  else
96
102
  if value.class == String
97
103
  if value == '__FILE__'
98
- File.open("#{info[:file_path]}/#{info[:package_name]}-#{info[:package_version]}.zip", 'r') { |file|
104
+ File.open("#{call_params[:file_path]}/#{call_params[:package_name]}-#{call_params[:package_version]}.zip", 'r') { |file|
99
105
  params[-1][key.to_sym] = file
100
106
  }
101
107
  else
102
- params[-1][key.to_sym] = value % info
108
+ params[-1][key.to_sym] = value % call_params
103
109
  end
104
110
  else
105
111
  params[-1][key.to_sym] = value
@@ -111,19 +117,20 @@ module RubyAem
111
117
  # If none of the response specifications contains the status code, a failure result
112
118
  # will then be returned.
113
119
  #
114
- # @param data data payload
115
- # @param status_code response HTTP status code
116
- # @param headers response HTTP headers
117
- # @param responses a list of response specifications as configured in conf/spec.yaml
118
- # @param info additional information
120
+ # @param response response containing HTTP status code, body, and headers
121
+ # @param responses_spec a list of response specifications as configured in conf/spec.yaml
122
+ # @param call_params API call parameters
119
123
  # @return RubyAem::Result
120
- def handle(data, status_code, headers, responses, info)
121
- if responses.key?(status_code)
122
- response_spec = responses[status_code]
124
+ # @raise RubyAem::Error when the response status code is unexpected
125
+ def handle(response, responses_spec, call_params)
126
+ if responses_spec.key?(response.status_code)
127
+ response_spec = responses_spec[response.status_code]
123
128
  handler = response_spec['handler']
124
- result = Handlers.send(handler, data, status_code, headers, response_spec, info)
129
+ result = Handlers.send(handler, response, response_spec, call_params)
125
130
  else
126
- result = Result.new('failure', "Unexpected response\nstatus code: #{status_code}\nheaders: #{headers}\ndata: #{data}")
131
+ message = "Unexpected response\nstatus code: #{response.status_code}\nheaders: #{response.headers}\nbody: #{response.body}"
132
+ result = Result.new(message, response)
133
+ raise RubyAem::Error.new(message, result)
127
134
  end
128
135
  end
129
136
 
@@ -0,0 +1,28 @@
1
+ =begin
2
+ Copyright 2016 Shine Solutions
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ =end
16
+
17
+ module RubyAem
18
+
19
+ class Error < StandardError
20
+ attr_accessor :result
21
+
22
+ def initialize(message, result)
23
+ super(message)
24
+ self.result = result
25
+ end
26
+
27
+ end
28
+ end
@@ -18,24 +18,22 @@ module RubyAem
18
18
  # Response handlers for file payload.
19
19
  module Handlers
20
20
 
21
- # Handle downloaded file by copying from temporary location to file_path info.
21
+ # Handle downloaded file by copying from temporary location to file_path call param.
22
22
  # The downloaded file in temporary location will then be deleted.
23
23
  # data, status_code, and headers are all returned from RubyAem::Client call.
24
24
  #
25
- # @param data data payload
26
- # @param status_code response HTTP status code
27
- # @param headers response HTTP headers
25
+ # @param response HTTP response containing status_code, body, and headers
28
26
  # @param response_spec response specification as configured in conf/spec.yaml
29
- # @param info additional information
27
+ # @param call_params API call parameters
30
28
  # @return RubyAem::Result
31
- def Handlers.file_download(data, status_code, headers, response_spec, info)
29
+ def Handlers.file_download(response, response_spec, call_params)
32
30
 
33
- FileUtils.cp(data.path, "#{info[:file_path]}/#{info[:package_name]}-#{info[:package_version]}.zip")
34
- data.delete
31
+ FileUtils.cp(response.body.path, "#{call_params[:file_path]}/#{call_params[:package_name]}-#{call_params[:package_version]}.zip")
32
+ response.body.delete
35
33
 
36
- message = response_spec['message'] % info
34
+ message = response_spec['message'] % call_params
37
35
 
38
- RubyAem::Result.new('success', message)
36
+ RubyAem::Result.new(message, response)
39
37
  end
40
38
 
41
39
  end
@@ -23,23 +23,20 @@ module RubyAem
23
23
  # Parse authorizable ID from response body data.
24
24
  # This is used to get the authorizable ID of a newly created user/group.
25
25
  #
26
- # @param data data payload
27
- # @param status_code response HTTP status code
28
- # @param headers response HTTP headers
26
+ # @param response HTTP response containing status_code, body, and headers
29
27
  # @param response_spec response specification as configured in conf/spec.yaml
30
- # @param info additional information
28
+ # @param call_params API call parameters
31
29
  # @return RubyAem::Result
32
- def Handlers.html_authorizable_id(data, status_code, headers, response_spec, info)
30
+ def Handlers.html_authorizable_id(response, response_spec, call_params)
33
31
 
34
- html = Nokogiri::HTML(data)
32
+ html = Nokogiri::HTML(response.body)
35
33
  authorizable_id = html.xpath('//title/text()').to_s
36
- authorizable_id.slice! "Content created #{info[:path]}"
37
- info[:authorizable_id] = authorizable_id.sub(/^\//, '')
34
+ authorizable_id.slice! "Content created #{call_params[:path]}"
35
+ call_params[:authorizable_id] = authorizable_id.sub(/^\//, '')
38
36
 
39
- status = response_spec['status']
40
- message = response_spec['message'] % info
37
+ message = response_spec['message'] % call_params
41
38
 
42
- RubyAem::Result.new(status, message)
39
+ RubyAem::Result.new(message, response)
43
40
  end
44
41
 
45
42
  end