Class: TestPack1::AlertItem
- Defined in:
- lib/test_pack_1/models/alert_item.rb
Overview
An alert generated for a device based on a rule.
Instance Attribute Summary collapse
-
#comment ⇒ String
A user comment associated with the alert.
-
#description ⇒ String
A description explaning the rule the alert is based on.
-
#details ⇒ String
Additional details for the alert.
-
#device_id ⇒ Integer
The id of the device the alert was generated for.
-
#message ⇒ String
The title of the rule the alert is based on.
-
#rule_id ⇒ Integer
The id of the rule the alert is based on.
-
#timestamp_end ⇒ DateTime
The timestamp when the alert ended.
-
#timestamp_start ⇒ DateTime
The timestamp when the alert began.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(device_id = nil, rule_id = nil, timestamp_start = nil, timestamp_end = nil, message = nil, comment = nil, description = nil, details = nil) ⇒ AlertItem
constructor
A new instance of AlertItem.
Methods inherited from BaseModel
Constructor Details
#initialize(device_id = nil, rule_id = nil, timestamp_start = nil, timestamp_end = nil, message = nil, comment = nil, description = nil, details = nil) ⇒ AlertItem
Returns a new instance of AlertItem.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/test_pack_1/models/alert_item.rb', line 59 def initialize(device_id = nil, rule_id = nil, = nil, = nil, = nil, comment = nil, description = nil, details = nil) @device_id = device_id @rule_id = rule_id = = = @comment = comment @description = description @details = details end |
Instance Attribute Details
#comment ⇒ String
A user comment associated with the alert.
34 35 36 |
# File 'lib/test_pack_1/models/alert_item.rb', line 34 def comment @comment end |
#description ⇒ String
A description explaning the rule the alert is based on.
38 39 40 |
# File 'lib/test_pack_1/models/alert_item.rb', line 38 def description @description end |
#details ⇒ String
Additional details for the alert. Note that the structure of this data is subject to change.
43 44 45 |
# File 'lib/test_pack_1/models/alert_item.rb', line 43 def details @details end |
#device_id ⇒ Integer
The id of the device the alert was generated for.
12 13 14 |
# File 'lib/test_pack_1/models/alert_item.rb', line 12 def device_id @device_id end |
#message ⇒ String
The title of the rule the alert is based on.
30 31 32 |
# File 'lib/test_pack_1/models/alert_item.rb', line 30 def end |
#rule_id ⇒ Integer
The id of the rule the alert is based on.
16 17 18 |
# File 'lib/test_pack_1/models/alert_item.rb', line 16 def rule_id @rule_id end |
#timestamp_end ⇒ DateTime
The timestamp when the alert ended. The timestamp is in your system-configured time zone without UTC offset.
26 27 28 |
# File 'lib/test_pack_1/models/alert_item.rb', line 26 def end |
#timestamp_start ⇒ DateTime
The timestamp when the alert began. The timestamp is in your system-configured time zone without UTC offset.
21 22 23 |
# File 'lib/test_pack_1/models/alert_item.rb', line 21 def end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/test_pack_1/models/alert_item.rb', line 78 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. device_id = hash['deviceId'] rule_id = hash['ruleId'] = APIHelper.rfc3339(hash['timestampStart']) if hash['timestampStart'] = APIHelper.rfc3339(hash['timestampEnd']) if hash['timestampEnd'] = hash['message'] comment = hash['comment'] description = hash['description'] details = hash['details'] # Create object from extracted values. AlertItem.new(device_id, rule_id, , , , comment, description, details) end |
.names ⇒ Object
A mapping from model property names to API property names.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/test_pack_1/models/alert_item.rb', line 46 def self.names @_hash = {} if @_hash.nil? @_hash['device_id'] = 'deviceId' @_hash['rule_id'] = 'ruleId' @_hash['timestamp_start'] = 'timestampStart' @_hash['timestamp_end'] = 'timestampEnd' @_hash['message'] = 'message' @_hash['comment'] = 'comment' @_hash['description'] = 'description' @_hash['details'] = 'details' @_hash end |