nexus_cli 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/.gitignore +4 -1
  2. data/.travis.yml +5 -0
  3. data/Gemfile +40 -0
  4. data/Guardfile +27 -0
  5. data/README.md +20 -23
  6. data/Thorfile +66 -0
  7. data/VERSION +1 -1
  8. data/{pro → features/pro}/nexus_custom_metadata.feature +0 -0
  9. data/{pro → features/pro}/nexus_pro.feature +0 -0
  10. data/features/support/env.rb +41 -32
  11. data/lib/nexus_cli.rb +26 -10
  12. data/lib/nexus_cli/base_remote.rb +32 -0
  13. data/lib/nexus_cli/configuration.rb +24 -5
  14. data/lib/nexus_cli/connection.rb +81 -0
  15. data/lib/nexus_cli/mixins/artifact_actions.rb +186 -0
  16. data/lib/nexus_cli/mixins/global_settings_actions.rb +64 -0
  17. data/lib/nexus_cli/mixins/logging_actions.rb +45 -0
  18. data/lib/nexus_cli/{nexus_pro_remote.rb → mixins/pro/custom_metadata_actions.rb} +5 -199
  19. data/lib/nexus_cli/mixins/pro/smart_proxy_actions.rb +214 -0
  20. data/lib/nexus_cli/mixins/repository_actions.rb +245 -0
  21. data/lib/nexus_cli/mixins/user_actions.rb +125 -0
  22. data/lib/nexus_cli/remote/oss_remote.rb +11 -0
  23. data/lib/nexus_cli/remote/pro_remote.rb +59 -0
  24. data/lib/nexus_cli/remote_factory.rb +24 -0
  25. data/lib/nexus_cli/tasks.rb +3 -3
  26. data/spec/fixtures/nexus.config +4 -0
  27. data/spec/spec_helper.rb +14 -2
  28. data/spec/{configuration_spec.rb → unit/nexus_cli/configuration_spec.rb} +0 -0
  29. data/spec/{oss_remote_spec.rb → unit/nexus_cli/oss_remote_spec.rb} +15 -5
  30. data/spec/{pro_remote_spec.rb → unit/nexus_cli/pro_remote_spec.rb} +6 -1
  31. metadata +32 -17
  32. data/Gemfile.lock +0 -65
  33. data/lib/nexus_cli/kernel.rb +0 -33
  34. data/lib/nexus_cli/nexus_oss_remote.rb +0 -636
  35. data/lib/nexus_cli/nexus_remote_factory.rb +0 -65
