Class: JunosSpace::Platform::AuditLog

Inherits:
Object
  • Object
show all
Defined in:
lib/junos-space-api/platform/audit.rb

Constant Summary collapse

@@audit_uri =
'/api/space/audit-log-management/audit-logs'

Instance Method Summary collapse

Instance Method Details

#info(id) ⇒ Object

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.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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

#listObject

list

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



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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