nexus_api 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f04df8459ef2419a7016b5dc3846ba6befebf51ba6440909e800c18a61feef38
4
- data.tar.gz: 9577d72f80e3deff168266bc58544c466699f492634ccd5c225dd140ef01848b
3
+ metadata.gz: 593a1c9c8f0ae411f0dceb74937549defaa861aed877a911363535ef08c1666c
4
+ data.tar.gz: 041e2a1f1acc3955688d56fc840a41c2b8f337499c0f7bfa751eff7fecd73ba5
5
5
  SHA512:
6
- metadata.gz: f9f0944af34bcd1ef181fef60daaef5ff7c8f804b3ecfff9ecc12c6eb38ff42cc1afae192501ad427f3d8d5f751254e5c8815f039e809cac409c64c6cc85071d
7
- data.tar.gz: d27cf15a296d562548e3021c5f68ff2919ee15fd8d8dbedbf56cfee57c29caeb7d8d0c9a3c9f0ebfcd9cea535ab0b96a1e18acdf24e2fb70dafdd85e80c2801e
6
+ metadata.gz: 7e5b2a098e126a0e5d80819949ad50e78be80ef3ba69128e1a00e1cb15963baa69922acb811198f0abc11846a2a677dcbfd5eb471774424809afa64e51aa0b86
7
+ data.tar.gz: bb214d0d407c604860e63eadd0bf489a7b61d6b9d1cadf3d639f8d0212d3ad53ae9e8f916b55efdfd5881b3140ba084656282fd4028dec13a40233f8f55c7633
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ 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.4.0](https://github.com/Cisco-AMP/nexus_api/compare/v1.3.0...v1.4.0) - 2020-05-05
9
+ ### Added
10
+ - Optional `tag` parameter to `associate_tag()` and `delete_associated_tag()` methods
11
+
12
+ ### Changed
13
+ - Made `sha1` parameter optional for `associate_tag()` and `delete_associated_tag()` methods
14
+
15
+
8
16
  ## [1.3.0](https://github.com/Cisco-AMP/nexus_api/compare/v1.2.1...v1.3.0) - 2020-04-30
9
17
  ### Added
10
18
  - Optional source and general keyword match into staging endpoint method (`move_components_to()`)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nexus_api (1.3.0)
4
+ nexus_api (1.4.0)
5
5
  bundler (~> 2)
6
6
  docker-api (~> 1.34.2)
7
7
  dotenv (~> 2.7.5)
@@ -21,24 +21,47 @@ module NexusAPI
21
21
  end
22
22
 
23
23
  # POST /service/rest/v1/tags/associate/{tagName}
24
- def associate_tag(name:, sha1:, repository: nil)
24
+ def associate_tag(name:, sha1: nil, repository: nil, tag: nil)
25
25
  repository ||= @team_config.tag_repository
26
- search_query =
27
- "?"\
28
- "wait=true&"\
29
- "repository=#{repository}&"\
30
- "sha1=#{sha1}"
26
+ if sha1.nil? && repository.nil? && tag.nil?
27
+ puts_error(__method__)
28
+ return false
29
+ end
30
+
31
+ search_query = "?wait=true"
32
+ search_query += "&sha1=#{sha1}" unless sha1.nil?
33
+ search_query += "&repository=#{repository}" unless repository.nil?
34
+ search_query += "&tag=#{tag}" unless tag.nil?
35
+
31
36
  @connection.post(endpoint: "tags/associate/#{name}" + search_query)
32
37
  end
33
38
 
34
39
  # DELETE /service/rest/v1/tags/associate/{tagName}
35
- def delete_associated_tag(name:, sha1:, repository: nil)
40
+ def delete_associated_tag(name:, sha1: nil, repository: nil, tag: nil)
36
41
  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
+ parameters = {}
43
+ parameters['sha1'] = sha1 unless sha1.nil?
44
+ parameters['repository'] = repository unless repository.nil?
45
+ parameters['tag'] = tag unless tag.nil?
46
+ if parameters.empty?
47
+ puts_error(__method__)
48
+ return false
49
+ end
50
+
51
+ search_query = parameters.map do |parameter, value|
52
+ "#{parameter}=#{value}"
53
+ end.join("&")
54
+
55
+ @connection.delete(endpoint: "tags/associate/#{name}?" + search_query)
56
+ end
57
+
58
+
59
+ private
60
+
61
+ def puts_error(method)
62
+ puts "ERROR: NexusAPI::API::#{method}() requires AT LEAST one optional parameter to"
63
+ puts " be set otherwise ALL assets in Nexus will be tagged. If this is desired"
64
+ puts " please open an issue or a PR to add a new method to handle this case."
42
65
  end
43
66
  end
44
67
  end
@@ -1,4 +1,4 @@
1
1
  module NexusAPI
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
4
4
 
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.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Levesque