Class: Intrinsic::AsyncEventsClient

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:) ⇒ AsyncEventsClient

Parameters:



59
60
61
62
# File 'lib/intrinsic/events/client.rb', line 59

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

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



55
56
57
# File 'lib/intrinsic/events/client.rb', line 55

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:



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/intrinsic/events/client.rb', line 88

def create_event_async(event_type_name:, request:, request_options: nil)
  Async do
    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
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:



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/intrinsic/events/client.rb', line 70

def create_event_sync(event_type_name:, request:, request_options: nil)
  Async do
    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
end