Class: Artifactory::Resource::System

Inherits:
Base
  • Object
show all
Defined in:
lib/artifactory/resources/system.rb

Class Method Summary collapse

Methods inherited from Base

attribute, attributes, #attributes, #client, #client=, #client?, #extract_client!, extract_client!, find_from_config, #format_repos!, format_repos!, from_hash, from_url, has_attribute?, #initialize, #inspect, list_from_config, #set, #to_hash, #to_json, #to_matrix_properties, #to_s, url_safe, #url_safe

Constructor Details

This class inherits a constructor from Artifactory::Resource::Base

Class Method Details

.configuration(options = {}) ⇒ REXML::Document

Get the current system configuration as XML.

Examples:

Get the current configuration

System.configuration

Parameters:

  • options (Hash) (defaults to: {})

    the list of options

Options Hash (options):

Returns:

  • (REXML::Document)

    the parsed XML document



66
67
68
69
70
71
# File 'lib/artifactory/resources/system.rb', line 66

def configuration(options = {})
  client   = extract_client!(options)
  response = client.get('/api/system/configuration')

  REXML::Document.new(response)
end

.info(options = {}) ⇒ String

Get general system information.

Examples:

Get the system information

System.info #=> "..."

Parameters:

  • options (Hash) (defaults to: {})

    the list of options

Options Hash (options):

Returns:

  • (String)

    a “table” of the system information as returned by the API



19
20
21
22
# File 'lib/artifactory/resources/system.rb', line 19

def info(options = {})
  client = extract_client!(options)
  client.get('/api/system')
end

.ping(options = {}) ⇒ Boolean

Check the status of the Artifactory server and API. This method will always return a boolean response, so it’s safe to call without exception handling.

Examples:

Wait until the Artifactory server is ready

until System.ping
  sleep(0.5)
  print '.'
end

Parameters:

  • options (Hash) (defaults to: {})

    the list of options

Options Hash (options):

Returns:

  • (Boolean)

    true if the Artifactory server is ready, false otherwise



44
45
46
47
48
49
# File 'lib/artifactory/resources/system.rb', line 44

def ping(options = {})
  client = extract_client!(options)
  !!client.get('/api/system/ping')
rescue Error::ConnectionError
  false
end

.update_configuration(xml, options = {}) ⇒ Object

Update the configuration with the given XML.

Examples:

Update the configuration

new_config = File.new('/path/to/new.xml')
System.update_configuration(new_config)

Parameters:

  • options (Hash) (defaults to: {})

    the list of options

  • xml (File)

    a pointer to the file descriptor of the XML to upload

Options Hash (options):



88
89
90
91
92
93
94
95
# File 'lib/artifactory/resources/system.rb', line 88

def update_configuration(xml, options = {})
  client = extract_client!(options)

  # The Artifactory api requires a content type of 'application/xml'.
  # See http://bit.ly/1l2IvZY
  headers = { 'Content-Type' => 'application/xml' }
  client.post('/api/system/configuration', xml, headers)
end

.version(options = {}) ⇒ Hash

Get the version information from the server.

Examples:

Get the version information

System.version #=> { ... }

Parameters:

  • options (Hash) (defaults to: {})

    the list of options

Options Hash (options):

Returns:

  • (Hash)

    the parsed JSON from the response



112
113
114
115
# File 'lib/artifactory/resources/system.rb', line 112

def version(options = {})
  client = extract_client!(options)
  client.get('/api/system/version')
end