Class: Intrinsic::EventsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/intrinsic/events/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ EventsClient

Parameters:



16
17
18
19
# File 'lib/intrinsic/events/client.rb', line 16

def initialize(request_client:)
  # @type [RequestClient]
  @request_client = request_client
end

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



12
13
14
# File 'lib/intrinsic/events/client.rb', line 12

def request_client
  @request_client
end

Instance Method Details

#create_event_async(event_type_name:, request:, request_options: nil) ⇒ CreateEventAsyncResponse

Creates an event in an asynchronous manner. Returns an ID for the event created as well as the set of detection ids associated with the event.

Parameters:

  • event_type_name (String)

    The type of event being created. To create an event type, see the event types API.

  • request (CREATE_EVENT_ASYNC_REQUEST)
  • request_options (RequestOptions) (defaults to: nil)

Returns:



43
44
45
46
47
48
49
50
51
# File 'lib/intrinsic/events/client.rb', line 43

def create_event_async(event_type_name:, request:, request_options: nil)
  response = @request_client.conn.post("/api/v2/events/async/#{event_type_name}") do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["X-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
    req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
  end
  CreateEventAsyncResponse.from_json(json_object: response.body)
end

#create_event_sync(event_type_name:, request:, request_options: nil) ⇒ CreateEventSyncResponse

Creates an event in a synchronous, blocking matter. Note for long-running tasks, the Asynchronous API is recommended instead. Returns an ID for the event created as well as the set of detections that were run.

Parameters:

  • event_type_name (String)

    The type of event being created. To create an event type, see the event types API.

  • request (CREATE_EVENT_SYNC_REQUEST)
  • request_options (RequestOptions) (defaults to: nil)

Returns:



27
28
29
30
31
32
33
34
35
# File 'lib/intrinsic/events/client.rb', line 27

def create_event_sync(event_type_name:, request:, request_options: nil)
  response = @request_client.conn.post("/api/v2/events/sync/#{event_type_name}") do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["X-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
    req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
  end
  CreateEventSyncResponse.from_json(json_object: response.body)
end