# Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. # typed: true # frozen_string_literal: true require 'faraday' require 'faraday/multipart' require 'sorbet-runtime' module SpeakeasyClientSDK extend T::Sig class Requests extend T::Sig # REST APIs for retrieving request information sig { params(sdk_config: SDKConfiguration).void } def initialize(sdk_config) @sdk_configuration = sdk_config end sig { params(request: T.nilable(::SpeakeasyClientSDK::Operations::GenerateRequestPostmanCollectionRequest)).returns(Utils::FieldAugmented) } def generate_request_postman_collection(request) # generate_request_postman_collection - Generate a Postman collection for a particular request. # Generates a Postman collection for a particular request. # Allowing it to be replayed with the same inputs that were captured by the SDK. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::Operations::GenerateRequestPostmanCollectionRequest, base_url, '/v1/eventlog/{requestID}/generate/postman', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json;q=1, application/octet-stream;q=0' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers 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::GenerateRequestPostmanCollectionResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 res.postman_collection = r.env.response_body if Utils.match_content_type(content_type, 'application/octet-stream') else 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::GetRequestFromEventLogRequest)).returns(Utils::FieldAugmented) } def get_request_from_event_log(request) # get_request_from_event_log - Get information about a particular request. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::Operations::GetRequestFromEventLogRequest, base_url, '/v1/eventlog/{requestID}', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers 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::GetRequestFromEventLogResponse.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, ::SpeakeasyClientSDK::Shared::UnboundedRequest) res.unbounded_request = out end else 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::QueryEventLogRequest)).returns(Utils::FieldAugmented) } def query_event_log(request) # query_event_log - Query the event log to retrieve a list of requests. # Supports retrieving a list of request captured by the SDK for this workspace. # Allows the filtering of requests on a number of criteria such as ApiID, VersionID, Path, Method, etc. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/v1/eventlog/query" headers = {} query_params = Utils.get_query_params(::SpeakeasyClientSDK::Operations::QueryEventLogRequest, 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::QueryEventLogResponse.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::BoundedRequest]) res.bounded_requests = out end else 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