nexus_api 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +17 -5
- data/lib/endpoints/assets.rb +16 -0
- data/lib/endpoints/blobstore.rb +17 -0
- data/lib/endpoints/components.rb +79 -0
- data/lib/endpoints/content-selectors.rb +9 -0
- data/lib/endpoints/email.rb +8 -0
- data/lib/endpoints/formats.rb +6 -0
- data/lib/endpoints/iq.rb +9 -0
- data/lib/endpoints/ldap.rb +10 -0
- data/lib/endpoints/license.rb +7 -0
- data/lib/endpoints/lifecycle.rb +7 -0
- data/lib/endpoints/privileges.rb +19 -0
- data/lib/endpoints/read-only.rb +8 -0
- data/lib/endpoints/realms.rb +7 -0
- data/lib/endpoints/repositories.rb +104 -0
- data/lib/endpoints/roles.rb +9 -0
- data/lib/endpoints/routing-rules.rb +9 -0
- data/lib/endpoints/saml.rb +9 -0
- data/lib/endpoints/script.rb +37 -0
- data/lib/endpoints/search.rb +18 -0
- data/lib/endpoints/ssl.rb +8 -0
- data/lib/endpoints/staging.rb +6 -0
- data/lib/endpoints/status.rb +15 -0
- data/lib/endpoints/support.rb +5 -0
- data/lib/endpoints/tags.rb +44 -0
- data/lib/endpoints/tasks.rb +8 -0
- data/lib/endpoints/user-sources.rb +5 -0
- data/lib/endpoints/user-tokens.rb +5 -0
- data/lib/endpoints/users.rb +10 -0
- data/lib/endpoints.rb +28 -0
- data/lib/nexus_api/nexus_connection.rb +20 -15
- data/lib/nexus_api/version.rb +1 -1
- data/lib/nexus_api.rb +1 -284
- data/lib/utilities/parameter_builder.rb +92 -0
- data/nexus_api.gemspec +2 -1
- metadata +47 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54540d2831ebe3afc8edbb9dbb5e32f68100d3f4618306d0818edb00ed74a3c8
|
4
|
+
data.tar.gz: d950c2e81a149d411b3d13fb6635488ff79f794d0d7a585069b8a2b39915ebc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a24f487215f4994725270ac80c522257622113f86019f0f99af7d02d8abad5564bfbb6a353ffb12b851b0b69f3af8b2571e31a313b13bdf7ea63fe3d5000953
|
7
|
+
data.tar.gz: 7e9a259841115128402c789caf2b72e84160c50949f08367c38acb9199c6136e8fe0f5620e0eda9fa2c33cb6b40fb1943a8bf8e14f559b4cd7a428837213a8a4
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,15 @@ 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.1.0](https://github.com/Cisco-AMP/nexus_api/compare/v1.0.4...v1.1.0) - 2020-04-20
|
9
|
+
### Changed
|
10
|
+
- `list_repositories` to use the new `beta` API version which returns richer content than the old `v1` version
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- create methods for hosted `docker`, `maven`, `npm`, `pypi`, and `yum` repository types (`raw` and `rubygems` aren't supported yet)
|
14
|
+
- delete method for any repository type
|
15
|
+
|
16
|
+
|
8
17
|
## [1.0.4](https://github.com/Cisco-AMP/nexus_api/compare/v1.0.3...v1.0.4) - 2020-03-23
|
9
18
|
### Added
|
10
19
|
- URL escaping
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nexus_api (1.0
|
4
|
+
nexus_api (1.1.0)
|
5
5
|
bundler (~> 2)
|
6
6
|
docker-api (~> 1.34.2)
|
7
7
|
dotenv (~> 2.7.5)
|
@@ -13,7 +13,11 @@ PATH
|
|
13
13
|
GEM
|
14
14
|
remote: https://rubygems.org/
|
15
15
|
specs:
|
16
|
+
addressable (2.7.0)
|
17
|
+
public_suffix (>= 2.0.2, < 5.0)
|
16
18
|
coderay (1.1.2)
|
19
|
+
crack (0.4.3)
|
20
|
+
safe_yaml (~> 1.0.0)
|
17
21
|
diff-lcs (1.3)
|
18
22
|
docile (1.3.2)
|
19
23
|
docker-api (1.34.2)
|
@@ -22,12 +26,13 @@ GEM
|
|
22
26
|
domain_name (0.5.20190701)
|
23
27
|
unf (>= 0.0.5, < 1.0.0)
|
24
28
|
dotenv (2.7.5)
|
25
|
-
excon (0.
|
29
|
+
excon (0.73.0)
|
30
|
+
hashdiff (1.0.1)
|
26
31
|
http-accept (1.7.0)
|
27
32
|
http-cookie (1.0.3)
|
28
33
|
domain_name (~> 0.5)
|
29
34
|
method_source (0.9.2)
|
30
|
-
mime-types (3.3)
|
35
|
+
mime-types (3.3.1)
|
31
36
|
mime-types-data (~> 3.2015)
|
32
37
|
mime-types-data (3.2019.1009)
|
33
38
|
multi_json (1.14.1)
|
@@ -35,6 +40,7 @@ GEM
|
|
35
40
|
pry (0.12.2)
|
36
41
|
coderay (~> 1.1.0)
|
37
42
|
method_source (~> 0.9.0)
|
43
|
+
public_suffix (4.0.4)
|
38
44
|
rake (10.5.0)
|
39
45
|
rest-client (2.1.0)
|
40
46
|
http-accept (>= 1.7.0, < 2.0)
|
@@ -54,6 +60,7 @@ GEM
|
|
54
60
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
61
|
rspec-support (~> 3.9.0)
|
56
62
|
rspec-support (3.9.0)
|
63
|
+
safe_yaml (1.0.5)
|
57
64
|
simplecov (0.18.5)
|
58
65
|
docile (~> 1.1)
|
59
66
|
simplecov-html (~> 0.11)
|
@@ -61,7 +68,11 @@ GEM
|
|
61
68
|
thor (0.20.3)
|
62
69
|
unf (0.1.4)
|
63
70
|
unf_ext
|
64
|
-
unf_ext (0.0.7.
|
71
|
+
unf_ext (0.0.7.7)
|
72
|
+
webmock (3.8.3)
|
73
|
+
addressable (>= 2.3.6)
|
74
|
+
crack (>= 0.3.2)
|
75
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
65
76
|
|
66
77
|
PLATFORMS
|
67
78
|
ruby
|
@@ -69,7 +80,8 @@ PLATFORMS
|
|
69
80
|
DEPENDENCIES
|
70
81
|
nexus_api!
|
71
82
|
rspec (~> 3.0)
|
72
|
-
simplecov (~> 0.18
|
83
|
+
simplecov (~> 0.18)
|
84
|
+
webmock (~> 3.8)
|
73
85
|
|
74
86
|
BUNDLED WITH
|
75
87
|
2.0.2
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/v1/assets
|
4
|
+
def list_assets(repository: nil, paginate: false)
|
5
|
+
repository ||= @team_config.assets_repository
|
6
|
+
@connection.get_response(endpoint: "assets?repository=#{repository}", paginate: paginate)
|
7
|
+
end
|
8
|
+
|
9
|
+
# GET /service/rest/v1/assets/{id}
|
10
|
+
def list_asset(id:)
|
11
|
+
@connection.get_response(endpoint: "assets/#{id}")
|
12
|
+
end
|
13
|
+
|
14
|
+
# DELETE /service/rest/v1/assets/{id}
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/beta/blobstores
|
4
|
+
# DELETE /service/rest/beta/blobstores/{name}
|
5
|
+
# POST /service/rest/beta/blobstores/file
|
6
|
+
# GET /service/rest/beta/blobstores/file/{name}
|
7
|
+
# PUT /service/rest/beta/blobstores/file/{name}
|
8
|
+
# POST /service/rest/beta/blobstores/group
|
9
|
+
# GET /service/rest/beta/blobstores/group/{name}
|
10
|
+
# PUT /service/rest/beta/blobstores/group/{name}
|
11
|
+
# POST /service/rest/beta/blobstores/group/promote/{name}
|
12
|
+
# POST /service/rest/beta/blobstores/s3
|
13
|
+
# GET /service/rest/beta/blobstores/s3/{name}
|
14
|
+
# PUT /service/rest/beta/blobstores/s3/{name}
|
15
|
+
# GET /service/rest/v1/blobstores/{id}/quota-status
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/v1/components
|
4
|
+
def list_components(repository: nil, paginate: false)
|
5
|
+
repository ||= @team_config.components_repository
|
6
|
+
@connection.get_response(endpoint: "components?repository=#{repository}", paginate: paginate)
|
7
|
+
end
|
8
|
+
|
9
|
+
# POST /service/rest/v1/components
|
10
|
+
def upload_maven_component(filename:, group_id:, artifact_id:, version:, repository: nil, tag: nil)
|
11
|
+
repository ||= @team_config.maven_repository
|
12
|
+
parameters = {
|
13
|
+
'maven2.groupId' => group_id,
|
14
|
+
'maven2.artifactId' => artifact_id,
|
15
|
+
'maven2.version' => version,
|
16
|
+
'maven2.asset1' => File.open(filename, 'r'),
|
17
|
+
'maven2.asset1.extension' => filename.split('.').last,
|
18
|
+
}
|
19
|
+
parameters['maven2.tag'] = tag if tag
|
20
|
+
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
21
|
+
end
|
22
|
+
|
23
|
+
def upload_npm_component(filename:, repository: nil, tag: nil)
|
24
|
+
repository ||= @team_config.npm_repository
|
25
|
+
parameters = {
|
26
|
+
'npm.asset' => File.open(filename, 'r'),
|
27
|
+
}
|
28
|
+
parameters['npm.tag'] = tag if tag
|
29
|
+
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
30
|
+
end
|
31
|
+
|
32
|
+
def upload_pypi_component(filename:, repository: nil, tag: nil)
|
33
|
+
repository ||= @team_config.pypi_repository
|
34
|
+
parameters = {
|
35
|
+
'pypi.asset' => File.open(filename, 'r'),
|
36
|
+
}
|
37
|
+
parameters['pypi.tag'] = tag if tag
|
38
|
+
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
39
|
+
end
|
40
|
+
|
41
|
+
def upload_raw_component(filename:, directory:, repository: nil, tag: nil)
|
42
|
+
repository ||= @team_config.raw_repository
|
43
|
+
parameters = {
|
44
|
+
'raw.directory' => directory,
|
45
|
+
'raw.asset1' => File.open(filename, 'r'),
|
46
|
+
'raw.asset1.filename' => filename.split('/').last,
|
47
|
+
}
|
48
|
+
parameters['raw.tag'] = tag if tag
|
49
|
+
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
50
|
+
end
|
51
|
+
|
52
|
+
def upload_rubygems_component(filename:, repository: nil, tag: nil)
|
53
|
+
repository ||= @team_config.rubygems_repository
|
54
|
+
parameters = {
|
55
|
+
'rubygems.asset' => File.open(filename, 'r'),
|
56
|
+
}
|
57
|
+
parameters['rubygems.tag'] = tag if tag
|
58
|
+
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
59
|
+
end
|
60
|
+
|
61
|
+
def upload_yum_component(filename:, directory:, repository: nil, tag: nil)
|
62
|
+
repository ||= @team_config.yum_repository
|
63
|
+
parameters = {
|
64
|
+
'yum.directory' => directory,
|
65
|
+
'yum.asset' => File.open(filename, 'r'),
|
66
|
+
'yum.asset.filename' => filename.split('/').last,
|
67
|
+
}
|
68
|
+
parameters['yum.tag'] = tag if tag
|
69
|
+
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
70
|
+
end
|
71
|
+
|
72
|
+
# GET /service/rest/v1/components/{id}
|
73
|
+
def list_component(id:)
|
74
|
+
@connection.get_response(endpoint: "components/#{id}")
|
75
|
+
end
|
76
|
+
|
77
|
+
# DELETE /service/rest/v1/components/{id}
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/beta/security/content-selectors
|
4
|
+
# POST /service/rest/beta/security/content-selectors
|
5
|
+
# GET /service/rest/beta/security/content-selectors/{name}
|
6
|
+
# PUT /service/rest/beta/security/content-selectors/{name}
|
7
|
+
# DELETE /service/rest/beta/security/content-selectors/{name}
|
8
|
+
end
|
9
|
+
end
|
data/lib/endpoints/iq.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/beta/security/ldap
|
4
|
+
# POST /service/rest/beta/security/ldap
|
5
|
+
# GET /service/rest/beta/security/ldap/{name}
|
6
|
+
# PUT /service/rest/beta/security/ldap/{name}
|
7
|
+
# DELETE /service/rest/beta/security/ldap/{name}
|
8
|
+
# POST /service/rest/beta/security/ldap/change-order
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/beta/security/privileges
|
4
|
+
# GET /service/rest/beta/security/privileges/{privilegeId}
|
5
|
+
# DELETE /service/rest/beta/security/privileges/{privilegeId}
|
6
|
+
# POST /service/rest/beta/security/privileges/application
|
7
|
+
# PUT /service/rest/beta/security/privileges/application/{privilegeId}
|
8
|
+
# POST /service/rest/beta/security/privileges/repository-admin
|
9
|
+
# PUT /service/rest/beta/security/privileges/repository-admin/{privilegeId}
|
10
|
+
# POST /service/rest/beta/security/privileges/repository-content-selector
|
11
|
+
# PUT /service/rest/beta/security/privileges/repository-content-selector/{privilegeId}
|
12
|
+
# POST /service/rest/beta/security/privileges/repository-view
|
13
|
+
# PUT /service/rest/beta/security/privileges/repository-view/{privilegeId}
|
14
|
+
# POST /service/rest/beta/security/privileges/script
|
15
|
+
# PUT /service/rest/beta/security/privileges/script/{privilegeId}
|
16
|
+
# POST /service/rest/beta/security/privileges/wildcard
|
17
|
+
# PUT /service/rest/beta/security/privileges/wildcard/{privilegeId}
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'utilities/parameter_builder'
|
2
|
+
|
3
|
+
module NexusAPI
|
4
|
+
class API
|
5
|
+
# GET /service/rest/v1/repositories (This endpoint does not paginate)
|
6
|
+
# GET /service/rest/beta/repositories
|
7
|
+
def list_repositories
|
8
|
+
@connection.get_response(endpoint: 'repositories', api_version: 'beta')
|
9
|
+
end
|
10
|
+
|
11
|
+
def list_repository_names
|
12
|
+
list_repositories.map { |repo| repo['name'] }
|
13
|
+
end
|
14
|
+
|
15
|
+
# DELETE /service/rest/beta/repositories/{repositoryName}
|
16
|
+
def delete_repository(name:)
|
17
|
+
@connection.delete(endpoint: "repositories/#{name}", api_version: 'beta')
|
18
|
+
end
|
19
|
+
|
20
|
+
# POST /service/rest/beta/repositories/{repositoryName}/health-check
|
21
|
+
# DELETE /service/rest/beta/repositories/{repositoryName}/health-check
|
22
|
+
# POST /service/rest/beta/repositories/{repositoryName}/invalidate-cache
|
23
|
+
# POST /service/rest/beta/repositories/{repositoryName}/rebuild-index
|
24
|
+
# POST /service/rest/beta/repositories/apt/hosted
|
25
|
+
# PUT /service/rest/beta/repositories/apt/hosted/{repositoryName}
|
26
|
+
# POST /service/rest/beta/repositories/apt/proxy
|
27
|
+
# PUT /service/rest/beta/repositories/apt/proxy/{repositoryName}
|
28
|
+
# POST /service/rest/beta/repositories/bower/group
|
29
|
+
# PUT /service/rest/beta/repositories/bower/group/{repositoryName}
|
30
|
+
# POST /service/rest/beta/repositories/bower/hosted
|
31
|
+
# PUT /service/rest/beta/repositories/bower/hosted/{repositoryName}
|
32
|
+
# POST /service/rest/beta/repositories/bower/proxy
|
33
|
+
# PUT /service/rest/beta/repositories/bower/proxy/{repositoryName}
|
34
|
+
# POST /service/rest/beta/repositories/conan/proxy
|
35
|
+
# PUT /service/rest/beta/repositories/conan/proxy/{repositoryName}
|
36
|
+
# POST /service/rest/beta/repositories/docker/group
|
37
|
+
# PUT /service/rest/beta/repositories/docker/group/{repositoryName}
|
38
|
+
# POST /service/rest/beta/repositories/docker/hosted
|
39
|
+
def create_repository_docker_hosted(name:, port:)
|
40
|
+
parameters = ParameterBuilder.docker_hosted(name, port)
|
41
|
+
@connection.post(endpoint: 'repositories/docker/hosted', parameters: parameters, api_version: 'beta')
|
42
|
+
end
|
43
|
+
|
44
|
+
# PUT /service/rest/beta/repositories/docker/hosted/{repositoryName}
|
45
|
+
# POST /service/rest/beta/repositories/docker/proxy
|
46
|
+
# PUT /service/rest/beta/repositories/docker/proxy/{repositoryName}
|
47
|
+
# POST /service/rest/beta/repositories/gitlfs/hosted
|
48
|
+
# PUT /service/rest/beta/repositories/gitlfs/hosted/{repositoryName}
|
49
|
+
# POST /service/rest/beta/repositories/go/group
|
50
|
+
# PUT /service/rest/beta/repositories/go/group/{repositoryName}
|
51
|
+
# POST /service/rest/beta/repositories/go/proxy
|
52
|
+
# PUT /service/rest/beta/repositories/go/proxy/{repositoryName}
|
53
|
+
# POST /service/rest/beta/repositories/helm/hosted
|
54
|
+
# PUT /service/rest/beta/repositories/helm/hosted/{repositoryName}
|
55
|
+
# POST /service/rest/beta/repositories/helm/proxy
|
56
|
+
# PUT /service/rest/beta/repositories/helm/proxy/{repositoryName}
|
57
|
+
# POST /service/rest/beta/repositories/maven/hosted
|
58
|
+
def create_repository_maven_hosted(name:)
|
59
|
+
parameters = ParameterBuilder.maven_hosted(name)
|
60
|
+
@connection.post(endpoint: 'repositories/maven/hosted', parameters: parameters, api_version: 'beta')
|
61
|
+
end
|
62
|
+
|
63
|
+
# PUT /service/rest/beta/repositories/maven/hosted/{repositoryName}
|
64
|
+
# POST /service/rest/beta/repositories/maven/proxy
|
65
|
+
# PUT /service/rest/beta/repositories/maven/proxy/{repositoryName}
|
66
|
+
# POST /service/rest/beta/repositories/npm/group
|
67
|
+
# PUT /service/rest/beta/repositories/npm/group/{repositoryName}
|
68
|
+
# POST /service/rest/beta/repositories/npm/hosted
|
69
|
+
def create_repository_npm_hosted(name:)
|
70
|
+
parameters = ParameterBuilder.npm_hosted(name)
|
71
|
+
@connection.post(endpoint: 'repositories/npm/hosted', parameters: parameters, api_version: 'beta')
|
72
|
+
end
|
73
|
+
|
74
|
+
# PUT /service/rest/beta/repositories/npm/hosted/{repositoryName}
|
75
|
+
# POST /service/rest/beta/repositories/npm/proxy
|
76
|
+
# PUT /service/rest/beta/repositories/npm/proxy/{repositoryName}
|
77
|
+
# POST /service/rest/beta/repositories/nuget/group
|
78
|
+
# PUT /service/rest/beta/repositories/nuget/group/{repositoryName}
|
79
|
+
# POST /service/rest/beta/repositories/nuget/hosted
|
80
|
+
# PUT /service/rest/beta/repositories/nuget/hosted/{repositoryName}
|
81
|
+
# POST /service/rest/beta/repositories/nuget/proxy
|
82
|
+
# PUT /service/rest/beta/repositories/nuget/proxy/{repositoryName}
|
83
|
+
# POST /service/rest/beta/repositories/p2/proxy
|
84
|
+
# PUT /service/rest/beta/repositories/p2/proxy/{repositoryName}
|
85
|
+
# POST /service/rest/beta/repositories/pypi/group
|
86
|
+
# PUT /service/rest/beta/repositories/pypi/group/{repositoryName}
|
87
|
+
# POST /service/rest/beta/repositories/pypi/hosted
|
88
|
+
def create_repository_pypi_hosted(name:)
|
89
|
+
parameters = ParameterBuilder.pypi_hosted(name)
|
90
|
+
@connection.post(endpoint: 'repositories/pypi/hosted', parameters: parameters, api_version: 'beta')
|
91
|
+
end
|
92
|
+
|
93
|
+
# PUT /service/rest/beta/repositories/pypi/hosted/{repositoryName}
|
94
|
+
# POST /service/rest/beta/repositories/pypi/proxy
|
95
|
+
# PUT /service/rest/beta/repositories/pypi/proxy/{repositoryName}
|
96
|
+
# POST /service/rest/beta/repositories/yum/hosted
|
97
|
+
def create_repository_yum_hosted(name:, depth:)
|
98
|
+
parameters = ParameterBuilder.yum_hosted(name, depth)
|
99
|
+
@connection.post(endpoint: 'repositories/yum/hosted', parameters: parameters, api_version: 'beta')
|
100
|
+
end
|
101
|
+
|
102
|
+
# PUT /service/rest/beta/repositories/yum/hosted/{repositoryName}
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/beta/security/roles
|
4
|
+
# POST /service/rest/beta/security/roles
|
5
|
+
# GET /service/rest/beta/security/roles/{id}
|
6
|
+
# PUT /service/rest/beta/security/roles/{id}
|
7
|
+
# DELETE /service/rest/beta/security/roles/{id}
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/beta/routing-rules
|
4
|
+
# POST /service/rest/beta/routing-rules
|
5
|
+
# GET /service/rest/beta/routing-rules/{name}
|
6
|
+
# PUT /service/rest/beta/routing-rules/{name}
|
7
|
+
# DELETE /service/rest/beta/routing-rules/{name}
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/v1/script
|
4
|
+
def list_scripts
|
5
|
+
@connection.get_response(endpoint: "script")
|
6
|
+
end
|
7
|
+
|
8
|
+
# POST /service/rest/v1/script
|
9
|
+
def upload_script(filename:)
|
10
|
+
puts_deprecated_notice
|
11
|
+
file = File.read(filename)
|
12
|
+
@connection.post(endpoint: "script", parameters: file)
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /service/rest/v1/script/{name}
|
16
|
+
# PUT /service/rest/v1/script/{name}
|
17
|
+
# DELETE /service/rest/v1/script/{name}
|
18
|
+
def delete_script(name:)
|
19
|
+
@connection.delete(endpoint: "script/#{name}")
|
20
|
+
end
|
21
|
+
|
22
|
+
# POST /service/rest/v1/script/{name}/run
|
23
|
+
def run_script(name:)
|
24
|
+
puts_deprecated_notice
|
25
|
+
@connection.post(endpoint: "script/#{name}/run", headers: {'Content-Type' => 'text/plain'})
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def puts_deprecated_notice
|
32
|
+
puts 'WARNING: This endpoint has been disabled in Nexus due to a vulnerability'
|
33
|
+
puts ' and may not work as intended. An HTTP 410 is an indication of this'
|
34
|
+
puts ' See https://issues.sonatype.org/browse/NEXUS-23205 for details'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/v1/search
|
4
|
+
|
5
|
+
# GET /service/rest/v1/search/assets
|
6
|
+
def search_asset(name:, format: nil, repository: nil, sha1: nil, version: nil, paginate: false)
|
7
|
+
repository ||= @team_config.search_repository
|
8
|
+
endpoint = "search/assets?q=#{name}"
|
9
|
+
endpoint += "&format=#{format}" unless format.nil?
|
10
|
+
endpoint += "&repository=#{repository}" unless repository.nil?
|
11
|
+
endpoint += "&sha1=#{sha1}" unless sha1.nil?
|
12
|
+
endpoint += "&version=#{version}" unless version.nil?
|
13
|
+
@connection.get_response(endpoint: endpoint, paginate: paginate)
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /service/rest/v1/search/assets/download
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/v1/status
|
4
|
+
def status
|
5
|
+
@connection.get(endpoint: 'status')
|
6
|
+
end
|
7
|
+
|
8
|
+
# GET /service/rest/v1/status/check
|
9
|
+
|
10
|
+
# GET /service/rest/v1/status/writable
|
11
|
+
def status_writable
|
12
|
+
@connection.get(endpoint: 'status/writable')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/v1/tags
|
4
|
+
def list_tags(paginate: false)
|
5
|
+
@connection.get_response(endpoint: 'tags', paginate: paginate)
|
6
|
+
end
|
7
|
+
|
8
|
+
# POST /service/rest/v1/tags
|
9
|
+
def create_tag(name:)
|
10
|
+
parameters = JSON.dump({
|
11
|
+
'name' => name,
|
12
|
+
})
|
13
|
+
@connection.post(endpoint: 'tags', parameters: parameters)
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /service/rest/v1/tags/{name}
|
17
|
+
# PUT /service/rest/v1/tags/{name}
|
18
|
+
# DELETE /service/rest/v1/tags/{name}
|
19
|
+
def delete_tag(name:)
|
20
|
+
@connection.delete(endpoint: "tags/#{name}")
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST /service/rest/v1/tags/associate/{tagName}
|
24
|
+
def associate_tag(name:, sha1:, repository: nil)
|
25
|
+
repository ||= @team_config.tag_repository
|
26
|
+
search_query =
|
27
|
+
"?"\
|
28
|
+
"wait=true&"\
|
29
|
+
"repository=#{repository}&"\
|
30
|
+
"sha1=#{sha1}"
|
31
|
+
@connection.post(endpoint: "tags/associate/#{name}" + search_query)
|
32
|
+
end
|
33
|
+
|
34
|
+
# DELETE /service/rest/v1/tags/associate/{tagName}
|
35
|
+
def delete_associated_tag(name:, sha1:, repository: nil)
|
36
|
+
repository ||= @team_config.tag_repository
|
37
|
+
search_query =
|
38
|
+
"?"\
|
39
|
+
"repository=#{repository}&"\
|
40
|
+
"sha1=#{sha1}"
|
41
|
+
@connection.delete(endpoint: "tags/associate/#{name}" + search_query)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module NexusAPI
|
2
|
+
class API
|
3
|
+
# GET /service/rest/beta/security/users
|
4
|
+
# POST /service/rest/beta/security/users
|
5
|
+
# PUT /service/rest/beta/security/users/{userId}
|
6
|
+
# DELETE /service/rest/beta/security/users/{userId}
|
7
|
+
# PUT /service/rest/beta/security/users/{userId}/change-password
|
8
|
+
# DELETE /service/rest/beta/security/users/{userId}/user-token
|
9
|
+
end
|
10
|
+
end
|
data/lib/endpoints.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'endpoints/assets'
|
2
|
+
require 'endpoints/blobstore'
|
3
|
+
require 'endpoints/components'
|
4
|
+
require 'endpoints/content-selectors'
|
5
|
+
require 'endpoints/email'
|
6
|
+
require 'endpoints/formats'
|
7
|
+
require 'endpoints/iq'
|
8
|
+
require 'endpoints/ldap'
|
9
|
+
require 'endpoints/license'
|
10
|
+
require 'endpoints/lifecycle'
|
11
|
+
require 'endpoints/privileges'
|
12
|
+
require 'endpoints/read-only'
|
13
|
+
require 'endpoints/realms'
|
14
|
+
require 'endpoints/repositories'
|
15
|
+
require 'endpoints/roles'
|
16
|
+
require 'endpoints/routing-rules'
|
17
|
+
require 'endpoints/saml'
|
18
|
+
require 'endpoints/script'
|
19
|
+
require 'endpoints/search'
|
20
|
+
require 'endpoints/ssl'
|
21
|
+
require 'endpoints/staging'
|
22
|
+
require 'endpoints/status'
|
23
|
+
require 'endpoints/support'
|
24
|
+
require 'endpoints/tags'
|
25
|
+
require 'endpoints/tasks'
|
26
|
+
require 'endpoints/user-sources'
|
27
|
+
require 'endpoints/user-tokens'
|
28
|
+
require 'endpoints/users'
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'base64'
|
2
|
+
require 'json'
|
2
3
|
require 'rest-client'
|
3
4
|
require 'uri'
|
4
5
|
|
5
6
|
module NexusAPI
|
6
7
|
class NexusConnection
|
7
|
-
VALID_RESPONSE_CODES = [200, 204].freeze
|
8
|
+
VALID_RESPONSE_CODES = [200, 201, 204].freeze
|
8
9
|
|
9
10
|
attr_accessor :continuation_token
|
10
11
|
|
@@ -14,40 +15,43 @@ module NexusAPI
|
|
14
15
|
@hostname = hostname
|
15
16
|
end
|
16
17
|
|
17
|
-
def get_response(endpoint:, paginate: false, headers: {'Content-Type' => 'application/json'})
|
18
|
-
response = send_get(endpoint, paginate, headers)
|
18
|
+
def get_response(endpoint:, paginate: false, headers: {'Content-Type' => 'application/json'}, api_version: 'v1')
|
19
|
+
response = send_get(endpoint, paginate, headers, api_version)
|
19
20
|
response.nil? ? Hash.new : jsonize(response)
|
20
21
|
end
|
21
22
|
|
22
|
-
def get(endpoint:, paginate: false, headers: {'Content-Type' => 'application/json'})
|
23
|
-
valid?(send_get(endpoint, paginate, headers))
|
23
|
+
def get(endpoint:, paginate: false, headers: {'Content-Type' => 'application/json'}, api_version: 'v1')
|
24
|
+
valid?(send_get(endpoint, paginate, headers, api_version))
|
24
25
|
end
|
25
26
|
|
26
|
-
def post(endpoint:, parameters: '', headers: {'Content-Type' => 'application/json'})
|
27
|
+
def post(endpoint:, parameters: '', headers: {'Content-Type' => 'application/json'}, api_version: 'v1')
|
27
28
|
response = send_request(
|
28
29
|
:post,
|
29
30
|
endpoint,
|
30
31
|
parameters: parameters,
|
31
|
-
headers: headers
|
32
|
+
headers: headers,
|
33
|
+
api_version: api_version
|
32
34
|
)
|
33
35
|
valid?(response)
|
34
36
|
end
|
35
37
|
|
36
|
-
def put(endpoint:, parameters: '', headers: {'Content-Type' => 'application/json'})
|
38
|
+
def put(endpoint:, parameters: '', headers: {'Content-Type' => 'application/json'}, api_version: 'v1')
|
37
39
|
response = send_request(
|
38
40
|
:put,
|
39
41
|
endpoint,
|
40
42
|
parameters: parameters,
|
41
|
-
headers: headers
|
43
|
+
headers: headers,
|
44
|
+
api_version: api_version
|
42
45
|
)
|
43
46
|
valid?(response)
|
44
47
|
end
|
45
48
|
|
46
|
-
def delete(endpoint:, headers: {'Content-Type' => 'application/json'})
|
49
|
+
def delete(endpoint:, headers: {'Content-Type' => 'application/json'}, api_version: 'v1')
|
47
50
|
response = send_request(
|
48
51
|
:delete,
|
49
52
|
endpoint,
|
50
|
-
headers: headers
|
53
|
+
headers: headers,
|
54
|
+
api_version: api_version
|
51
55
|
)
|
52
56
|
valid?(response)
|
53
57
|
end
|
@@ -103,8 +107,8 @@ module NexusAPI
|
|
103
107
|
{ :Authorization => 'Basic ' + Base64.strict_encode64( "#{@username}:#{@password}" ) }
|
104
108
|
end
|
105
109
|
|
106
|
-
def send_request(connection_method, endpoint, parameters: '', headers: {})
|
107
|
-
url = "https://#{@hostname}/service/rest
|
110
|
+
def send_request(connection_method, endpoint, parameters: '', headers: {}, api_version: 'v1')
|
111
|
+
url = "https://#{@hostname}/service/rest/#{api_version}/#{endpoint}"
|
108
112
|
catch_connection_error do
|
109
113
|
RestClient::Request.execute(
|
110
114
|
method: connection_method,
|
@@ -115,14 +119,15 @@ module NexusAPI
|
|
115
119
|
end
|
116
120
|
end
|
117
121
|
|
118
|
-
def send_get(endpoint, paginate, headers)
|
122
|
+
def send_get(endpoint, paginate, headers, api_version)
|
119
123
|
# paginate answers is the user requesting pagination, paginate? answers does a continuation token exist
|
120
124
|
# if an empty continuation token is included in the request we'll get an ArrayIndexOutOfBoundsException
|
121
125
|
endpoint += "&continuationToken=#{@continuation_token}" if paginate && paginate?
|
122
126
|
response = send_request(
|
123
127
|
:get,
|
124
128
|
endpoint,
|
125
|
-
headers: headers
|
129
|
+
headers: headers,
|
130
|
+
api_version: api_version
|
126
131
|
)
|
127
132
|
end
|
128
133
|
|
data/lib/nexus_api/version.rb
CHANGED
data/lib/nexus_api.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
require 'endpoints'
|
1
2
|
require 'nexus_api/version'
|
2
3
|
require 'nexus_api/docker_shell'
|
3
4
|
require 'nexus_api/docker_manager'
|
4
5
|
require 'nexus_api/nexus_connection'
|
5
6
|
require 'nexus_api/config_manager'
|
6
|
-
require 'json'
|
7
7
|
require 'pry'
|
8
8
|
|
9
9
|
# Nexus API docs:
|
@@ -40,289 +40,6 @@ module NexusAPI
|
|
40
40
|
@team_config = NexusAPI::ConfigManager.new(config_path: team_config)
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
# ---ASSETS---
|
45
|
-
# GET /service/rest/v1/assets
|
46
|
-
def list_assets(repository: nil, paginate: false)
|
47
|
-
repository ||= @team_config.assets_repository
|
48
|
-
@connection.get_response(endpoint: "assets?repository=#{repository}", paginate: paginate)
|
49
|
-
end
|
50
|
-
|
51
|
-
# GET /service/rest/v1/assets/{id}
|
52
|
-
def list_asset(id:)
|
53
|
-
@connection.get_response(endpoint: "assets/#{id}")
|
54
|
-
end
|
55
|
-
|
56
|
-
# DELETE /service/rest/v1/assets/{id}
|
57
|
-
|
58
|
-
|
59
|
-
# ---BLOB STORE---
|
60
|
-
# GET /service/rest/v1/blobstores/{id}/quota-status
|
61
|
-
|
62
|
-
|
63
|
-
# ---COMPONENTS---
|
64
|
-
# GET /service/rest/v1/components
|
65
|
-
def list_components(repository: nil, paginate: false)
|
66
|
-
repository ||= @team_config.components_repository
|
67
|
-
@connection.get_response(endpoint: "components?repository=#{repository}", paginate: paginate)
|
68
|
-
end
|
69
|
-
|
70
|
-
# POST /service/rest/v1/components
|
71
|
-
def upload_maven_component(filename:, group_id:, artifact_id:, version:, repository: nil, tag: nil)
|
72
|
-
repository ||= @team_config.maven_repository
|
73
|
-
parameters = {
|
74
|
-
'maven2.groupId' => group_id,
|
75
|
-
'maven2.artifactId' => artifact_id,
|
76
|
-
'maven2.version' => version,
|
77
|
-
'maven2.asset1' => File.open(filename, 'r'),
|
78
|
-
'maven2.asset1.extension' => filename.split('.').last,
|
79
|
-
}
|
80
|
-
parameters['maven2.tag'] = tag if tag
|
81
|
-
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
82
|
-
end
|
83
|
-
|
84
|
-
def upload_npm_component(filename:, repository: nil, tag: nil)
|
85
|
-
repository ||= @team_config.npm_repository
|
86
|
-
parameters = {
|
87
|
-
'npm.asset' => File.open(filename, 'r'),
|
88
|
-
}
|
89
|
-
parameters['npm.tag'] = tag if tag
|
90
|
-
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
91
|
-
end
|
92
|
-
|
93
|
-
def upload_pypi_component(filename:, repository: nil, tag: nil)
|
94
|
-
repository ||= @team_config.pypi_repository
|
95
|
-
parameters = {
|
96
|
-
'pypi.asset' => File.open(filename, 'r'),
|
97
|
-
}
|
98
|
-
parameters['pypi.tag'] = tag if tag
|
99
|
-
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
100
|
-
end
|
101
|
-
|
102
|
-
def upload_raw_component(filename:, directory:, repository: nil, tag: nil)
|
103
|
-
repository ||= @team_config.raw_repository
|
104
|
-
parameters = {
|
105
|
-
'raw.directory' => directory,
|
106
|
-
'raw.asset1' => File.open(filename, 'r'),
|
107
|
-
'raw.asset1.filename' => filename.split('/').last,
|
108
|
-
}
|
109
|
-
parameters['raw.tag'] = tag if tag
|
110
|
-
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
111
|
-
end
|
112
|
-
|
113
|
-
def upload_rubygems_component(filename:, repository: nil, tag: nil)
|
114
|
-
repository ||= @team_config.rubygems_repository
|
115
|
-
parameters = {
|
116
|
-
'rubygems.asset' => File.open(filename, 'r'),
|
117
|
-
}
|
118
|
-
parameters['rubygems.tag'] = tag if tag
|
119
|
-
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
120
|
-
end
|
121
|
-
|
122
|
-
def upload_yum_component(filename:, directory:, repository: nil, tag: nil)
|
123
|
-
repository ||= @team_config.yum_repository
|
124
|
-
parameters = {
|
125
|
-
'yum.directory' => directory,
|
126
|
-
'yum.asset' => File.open(filename, 'r'),
|
127
|
-
'yum.asset.filename' => filename.split('/').last,
|
128
|
-
}
|
129
|
-
parameters['yum.tag'] = tag if tag
|
130
|
-
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
131
|
-
end
|
132
|
-
|
133
|
-
# GET /service/rest/v1/components/{id}
|
134
|
-
def list_component(id:)
|
135
|
-
@connection.get_response(endpoint: "components/#{id}")
|
136
|
-
end
|
137
|
-
|
138
|
-
# DELETE /service/rest/v1/components/{id}
|
139
|
-
|
140
|
-
|
141
|
-
# ---FORMATS---
|
142
|
-
# GET /service/rest/v1/formats/{format}/upload-specs
|
143
|
-
# GET /service/rest/v1/formats/upload-specs
|
144
|
-
|
145
|
-
|
146
|
-
# ---LIFECYCLE---
|
147
|
-
# PUT /service/rest/v1/lifecycle/bounce
|
148
|
-
# GET /service/rest/v1/lifecycle/phase
|
149
|
-
# PUT /service/rest/v1/lifecycle/phase
|
150
|
-
|
151
|
-
|
152
|
-
# ---MAINTENANCE---
|
153
|
-
# PUT /service/rest/v1/maintenance/{databaseName}/check
|
154
|
-
# PUT /service/rest/v1/maintenance/{databaseName}/reinstall
|
155
|
-
# PUT /service/rest/v1/maintenance/{databaseName}/repair
|
156
|
-
# GET /service/rest/v1/maintenance/{databaseName}/role
|
157
|
-
# PUT /service/rest/v1/maintenance/{databaseName}/role
|
158
|
-
# GET /service/rest/v1/maintenance/{databaseName}/status
|
159
|
-
# PUT /service/rest/v1/maintenance/{databaseName}/status
|
160
|
-
|
161
|
-
|
162
|
-
# ---NODES---
|
163
|
-
# GET /service/rest/v1/nodes
|
164
|
-
# PUT /service/rest/v1/nodes
|
165
|
-
# GET /service/rest/v1/nodes/supportzipdownload
|
166
|
-
# POST /service/rest/v1/nodes/supportzips
|
167
|
-
|
168
|
-
|
169
|
-
# ---READ-ONLY---
|
170
|
-
# GET /service/rest/v1/read-only
|
171
|
-
# POST /service/rest/v1/read-only/force-release
|
172
|
-
# POST /service/rest/v1/read-only/freeze
|
173
|
-
# POST /service/rest/v1/read-only/release
|
174
|
-
|
175
|
-
|
176
|
-
# ---REPOSITORIES--- (This endpoint does not paginate)
|
177
|
-
# GET /service/rest/v1/repositories
|
178
|
-
def list_repositories
|
179
|
-
@connection.get_response(endpoint: 'repositories')
|
180
|
-
end
|
181
|
-
|
182
|
-
def list_repository_names
|
183
|
-
list_repositories.map { |repo| repo['name'] }
|
184
|
-
end
|
185
|
-
|
186
|
-
|
187
|
-
# ---ROUTING-RULES---
|
188
|
-
# GET /service/rest/v1/beta/routing-rules
|
189
|
-
# POST /service/rest/v1/beta/routing-rules
|
190
|
-
# GET /service/rest/v1/beta/routing-rules/{name}
|
191
|
-
# PUT /service/rest/v1/beta/routing-rules/{name}
|
192
|
-
# DELETE /service/rest/v1/beta/routing-rules/{name}
|
193
|
-
|
194
|
-
|
195
|
-
# ---SCRIPT---
|
196
|
-
# GET /service/rest/v1/script
|
197
|
-
def list_scripts
|
198
|
-
@connection.get_response(endpoint: "script")
|
199
|
-
end
|
200
|
-
|
201
|
-
# POST /service/rest/v1/script
|
202
|
-
def upload_script(filename:)
|
203
|
-
file = File.read(filename)
|
204
|
-
@connection.post(endpoint: "script", parameters: file)
|
205
|
-
end
|
206
|
-
|
207
|
-
# GET /service/rest/v1/script/{name}
|
208
|
-
# PUT /service/rest/v1/script/{name}
|
209
|
-
# DELETE /service/rest/v1/script/{name}
|
210
|
-
def delete_script(name:)
|
211
|
-
@connection.delete(endpoint: "script/#{name}")
|
212
|
-
end
|
213
|
-
|
214
|
-
# POST /service/rest/v1/script/{name}/run
|
215
|
-
def run_script(name:)
|
216
|
-
@connection.post(endpoint: "script/#{name}/run", headers: {'Content-Type' => 'text/plain'})
|
217
|
-
end
|
218
|
-
|
219
|
-
|
220
|
-
# ---SEARCH---
|
221
|
-
# GET /service/rest/v1/search
|
222
|
-
|
223
|
-
# GET /service/rest/v1/search/assets
|
224
|
-
def search_asset(name:, format: nil, repository: nil, sha1: nil, version: nil, paginate: false)
|
225
|
-
repository ||= @team_config.search_repository
|
226
|
-
endpoint = "search/assets?q=#{name}"
|
227
|
-
endpoint += "&format=#{format}" unless format.nil?
|
228
|
-
endpoint += "&repository=#{repository}" unless repository.nil?
|
229
|
-
endpoint += "&sha1=#{sha1}" unless sha1.nil?
|
230
|
-
endpoint += "&version=#{version}" unless version.nil?
|
231
|
-
@connection.get_response(endpoint: endpoint, paginate: paginate)
|
232
|
-
end
|
233
|
-
|
234
|
-
# GET /service/rest/v1/search/assets/download
|
235
|
-
|
236
|
-
|
237
|
-
# ---SECURITY MANAGEMENT---
|
238
|
-
# GET /service/rest/v1/beta/security/user-sources
|
239
|
-
|
240
|
-
|
241
|
-
# ---SECURITY MANAGEMENT: USER TOKENS---
|
242
|
-
# DELETE /service/rest/v1/beta/security/user-tokens
|
243
|
-
|
244
|
-
|
245
|
-
# ---SECURITY MANAGEMENT: USERS---
|
246
|
-
# GET /service/rest/v1/beta/security/users
|
247
|
-
# POST /service/rest/v1/beta/security/users
|
248
|
-
# PUT /service/rest/v1/beta/security/users/{userId}
|
249
|
-
# DELETE /service/rest/v1/beta/security/users/{userId}
|
250
|
-
# PUT /service/rest/v1/beta/security/users/{userId}/change-password
|
251
|
-
# DELETE /service/rest/v1/beta/security/users/{userId}/user-token
|
252
|
-
|
253
|
-
|
254
|
-
# ---STAGING---
|
255
|
-
# POST /service/rest/v1/staging/delete
|
256
|
-
# POST /service/rest/v1/staging/move/{destination}
|
257
|
-
|
258
|
-
|
259
|
-
# ---STATUS---
|
260
|
-
# GET /service/rest/v1/status
|
261
|
-
def status
|
262
|
-
@connection.get(endpoint: 'status')
|
263
|
-
end
|
264
|
-
|
265
|
-
# GET /service/rest/v1/status/writable
|
266
|
-
def status_writable
|
267
|
-
@connection.get(endpoint: 'status/writable')
|
268
|
-
end
|
269
|
-
|
270
|
-
|
271
|
-
# ---SUPPORT---
|
272
|
-
# POST /service/rest/v1/support/supportzip
|
273
|
-
|
274
|
-
|
275
|
-
# ---TAGS---
|
276
|
-
# GET /service/rest/v1/tags
|
277
|
-
def list_tags(paginate: false)
|
278
|
-
@connection.get_response(endpoint: 'tags', paginate: paginate)
|
279
|
-
end
|
280
|
-
|
281
|
-
# POST /service/rest/v1/tags
|
282
|
-
def create_tag(name:)
|
283
|
-
parameters = JSON.dump({
|
284
|
-
'name' => name,
|
285
|
-
})
|
286
|
-
@connection.post(endpoint: 'tags', parameters: parameters)
|
287
|
-
end
|
288
|
-
|
289
|
-
# GET /service/rest/v1/tags/{name}
|
290
|
-
# PUT /service/rest/v1/tags/{name}
|
291
|
-
# DELETE /service/rest/v1/tags/{name}
|
292
|
-
def delete_tag(name:)
|
293
|
-
@connection.delete(endpoint: "tags/#{name}")
|
294
|
-
end
|
295
|
-
|
296
|
-
# POST /service/rest/v1/tags/associate/{tagName}
|
297
|
-
def associate_tag(name:, sha1:, repository: nil)
|
298
|
-
repository ||= @team_config.tag_repository
|
299
|
-
search_query =
|
300
|
-
"?"\
|
301
|
-
"wait=true&"\
|
302
|
-
"repository=#{repository}&"\
|
303
|
-
"sha1=#{sha1}"
|
304
|
-
@connection.post(endpoint: "tags/associate/#{name}" + search_query)
|
305
|
-
end
|
306
|
-
|
307
|
-
# DELETE /service/rest/v1/tags/associate/{tagName}
|
308
|
-
def delete_associated_tag(name:, sha1:, repository: nil)
|
309
|
-
repository ||= @team_config.tag_repository
|
310
|
-
search_query =
|
311
|
-
"?"\
|
312
|
-
"repository=#{repository}&"\
|
313
|
-
"sha1=#{sha1}"
|
314
|
-
@connection.delete(endpoint: "tags/associate/#{name}" + search_query)
|
315
|
-
end
|
316
|
-
|
317
|
-
|
318
|
-
# ---TASKS---
|
319
|
-
# GET /service/rest/v1/tasks
|
320
|
-
# GET /service/rest/v1/tasks/{id}
|
321
|
-
# POST /service/rest/v1/tasks/{id}/run
|
322
|
-
# POST /service/rest/v1/tasks/{id}/stop
|
323
|
-
|
324
|
-
|
325
|
-
# ---CUSTOM FUNCTIONS---
|
326
43
|
def get_asset_size(asset_url:)
|
327
44
|
@connection.content_length(asset_url: asset_url)
|
328
45
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module NexusAPI
|
4
|
+
class ParameterBuilder
|
5
|
+
# Write Policies
|
6
|
+
ALLOW = 'ALLOW'
|
7
|
+
ALLOW_ONCE = 'ALLOW_ONCE'
|
8
|
+
DENY = 'DENY'
|
9
|
+
|
10
|
+
# Version Policy
|
11
|
+
RELEASE = 'RELEASE'
|
12
|
+
SNAPSHOT = 'SNAPSHOT'
|
13
|
+
MIXED = 'MIXED'
|
14
|
+
|
15
|
+
# Layout or Deploy Policy
|
16
|
+
STRICT = 'STRICT'
|
17
|
+
PERMISSIVE = 'PERMISSIVE'
|
18
|
+
|
19
|
+
def self.docker_hosted(name, port, write_policy: ALLOW_ONCE)
|
20
|
+
{
|
21
|
+
'name' => name,
|
22
|
+
'online' => true,
|
23
|
+
'storage' => {
|
24
|
+
'blobStoreName' => 'default',
|
25
|
+
'strictContentTypeValidation' => true,
|
26
|
+
'writePolicy' => write_policy
|
27
|
+
},
|
28
|
+
'docker' => {
|
29
|
+
'v1Enabled' => false,
|
30
|
+
'forceBasicAuth' => true,
|
31
|
+
'httpPort' => port
|
32
|
+
}
|
33
|
+
}.to_json
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.maven_hosted(name, write_policy: ALLOW_ONCE, version_policy: RELEASE, layout_policy: STRICT)
|
37
|
+
{
|
38
|
+
'name' => name,
|
39
|
+
'online' => true,
|
40
|
+
'storage' => {
|
41
|
+
'blobStoreName' => 'default',
|
42
|
+
'strictContentTypeValidation' => true,
|
43
|
+
'writePolicy' => write_policy
|
44
|
+
},
|
45
|
+
'maven' => {
|
46
|
+
'versionPolicy' => version_policy,
|
47
|
+
'layoutPolicy' => layout_policy
|
48
|
+
}
|
49
|
+
}.to_json
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.npm_hosted(name, write_policy: ALLOW_ONCE)
|
53
|
+
{
|
54
|
+
'name' => name,
|
55
|
+
'online' => true,
|
56
|
+
'storage' => {
|
57
|
+
'blobStoreName' => 'default',
|
58
|
+
'strictContentTypeValidation' => true,
|
59
|
+
'writePolicy' => write_policy
|
60
|
+
}
|
61
|
+
}.to_json
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.pypi_hosted(name, write_policy: ALLOW_ONCE)
|
65
|
+
{
|
66
|
+
'name' => name,
|
67
|
+
'online' => true,
|
68
|
+
'storage' => {
|
69
|
+
'blobStoreName' => 'default',
|
70
|
+
'strictContentTypeValidation' => true,
|
71
|
+
'writePolicy' => write_policy
|
72
|
+
}
|
73
|
+
}.to_json
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.yum_hosted(name, depth, write_policy: ALLOW_ONCE, deploy_policy: STRICT)
|
77
|
+
{
|
78
|
+
'name' => name,
|
79
|
+
'online' => true,
|
80
|
+
'storage' => {
|
81
|
+
'blobStoreName' => 'default',
|
82
|
+
'strictContentTypeValidation' => true,
|
83
|
+
'writePolicy' => write_policy
|
84
|
+
},
|
85
|
+
'yum' => {
|
86
|
+
'repodataDepth' => depth,
|
87
|
+
'deployPolicy' => deploy_policy
|
88
|
+
}
|
89
|
+
}.to_json
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/nexus_api.gemspec
CHANGED
@@ -32,5 +32,6 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_runtime_dependency 'thor', "~> 0.20.3"
|
33
33
|
|
34
34
|
spec.add_development_dependency 'rspec', "~> 3.0"
|
35
|
-
spec.add_development_dependency 'simplecov', "~> 0.18
|
35
|
+
spec.add_development_dependency 'simplecov', "~> 0.18"
|
36
|
+
spec.add_development_dependency 'webmock', "~> 3.8"
|
36
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexus_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis Levesque
|
@@ -129,14 +129,28 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 0.18
|
132
|
+
version: '0.18'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 0.18
|
139
|
+
version: '0.18'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: webmock
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '3.8'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '3.8'
|
140
154
|
description:
|
141
155
|
email:
|
142
156
|
- francis.d.levesque@gmail.com
|
@@ -163,6 +177,35 @@ files:
|
|
163
177
|
- bin/release
|
164
178
|
- bin/setup
|
165
179
|
- bin/test
|
180
|
+
- lib/endpoints.rb
|
181
|
+
- lib/endpoints/assets.rb
|
182
|
+
- lib/endpoints/blobstore.rb
|
183
|
+
- lib/endpoints/components.rb
|
184
|
+
- lib/endpoints/content-selectors.rb
|
185
|
+
- lib/endpoints/email.rb
|
186
|
+
- lib/endpoints/formats.rb
|
187
|
+
- lib/endpoints/iq.rb
|
188
|
+
- lib/endpoints/ldap.rb
|
189
|
+
- lib/endpoints/license.rb
|
190
|
+
- lib/endpoints/lifecycle.rb
|
191
|
+
- lib/endpoints/privileges.rb
|
192
|
+
- lib/endpoints/read-only.rb
|
193
|
+
- lib/endpoints/realms.rb
|
194
|
+
- lib/endpoints/repositories.rb
|
195
|
+
- lib/endpoints/roles.rb
|
196
|
+
- lib/endpoints/routing-rules.rb
|
197
|
+
- lib/endpoints/saml.rb
|
198
|
+
- lib/endpoints/script.rb
|
199
|
+
- lib/endpoints/search.rb
|
200
|
+
- lib/endpoints/ssl.rb
|
201
|
+
- lib/endpoints/staging.rb
|
202
|
+
- lib/endpoints/status.rb
|
203
|
+
- lib/endpoints/support.rb
|
204
|
+
- lib/endpoints/tags.rb
|
205
|
+
- lib/endpoints/tasks.rb
|
206
|
+
- lib/endpoints/user-sources.rb
|
207
|
+
- lib/endpoints/user-tokens.rb
|
208
|
+
- lib/endpoints/users.rb
|
166
209
|
- lib/nexus_api.rb
|
167
210
|
- lib/nexus_api/cli.rb
|
168
211
|
- lib/nexus_api/cli_commands/commands.rb
|
@@ -178,6 +221,7 @@ files:
|
|
178
221
|
- lib/nexus_api/docker_shell.rb
|
179
222
|
- lib/nexus_api/nexus_connection.rb
|
180
223
|
- lib/nexus_api/version.rb
|
224
|
+
- lib/utilities/parameter_builder.rb
|
181
225
|
- nexus_api.gemspec
|
182
226
|
- team_configs/default.yaml
|
183
227
|
- team_configs/template.yaml
|