# 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 ApiEndpoints 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(request: T.nilable(::SpeakeasyClientSDK::Operations::DeleteApiEndpointRequest)).returns(::SpeakeasyClientSDK::Operations::DeleteApiEndpointResponse) } def delete_api_endpoint(request) # delete_api_endpoint - Delete an ApiEndpoint. # Delete an ApiEndpoint. This will also delete all associated Request Logs (if using a Postgres datastore). url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::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 = ::SpeakeasyClientSDK::Operations::DeleteApiEndpointResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 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::FindApiEndpointRequest)).returns(::SpeakeasyClientSDK::Operations::FindApiEndpointResponse) } def find_api_endpoint(request) # find_api_endpoint - 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. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::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 = ::SpeakeasyClientSDK::Operations::FindApiEndpointResponse.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::ApiEndpoint) res.api_endpoint = 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::GenerateOpenApiSpecForApiEndpointRequest)).returns(::SpeakeasyClientSDK::Operations::GenerateOpenApiSpecForApiEndpointResponse) } def generate_open_api_spec_for_api_endpoint(request) # generate_open_api_spec_for_api_endpoint - 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. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::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 = ::SpeakeasyClientSDK::Operations::GenerateOpenApiSpecForApiEndpointResponse.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::GenerateOpenApiSpecDiff) res.generate_open_api_spec_diff = 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::GeneratePostmanCollectionForApiEndpointRequest)).returns(::SpeakeasyClientSDK::Operations::GeneratePostmanCollectionForApiEndpointResponse) } def generate_postman_collection_for_api_endpoint(request) # generate_postman_collection_for_api_endpoint - 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. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::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 = ::SpeakeasyClientSDK::Operations::GeneratePostmanCollectionForApiEndpointResponse.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::GetAllApiEndpointsRequest)).returns(::SpeakeasyClientSDK::Operations::GetAllApiEndpointsResponse) } def get_all_api_endpoints(request) # get_all_api_endpoints - Get all Api endpoints for a particular apiID. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::Operations::GetAllApiEndpointsRequest, base_url, '/v1/apis/{apiID}/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 = ::SpeakeasyClientSDK::Operations::GetAllApiEndpointsResponse.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::ApiEndpoint]) res.api_endpoints = 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::GetAllForVersionApiEndpointsRequest)).returns(::SpeakeasyClientSDK::Operations::GetAllForVersionApiEndpointsResponse) } def get_all_for_version_api_endpoints(request) # get_all_for_version_api_endpoints - Get all ApiEndpoints for a particular apiID and versionID. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::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 = ::SpeakeasyClientSDK::Operations::GetAllForVersionApiEndpointsResponse.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::ApiEndpoint]) res.api_endpoints = 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::GetApiEndpointRequest)).returns(::SpeakeasyClientSDK::Operations::GetApiEndpointResponse) } def get_api_endpoint(request) # get_api_endpoint - Get an ApiEndpoint. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::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 = ::SpeakeasyClientSDK::Operations::GetApiEndpointResponse.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::ApiEndpoint) res.api_endpoint = 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: ::SpeakeasyClientSDK::Operations::UpsertApiEndpointRequest).returns(::SpeakeasyClientSDK::Operations::UpsertApiEndpointResponse) } def upsert_api_endpoint(request) # upsert_api_endpoint - Upsert an ApiEndpoint. # Upsert an ApiEndpoint. If the ApiEndpoint does not exist it will be created, otherwise it will be updated. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::SpeakeasyClientSDK::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 = ::SpeakeasyClientSDK::Operations::UpsertApiEndpointResponse.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::ApiEndpoint) res.api_endpoint = 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