# 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 SpeakeasyClientSDKApiEndpoints extend T::Sig # REST APIs for managing ApiEndpoint entities sig { params(sdk_config: SDKConfiguration).void } def initialize(sdk_config) @sdk_configuration = sdk_config end sig { params(api_id: ::String, version_id: ::String).returns(::OpenApiSDK::Operations::GetAllForVersionApiEndpointsResponse) } def get_all(api_id, version_id) # get_all - Get all ApiEndpoints for a particular apiID and versionID. request = ::OpenApiSDK::Operations::GetAllForVersionApiEndpointsRequest.new( api_id: api_id, version_id: version_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::GetAllForVersionApiEndpointsRequest, base_url, '/v1/apis/{apiID}/version/{versionID}/api_endpoints', 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::GetAllForVersionApiEndpointsResponse.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::ApiEndpoint]) res.api_endpoints = 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(api_id: ::String, version_id: ::String, display_name: ::String).returns(::OpenApiSDK::Operations::FindApiEndpointResponse) } def find(api_id, version_id, display_name) # find - Find an ApiEndpoint via its displayName. # Find an ApiEndpoint via its displayName (set by operationId from a registered OpenAPI schema). # This is useful for finding the ID of an ApiEndpoint to use in the /v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID} endpoints. request = ::OpenApiSDK::Operations::FindApiEndpointRequest.new( api_id: api_id, version_id: version_id, display_name: display_name ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::FindApiEndpointRequest, base_url, '/v1/apis/{apiID}/version/{versionID}/api_endpoints/find/{displayName}', 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::FindApiEndpointResponse.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::ApiEndpoint) res.api_endpoint = 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(api_id: ::String, version_id: ::String, api_endpoint_id: ::String).returns(::OpenApiSDK::Operations::DeleteApiEndpointResponse) } def delete(api_id, version_id, api_endpoint_id) # delete - Delete an ApiEndpoint. # Delete an ApiEndpoint. This will also delete all associated Request Logs (if using a Postgres datastore). request = ::OpenApiSDK::Operations::DeleteApiEndpointRequest.new( api_id: api_id, version_id: version_id, api_endpoint_id: api_endpoint_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::DeleteApiEndpointRequest, base_url, '/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.delete(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::DeleteApiEndpointResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 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(api_id: ::String, version_id: ::String, api_endpoint_id: ::String).returns(::OpenApiSDK::Operations::GetApiEndpointResponse) } def get(api_id, version_id, api_endpoint_id) # get - Get an ApiEndpoint. request = ::OpenApiSDK::Operations::GetApiEndpointRequest.new( api_id: api_id, version_id: version_id, api_endpoint_id: api_endpoint_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::GetApiEndpointRequest, base_url, '/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}', 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::GetApiEndpointResponse.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::ApiEndpoint) res.api_endpoint = 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(api_id: ::String, version_id: ::String, api_endpoint_id: ::String, api_endpoint: ::OpenApiSDK::Shared::ApiEndpointInput).returns(::OpenApiSDK::Operations::UpsertApiEndpointResponse) } def upsert(api_id, version_id, api_endpoint_id, api_endpoint) # upsert - Upsert an ApiEndpoint. # Upsert an ApiEndpoint. If the ApiEndpoint does not exist it will be created, otherwise it will be updated. request = ::OpenApiSDK::Operations::UpsertApiEndpointRequest.new( api_id: api_id, version_id: version_id, api_endpoint_id: api_endpoint_id, api_endpoint: api_endpoint ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::UpsertApiEndpointRequest, base_url, '/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}', request, @sdk_configuration.globals ) headers = {} req_content_type, data, form = Utils.serialize_request_body(request, :api_endpoint, :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.put(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::UpsertApiEndpointResponse.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::ApiEndpoint) res.api_endpoint = 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(api_id: ::String, version_id: ::String, api_endpoint_id: ::String).returns(::OpenApiSDK::Operations::GenerateOpenApiSpecForApiEndpointResponse) } def generate_open_api_spec(api_id, version_id, api_endpoint_id) # generate_open_api_spec - Generate an OpenAPI specification for a particular ApiEndpoint. # This endpoint will generate a new operation in any registered OpenAPI document if the operation does not already exist in the document. # Returns the original document and the newly generated document allowing a diff to be performed to see what has changed. request = ::OpenApiSDK::Operations::GenerateOpenApiSpecForApiEndpointRequest.new( api_id: api_id, version_id: version_id, api_endpoint_id: api_endpoint_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::GenerateOpenApiSpecForApiEndpointRequest, base_url, '/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}/generate/openapi', 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::GenerateOpenApiSpecForApiEndpointResponse.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::GenerateOpenApiSpecDiff) res.generate_open_api_spec_diff = 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(api_id: ::String, version_id: ::String, api_endpoint_id: ::String).returns(::OpenApiSDK::Operations::GeneratePostmanCollectionForApiEndpointResponse) } def generate_postman_collection(api_id, version_id, api_endpoint_id) # generate_postman_collection - Generate a Postman collection for a particular ApiEndpoint. # Generates a postman collection that allows the endpoint to be called from postman variables produced for any path/query/header parameters included in the OpenAPI document. request = ::OpenApiSDK::Operations::GeneratePostmanCollectionForApiEndpointRequest.new( api_id: api_id, version_id: version_id, api_endpoint_id: api_endpoint_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::GeneratePostmanCollectionForApiEndpointRequest, base_url, '/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}/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::GeneratePostmanCollectionForApiEndpointResponse.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