Class: Samsara::Types::AlertEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/types/alert_event.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alert_event_url:, alert_condition_description:, alert_condition_id:, details:, org_id:, resolved:, start_ms:, summary:, device: OMIT, driver: OMIT, dvir: OMIT, additional_properties: nil) ⇒ Samsara::Types::AlertEvent

Parameters:

  • alert_event_url (String)

    Link to the alert in the Samsara dashboard

  • alert_condition_description (String)

    Human-readable description of the alert condition

  • alert_condition_id (Samsara::Types::AlertEventAlertConditionId)

    Identifier for the type of alert

  • details (String)

    Human-readable string with dynamic details about the alert

  • org_id (Integer)

    Organization ID

  • resolved (Boolean)

    Whether the alert has been resolved

  • start_ms (Long)

    Unix epoch timestamp when the event was triggered

  • summary (String)

    Brief summary of the event

  • device (Samsara::Types::AlertEventDevice) (defaults to: OMIT)
  • driver (Samsara::Types::AlertEventDriver) (defaults to: OMIT)
  • dvir (Samsara::Types::AlertEventDvir) (defaults to: OMIT)

    DVIR-specific fields

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/samsara_api/types/alert_event.rb', line 55

def initialize(alert_event_url:, alert_condition_description:, alert_condition_id:, details:, org_id:, resolved:, start_ms:, summary:, device: OMIT, driver: OMIT, dvir: OMIT, additional_properties: nil)
  @alert_event_url = alert_event_url
  @alert_condition_description = alert_condition_description
  @alert_condition_id = alert_condition_id
  @details = details
  @org_id = org_id
  @resolved = resolved
  @start_ms = start_ms
  @summary = summary
  @device = device if device != OMIT
  @driver = driver if driver != OMIT
  @dvir = dvir if dvir != OMIT
  @additional_properties = additional_properties
  @_field_set = { "alertEventUrl": alert_event_url, "alertConditionDescription": alert_condition_description, "alertConditionId": alert_condition_id, "details": details, "orgId": org_id, "resolved": resolved, "startMs": start_ms, "summary": summary, "device": device, "driver": driver, "dvir": dvir }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



35
36
37
# File 'lib/samsara_api/types/alert_event.rb', line 35

def additional_properties
  @additional_properties
end

#alert_condition_descriptionString (readonly)

Returns Human-readable description of the alert condition.

Returns:

  • (String)

    Human-readable description of the alert condition



15
16
17
# File 'lib/samsara_api/types/alert_event.rb', line 15

def alert_condition_description
  @alert_condition_description
end

#alert_condition_idSamsara::Types::AlertEventAlertConditionId (readonly)

Returns Identifier for the type of alert.

Returns:



17
18
19
# File 'lib/samsara_api/types/alert_event.rb', line 17

def alert_condition_id
  @alert_condition_id
end

#alert_event_urlString (readonly)

Returns Link to the alert in the Samsara dashboard.

Returns:

  • (String)

    Link to the alert in the Samsara dashboard



13
14
15
# File 'lib/samsara_api/types/alert_event.rb', line 13

def alert_event_url
  @alert_event_url
end

#detailsString (readonly)

Returns Human-readable string with dynamic details about the alert.

Returns:

  • (String)

    Human-readable string with dynamic details about the alert



19
20
21
# File 'lib/samsara_api/types/alert_event.rb', line 19

def details
  @details
end

#deviceSamsara::Types::AlertEventDevice (readonly)



29
30
31
# File 'lib/samsara_api/types/alert_event.rb', line 29

def device
  @device
end

#driverSamsara::Types::AlertEventDriver (readonly)



31
32
33
# File 'lib/samsara_api/types/alert_event.rb', line 31

def driver
  @driver
end

#dvirSamsara::Types::AlertEventDvir (readonly)

Returns DVIR-specific fields.

Returns:



33
34
35
# File 'lib/samsara_api/types/alert_event.rb', line 33

def dvir
  @dvir
end

#org_idInteger (readonly)

Returns Organization ID.

