class Artifactory::Resource::Backup

Public Class Methods

all(options = {}) click to toggle source

Get a list of all backup jobs in the system.

@param [Hash] options

the list of options

@option options [Artifactory::Client] :client

the client object to make the request with

@return [Array<Resource::Backup>]

the list of backup jobs
# File lib/artifactory/resources/backup.rb, line 34
def all(options = {})
  config = Resource::System.configuration(options)
  list_from_config("config/backups/backup", config, options)
end
find(key, options = {}) click to toggle source

Find (fetch) a backup job by its key.

@example Find a Backup by its key.

backup.find('backup-daily') #=> #<Backup key: 'backup-daily' ...>

@param [String] key

the name of the backup job to find

@param [Hash] options

the list of options

@option options [Artifactory::Client] :client

the client object to make the request with

@return [Resource::Backup, nil]

an instance of the backup job that matches the given key, or +nil+
if one does not exist
# File lib/artifactory/resources/backup.rb, line 57
def find(key, options = {})
  config = Resource::System.configuration(options)
  find_from_config("config/backups/backup/key[text()='#{key}']", config, options)
rescue Error::HTTPError => e
  raise unless e.code == 404

  nil
end

Private Class Methods

find_from_config(xpath, config, options = {}) click to toggle source

Find all the sibling text elements in the Artifactory configuration file of a node matching the specified xpath

@param [String] xpath

xpath expression for the element whose siblings are to be found

@param [REXML] config

Artifactory configuration file as an REXML doc

@param [Hash] options

the list of options
# File lib/artifactory/resources/backup.rb, line 103
def find_from_config(xpath, config, options = {})
  name_node = REXML::XPath.match(config, xpath)
  return nil if name_node.empty?

  properties = Util.xml_to_hash(name_node[0].parent, "excludedRepositories", false)
  from_hash(properties, options)
end
list_from_config(xpath, config, options = {}) click to toggle source

List all the child text elements in the Artifactory configuration file of a node matching the specified xpath

@param [String] xpath

xpath expression for the parent element whose children are to be listed

@param [REXML] config

Artifactory config as an REXML file

@param [Hash] options

the list of options

@return [~Resource::Base]

# File lib/artifactory/resources/backup.rb, line 83
def list_from_config(xpath, config, options = {})
  REXML::XPath.match(config, xpath).map do |r|
    hash = Util.xml_to_hash(r, "excludedRepositories", false)
    from_hash(hash, options)
  end
end