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_query_string_parameters, #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



82
83
84
85
86
87
# File 'lib/artifactory/resources/system.rb', line 82

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



35
36
37
38
# File 'lib/artifactory/resources/system.rb', line 35

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



60
61
62
63
64
65
# File 'lib/artifactory/resources/system.rb', line 60

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):



104
105
106
107
108
109
110
111
# File 'lib/artifactory/resources/system.rb', line 104

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



128
129
130
131
# File 'lib/artifactory/resources/system.rb', line 128

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