Module: NexusCli::GlobalSettingsActions
Overview
Instance Method Summary collapse
-
#get_global_settings ⇒ File
Retrieves the global settings of the Nexus server.
- #get_global_settings_json ⇒ Object
- #reset_global_settings ⇒ Object
- #upload_global_settings(json = nil) ⇒ Object
Instance Method Details
#get_global_settings ⇒ File
Retrieves the global settings of the Nexus server
10 11 12 13 14 15 16 17 18 |
# File 'lib/nexus_cli/mixins/global_settings_actions.rb', line 10 def get_global_settings json = get_global_settings_json pretty_json = JSON.pretty_generate(JSON.parse(json)) Dir.mkdir(File.("~/.nexus")) unless Dir.exists?(File.("~/.nexus")) destination = File.join(File.("~/.nexus"), "global_settings.json") artifact_file = File.open(destination, 'wb') do |file| file.write(pretty_json) end end |
#get_global_settings_json ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/nexus_cli/mixins/global_settings_actions.rb', line 20 def get_global_settings_json response = nexus.get(nexus_url("service/local/global_settings/current"), :header => DEFAULT_ACCEPT_HEADER) case response.status when 200 return response.content else raise UnexpectedStatusCodeException.new(response.status) end end |
#reset_global_settings ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/nexus_cli/mixins/global_settings_actions.rb', line 46 def reset_global_settings response = nexus.get(nexus_url("service/local/global_settings/default"), :header => DEFAULT_ACCEPT_HEADER) case response.status when 200 default_json = response.content else raise UnexpectedStatusCodeException.new(response.status) end response = nexus.put(nexus_url("service/local/global_settings/current"), :body => default_json, :header => DEFAULT_CONTENT_TYPE_HEADER) case response.status when 204 return true else raise UnexpectedStatusCodeException.new(response.status) end end |
#upload_global_settings(json = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nexus_cli/mixins/global_settings_actions.rb', line 30 def upload_global_settings(json=nil) global_settings = nil if json == nil global_settings = File.read(File.join(File.("~/.nexus"), "global_settings.json")) else global_settings = json end response = nexus.put(nexus_url("service/local/global_settings/current"), :body => global_settings, :header => DEFAULT_CONTENT_TYPE_HEADER) case response.status when 204 return true when 400 raise BadSettingsException.new(response.content) end end |