nexus_api 1.2.0 → 1.5.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/CHANGELOG.md +32 -0
- data/Gemfile.lock +3 -3
- data/README.md +13 -5
- data/lib/endpoints/assets.rb +9 -0
- data/lib/endpoints/components.rb +9 -0
- data/lib/endpoints/privileges.rb +27 -0
- data/lib/endpoints/roles.rb +22 -0
- data/lib/endpoints/search.rb +17 -0
- data/lib/endpoints/staging.rb +5 -2
- data/lib/endpoints/tags.rb +44 -12
- data/lib/endpoints/users.rb +21 -0
- data/lib/nexus_api/cli_commands/list.rb +15 -0
- data/lib/nexus_api/cli_commands/tag.rb +1 -1
- data/lib/nexus_api/docker_manager.rb +2 -2
- data/lib/nexus_api/nexus_connection.rb +13 -3
- data/lib/nexus_api/version.rb +1 -1
- data/lib/utilities/parameter_builder.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae2066e62934bcfeed3480aa351da4ad8053d258c762b4ed8cfc006a64eae7c3
|
4
|
+
data.tar.gz: 597ba898fabbf3efcb1c2ab22f0557875d33cb6af24fd8a9338cf7be4c83b942
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3015d930671ca0f18b89647f55a2fda2496c5ddd5c3df9540cd2d0012530a8ecf379f9aeaead6ab7a8a132e45c825cf89d25a78efb2b58b999343698a6d6531d
|
7
|
+
data.tar.gz: f217d6c26156c2dc7960ce5f393b211bdc560134ede1cb95658a7c0e4b54c4f6b02f8ff4e055f2d573c0082e487f223cd90018966ef97249d390e8d0c8ad386b
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,38 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
|
8
|
+
## [1.5.0](https://github.com/Cisco-AMP/nexus_api/compare/v1.4.1...v1.5.0) - 2020-06-10
|
9
|
+
### Added
|
10
|
+
- New methods around the `privileges` endpoint
|
11
|
+
- New methods around the `roles` endpoint
|
12
|
+
- New methods around the `users` endpoint
|
13
|
+
- New `list_all_*` methods for endpoints that paginate so the user doesn't have to page through results themselves if they just want all the raw data
|
14
|
+
|
15
|
+
|
16
|
+
## [1.4.1](https://github.com/Cisco-AMP/nexus_api/compare/v1.4.0...v1.4.1) - 2020-05-08
|
17
|
+
### Changed
|
18
|
+
- Error reporting to be more descriptive
|
19
|
+
|
20
|
+
|
21
|
+
## [1.4.0](https://github.com/Cisco-AMP/nexus_api/compare/v1.3.0...v1.4.0) - 2020-05-05
|
22
|
+
### Added
|
23
|
+
- Optional `tag` parameter to `associate_tag()` and `delete_associated_tag()` methods
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
- Made `sha1` parameter optional for `associate_tag()` and `delete_associated_tag()` methods
|
27
|
+
|
28
|
+
|
29
|
+
## [1.3.0](https://github.com/Cisco-AMP/nexus_api/compare/v1.2.1...v1.3.0) - 2020-04-30
|
30
|
+
### Added
|
31
|
+
- Optional source and general keyword match into staging endpoint method (`move_components_to()`)
|
32
|
+
|
33
|
+
|
34
|
+
## [1.2.1](https://github.com/Cisco-AMP/nexus_api/compare/v1.2.0...v1.2.1) - 2020-04-29
|
35
|
+
### Fixed
|
36
|
+
- Correctly building request URLs when pagination is the only argument
|
37
|
+
- `bin/nexus_api tag list` now using pagination
|
38
|
+
|
39
|
+
|
8
40
|
## [1.2.0](https://github.com/Cisco-AMP/nexus_api/compare/v1.1.0...v1.2.0) - 2020-04-24
|
9
41
|
### Added
|
10
42
|
- `move_components_to` method for moving all components that match a given tag into a new destination
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nexus_api (1.
|
4
|
+
nexus_api (1.5.0)
|
5
5
|
bundler (~> 2)
|
6
6
|
docker-api (~> 1.34.2)
|
7
7
|
dotenv (~> 2.7.5)
|
@@ -34,7 +34,7 @@ GEM
|
|
34
34
|
method_source (0.9.2)
|
35
35
|
mime-types (3.3.1)
|
36
36
|
mime-types-data (~> 3.2015)
|
37
|
-
mime-types-data (3.
|
37
|
+
mime-types-data (3.2020.0512)
|
38
38
|
multi_json (1.14.1)
|
39
39
|
netrc (0.11.0)
|
40
40
|
pry (0.12.2)
|
@@ -84,4 +84,4 @@ DEPENDENCIES
|
|
84
84
|
webmock (~> 3.8)
|
85
85
|
|
86
86
|
BUNDLED WITH
|
87
|
-
2.
|
87
|
+
2.1.4
|
data/README.md
CHANGED
@@ -59,21 +59,24 @@ api = NexusAPI::API.new(
|
|
59
59
|
username: NEXUS_USERNAME,
|
60
60
|
password: NEXUS_PASSWORD,
|
61
61
|
hostname: NEXUS_HOSTNAME,
|
62
|
-
docker_pull_hostname:
|
63
|
-
docker_push_hostname:
|
62
|
+
docker_pull_hostname: DOCKER_PULL_HOSTNAME, # Optional
|
63
|
+
docker_push_hostname: DOCKER_PUSH_HOSTNAME, # Optional
|
64
64
|
config: "team_configs/#{CONFIG_NAME}", # Optional
|
65
65
|
)
|
66
66
|
# NOTE: All Docker commands will fail if the docker hostnames are not initialized
|
67
67
|
|
68
68
|
# You can query information through the list methods
|
69
|
-
api.list_repositories
|
70
|
-
api.list_repository_names
|
71
69
|
api.list_assets(repository: REPOSITORY_NAME)
|
72
70
|
api.list_asset(id: ASSET_ID)
|
73
71
|
api.list_components(repository: REPOSITORY_NAME)
|
74
72
|
api.list_component(id: ASSET_ID)
|
73
|
+
api.list_privileges
|
74
|
+
api.list_repositories
|
75
|
+
api.list_repository_names
|
76
|
+
api.list_roles
|
75
77
|
api.list_scripts
|
76
78
|
api.list_tags
|
79
|
+
api.list_users
|
77
80
|
|
78
81
|
# You can search for an asset by its name
|
79
82
|
# Optionally, you can pass in additional fields to filter the results
|
@@ -90,7 +93,12 @@ api.search_asset(
|
|
90
93
|
# - list_components
|
91
94
|
# - list_tags
|
92
95
|
# - search_asset
|
93
|
-
# You can use the following
|
96
|
+
# You can use the following methods to automatically gather data from all pages for you:
|
97
|
+
# - list_all_assets
|
98
|
+
# - list_all_components
|
99
|
+
# - list_all_tags
|
100
|
+
# - search_all_assets
|
101
|
+
# Or you can use the following pattern to page through if additional processing is desired:
|
94
102
|
set = Array.new.tap do |set|
|
95
103
|
loop do
|
96
104
|
set.concat(api.METHOD_YOU_WANT(ARGUMENTS, paginate: true))
|
data/lib/endpoints/assets.rb
CHANGED
@@ -6,6 +6,15 @@ module NexusAPI
|
|
6
6
|
@connection.get_response(endpoint: "assets?repository=#{repository}", paginate: paginate)
|
7
7
|
end
|
8
8
|
|
9
|
+
def list_all_assets(repository: nil)
|
10
|
+
assets = Array.new.tap do |assets|
|
11
|
+
loop do
|
12
|
+
assets.concat(list_assets(repository: repository, paginate: true))
|
13
|
+
break unless paginate?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
9
18
|
# GET /service/rest/v1/assets/{id}
|
10
19
|
def list_asset(id:)
|
11
20
|
@connection.get_response(endpoint: "assets/#{id}")
|
data/lib/endpoints/components.rb
CHANGED
@@ -6,6 +6,15 @@ module NexusAPI
|
|
6
6
|
@connection.get_response(endpoint: "components?repository=#{repository}", paginate: paginate)
|
7
7
|
end
|
8
8
|
|
9
|
+
def list_all_components(repository: nil)
|
10
|
+
components = Array.new.tap do |components|
|
11
|
+
loop do
|
12
|
+
components.concat(list_components(repository: repository, paginate: true))
|
13
|
+
break unless paginate?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
9
18
|
# POST /service/rest/v1/components
|
10
19
|
def upload_maven_component(filename:, group_id:, artifact_id:, version:, repository: nil, tag: nil)
|
11
20
|
repository ||= @team_config.maven_repository
|
data/lib/endpoints/privileges.rb
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
module NexusAPI
|
2
2
|
class API
|
3
3
|
# GET /service/rest/beta/security/privileges
|
4
|
+
def list_privileges
|
5
|
+
@connection.get_response(endpoint: 'security/privileges', api_version: 'beta')
|
6
|
+
end
|
7
|
+
|
4
8
|
# GET /service/rest/beta/security/privileges/{privilegeId}
|
9
|
+
def list_privilege(privilege_id:)
|
10
|
+
@connection.get_response(endpoint: "security/privileges/#{privilege_id}", api_version: 'beta')
|
11
|
+
end
|
12
|
+
|
5
13
|
# DELETE /service/rest/beta/security/privileges/{privilegeId}
|
14
|
+
def delete_privilege(privilege_id:)
|
15
|
+
@connection.delete(endpoint: "security/privileges/#{privilege_id}", api_version: 'beta')
|
16
|
+
end
|
17
|
+
|
6
18
|
# POST /service/rest/beta/security/privileges/application
|
7
19
|
# PUT /service/rest/beta/security/privileges/application/{privilegeId}
|
8
20
|
# POST /service/rest/beta/security/privileges/repository-admin
|
@@ -10,6 +22,21 @@ module NexusAPI
|
|
10
22
|
# POST /service/rest/beta/security/privileges/repository-content-selector
|
11
23
|
# PUT /service/rest/beta/security/privileges/repository-content-selector/{privilegeId}
|
12
24
|
# POST /service/rest/beta/security/privileges/repository-view
|
25
|
+
def create_privilege_repository_view(name:, description: nil, actions: ['READ'], format: '*', repository: '*')
|
26
|
+
parameters = {
|
27
|
+
# The name is also used as the privilege_id
|
28
|
+
'name' => name,
|
29
|
+
'description' => description,
|
30
|
+
# READ, BROWSE, EDIT, ADD, DELETE, RUN, ASSOCIATE, DISASSOCIATE, ALL
|
31
|
+
'actions' => actions,
|
32
|
+
# The repository format (i.e 'nuget', 'npm') this privilege will grant access to (or * for all)
|
33
|
+
'format' => format,
|
34
|
+
# The name of the repository this privilege will grant access to (or * for all)
|
35
|
+
'repository' => repository
|
36
|
+
}
|
37
|
+
@connection.post(endpoint: 'security/privileges/repository-view', parameters: parameters, api_version: 'beta')
|
38
|
+
end
|
39
|
+
|
13
40
|
# PUT /service/rest/beta/security/privileges/repository-view/{privilegeId}
|
14
41
|
# POST /service/rest/beta/security/privileges/script
|
15
42
|
# PUT /service/rest/beta/security/privileges/script/{privilegeId}
|
data/lib/endpoints/roles.rb
CHANGED
@@ -1,9 +1,31 @@
|
|
1
1
|
module NexusAPI
|
2
2
|
class API
|
3
3
|
# GET /service/rest/beta/security/roles
|
4
|
+
def list_roles
|
5
|
+
@connection.get_response(endpoint: 'security/roles', api_version: 'beta')
|
6
|
+
end
|
7
|
+
|
4
8
|
# POST /service/rest/beta/security/roles
|
9
|
+
def create_role(id:, name:, description: nil, privileges: [], roles: [])
|
10
|
+
parameters = {
|
11
|
+
'id' => id,
|
12
|
+
'name' => name,
|
13
|
+
'description' => description,
|
14
|
+
'privileges' => privileges,
|
15
|
+
'roles' => roles
|
16
|
+
}
|
17
|
+
@connection.post(endpoint: 'security/roles', parameters: parameters, api_version: 'beta')
|
18
|
+
end
|
19
|
+
|
5
20
|
# GET /service/rest/beta/security/roles/{id}
|
21
|
+
def list_role(id:)
|
22
|
+
@connection.get_response(endpoint: "security/roles/#{id}?source=default", api_version: 'beta')
|
23
|
+
end
|
24
|
+
|
6
25
|
# PUT /service/rest/beta/security/roles/{id}
|
7
26
|
# DELETE /service/rest/beta/security/roles/{id}
|
27
|
+
def delete_role(id:)
|
28
|
+
@connection.delete(endpoint: "security/roles/#{id}", api_version: 'beta')
|
29
|
+
end
|
8
30
|
end
|
9
31
|
end
|
data/lib/endpoints/search.rb
CHANGED
@@ -13,6 +13,23 @@ module NexusAPI
|
|
13
13
|
@connection.get_response(endpoint: endpoint, paginate: paginate)
|
14
14
|
end
|
15
15
|
|
16
|
+
def search_all_assets(name:, format: nil, repository: nil, sha1: nil, version: nil)
|
17
|
+
results = Array.new.tap do |results|
|
18
|
+
loop do
|
19
|
+
results.concat(
|
20
|
+
search_asset(
|
21
|
+
name: name,
|
22
|
+
format: format,
|
23
|
+
repository: repository,
|
24
|
+
sha1: sha1,
|
25
|
+
version: version,
|
26
|
+
paginate: true
|
27
|
+
))
|
28
|
+
break unless paginate?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
16
33
|
# GET /service/rest/v1/search/assets/download
|
17
34
|
end
|
18
35
|
end
|
data/lib/endpoints/staging.rb
CHANGED
@@ -2,8 +2,11 @@ module NexusAPI
|
|
2
2
|
class API
|
3
3
|
# POST /service/rest/v1/staging/delete
|
4
4
|
# POST /service/rest/v1/staging/move/{destination}
|
5
|
-
def move_components_to(destination:, tag:)
|
6
|
-
|
5
|
+
def move_components_to(destination:, tag:, source: nil, keyword: nil)
|
6
|
+
endpoint = "staging/move/#{destination}?tag=#{tag}"
|
7
|
+
endpoint += "&repository=#{source}" unless source.nil?
|
8
|
+
endpoint += "&q=#{keyword}" unless keyword.nil?
|
9
|
+
@connection.post(endpoint: endpoint)
|
7
10
|
end
|
8
11
|
end
|
9
12
|
end
|
data/lib/endpoints/tags.rb
CHANGED
@@ -5,6 +5,15 @@ module NexusAPI
|
|
5
5
|
@connection.get_response(endpoint: 'tags', paginate: paginate)
|
6
6
|
end
|
7
7
|
|
8
|
+
def list_all_tags
|
9
|
+
tags = Array.new.tap do |tags|
|
10
|
+
loop do
|
11
|
+
tags.concat(list_tags(paginate: true))
|
12
|
+
break unless paginate?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
8
17
|
# POST /service/rest/v1/tags
|
9
18
|
def create_tag(name:)
|
10
19
|
parameters = JSON.dump({
|
@@ -21,24 +30,47 @@ module NexusAPI
|
|
21
30
|
end
|
22
31
|
|
23
32
|
# POST /service/rest/v1/tags/associate/{tagName}
|
24
|
-
def associate_tag(name:, sha1
|
33
|
+
def associate_tag(name:, sha1: nil, repository: nil, tag: nil)
|
25
34
|
repository ||= @team_config.tag_repository
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
35
|
+
if sha1.nil? && repository.nil? && tag.nil?
|
36
|
+
puts_error(__method__)
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
|
40
|
+
search_query = "?wait=true"
|
41
|
+
search_query += "&sha1=#{sha1}" unless sha1.nil?
|
42
|
+
search_query += "&repository=#{repository}" unless repository.nil?
|
43
|
+
search_query += "&tag=#{tag}" unless tag.nil?
|
44
|
+
|
31
45
|
@connection.post(endpoint: "tags/associate/#{name}" + search_query)
|
32
46
|
end
|
33
47
|
|
34
48
|
# DELETE /service/rest/v1/tags/associate/{tagName}
|
35
|
-
def delete_associated_tag(name:, sha1
|
49
|
+
def delete_associated_tag(name:, sha1: nil, repository: nil, tag: nil)
|
36
50
|
repository ||= @team_config.tag_repository
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
51
|
+
parameters = {}
|
52
|
+
parameters['sha1'] = sha1 unless sha1.nil?
|
53
|
+
parameters['repository'] = repository unless repository.nil?
|
54
|
+
parameters['tag'] = tag unless tag.nil?
|
55
|
+
if parameters.empty?
|
56
|
+
puts_error(__method__)
|
57
|
+
return false
|
58
|
+
end
|
59
|
+
|
60
|
+
search_query = parameters.map do |parameter, value|
|
61
|
+
"#{parameter}=#{value}"
|
62
|
+
end.join("&")
|
63
|
+
|
64
|
+
@connection.delete(endpoint: "tags/associate/#{name}?" + search_query)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def puts_error(method)
|
71
|
+
puts "ERROR: NexusAPI::API::#{method}() requires AT LEAST one optional parameter to"
|
72
|
+
puts " be set otherwise ALL assets in Nexus will be tagged. If this is desired"
|
73
|
+
puts " please open an issue or a PR to add a new method to handle this case."
|
42
74
|
end
|
43
75
|
end
|
44
76
|
end
|
data/lib/endpoints/users.rb
CHANGED
@@ -1,9 +1,30 @@
|
|
1
1
|
module NexusAPI
|
2
2
|
class API
|
3
3
|
# GET /service/rest/beta/security/users
|
4
|
+
def list_users
|
5
|
+
@connection.get_response(endpoint: 'security/users', api_version: 'beta')
|
6
|
+
end
|
7
|
+
|
4
8
|
# POST /service/rest/beta/security/users
|
9
|
+
def create_user(user_id:, first_name:, last_name:, email:, password:, roles:)
|
10
|
+
parameters = {
|
11
|
+
'userId' => user_id,
|
12
|
+
'firstName' => first_name,
|
13
|
+
'lastName' => last_name,
|
14
|
+
'emailAddress' => email,
|
15
|
+
'password' => password,
|
16
|
+
'status' => 'active',
|
17
|
+
'roles' => roles,
|
18
|
+
}
|
19
|
+
@connection.post(endpoint: 'security/users', parameters: parameters, api_version: 'beta')
|
20
|
+
end
|
21
|
+
|
5
22
|
# PUT /service/rest/beta/security/users/{userId}
|
6
23
|
# DELETE /service/rest/beta/security/users/{userId}
|
24
|
+
def delete_user(user_id:)
|
25
|
+
@connection.delete(endpoint: "security/users/#{user_id}", api_version: 'beta')
|
26
|
+
end
|
27
|
+
|
7
28
|
# PUT /service/rest/beta/security/users/{userId}/change-password
|
8
29
|
# DELETE /service/rest/beta/security/users/{userId}/user-token
|
9
30
|
end
|
@@ -51,16 +51,31 @@ module NexusAPI
|
|
51
51
|
print_paginating_set(action: :list_components, params: {repository: options[:repository]}, filter: 'name', proc: proc)
|
52
52
|
end
|
53
53
|
|
54
|
+
desc 'privileges', 'Prints out a list of all privileges'
|
55
|
+
def privileges
|
56
|
+
print_set(action: :list_privileges, filter: 'name')
|
57
|
+
end
|
58
|
+
|
54
59
|
desc 'repositories', 'Prints out a list of all repositories'
|
55
60
|
def repositories
|
56
61
|
print_set(action: :list_repositories, filter: 'name')
|
57
62
|
end
|
58
63
|
|
64
|
+
desc 'roles', 'Prints out a list of all roles'
|
65
|
+
def roles
|
66
|
+
print_set(action: :list_roles, filter: 'name')
|
67
|
+
end
|
68
|
+
|
59
69
|
desc 'status', 'Prints out if the Nexus server can respond to read and write requests'
|
60
70
|
def status
|
61
71
|
setup
|
62
72
|
puts "Nexus can respond to read requests: #{@api.status}"
|
63
73
|
puts "Nexus can respond to write requests: #{@api.status_writable}"
|
64
74
|
end
|
75
|
+
|
76
|
+
desc 'users', 'Prints out a list of all users'
|
77
|
+
def users
|
78
|
+
print_set(action: :list_users, filter: 'emailAddress')
|
79
|
+
end
|
65
80
|
end
|
66
81
|
end
|
@@ -31,7 +31,7 @@ module NexusAPI
|
|
31
31
|
desc 'list', 'Prints out a list of all tags'
|
32
32
|
option :full, :aliases => '-f', :desc => 'Print full JSON output'
|
33
33
|
def list
|
34
|
-
|
34
|
+
print_paginating_set(action: :list_tags, params: {}, filter: 'name')
|
35
35
|
end
|
36
36
|
|
37
37
|
desc 'remove', 'Removes a tag from an asset'
|
@@ -15,8 +15,8 @@ module NexusAPI
|
|
15
15
|
return false unless docker_valid?
|
16
16
|
image_name = image_name(@pull_host, image_name, tag)
|
17
17
|
begin
|
18
|
-
|
19
|
-
rescue Docker::Error::NotFoundError
|
18
|
+
@docker.pull_image(@username, @password, image_name)
|
19
|
+
rescue Docker::Error::NotFoundError
|
20
20
|
puts "ERROR: Failed to pull Docker image #{image_name}.\nDoes it exist in Nexus?"
|
21
21
|
return false
|
22
22
|
end
|
@@ -88,7 +88,11 @@ module NexusAPI
|
|
88
88
|
|
89
89
|
def handle(error)
|
90
90
|
puts "ERROR: Request failed"
|
91
|
-
|
91
|
+
if error.is_a?(RestClient::Response)
|
92
|
+
puts error.description
|
93
|
+
else
|
94
|
+
puts error.to_s
|
95
|
+
end
|
92
96
|
end
|
93
97
|
|
94
98
|
def catch_connection_error
|
@@ -98,8 +102,12 @@ module NexusAPI
|
|
98
102
|
return handle(error)
|
99
103
|
rescue RestClient::Unauthorized => error
|
100
104
|
return handle(error)
|
105
|
+
rescue RestClient::Exceptions::ReadTimeout => error
|
106
|
+
return handle(error)
|
101
107
|
rescue RestClient::ExceptionWithResponse => error
|
102
108
|
return handle(error.response)
|
109
|
+
rescue StandardError => error
|
110
|
+
return handle(error)
|
103
111
|
end
|
104
112
|
end
|
105
113
|
|
@@ -108,6 +116,7 @@ module NexusAPI
|
|
108
116
|
end
|
109
117
|
|
110
118
|
def send_request(connection_method, endpoint, parameters: '', headers: {}, api_version: 'v1')
|
119
|
+
parameters = parameters.to_json if headers['Content-Type'] == 'application/json'
|
111
120
|
url = "https://#{@hostname}/service/rest/#{api_version}/#{endpoint}"
|
112
121
|
catch_connection_error do
|
113
122
|
RestClient::Request.execute(
|
@@ -120,10 +129,11 @@ module NexusAPI
|
|
120
129
|
end
|
121
130
|
|
122
131
|
def send_get(endpoint, paginate, headers, api_version)
|
132
|
+
url_marker = endpoint.include?('?') ? '&' : '?'
|
123
133
|
# paginate answers is the user requesting pagination, paginate? answers does a continuation token exist
|
124
134
|
# if an empty continuation token is included in the request we'll get an ArrayIndexOutOfBoundsException
|
125
|
-
endpoint += "
|
126
|
-
|
135
|
+
endpoint += "#{url_marker}continuationToken=#{@continuation_token}" if paginate && paginate?
|
136
|
+
send_request(
|
127
137
|
:get,
|
128
138
|
endpoint,
|
129
139
|
headers: headers,
|
data/lib/nexus_api/version.rb
CHANGED
@@ -30,7 +30,7 @@ module NexusAPI
|
|
30
30
|
'forceBasicAuth' => true,
|
31
31
|
'httpPort' => port
|
32
32
|
}
|
33
|
-
}
|
33
|
+
}
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.maven_hosted(name, write_policy: ALLOW_ONCE, version_policy: RELEASE, layout_policy: STRICT)
|
@@ -46,7 +46,7 @@ module NexusAPI
|
|
46
46
|
'versionPolicy' => version_policy,
|
47
47
|
'layoutPolicy' => layout_policy
|
48
48
|
}
|
49
|
-
}
|
49
|
+
}
|
50
50
|
end
|
51
51
|
|
52
52
|
def self.npm_hosted(name, write_policy: ALLOW_ONCE)
|
@@ -58,7 +58,7 @@ module NexusAPI
|
|
58
58
|
'strictContentTypeValidation' => true,
|
59
59
|
'writePolicy' => write_policy
|
60
60
|
}
|
61
|
-
}
|
61
|
+
}
|
62
62
|
end
|
63
63
|
|
64
64
|
def self.pypi_hosted(name, write_policy: ALLOW_ONCE)
|
@@ -70,7 +70,7 @@ module NexusAPI
|
|
70
70
|
'strictContentTypeValidation' => true,
|
71
71
|
'writePolicy' => write_policy
|
72
72
|
}
|
73
|
-
}
|
73
|
+
}
|
74
74
|
end
|
75
75
|
|
76
76
|
def self.yum_hosted(name, depth, write_policy: ALLOW_ONCE, deploy_policy: STRICT)
|
@@ -86,7 +86,7 @@ module NexusAPI
|
|
86
86
|
'repodataDepth' => depth,
|
87
87
|
'deployPolicy' => deploy_policy
|
88
88
|
}
|
89
|
-
}
|
89
|
+
}
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|