# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. # typed: true # frozen_string_literal: true require 'faraday' require 'faraday/multipart' require 'sorbet-runtime' module OpenApiSDK 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(filters: T.nilable(::OpenApiSDK::Shared::Filters)).returns(::OpenApiSDK::Operations::QueryEventLogResponse) } def query(filters = nil) # query - 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. request = ::OpenApiSDK::Operations::QueryEventLogRequest.new( filters: filters ) 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(::OpenApiSDK::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 = ::OpenApiSDK::Operations::QueryEventLogResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, T::Array[::OpenApiSDK::Shared::BoundedRequest]) res.bounded_requests = out end elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(request_id: ::String).returns(::OpenApiSDK::Operations::GetRequestFromEventLogResponse) } def get(request_id) # get - Get information about a particular request. request = ::OpenApiSDK::Operations::GetRequestFromEventLogRequest.new( request_id: request_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::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 = ::OpenApiSDK::Operations::GetRequestFromEventLogResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::UnboundedRequest) res.unbounded_request = out end elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(request_id: ::String).returns(::OpenApiSDK::Operations::GenerateRequestPostmanCollectionResponse) } def generate_postman_collection(request_id) # generate_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. request = ::OpenApiSDK::Operations::GenerateRequestPostmanCollectionRequest.new( request_id: request_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::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 = ::OpenApiSDK::Operations::GenerateRequestPostmanCollectionResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 res.postman_collection = r.env.response_body if Utils.match_content_type(content_type, 'application/octet-stream') elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end end end