# 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 Suggest extend T::Sig # REST APIs for managing LLM OAS suggestions sig { params(sdk_config: SDKConfiguration).void } def initialize(sdk_config) @sdk_configuration = sdk_config end sig { params(x_session_id: ::String, request_body: ::OpenApiSDK::Operations::SuggestOpenAPIRequestBody).returns(::OpenApiSDK::Operations::SuggestOpenAPIResponse) } def openapi(x_session_id, request_body) # openapi - (DEPRECATED) Generate suggestions for improving an OpenAPI document. # Get suggestions from an LLM model for improving an OpenAPI document. request = ::OpenApiSDK::Operations::SuggestOpenAPIRequest.new( x_session_id: x_session_id, request_body: request_body ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/v1/suggest/openapi" headers = Utils.get_headers(request, @sdk_configuration.globals) req_content_type, data, form = Utils.serialize_request_body(request, :request_body, :multipart) 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 = ::OpenApiSDK::Operations::SuggestOpenAPIResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 res.schema = r.env.response_body if Utils.match_content_type(content_type, 'application/json') end res end sig { params(x_session_id: ::String, suggest_request_body: ::OpenApiSDK::Shared::SuggestRequestBody).returns(::OpenApiSDK::Operations::SuggestResponse) } def generate(x_session_id, suggest_request_body) # generate - Generate suggestions for improving an OpenAPI document. # Get suggestions from an LLM model for improving an OpenAPI document. request = ::OpenApiSDK::Operations::SuggestRequest.new( x_session_id: x_session_id, suggest_request_body: suggest_request_body ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/v1/suggest/openapi_from_summary" headers = Utils.get_headers(request, @sdk_configuration.globals) req_content_type, data, form = Utils.serialize_request_body(request, :suggest_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 = ::OpenApiSDK::Operations::SuggestResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 res.schema = r.env.response_body if Utils.match_content_type(content_type, 'application/json') end res end sig { params(x_session_id: ::String, namespace_name: ::String, revision_reference: ::String, suggest_request_body: T.nilable(::OpenApiSDK::Shared::SuggestRequestBody)).returns(::OpenApiSDK::Operations::SuggestOpenAPIRegistryResponse) } def openapi_registry(x_session_id, namespace_name, revision_reference, suggest_request_body = nil) # openapi_registry - Generate suggestions for improving an OpenAPI document stored in the registry. # Get suggestions from an LLM model for improving an OpenAPI document stored in the registry. request = ::OpenApiSDK::Operations::SuggestOpenAPIRegistryRequest.new( x_session_id: x_session_id, namespace_name: namespace_name, revision_reference: revision_reference, suggest_request_body: suggest_request_body ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::SuggestOpenAPIRegistryRequest, base_url, '/v1/suggest/openapi/{namespace_name}/{revision_reference}', request, @sdk_configuration.globals ) headers = Utils.get_headers(request, @sdk_configuration.globals) req_content_type, data, form = Utils.serialize_request_body(request, :suggest_request_body, :json) headers['content-type'] = req_content_type 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 = ::OpenApiSDK::Operations::SuggestOpenAPIRegistryResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 res.schema = r.env.response_body if Utils.match_content_type(content_type, 'application/json') end res end end end