class JunosSpace::Platform::AuditLog

Public Instance Methods

info(id) click to toggle source

info(log)

Returns information about the audit log 'id'. This information is returned in a Hash with the log ID, user, IP address, description, time, task name, and result.

# File lib/junos-space-api/platform/audit.rb, line 39
def info(id)
  result = {}
  
  begin
    res = RestClient.get("#{JunosSpace.base_uri}#{@@audit_uri}/#{id}")
    doc = Nokogiri::XML::Document.parse(res)

    doc.xpath('//audit-log').each do |log|
      result["id"] = id
      result["user"] = log.xpath('userName').text
      result["ip"] = log.xpath('userIpAddr').text
      result["description"] = log.xpath('description').text
      result["time"] = log.xpath('logTime').text
      result["task"] = log.xpath('taskName').text
      result["result"] = log.xpath('result').text
    end

    return result
  rescue RestClient::Unauthorized
    result['status'] = '401 Error - Auth failure (bad username/password).'
    
    return result
  end
end
list() click to toggle source

list

Returns an array of all of the audit logs in Space.

# File lib/junos-space-api/platform/audit.rb, line 12
def list
  result = []
  
  begin
    res = RestClient.get("#{JunosSpace.base_uri}#{@@audit_uri}")
    doc = Nokogiri::XML::Document.parse(res)

    doc.xpath('//audit-log').each do |log|
      id = log.xpath('@key').text
      
      result << id
    end

    return result
  rescue RestClient::Unauthorized
    result['status'] = '401 Error - Auth failure (bad username/password).'
    
    return result
  end
end