Class: Intrinsic::AsyncEventsClient
- Inherits:
-
Object
- Object
- Intrinsic::AsyncEventsClient
- 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:) ⇒ AsyncEventsClient constructor
Constructor Details
#initialize(request_client:) ⇒ AsyncEventsClient
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_client ⇒ Object (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.
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..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 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.
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..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 end |