@@ -0,0 +1,81 @@
1
+ module NexusCli
2
+ class Connection
3
+ attr_reader :nexus
4
+ attr_reader :configuration
5
+ attr_reader :ssl_verify
6
+
7
+ def initialize(configuration, ssl_verify)
8
+ @configuration = configuration
9
+ @ssl_verify = ssl_verify
10
+ @nexus = setup_nexus(configuration)
11
+ end
12
+
13
+ # Returns an HTTPClient instance with settings to connect
14
+ # to a Nexus server.
15
+ #
16
+ # @return [HTTPClient]
17
+ def setup_nexus(configuration)
18
+ client = HTTPClient.new
19
+ client.send_timeout = 6000
20
+ client.receive_timeout = 6000
21
+ # https://github.com/nahi/httpclient/issues/63
22
+ client.set_auth(nil, configuration['username'], configuration['password'])
23
+ client.www_auth.basic_auth.challenge(configuration['url'])
24
+ client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE unless ssl_verify
25
+
26
+ client
27
+ end
28
+
29
+ # Joins a given url to the current url stored in the configuraiton
30
+ # and returns the combined String.
31
+ #
32
+ # @param [String] url
33
+ #
34
+ # @return [String]
35
+ def nexus_url(url)
36
+ File.join(configuration['url'], url)
37
+ end
38
+
39
+ # Gets that current status of the Nexus server. On a non-error
40
+ # status code, returns a Hash of values from the server.
41
+ #
42
+ # @return [Hash]
43
+ def status
44
+ response = nexus.get(nexus_url("service/local/status"))
45
+ case response.status
46
+ when 200
47
+ doc = Nokogiri::XML(response.content).xpath("/status/data")
48
+ data = Hash.new
49
+ data['app_name'] = doc.xpath("appName")[0].text
50
+ data['version'] = doc.xpath("version")[0].text
51
+ data['edition_long'] = doc.xpath("editionLong")[0].text
52
+ data['state'] = doc.xpath("state")[0].text
53
+ data['started_at'] = doc.xpath("startedAt")[0].text
54
+ data['base_url'] = doc.xpath("baseUrl")[0].text
55
+ return data
56
+ when 401
57
+ raise PermissionsException
58
+ when 503
59
+ raise CouldNotConnectToNexusException
60
+ else
61
+ raise UnexpectedStatusCodeException.new(response.status)
62
+ end
63
+ end
64
+
65
+ # Transforms a given [String] into a sanitized version by
66
+ # replacing spaces with underscores and downcasing.
67
+ #
68
+ # @param unsanitized_string [String] the String to sanitize
69
+ #
70
+ # @return [String] the sanitized String
71
+ def sanitize_for_id(unsanitized_string)
72
+ unsanitized_string.gsub(" ", "_").downcase
73
+ end
74
+
75
+ # Determines whether or not the Nexus server being
76
+ # connected to is running Nexus Pro.
77
+ def running_nexus_pro?
78
+ status['edition_long'] == "Professional"
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,186 @@
1
+ require 'erb'
2
+ require 'tempfile'
3
+
4
+ module NexusCli
5
+ # @author Kyle Allan <kallan@riotgames.com>
6
+ module ArtifactActions
7
+
8
+ # Retrieves a file from the Nexus server using the given [String] artifact
9
+ # identifier. Optionally provide a destination [String].
10
+ #
11
+ # @param [String] artifact
12
+ # @param [String] destination
13
+ #
14
+ # @return [Hash] Some information about the artifact that was pulled.
15
+ def pull_artifact(artifact, destination=nil)
16
+ group_id, artifact_id, version, extension = parse_artifact_string(artifact)
17
+ version = Nokogiri::XML(get_artifact_info(artifact)).xpath("//version").first.content() if version.casecmp("latest")
18
+ file_name = "#{artifact_id}-#{version}.#{extension}"
19
+ destination = File.join(File.expand_path(destination || "."), file_name)
20
+ response = nexus.get(nexus_url("service/local/artifact/maven/redirect"), :query => {:g => group_id, :a => artifact_id, :v => version, :e => extension, :r => configuration['repository']})
21
+ case response.status
22
+ when 301, 307
23
+ # Follow redirect and stream in chunks.
24
+ artifact_file = File.open(destination, "wb") do |io|
25
+ nexus.get(response.content.gsub(/If you are not automatically redirected use this url: /, "")) do |chunk|
26
+ io.write(chunk)
27
+ end
28
+ end
29
+ when 404
30
+ raise ArtifactNotFoundException
31
+ else
32
+ raise UnexpectedStatusCodeException.new(response.status)
33
+ end
34
+ {
35
+ :file_name => file_name,
36
+ :file_path => File.expand_path(destination),
37
+ :version => version,
38
+ :size => File.size(File.expand_path(destination))
39
+ }
40
+ end
41
+
42
+ # Pushes the given [file] to the Nexus server
43
+ # under the given [artifact] identifier.
44
+ #
45
+ # @param artifact [String] the Maven identifier
46
+ # @param file [type] the path to the file
47
+ #
48
+ # @return [Boolean] returns true when successful
49
+ def push_artifact(artifact, file)
50
+ group_id, artifact_id, version, extension = parse_artifact_string(artifact)
51
+ file_name = "#{artifact_id}-#{version}.#{extension}"
52
+ put_string = "content/repositories/#{configuration['repository']}/#{group_id.gsub(".", "/")}/#{artifact_id.gsub(".", "/")}/#{version}/#{file_name}"
53
+ response = nexus.put(nexus_url(put_string), File.open(file))
54
+
55
+ case response.status
56
+ when 201
57
+ pom_name = "#{artifact_id}-#{version}.pom"
58
+ put_string = "content/repositories/#{configuration['repository']}/#{group_id.gsub(".", "/")}/#{artifact_id.gsub(".", "/")}/#{version}/#{pom_name}"
59
+ pom_file = generate_fake_pom(pom_name, group_id, artifact_id, version, extension)
60
+ nexus.put(nexus_url(put_string), File.open(pom_file))
61
+ delete_string = "/service/local/metadata/repositories/#{configuration['repository']}/content/#{group_id.gsub(".", "/")}/#{artifact_id.gsub(".", "/")}"
62
+ nexus.delete(nexus_url(delete_string))
63
+ return true
64
+ when 400
65
+ raise BadUploadRequestException
66
+ when 401
67
+ raise PermissionsException
68
+ when 403
69
+ raise PermissionsException
70
+ when 404
71
+ raise NexusHTTP404.new(response.content)
72
+ else
73
+ raise UnexpectedStatusCodeException.new(response.status)
74
+ end
75
+ end
76
+
77
+ def delete_artifact(artifact)
78
+ group_id, artifact_id, version = parse_artifact_string(artifact)
79
+ response = nexus.delete(nexus_url("content/repositories/#{configuration['repository']}/#{group_id.gsub(".", "/")}/#{artifact_id.gsub(".", "/")}/#{version}"))
80
+ case response.status
81
+ when 204
82
+ return true
83
+ else
84
+ raise UnexpectedStatusCodeException.new(response.status)
85
+ end
86
+ end
87
+
88
+
89
+ # Retrieves information about the given [artifact] and returns
90
+ # it in as a [String] of XML.
91
+ #
92
+ # @param artifact [String] the Maven identifier
93
+ #
94
+ # @return [String] A string of XML data about the desired artifact
95
+ def get_artifact_info(artifact)
96
+ group_id, artifact_id, version, extension = parse_artifact_string(artifact)
97
+ response = nexus.get(nexus_url("service/local/artifact/maven/resolve"), :query => {:g => group_id, :a => artifact_id, :v => version, :e => extension, :r => configuration['repository']})
98
+ case response.status
99
+ when 200
100
+ return response.content
101
+ when 404
102
+ raise ArtifactNotFoundException
103
+ when 503
104
+ raise CouldNotConnectToNexusException
105
+ else
106
+ raise UnexpectedStatusCodeException.new(response.status)
107
+ end
108
+ end
109
+
110
+
111
+ # Searches for an artifact using the given identifier.
112
+ #
113
+ # @param artifact [String] the Maven identifier
114
+ # @example com.artifact:my-artifact
115
+ #
116
+ # @return [Array<String>] a formatted Array of results
117
+ # @example
118
+ # 1.0.0 `nexus-cli pull com.artifact:my-artifact:1.0.0:tgz`
119
+ # 2.0.0 `nexus-cli pull com.artifact:my-artifact:2.0.0:tgz`
120
+ # 3.0.0 `nexus-cli pull com.artifact:my-artifact:3.0.0:tgz`
121
+ def search_for_artifacts(artifact)
122
+ group_id, artifact_id = artifact.split(":")
123
+ response = nexus.get(nexus_url("service/local/data_index"), :query => {:g => group_id, :a => artifact_id})
124
+ case response.status
125
+ when 200
126
+ doc = Nokogiri::XML(response.content)
127
+ return format_search_results(doc, group_id, artifact_id)
128
+ else
129
+ raise UnexpectedStatusCodeException.new(response.status)
130
+ end
131
+ end
132
+
133
+ def transfer_artifact(artifact, from_repository, to_repository)
134
+ do_transfer_artifact(artifact, from_repository, to_repository)
135
+ end
136
+
137
+ private
138
+
139
+ # Formats the given XML into an [Array<String>] so it
140
+ # can be displayed nicely.
141
+ #
142
+ # @param doc [Nokogiri::XML] the xml search results
143
+ # @param group_id [String] the group id
144
+ # @param artifact_id [String] the artifact id
145
+ #
146
+ # @return [type] [description]
147
+ def format_search_results(doc, group_id, artifact_id)
148
+ versions = doc.xpath("//version").inject([]) {|array,node| array << "#{node.content()}"}
149
+ if versions.length > 0
150
+ indent_size = versions.max{|a,b| a.length <=> b.length}.size+4
151
+ formated_results = ['Found Versions:']
152
+ versions.inject(formated_results) do |array,version|
153
+ temp_version = version + ":"
154
+ array << "#{temp_version.ljust(indent_size)} `nexus-cli pull #{group_id}:#{artifact_id}:#{version}:tgz`"
155
+ end
156
+ else
157
+ formated_results = ['No Versions Found.']
158
+ end
159
+ end
160
+
161
+ # Transfers an artifact from one repository
162
+ # to another. Sometimes called a `promotion`
163
+ #
164
+ # @param artifact [String] a Maven identifier
165
+ # @param from_repository [String] the name of the from repository
166
+ # @param to_repository [String] the name of the to repository
167
+ #
168
+ # @return [Boolean] returns true when successful
169
+ def do_transfer_artifact(artifact, from_repository, to_repository)
170
+ Dir.mktmpdir do |temp_dir|
171
+ configuration["repository"] = sanitize_for_id(from_repository)
172
+ artifact_file = pull_artifact(artifact, temp_dir)
173
+ configuration["repository"] = sanitize_for_id(to_repository)
174
+ push_artifact(artifact, artifact_file[:file_path])
175
+ end
176
+ end
177
+
178
+ def generate_fake_pom(pom_name, group_id, artifact_id, version, extension)
179
+ Tempfile.open(pom_name) do |file|
180
+ template_path = File.join(NexusCli.root, "data", "pom.xml.erb")
181
+ file.puts ERB.new(File.read(template_path)).result(binding)
182
+ file
183
+ end
184
+ end
185
+ end
186
+ end
@@ -0,0 +1,64 @@
1
+ require 'json'
2
+
3
+ module NexusCli
4
+ # @author Kyle Allan <kallan@riotgames.com>
5
+ module GlobalSettingsActions
6
+
7
+ # Retrieves the global settings of the Nexus server
8
+ #
9
+ # @return [File] a File with the global settings.
10
+ def get_global_settings
11
+ json = get_global_settings_json
12
+ pretty_json = JSON.pretty_generate(JSON.parse(json))
13
+ Dir.mkdir(File.expand_path("~/.nexus")) unless Dir.exists?(File.expand_path("~/.nexus"))
14
+ destination = File.join(File.expand_path("~/.nexus"), "global_settings.json")
15
+ artifact_file = File.open(destination, 'wb') do |file|
16
+ file.write(pretty_json)
17
+ end
18
+ end
19
+
20
+ def get_global_settings_json
21
+ response = nexus.get(nexus_url("service/local/global_settings/current"), :header => DEFAULT_ACCEPT_HEADER)
22
+ case response.status
23
+ when 200
24
+ return response.content
25
+ else
26
+ raise UnexpectedStatusCodeException.new(response.status)
27
+ end
28
+ end
29
+
30
+ def upload_global_settings(json=nil)
31
+ global_settings = nil
32
+ if json == nil
33
+ global_settings = File.read(File.join(File.expand_path("~/.nexus"), "global_settings.json"))
34
+ else
35
+ global_settings = json
36
+ end
37
+ response = nexus.put(nexus_url("service/local/global_settings/current"), :body => global_settings, :header => DEFAULT_CONTENT_TYPE_HEADER)
38
+ case response.status
39
+ when 204
40
+ return true
41
+ when 400
42
+ raise BadSettingsException.new(response.content)
43
+ end
44
+ end
45
+
46
+ def reset_global_settings
47
+ response = nexus.get(nexus_url("service/local/global_settings/default"), :header => DEFAULT_ACCEPT_HEADER)
48
+ case response.status
49
+ when 200
50
+ default_json = response.content
51
+ else
52
+ raise UnexpectedStatusCodeException.new(response.status)
53
+ end
54
+
55
+ response = nexus.put(nexus_url("service/local/global_settings/current"), :body => default_json, :header => DEFAULT_CONTENT_TYPE_HEADER)
56
+ case response.status
57
+ when 204
58
+ return true
59
+ else
60
+ raise UnexpectedStatusCodeException.new(response.status)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,45 @@
1
+ module NexusCli
2
+ # @author Kyle Allan <kallan@riotgames.com>
3
+ module LoggingActions
4
+
5
+ # Gets information about the current logging
6
+ # levels in Nexus.
7
+ #
8
+ #
9
+ # @return [String] a String of JSON representing the current logging levels of Nexus
10
+ def get_logging_info
11
+ response = nexus.get(nexus_url("service/local/log/config"), :header => DEFAULT_ACCEPT_HEADER)
12
+ case response.status
13
+ when 200
14
+ return response.content
15
+ else
16
+ raise UnexpectedStatusCodeException.new(response.status)
17
+ end
18
+ end
19
+
20
+
21
+ # Sets the logging level of Nexus to one of
22
+ # "INFO", "DEBUG", or "ERROR".
23
+ #
24
+ # @param level [String] the logging level to set
25
+ #
26
+ # @return [Boolean] true if the logging level has been set, false otherwise
27
+ def set_logger_level(level)
28
+ raise InvalidLoggingLevelException unless ["INFO", "DEBUG", "ERROR"].include?(level.upcase)
29
+ response = nexus.put(nexus_url("service/local/log/config"), :body => create_logger_level_json(level), :header => DEFAULT_CONTENT_TYPE_HEADER)
30
+ case response.status
31
+ when 200
32
+ return true
33
+ else
34
+ raise UnexpectedStatusCodeException.new(response.status)
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def create_logger_level_json(level)
41
+ params = {:rootLoggerLevel => level.upcase}
42
+ JSON.dump(:data => params)
43
+ end
44
+ end
45
+ end
@@ -1,9 +1,7 @@
1
- require 'httpclient'
2
- require 'nokogiri'
3
- require 'yaml'
4
-
5
1
  module NexusCli
