nexus_cli 0.8.3 → 0.8.4
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.
- data/VERSION +1 -1
- data/lib/nexus_cli/errors.rb +15 -0
- data/lib/nexus_cli/nexus_oss_remote.rb +25 -16
- metadata +3 -3
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.8.
|
|
1
|
+
0.8.4
|
data/lib/nexus_cli/errors.rb
CHANGED
|
@@ -230,4 +230,19 @@ The output from the server was:
|
|
|
230
230
|
end
|
|
231
231
|
status_code(125)
|
|
232
232
|
end
|
|
233
|
+
|
|
234
|
+
class RepositoryInGroupException < NexusCliError
|
|
235
|
+
def message
|
|
236
|
+
"You are attempting to add a repository that is already a part of this group."
|
|
237
|
+
end
|
|
238
|
+
status_code(126)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
class RepositoryNotInGroupException < NexusCliError
|
|
242
|
+
def message
|
|
243
|
+
"You are attempting to remove a repository that isn't a part of the group."
|
|
244
|
+
end
|
|
245
|
+
status_code(127)
|
|
246
|
+
end
|
|
247
|
+
|
|
233
248
|
end
|
|
@@ -335,13 +335,15 @@ module NexusCli
|
|
|
335
335
|
case response.status
|
|
336
336
|
when 201
|
|
337
337
|
return true
|
|
338
|
+
when 400
|
|
339
|
+
raise CreateRepsitoryException.new(response.content)
|
|
338
340
|
else
|
|
339
341
|
raise UnexpectedStatusCodeException.new(response.status)
|
|
340
342
|
end
|
|
341
343
|
end
|
|
342
344
|
|
|
343
345
|
def get_group_repository(group_id)
|
|
344
|
-
response = nexus.get(nexus_url("service/local/repo_groups/#{group_id}"), :header => DEFAULT_ACCEPT_HEADER)
|
|
346
|
+
response = nexus.get(nexus_url("service/local/repo_groups/#{group_id.gsub(" ", "_").downcase}"), :header => DEFAULT_ACCEPT_HEADER)
|
|
345
347
|
case response.status
|
|
346
348
|
when 200
|
|
347
349
|
return response.content
|
|
@@ -352,8 +354,16 @@ module NexusCli
|
|
|
352
354
|
end
|
|
353
355
|
end
|
|
354
356
|
|
|
357
|
+
def repository_in_group?(group_id, repository_to_check)
|
|
358
|
+
group_repository = JSON.parse(get_group_repository(group_id))
|
|
359
|
+
repositories_in_group = group_repository["data"]["repositories"]
|
|
360
|
+
|
|
361
|
+
repositories_in_group.find{|repository| repository["id"] == repository_to_check}
|
|
362
|
+
end
|
|
363
|
+
|
|
355
364
|
def add_to_group_repository(group_id, repository_to_add_id)
|
|
356
|
-
|
|
365
|
+
raise RepositoryInGroupException if repository_in_group?(group_id, repository_to_add_id)
|
|
366
|
+
response = nexus.put(nexus_url("service/local/repo_groups/#{group_id.gsub(" ", "_").downcase}"), :body => create_add_to_group_repository_json(group_id, repository_to_add_id), :header => DEFAULT_CONTENT_TYPE_HEADER)
|
|
357
367
|
case response.status
|
|
358
368
|
when 200
|
|
359
369
|
return true
|
|
@@ -365,7 +375,8 @@ module NexusCli
|
|
|
365
375
|
end
|
|
366
376
|
|
|
367
377
|
def remove_from_group_repository(group_id, repository_to_remove_id)
|
|
368
|
-
|
|
378
|
+
raise RepositoryNotInGroupException unless repository_in_group?(group_id, repository_to_remove_id)
|
|
379
|
+
response = nexus.put(nexus_url("service/local/repo_groups/#{group_id.gsub(" ", "_").downcase}"), :body => create_remove_from_group_repository_json(group_id, repository_to_remove_id), :header => DEFAULT_CONTENT_TYPE_HEADER)
|
|
369
380
|
case response.status
|
|
370
381
|
when 200
|
|
371
382
|
return true
|
|
@@ -375,7 +386,7 @@ module NexusCli
|
|
|
375
386
|
end
|
|
376
387
|
|
|
377
388
|
def delete_group_repository(group_id)
|
|
378
|
-
response = nexus.delete(nexus_url("service/local/repo_groups/#{group_id}"))
|
|
389
|
+
response = nexus.delete(nexus_url("service/local/repo_groups/#{group_id.gsub(" ", "_").downcase}"))
|
|
379
390
|
case response.status
|
|
380
391
|
when 204
|
|
381
392
|
return true
|
|
@@ -458,26 +469,24 @@ module NexusCli
|
|
|
458
469
|
end
|
|
459
470
|
|
|
460
471
|
def create_add_to_group_repository_json(group_id, repository_to_add_id)
|
|
461
|
-
group_repository_json = get_group_repository(group_id)
|
|
462
|
-
repositories =
|
|
472
|
+
group_repository_json = JSON.parse(get_group_repository(group_id))
|
|
473
|
+
repositories = group_repository_json["data"]["repositories"]
|
|
463
474
|
repositories << {:id => repository_to_add_id}
|
|
464
475
|
params = {:repositories => repositories}
|
|
465
|
-
params[:id] =
|
|
476
|
+
params[:id] = group_repository_json["data"]["id"]
|
|
477
|
+
params[:name] = group_repository_json["data"]["name"]
|
|
466
478
|
JSON.dump(:data => params)
|
|
467
479
|
end
|
|
468
480
|
|
|
469
481
|
def create_remove_from_group_repository_json(group_id, repository_to_remove_id)
|
|
470
|
-
group_repository_json = get_group_repository(group_id)
|
|
471
|
-
repositories =
|
|
482
|
+
group_repository_json = JSON.parse(get_group_repository(group_id))
|
|
483
|
+
repositories = group_repository_json["data"]["repositories"]
|
|
484
|
+
|
|
485
|
+
repositories.delete(repository_in_group?(group_id, repository_to_remove_id))
|
|
472
486
|
|
|
473
|
-
entry_to_remove = repositories.find{|repository| repository["id"] == repository_to_remove_id}
|
|
474
|
-
if entry_to_remove.nil?
|
|
475
|
-
raise RepositoryNotFoundException
|
|
476
|
-
else
|
|
477
|
-
repositories.delete(entry_to_remove)
|
|
478
|
-
end
|
|
479
487
|
params = {:repositories => repositories}
|
|
480
|
-
params[:id] =
|
|
488
|
+
params[:id] = group_repository_json["data"]["id"]
|
|
489
|
+
params[:name] = group_repository_json["data"]["name"]
|
|
481
490
|
JSON.dump(:data => params)
|
|
482
491
|
end
|
|
483
492
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nexus_cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.4
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -253,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
253
253
|
version: '0'
|
|
254
254
|
segments:
|
|
255
255
|
- 0
|
|
256
|
-
hash:
|
|
256
|
+
hash: 25935714722440689
|
|
257
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
258
|
none: false
|
|
259
259
|
requirements:
|
|
@@ -262,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
262
262
|
version: '0'
|
|
263
263
|
segments:
|
|
264
264
|
- 0
|
|
265
|
-
hash:
|
|
265
|
+
hash: 25935714722440689
|
|
266
266
|
requirements: []
|
|
267
267
|
rubyforge_project:
|
|
268
268
|
rubygems_version: 1.8.21
|