# Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. # typed: true # frozen_string_literal: true require 'faraday' require 'faraday/multipart' require 'sorbet-runtime' module SpeakeasyClientSDK extend T::Sig class Events extend T::Sig # REST APIs for capturing event data sig { params(sdk_config: SDKConfiguration).void } def initialize(sdk_config) @sdk_configuration = sdk_config end sig { params(request: T.nilable(::SpeakeasyClientSDK::Operations::GetWorkspaceEventsByTargetRequest)).returns(::SpeakeasyClientSDK::Operations::GetWorkspaceEventsByTargetResponse) } def get_workspace_events_by_target(request) # get_workspace_events_by_target - Load recent events for a particular workspace url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::Operations::GetWorkspaceEventsByTargetRequest, base_url, '/v1/workspace/{workspaceID}/events/targets/{targetID}/events', request, @sdk_configuration.globals ) headers = {} query_params = Utils.get_query_params(::SpeakeasyClientSDK::Operations::GetWorkspaceEventsByTargetRequest, request, @sdk_configuration.globals) headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers req.params = query_params Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::SpeakeasyClientSDK::Operations::GetWorkspaceEventsByTargetResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, T::Array[::SpeakeasyClientSDK::Shared::CliEvent]) res.cli_event_batch = out end elsif r.status >= 500 && r.status < 600 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::SpeakeasyClientSDK::Shared::Error) res.error = out end end res end sig { params(request: T.nilable(::SpeakeasyClientSDK::Operations::GetWorkspaceTargetsRequest)).returns(::SpeakeasyClientSDK::Operations::GetWorkspaceTargetsResponse) } def get_workspace_targets(request) # get_workspace_targets - Load targets for a particular workspace url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::Operations::GetWorkspaceTargetsRequest, base_url, '/v1/workspace/{workspaceID}/events/targets', request, @sdk_configuration.globals ) headers = {} query_params = Utils.get_query_params(::SpeakeasyClientSDK::Operations::GetWorkspaceTargetsRequest, request, @sdk_configuration.globals) headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers req.params = query_params Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::SpeakeasyClientSDK::Operations::GetWorkspaceTargetsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, T::Array[::SpeakeasyClientSDK::Shared::TargetSDK]) res.target_sdk_list = out end elsif r.status >= 500 && r.status < 600 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::SpeakeasyClientSDK::Shared::Error) res.error = out end end res end sig { params(request: ::SpeakeasyClientSDK::Operations::PostWorkspaceEventsRequest).returns(::SpeakeasyClientSDK::Operations::PostWorkspaceEventsResponse) } def post_workspace_events(request) # post_workspace_events - Post events for a specific workspace # Sends an array of events to be stored for a particular workspace. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::Operations::PostWorkspaceEventsRequest, base_url, '/v1/workspace/{workspaceID}/events', request, @sdk_configuration.globals ) headers = {} req_content_type, data, form = Utils.serialize_request_body(request, :request_body, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.post(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::SpeakeasyClientSDK::Operations::PostWorkspaceEventsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 elsif r.status >= 500 && r.status < 600 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::SpeakeasyClientSDK::Shared::Error) res.error = out end end res end sig { params(request: T.nilable(::SpeakeasyClientSDK::Operations::SearchWorkspaceEventsRequest)).returns(::SpeakeasyClientSDK::Operations::SearchWorkspaceEventsResponse) } def search_workspace_events(request) # search_workspace_events - Search events for a particular workspace by any field url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::Operations::SearchWorkspaceEventsRequest, base_url, '/v1/workspace/{workspaceID}/events', request, @sdk_configuration.globals ) headers = {} query_params = Utils.get_query_params(::SpeakeasyClientSDK::Operations::SearchWorkspaceEventsRequest, request, @sdk_configuration.globals) headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers req.params = query_params Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::SpeakeasyClientSDK::Operations::SearchWorkspaceEventsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, T::Array[::SpeakeasyClientSDK::Shared::CliEvent]) res.cli_event_batch = out end elsif r.status >= 500 && r.status < 600 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::SpeakeasyClientSDK::Shared::Error) res.error = out end end res end end end