6
- class ProRemote < OSSRemote
2
+ # @author Kyle Allan <kallan@riotgames.com>
3
+ module CustomMetadataActions
4
+
7
5
  # Gets the custom metadata for an artifact
8
6
  # @param [String] artifact The GAVE string of the artifact
9
7
  # @result [String] The resulting custom metadata xml from the get operation
@@ -82,186 +80,6 @@ module NexusCli
82
80
  return result.nil? ? "" : result.to_xml(:indent => 4)
83
81
  end
84
82
 
85
- def get_pub_sub(repository_id)
86
- response = nexus.get(nexus_url("service/local/smartproxy/pub-sub/#{repository_id}"))
87
- case response.status
88
- when 200
89
- return response.content
90
- else
91
- raise UnexpectedStatusCodeException.new(response.status)
92
- end
93
- end
94
-
95
- def enable_artifact_publish(repository_id)
96
- params = {:repositoryId => repository_id}
97
- params[:publish] = true
98
- artifact_publish(repository_id, params)
99
- end
100
-
101
- def disable_artifact_publish(repository_id)
102
- params = {:repositoryId => repository_id}
103
- params[:publish] = false
104
- artifact_publish(repository_id, params)
105
- end
106
-
107
- def artifact_publish(repository_id, params)
108
- response = nexus.put(nexus_url("service/local/smartproxy/pub-sub/#{sanitize_for_id(repository_id)}"), :body => create_pub_sub_json(params), :header => DEFAULT_CONTENT_TYPE_HEADER)
109
- case response.status
110
- when 200
111
- return true
112
- else
113
- raise UnexpectedStatusCodeException.new(response.status)
114
- end
115
- end
116
-
117
- def enable_artifact_subscribe(repository_id, preemptive_fetch)
118
- raise NotProxyRepositoryException.new(repository_id) unless Nokogiri::XML(get_repository_info(repository_id)).xpath("/repository/data/repoType").first.content == "proxy"
119
-
120
- params = {:repositoryId => repository_id}
121
- params[:subscribe] = true
122
- params[:preemptiveFetch] = preemptive_fetch
123
- artifact_subscribe(repository_id, params)
124
- end
125
-
126
- def disable_artifact_subscribe(repository_id)
127
- raise NotProxyRepositoryException.new(repository_id) unless Nokogiri::XML(get_repository_info(repository_id)).xpath("/repository/data/repoType").first.content == "proxy"
128
-
129
- params = {:repositoryId => repository_id}
130
- params[:subscribe] = false
131
- artifact_subscribe(repository_id, params)
132
- end
133
-
134
- def artifact_subscribe(repository_id, params)
135
- response = nexus.put(nexus_url("service/local/smartproxy/pub-sub/#{sanitize_for_id(repository_id)}"), :body => create_pub_sub_json(params), :header => DEFAULT_CONTENT_TYPE_HEADER)
136
- case response.status
137
- when 200
138
- return true
139
- else
140
- raise UnexpectedStatusCodeException.new(response.status)
141
- end
142
- end
143
-
144
- def enable_smart_proxy(host=nil, port=nil)
145
- params = {:enabled => true}
146
- params[:host] = host unless host.nil?
147
- params[:port] = port unless port.nil?
148
- smart_proxy(params)
149
- end
150
-
151
- def disable_smart_proxy
152
- params = {:enabled => false}
153
- smart_proxy(params)
154
- end
155
-
156
- def smart_proxy(params)
157
- response = nexus.put(nexus_url("service/local/smartproxy/settings"), :body => create_smart_proxy_settings_json(params), :header => DEFAULT_CONTENT_TYPE_HEADER)
158
- case response.status
159
- when 200
160
- return true
161
- else
162
- raise UnexpectedStatusCodeException.new(response.status)
163
- end
164
- end
165
-
166
- def get_smart_proxy_settings
167
- response = nexus.get(nexus_url("service/local/smartproxy/settings"), :header => DEFAULT_ACCEPT_HEADER)
168
- case response.status
169
- when 200
170
- return response.content
171
- else
172
- raise UnexpectedStatusCodeException.new(response.status)
173
- end
174
- end
175
-
176
- def get_smart_proxy_key
177
- response = nexus.get(nexus_url("service/local/smartproxy/settings"), :header => DEFAULT_ACCEPT_HEADER)
178
- case response.status
179
- when 200
180
- return response.content
181
- else
182
- raise UnexpectedStatusCodeException.new(response.status)
183
- end
184
- end
185
-
186
- def add_trusted_key(certificate, description, path=true)
187
- params = {:description => description}
188
- params[:certificate] = path ? File.read(File.expand_path(certificate)) : certificate
189
- response = nexus.post(nexus_url("service/local/smartproxy/trusted-keys"), :body => create_add_trusted_key_json(params), :header => DEFAULT_CONTENT_TYPE_HEADER)
190
- case response.status
191
- when 201
192
- return true
193
- else
194
- raise UnexpectedStatusCodeException.new(response.status)
195
- end
196
- end
197
-
198
- def delete_trusted_key(key_id)
199
- response = nexus.delete(nexus_url("service/local/smartproxy/trusted-keys/#{key_id}"))
200
- case response.status
201
- when 204
202
- return true
203
- else
204
- raise UnexpectedStatusCodeException.new(response.status)
205
- end
206
- end
207
-
208
- def get_trusted_keys
209
- response = nexus.get(nexus_url("service/local/smartproxy/trusted-keys"), :header => DEFAULT_ACCEPT_HEADER)
210
- case response.status
211
- when 200
212
- return response.content
213
- else
214
- raise UnexpectedStatusCodeException.new(response.status)
215
- end
216
- end
217
-
218
- def get_license_info
219
- response = nexus.get(nexus_url("service/local/licensing"), :header => DEFAULT_ACCEPT_HEADER)
220
- case response.status
221
- when 200
222
- return response.content
223
- else
224
- raise UnexpectedStatusCodeException.new(response.status)
225
- end
226
- end
227
-
228
- def install_license(license_file)
229
- file = File.read(File.expand_path(license_file))
230
- response = nexus.post(nexus_url("service/local/licensing/upload"), :body => file, :header => {"Content-Type" => "application/octet-stream"})
231
- case response.status
232
- when 201
233
- return true
234
- when 403
235
- raise LicenseInstallFailure
236
- else
237
- raise UnexpectedStatusCodeException.new(response.status)
238
- end
239
- end
240
-
241
- def install_license_bytes(bytes)
242
- response = nexus.post(nexus_url("service/local/licensing/upload"), :body => bytes, :header => {"Content-Type" => "application/octet-stream"})
243
- case response.status
244
- when 201
245
- return true
246
- when 403
247
- raise LicenseInstallFailure
248
- else
249
- raise UnexpectedStatusCodeException.new(response.status)
250
- end
251
- end
252
-
253
- def transfer_artifact(artifact, from_repository, to_repository)
254
- do_transfer_artifact(artifact, from_repository, to_repository)
255
-
256
- configuration["repository"] = sanitize_for_id(from_repository)
257
- from_artifact_metadata = get_custom_metadata_hash(artifact)
258
-
259
- configuration["repository"] = sanitize_for_id(to_repository)
260
- to_artifact_metadata = get_custom_metadata_hash(artifact)
261
-
262
- do_update_custom_metadata(artifact, from_artifact_metadata, to_artifact_metadata)
263
- end
264
-
265
83
  private
266
84
 
267
85
  def get_custom_metadata_hash(artifact)
@@ -283,19 +101,7 @@ module NexusCli
283
101
  raise UnexpectedStatusCodeException.new(response.status)
284
102
  end
285
103
  end
286
-
287
- def create_add_trusted_key_json(params)
288
- JSON.dump(:data => params)
289
- end
290
-
291
- def create_smart_proxy_settings_json(params)
292
- JSON.dump(:data => params)
293
- end
294
-
295
- def create_pub_sub_json(params)
296
- JSON.dump(:data => params)
297
- end
298
-
104
+
299
105
  # Converts an array of parameters used to update custom metadata
300
106
  # @param [Array] *params The array of key:value strings
301
107
  # @return [Hash] The resulting hash of parsed key:value items
@@ -359,4 +165,4 @@ module NexusCli
359
165
  end
360
166
  end
361
167
  end
362
- end
168
+ end