Returns:

  • (Integer)

    Organization ID



21
22
23
# File 'lib/samsara_api/types/alert_event.rb', line 21

def org_id
  @org_id
end

#resolvedBoolean (readonly)

Returns Whether the alert has been resolved.

Returns:

  • (Boolean)

    Whether the alert has been resolved



23
24
25
# File 'lib/samsara_api/types/alert_event.rb', line 23

def resolved
  @resolved
end

#start_msLong (readonly)

Returns Unix epoch timestamp when the event was triggered.

Returns:

  • (Long)

    Unix epoch timestamp when the event was triggered



25
26
27
# File 'lib/samsara_api/types/alert_event.rb', line 25

def start_ms
  @start_ms
end

#summaryString (readonly)

Returns Brief summary of the event.

Returns:

  • (String)

    Brief summary of the event



27
28
29
# File 'lib/samsara_api/types/alert_event.rb', line 27

def summary
  @summary
end

Class Method Details

.from_json(json_object:) ⇒ Samsara::Types::AlertEvent

Parameters:

  • json_object (String)

Returns:



76
77
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/samsara_api/types/alert_event.rb', line 76

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  alert_event_url = parsed_json["alertEventUrl"]
  alert_condition_description = parsed_json["alertConditionDescription"]
  alert_condition_id = parsed_json["alertConditionId"]
  details = parsed_json["details"]
  org_id = parsed_json["orgId"]
  resolved = parsed_json["resolved"]
  start_ms = parsed_json["startMs"]
  summary = parsed_json["summary"]
  unless parsed_json["device"].nil?
    device = parsed_json["device"].to_json
    device = Samsara::Types::AlertEventDevice.from_json(json_object: device)
  else
    device = nil
  end
  unless parsed_json["driver"].nil?
    driver = parsed_json["driver"].to_json
    driver = Samsara::Types::AlertEventDriver.from_json(json_object: driver)
  else
    driver = nil
  end
  unless parsed_json["dvir"].nil?
    dvir = parsed_json["dvir"].to_json
    dvir = Samsara::Types::AlertEventDvir.from_json(json_object: dvir)
  else
    dvir = nil
  end
  new(
    alert_event_url: alert_event_url,
    alert_condition_description: alert_condition_description,
    alert_condition_id: alert_condition_id,
    details: details,
    org_id: org_id,
    resolved: resolved,
    start_ms: start_ms,
    summary: summary,
    device: device,
    driver: driver,
    dvir: dvir,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/samsara_api/types/alert_event.rb', line 132

def self.validate_raw(obj:)
  obj.alert_event_url.is_a?(String) != false || raise("Passed value for field obj.alert_event_url is not the expected type, validation failed.")
  obj.alert_condition_description.is_a?(String) != false || raise("Passed value for field obj.alert_condition_description is not the expected type, validation failed.")
  obj.alert_condition_id.is_a?(Samsara::Types::AlertEventAlertConditionId) != false || raise("Passed value for field obj.alert_condition_id is not the expected type, validation failed.")
  obj.details.is_a?(String) != false || raise("Passed value for field obj.details is not the expected type, validation failed.")
  obj.org_id.is_a?(Integer) != false || raise("Passed value for field obj.org_id is not the expected type, validation failed.")
  obj.resolved.is_a?(Boolean) != false || raise("Passed value for field obj.resolved is not the expected type, validation failed.")
  obj.start_ms.is_a?(Long) != false || raise("Passed value for field obj.start_ms is not the expected type, validation failed.")
  obj.summary.is_a?(String) != false || raise("Passed value for field obj.summary is not the expected type, validation failed.")
  obj.device.nil? || Samsara::Types::AlertEventDevice.validate_raw(obj: obj.device)
  obj.driver.nil? || Samsara::Types::AlertEventDriver.validate_raw(obj: obj.driver)
  obj.dvir.nil? || Samsara::Types::AlertEventDvir.validate_raw(obj: obj.dvir)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


123
124
125
# File 'lib/samsara_api/types/alert_event.rb', line 123

def to_json
  @_field_set&.to_json
end