Class: Nexpose::TicketSummary

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose/ticket.rb

Overview

Summary of ticket information returned from a ticket listing request. For more details, issue a ticket detail request.

Direct Known Subclasses

Ticket

Defined Under Namespace

Modules: Priority, State

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, id) ⇒ TicketSummary

Returns a new instance of TicketSummary.



80
81
82
# File 'lib/nexpose/ticket.rb', line 80

def initialize(name, id)
  @id, @name = id, name
end

Instance Attribute Details

#asset_idObject Also known as: device_id

The asset the ticket is created for.



59
60
61
# File 'lib/nexpose/ticket.rb', line 59

def asset_id
  @asset_id
end

#assigned_toObject

The login name of person to whom the ticket is assigned. The user must have view asset privilege on the asset specified in the asset-id attribute.



65
66
67
# File 'lib/nexpose/ticket.rb', line 65

def assigned_to
  @assigned_to
end

#authorObject

The login name of the person who created the ticket.



72
73
74
# File 'lib/nexpose/ticket.rb', line 72

def author
  @author
end

#created_onObject

Date and time of ticket creation.



75
76
77
# File 'lib/nexpose/ticket.rb', line 75

def created_on
  @created_on
end

#idObject

The ID number of the ticket.



53
54
55
# File 'lib/nexpose/ticket.rb', line 53

def id
  @id
end

#nameObject

Ticket name.



56
57
58
# File 'lib/nexpose/ticket.rb', line 56

def name
  @name
end

#priorityObject

The relative priority of the ticket, assigned by the creator of the ticket.

See Also:



69
70
71
# File 'lib/nexpose/ticket.rb', line 69

def priority
  @priority
end

#stateObject

The current status of the ticket.



78
79
80
# File 'lib/nexpose/ticket.rb', line 78

def state
  @state
end

Class Method Details

.parse(xml) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/nexpose/ticket.rb', line 84

def self.parse(xml)
  ticket = new(xml.attributes['name'],
               xml.attributes['id'].to_i)
  ticket.asset_id = xml.attributes['device-id'].to_i
  ticket.assigned_to = xml.attributes['assigned-to']
  lookup = Ticket::Priority.constants.reduce({}) { |a, e| a[Ticket::Priority.const_get(e)] = e; a }
  ticket.priority = lookup[xml.attributes['priority']]
  ticket.author = xml.attributes['author']
  ticket.created_on = DateTime.parse(xml.attributes['created-on']).to_time
  ticket.created_on -= ticket.created_on.gmt_offset
  lookup = Ticket::State.constants.reduce({}) { |a, e| a[Ticket::State.const_get(e)] = e; a }
  ticket.state = lookup[xml.attributes['state']]
  ticket
end