Class: Intrinsic::CreateEventSyncResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/intrinsic/types/create_event_sync_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object:, id:, event_type_id:, content:, created_at:, detections:, fired_rules:, additional_properties: nil) ⇒ CreateEventSyncResponse

Parameters:

  • object (String)
  • id (String)

    ID of the created event

  • event_type_id (String)

    ID of the event type that was created

  • content (Hash{String => String})

    Arbitrary JSON payload for the request body

  • created_at (DateTime)

    Timestamp of when the event was created

  • detections (Array<DetectionObject>)

    List of detections created for the event

  • fired_rules (Array<FiredRuleObject>)

    List of fired rules created for the event

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 21

def initialize(object:, id:, event_type_id:, content:, created_at:, detections:, fired_rules:,
               additional_properties: nil)
  # @type [String]
  @object = object
  # @type [String] ID of the created event
  @id = id
  # @type [String] ID of the event type that was created
  @event_type_id = event_type_id
  # @type [Hash{String => String}] Arbitrary JSON payload for the request body
  @content = content
  # @type [DateTime] Timestamp of when the event was created
  @created_at = created_at
  # @type [Array<DetectionObject>] List of detections created for the event
  @detections = detections
  # @type [Array<FiredRuleObject>] List of fired rules created for the event
  @fired_rules = fired_rules
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



10
11
12
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 10

def additional_properties
  @additional_properties
end

#contentObject (readonly)

Returns the value of attribute content.



10
11
12
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 10

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at.



10
11
12
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 10

def created_at
  @created_at
end

#detectionsObject (readonly)

Returns the value of attribute detections.



10
11
12
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 10

def detections
  @detections
end

#event_type_idObject (readonly)

Returns the value of attribute event_type_id.



10
11
12
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 10

def event_type_id
  @event_type_id
end

#fired_rulesObject (readonly)

Returns the value of attribute fired_rules.



10
11
12
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 10

def fired_rules
  @fired_rules
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 10

def id
  @id
end

#objectObject (readonly)

Returns the value of attribute object.



10
11
12
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 10

def object
  @object
end

Class Method Details

.from_json(json_object:) ⇒ CreateEventSyncResponse

Deserialize a JSON object to an instance of CreateEventSyncResponse

Parameters:

  • json_object (JSON)

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 45

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  object = struct.object
  id = struct.id
  event_type_id = struct.event_type_id
  content = struct.content
  created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?)
  detections = parsed_json["detections"]&.map do |v|
    v = v.to_json
    DetectionObject.from_json(json_object: v)
  end
  fired_rules = parsed_json["fired_rules"]&.map do |v|
    v = v.to_json
    FiredRuleObject.from_json(json_object: v)
  end
  new(object: object, id: id, event_type_id: event_type_id, content: content, created_at: created_at,
      detections: detections, fired_rules: fired_rules, additional_properties: struct)
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


84
85
86
87
88
89
90
91
92
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 84

def self.validate_raw(obj:)
  obj.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.")
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.event_type_id.is_a?(String) != false || raise("Passed value for field obj.event_type_id is not the expected type, validation failed.")
  obj.content.is_a?(Hash) != false || raise("Passed value for field obj.content is not the expected type, validation failed.")
  obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.detections.is_a?(Array) != false || raise("Passed value for field obj.detections is not the expected type, validation failed.")
  obj.fired_rules.is_a?(Array) != false || raise("Passed value for field obj.fired_rules is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of CreateEventSyncResponse to a JSON object

Returns:

  • (JSON)


68
69
70
71
72
73
74
75
76
77
78
# File 'lib/intrinsic/types/create_event_sync_response.rb', line 68

def to_json(*_args)
  {
    "object": @object,
    "id": @id,
    "event_type_id": @event_type_id,
    "content": @content,
    "created_at": @created_at,
    "detections": @detections,
    "fired_rules": @fired_rules
  }.to_json
end