ruby_aem 1.2.0 → 1.3.0
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/ruby_aem.rb +6 -0
- data/lib/ruby_aem/client.rb +9 -11
- data/lib/ruby_aem/error.rb +2 -0
- data/lib/ruby_aem/handlers/json.rb +6 -9
- data/lib/ruby_aem/resources/aem.rb +4 -2
- data/lib/ruby_aem/resources/config_property.rb +1 -1
- data/lib/ruby_aem/resources/group.rb +2 -2
- data/lib/ruby_aem/resources/package.rb +137 -14
- data/lib/ruby_aem/resources/user.rb +2 -2
- data/lib/ruby_aem/result.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26336e9934e2dff340acbba3e5dc86357252968e
|
4
|
+
data.tar.gz: 84fa257232101ccbe014877c885463a8d8a61f15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c5dbcbd9a7c505dfaebff56d17e46dc48cf7e16909e7e01e04518e9ebca2bb17f245e8b05782bc9db0de4187b6790ec8265c06c2a94fe5ccf162c7244dd29b6
|
7
|
+
data.tar.gz: 470897acaf690a61bdba8efa5fb5b2018cbd53870aeadbef7b6fd9e108f3b5d96ad475de990a0be42ed9979b3a4fb9a3530d557d8bfd0cb547c66d43a4ca65f5
|
data/lib/ruby_aem.rb
CHANGED
@@ -52,6 +52,12 @@ module RubyAem
|
|
52
52
|
conf[:timeout] ||= 300
|
53
53
|
conf[:debug] ||= false
|
54
54
|
|
55
|
+
# handle custom configuration value being passed as a String
|
56
|
+
# e.g. when the values are passed via environment variables
|
57
|
+
conf[:port] = conf[:port].to_i
|
58
|
+
conf[:timeout] = conf[:timeout].to_i
|
59
|
+
conf[:debug] = conf[:debug] == 'true' if conf[:debug].is_a? String
|
60
|
+
|
55
61
|
SwaggerAemClient.configure { |swagger_conf|
|
56
62
|
[
|
57
63
|
swagger_conf.host = "#{conf[:protocol]}://#{conf[:host]}:#{conf[:port]}",
|
data/lib/ruby_aem/client.rb
CHANGED
@@ -56,7 +56,7 @@ module RubyAem
|
|
56
56
|
|
57
57
|
params = []
|
58
58
|
required_params = action_spec['params']['required'] || {}
|
59
|
-
required_params.each { |
|
59
|
+
required_params.each { |_key, value|
|
60
60
|
params.push(value % call_params)
|
61
61
|
}
|
62
62
|
params.push({})
|
@@ -94,18 +94,16 @@ module RubyAem
|
|
94
94
|
end
|
95
95
|
# if value is provided in optional param spec,
|
96
96
|
# then apply variable interpolation the same way as required param
|
97
|
-
|
98
|
-
if value
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
}
|
103
|
-
else
|
104
|
-
params[-1][key.to_sym] = value % call_params
|
105
|
-
end
|
97
|
+
elsif value.class == String
|
98
|
+
if value == '__FILE__'
|
99
|
+
File.open("#{call_params[:file_path]}/#{call_params[:package_name]}-#{call_params[:package_version]}.zip", 'r') { |file|
|
100
|
+
params[-1][key.to_sym] = file
|
101
|
+
}
|
106
102
|
else
|
107
|
-
params[-1][key.to_sym] = value
|
103
|
+
params[-1][key.to_sym] = value % call_params
|
108
104
|
end
|
105
|
+
else
|
106
|
+
params[-1][key.to_sym] = value
|
109
107
|
end
|
110
108
|
end
|
111
109
|
|
data/lib/ruby_aem/error.rb
CHANGED
@@ -46,17 +46,14 @@ module RubyAem
|
|
46
46
|
# @param response_spec response specification as configured in conf/spec.yaml
|
47
47
|
# @param call_params additional call_params information
|
48
48
|
# @return RubyAem::Result
|
49
|
-
def self.json_package_service(response,
|
49
|
+
def self.json_package_service(response, _response_spec, _call_params)
|
50
50
|
json = JSON.parse(response.body)
|
51
51
|
|
52
52
|
message = json['msg']
|
53
53
|
result = RubyAem::Result.new(message, response)
|
54
54
|
|
55
|
-
if json['success'] == true
|
56
|
-
|
57
|
-
else
|
58
|
-
raise RubyAem::Error.new(message, result)
|
59
|
-
end
|
55
|
+
return result if json['success'] == true
|
56
|
+
raise RubyAem::Error.new(message, result)
|
60
57
|
end
|
61
58
|
|
62
59
|
# Handle package filter JSON payload.
|
@@ -69,7 +66,7 @@ module RubyAem
|
|
69
66
|
json = JSON.parse(response.body)
|
70
67
|
|
71
68
|
filter = []
|
72
|
-
json.each do |key,
|
69
|
+
json.each do |key, _value|
|
73
70
|
filter.push(json[key]['root']) unless json[key]['root'].nil?
|
74
71
|
end
|
75
72
|
|
@@ -106,8 +103,8 @@ module RubyAem
|
|
106
103
|
json = JSON.parse(response.body)
|
107
104
|
|
108
105
|
agent_names = []
|
109
|
-
json.each do |key,
|
110
|
-
if !key.start_with? 'jcr:'
|
106
|
+
json.each do |key, _value|
|
107
|
+
if (!key.start_with? 'jcr:') && (!key.start_with? 'rep:')
|
111
108
|
agent_names.push(key)
|
112
109
|
end
|
113
110
|
end
|
@@ -61,7 +61,8 @@ module RubyAem
|
|
61
61
|
base_sleep_seconds: 2,
|
62
62
|
max_sleep_seconds: 2
|
63
63
|
}
|
64
|
-
}
|
64
|
+
}
|
65
|
+
)
|
65
66
|
opts[:_retries] ||= {}
|
66
67
|
opts[:_retries][:max_tries] ||= 30
|
67
68
|
opts[:_retries][:base_sleep_seconds] ||= 2
|
@@ -102,7 +103,8 @@ module RubyAem
|
|
102
103
|
base_sleep_seconds: 2,
|
103
104
|
max_sleep_seconds: 2
|
104
105
|
}
|
105
|
-
}
|
106
|
+
}
|
107
|
+
)
|
106
108
|
opts[:_retries] ||= {}
|
107
109
|
opts[:_retries][:max_tries] ||= 30
|
108
110
|
opts[:_retries][:base_sleep_seconds] ||= 2
|
@@ -44,7 +44,7 @@ module RubyAem
|
|
44
44
|
|
45
45
|
@call_params[:run_mode] = run_mode
|
46
46
|
@call_params[:config_node_name] = config_node_name
|
47
|
-
@call_params[
|
47
|
+
@call_params[name.to_sym] = @call_params[:value]
|
48
48
|
@call_params["#{type_hint_prefix}_type_hint".to_sym] = @call_params[:type]
|
49
49
|
|
50
50
|
config_name = Swagger.config_node_name_to_config_name(config_node_name)
|
@@ -34,7 +34,7 @@ module RubyAem
|
|
34
34
|
#
|
35
35
|
# @return RubyAem::Result
|
36
36
|
def create
|
37
|
-
@call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].
|
37
|
+
@call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].start_with? '/'
|
38
38
|
@client.call(self.class, __callee__.to_s, @call_params)
|
39
39
|
end
|
40
40
|
|
@@ -89,7 +89,7 @@ module RubyAem
|
|
89
89
|
#
|
90
90
|
# @return RubyAem::Result
|
91
91
|
def find_authorizable_id
|
92
|
-
@call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].
|
92
|
+
@call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].start_with? '/'
|
93
93
|
@client.call(self.class, __callee__.to_s, @call_params)
|
94
94
|
end
|
95
95
|
end
|
@@ -154,23 +154,61 @@ module RubyAem
|
|
154
154
|
@client.call(self.class, __callee__.to_s, @call_params)
|
155
155
|
end
|
156
156
|
|
157
|
-
#
|
158
|
-
#
|
157
|
+
# Find all versions of the package
|
158
|
+
# Result data should contain an array of version values, empty array if there's none.
|
159
159
|
#
|
160
160
|
# @return RubyAem::Result
|
161
|
-
def
|
161
|
+
def get_versions
|
162
|
+
packages = list_all.data
|
163
|
+
package_versions = packages.xpath("//packages/package[group=\"#{@call_params[:group_name]}\" and name=\"#{@call_params[:package_name]}\"]")
|
164
|
+
|
165
|
+
versions = []
|
166
|
+
package_versions.each do |package|
|
167
|
+
version = package.xpath('version/text()')
|
168
|
+
versions.push(version.to_s) if version.to_s != ''
|
169
|
+
end
|
170
|
+
|
171
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} has #{versions.length} version(s)"
|
172
|
+
result = RubyAem::Result.new(message, nil)
|
173
|
+
result.data = versions
|
174
|
+
|
175
|
+
result
|
176
|
+
end
|
177
|
+
|
178
|
+
# Check if this package exists.
|
179
|
+
# True result data indicates that the package exists, false otherwise.
|
180
|
+
#
|
181
|
+
# @return RubyAem::Result
|
182
|
+
def exists
|
162
183
|
packages = list_all.data
|
163
184
|
package = packages.xpath("//packages/package[group=\"#{@call_params[:group_name]}\" and name=\"#{@call_params[:package_name]}\" and version=\"#{@call_params[:package_version]}\"]")
|
164
185
|
|
165
186
|
if package.to_s != ''
|
166
|
-
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]}
|
167
|
-
|
187
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} exists"
|
188
|
+
exists = true
|
168
189
|
else
|
169
|
-
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]}
|
170
|
-
|
190
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} does not exist"
|
191
|
+
exists = false
|
171
192
|
end
|
172
193
|
result = RubyAem::Result.new(message, nil)
|
173
|
-
result.data =
|
194
|
+
result.data = exists
|
195
|
+
|
196
|
+
result
|
197
|
+
end
|
198
|
+
|
199
|
+
# Check if this package is uploaded. The indicator whether a package is uploaded is when it exists
|
200
|
+
# True result data indicates that the package is uploaded, false otherwise.
|
201
|
+
#
|
202
|
+
# @return RubyAem::Result
|
203
|
+
def is_uploaded
|
204
|
+
result = exists
|
205
|
+
|
206
|
+
result.message =
|
207
|
+
if result.data == true
|
208
|
+
"Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is uploaded"
|
209
|
+
else
|
210
|
+
"Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is not uploaded"
|
211
|
+
end
|
174
212
|
|
175
213
|
result
|
176
214
|
end
|
@@ -184,7 +222,7 @@ module RubyAem
|
|
184
222
|
package = packages.xpath("//packages/package[group=\"#{@call_params[:group_name]}\" and name=\"#{@call_params[:package_name]}\" and version=\"#{@call_params[:package_version]}\"]")
|
185
223
|
last_unpacked_by = package.xpath('lastUnpackedBy')
|
186
224
|
|
187
|
-
if
|
225
|
+
if !['', '<lastUnpackedBy/>', '<lastUnpackedBy>null</lastUnpackedBy>'].include? last_unpacked_by.to_s
|
188
226
|
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is installed"
|
189
227
|
is_installed = true
|
190
228
|
else
|
@@ -197,12 +235,60 @@ module RubyAem
|
|
197
235
|
result
|
198
236
|
end
|
199
237
|
|
238
|
+
# Check if this package is empty (has size 0).
|
239
|
+
# True result data indicates that the package is empty, false otherwise.
|
240
|
+
#
|
241
|
+
# @return RubyAem::Result
|
242
|
+
def is_empty
|
243
|
+
packages = list_all.data
|
244
|
+
package = packages.xpath("//packages/package[group=\"#{@call_params[:group_name]}\" and name=\"#{@call_params[:package_name]}\" and version=\"#{@call_params[:package_version]}\"]")
|
245
|
+
size = package.xpath('size/text()').to_s.to_i
|
246
|
+
|
247
|
+
if size.zero?
|
248
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is empty"
|
249
|
+
is_empty = true
|
250
|
+
else
|
251
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is not empty"
|
252
|
+
is_empty = false
|
253
|
+
end
|
254
|
+
result = RubyAem::Result.new(message, nil)
|
255
|
+
result.data = is_empty
|
256
|
+
|
257
|
+
result
|
258
|
+
end
|
259
|
+
|
260
|
+
# Check if this package is built. The indicator whether a package is built is when it exists and is not empty.
|
261
|
+
# True result data indicates that the package is built, false otherwise.
|
262
|
+
#
|
263
|
+
# @return RubyAem::Result
|
264
|
+
def is_built
|
265
|
+
exists_result = exists
|
266
|
+
|
267
|
+
if exists_result.data == true
|
268
|
+
is_empty_result = is_empty
|
269
|
+
if is_empty_result.data == false
|
270
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is built"
|
271
|
+
is_built = true
|
272
|
+
else
|
273
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is not built because it is empty"
|
274
|
+
is_built = false
|
275
|
+
end
|
276
|
+
else
|
277
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is not built because it does not exist"
|
278
|
+
is_built = false
|
279
|
+
end
|
280
|
+
result = RubyAem::Result.new(message, nil)
|
281
|
+
result.data = is_built
|
282
|
+
|
283
|
+
result
|
284
|
+
end
|
285
|
+
|
200
286
|
# Upload the package and wait until the package status states it is uploaded.
|
201
287
|
#
|
202
288
|
# @param file_path the directory where the package file to be uploaded is
|
203
289
|
# @param opts optional parameters:
|
204
290
|
# - force: if false then a package file will not be uploaded when the package already exists with the same group, name, and version, default is true (will overwrite existing package file)
|
205
|
-
# - _retries: retries library's options (http://www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to
|
291
|
+
# - _retries: retries library's options (http://www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_tries, base_sleep_seconds, max_sleep_seconds
|
206
292
|
# @return RubyAem::Result
|
207
293
|
def upload_wait_until_ready(
|
208
294
|
file_path,
|
@@ -240,7 +326,7 @@ module RubyAem
|
|
240
326
|
# Install the package and wait until the package status states it is installed.
|
241
327
|
#
|
242
328
|
# @param opts optional parameters:
|
243
|
-
# - _retries: retries library's options (http://www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to
|
329
|
+
# - _retries: retries library's options (http://www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_tries, base_sleep_seconds, max_sleep_seconds
|
244
330
|
# @return RubyAem::Result
|
245
331
|
def install_wait_until_ready(
|
246
332
|
opts = {
|
@@ -249,7 +335,8 @@ module RubyAem
|
|
249
335
|
base_sleep_seconds: 2,
|
250
336
|
max_sleep_seconds: 2
|
251
337
|
}
|
252
|
-
}
|
338
|
+
}
|
339
|
+
)
|
253
340
|
opts[:_retries] ||= {}
|
254
341
|
opts[:_retries][:max_tries] ||= 30
|
255
342
|
opts[:_retries][:base_sleep_seconds] ||= 2
|
@@ -274,7 +361,7 @@ module RubyAem
|
|
274
361
|
# Delete the package and wait until the package status states it is not uploaded.
|
275
362
|
#
|
276
363
|
# @param opts optional parameters:
|
277
|
-
# - _retries: retries library's options (http://www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to
|
364
|
+
# - _retries: retries library's options (http://www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_tries, base_sleep_seconds, max_sleep_seconds
|
278
365
|
# @return RubyAem::Result
|
279
366
|
def delete_wait_until_ready(
|
280
367
|
opts = {
|
@@ -283,7 +370,8 @@ module RubyAem
|
|
283
370
|
base_sleep_seconds: 2,
|
284
371
|
max_sleep_seconds: 2
|
285
372
|
}
|
286
|
-
}
|
373
|
+
}
|
374
|
+
)
|
287
375
|
opts[:_retries] ||= {}
|
288
376
|
opts[:_retries][:max_tries] ||= 30
|
289
377
|
opts[:_retries][:base_sleep_seconds] ||= 2
|
@@ -304,6 +392,41 @@ module RubyAem
|
|
304
392
|
}
|
305
393
|
result
|
306
394
|
end
|
395
|
+
|
396
|
+
# Build the package and wait until the package status states it is built (exists and not empty).
|
397
|
+
#
|
398
|
+
# @param opts optional parameters:
|
399
|
+
# - _retries: retries library's options (http://www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_tries, base_sleep_seconds, max_sleep_seconds
|
400
|
+
# @return RubyAem::Result
|
401
|
+
def build_wait_until_ready(
|
402
|
+
opts = {
|
403
|
+
_retries: {
|
404
|
+
max_tries: 30,
|
405
|
+
base_sleep_seconds: 2,
|
406
|
+
max_sleep_seconds: 2
|
407
|
+
}
|
408
|
+
}
|
409
|
+
)
|
410
|
+
opts[:_retries] ||= {}
|
411
|
+
opts[:_retries][:max_tries] ||= 30
|
412
|
+
opts[:_retries][:base_sleep_seconds] ||= 2
|
413
|
+
opts[:_retries][:max_sleep_seconds] ||= 2
|
414
|
+
|
415
|
+
# ensure integer retries setting (Puppet 3 passes numeric string)
|
416
|
+
opts[:_retries][:max_tries] = opts[:_retries][:max_tries].to_i
|
417
|
+
opts[:_retries][:base_sleep_seconds] = opts[:_retries][:base_sleep_seconds].to_i
|
418
|
+
opts[:_retries][:max_sleep_seconds] = opts[:_retries][:max_sleep_seconds].to_i
|
419
|
+
|
420
|
+
result = build
|
421
|
+
with_retries(max_tries: opts[:_retries][:max_tries], base_sleep_seconds: opts[:_retries][:base_sleep_seconds], max_sleep_seconds: opts[:_retries][:max_sleep_seconds]) { |retries_count|
|
422
|
+
check_result = is_built
|
423
|
+
puts format('Build check #%d: %s - %s', retries_count, check_result.data, check_result.message)
|
424
|
+
if check_result.data == false
|
425
|
+
raise StandardError.new(check_result.message)
|
426
|
+
end
|
427
|
+
}
|
428
|
+
result
|
429
|
+
end
|
307
430
|
end
|
308
431
|
end
|
309
432
|
end
|
@@ -36,7 +36,7 @@ module RubyAem
|
|
36
36
|
# @return RubyAem::Result
|
37
37
|
def create(password)
|
38
38
|
@call_params[:password] = password
|
39
|
-
@call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].
|
39
|
+
@call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].start_with? '/'
|
40
40
|
@client.call(self.class, __callee__.to_s, @call_params)
|
41
41
|
end
|
42
42
|
|
@@ -102,7 +102,7 @@ module RubyAem
|
|
102
102
|
#
|
103
103
|
# @return RubyAem::Result
|
104
104
|
def find_authorizable_id
|
105
|
-
@call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].
|
105
|
+
@call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].start_with? '/'
|
106
106
|
@client.call(self.class, __callee__.to_s, @call_params)
|
107
107
|
end
|
108
108
|
end
|
data/lib/ruby_aem/result.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_aem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shine Solutions
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|