Class: Intrinsic::EventsClient
- Inherits:
-
Object
- Object
- Intrinsic::EventsClient
- Defined in:
- lib/intrinsic/events/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
-
#create_event_async(event_type_name:, request:, request_options: nil) ⇒ CreateEventAsyncResponse
Creates an event in an asynchronous manner.
-
#create_event_sync(event_type_name:, request:, request_options: nil) ⇒ CreateEventSyncResponse
Creates an event in a synchronous, blocking matter.
- #initialize(request_client:) ⇒ EventsClient constructor
Constructor Details
#initialize(request_client:) ⇒ EventsClient
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_client ⇒ Object (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.
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..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-Key"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(request || {}), **(&.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.
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..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-Key"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact end CreateEventSyncResponse.from_json(json_object: response.body) end |