api

package
v0.7.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func NewExecuteFunctionRequest

func NewExecuteFunctionRequest(server string, body ExecuteFunctionJSONRequestBody) (*http.Request, error)

NewExecuteFunctionRequest calls the generic ExecuteFunction builder with application/json body

func NewExecuteFunctionRequestWithBody

func NewExecuteFunctionRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewExecuteFunctionRequestWithBody generates requests for ExecuteFunction with any type of body

func NewExecutionResultRequest

func NewExecutionResultRequest(server string, body ExecutionResultJSONRequestBody) (*http.Request, error)

NewExecutionResultRequest calls the generic ExecutionResult builder with application/json body

func NewExecutionResultRequestWithBody

func NewExecutionResultRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewExecutionResultRequestWithBody generates requests for ExecutionResult with any type of body

func NewHealthRequest

func NewHealthRequest(server string) (*http.Request, error)

NewHealthRequest generates requests for Health

func NewInstallFunctionRequest

func NewInstallFunctionRequest(server string, body InstallFunctionJSONRequestBody) (*http.Request, error)

NewInstallFunctionRequest calls the generic InstallFunction builder with application/json body

func NewInstallFunctionRequestWithBody

func NewInstallFunctionRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewInstallFunctionRequestWithBody generates requests for InstallFunction with any type of body

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type API

type API struct {
	Log  zerolog.Logger
	Node Node
}

API provides REST API functionality for the Bless head node.

func New

func New(log zerolog.Logger, node Node) *API

New creates a new instance of a Bless head node REST API. Access to node data is provided by the provided `node`.

func (*API) ExecuteFunction

func (a *API) ExecuteFunction(ctx echo.Context) error

ExecuteFunction implements the REST API endpoint for function execution.

func (*API) ExecutionResult

func (a *API) ExecutionResult(ctx echo.Context) error

ExecutionResult implements the REST API endpoint for retrieving the result of a function execution.

func (*API) Health

func (a *API) Health(ctx echo.Context) error

Execute implements the REST API endpoint for function execution.

func (*API) InstallFunction

func (a *API) InstallFunction(ctx echo.Context) error

type AggregatedResult

type AggregatedResult = aggregate.Result

AggregatedResult Result of an Execution Request

type AggregatedResults

type AggregatedResults = aggregate.Results

AggregatedResults List of unique results of the Execution Request

type AttributeAttestors

type AttributeAttestors = execute.AttributeAttestors

AttributeAttestors Require specific attestors as vouchers

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) ExecuteFunction

func (c *Client) ExecuteFunction(ctx context.Context, body ExecuteFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ExecuteFunctionWithBody

func (c *Client) ExecuteFunctionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ExecutionResult

func (c *Client) ExecutionResult(ctx context.Context, body ExecutionResultJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ExecutionResultWithBody

func (c *Client) ExecutionResultWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) Health

func (c *Client) Health(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) InstallFunction

func (c *Client) InstallFunction(ctx context.Context, body InstallFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) InstallFunctionWithBody

func (c *Client) InstallFunctionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// ExecuteFunctionWithBody request with any body
	ExecuteFunctionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	ExecuteFunction(ctx context.Context, body ExecuteFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// InstallFunctionWithBody request with any body
	InstallFunctionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	InstallFunction(ctx context.Context, body InstallFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ExecutionResultWithBody request with any body
	ExecutionResultWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	ExecutionResult(ctx context.Context, body ExecutionResultJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// Health request
	Health(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) ExecuteFunctionWithBodyWithResponse

func (c *ClientWithResponses) ExecuteFunctionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ExecuteFunctionResponse, error)

ExecuteFunctionWithBodyWithResponse request with arbitrary body returning *ExecuteFunctionResponse

func (*ClientWithResponses) ExecuteFunctionWithResponse

func (c *ClientWithResponses) ExecuteFunctionWithResponse(ctx context.Context, body ExecuteFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*ExecuteFunctionResponse, error)

func (*ClientWithResponses) ExecutionResultWithBodyWithResponse

func (c *ClientWithResponses) ExecutionResultWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ExecutionResultResponse, error)

ExecutionResultWithBodyWithResponse request with arbitrary body returning *ExecutionResultResponse

func (*ClientWithResponses) ExecutionResultWithResponse

func (c *ClientWithResponses) ExecutionResultWithResponse(ctx context.Context, body ExecutionResultJSONRequestBody, reqEditors ...RequestEditorFn) (*ExecutionResultResponse, error)

func (*ClientWithResponses) HealthWithResponse

func (c *ClientWithResponses) HealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthResponse, error)

HealthWithResponse request returning *HealthResponse

func (*ClientWithResponses) InstallFunctionWithBodyWithResponse

func (c *ClientWithResponses) InstallFunctionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*InstallFunctionResponse, error)

InstallFunctionWithBodyWithResponse request with arbitrary body returning *InstallFunctionResponse

func (*ClientWithResponses) InstallFunctionWithResponse

func (c *ClientWithResponses) InstallFunctionWithResponse(ctx context.Context, body InstallFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*InstallFunctionResponse, error)

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// ExecuteFunctionWithBodyWithResponse request with any body
	ExecuteFunctionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ExecuteFunctionResponse, error)

	ExecuteFunctionWithResponse(ctx context.Context, body ExecuteFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*ExecuteFunctionResponse, error)

	// InstallFunctionWithBodyWithResponse request with any body
	InstallFunctionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*InstallFunctionResponse, error)

	InstallFunctionWithResponse(ctx context.Context, body InstallFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*InstallFunctionResponse, error)

	// ExecutionResultWithBodyWithResponse request with any body
	ExecutionResultWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ExecutionResultResponse, error)

	ExecutionResultWithResponse(ctx context.Context, body ExecutionResultJSONRequestBody, reqEditors ...RequestEditorFn) (*ExecutionResultResponse, error)

	// HealthWithResponse request
	HealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type ExecuteFunctionJSONRequestBody

type ExecuteFunctionJSONRequestBody = ExecutionRequest

ExecuteFunctionJSONRequestBody defines body for ExecuteFunction for application/json ContentType.

type ExecuteFunctionResponse

type ExecuteFunctionResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *ExecutionResponse
}

func ParseExecuteFunctionResponse

func ParseExecuteFunctionResponse(rsp *http.Response) (*ExecuteFunctionResponse, error)

ParseExecuteFunctionResponse parses an HTTP response from a ExecuteFunctionWithResponse call

func (ExecuteFunctionResponse) Status

func (r ExecuteFunctionResponse) Status() string

Status returns HTTPResponse.Status

func (ExecuteFunctionResponse) StatusCode

func (r ExecuteFunctionResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ExecutionConfig

type ExecutionConfig = execute.Config

ExecutionConfig Configuration options for the Execution Request

type ExecutionParameter

type ExecutionParameter = execute.Parameter

ExecutionParameter defines model for ExecutionParameter.

type ExecutionRequest

type ExecutionRequest struct {
	// Config Configuration options for the Execution Request
	Config ExecutionConfig `json:"config,omitempty"`

	// FunctionId CID of the function
	FunctionId string `json:"function_id"`

	// Method Name of the WASM file to execute
	Method string `json:"method"`

	// Parameters CLI arguments for the Bless Function
	Parameters []ExecutionParameter `json:"parameters,omitempty"`

	// Topic In the scenario where workers form subgroups, you can target a specific subgroup by specifying its identifier
	Topic string `json:"topic,omitempty"`
}

ExecutionRequest defines model for ExecutionRequest.

type ExecutionResponse

type ExecutionResponse struct {
	// Cluster Information about the cluster of nodes that executed this request
	Cluster NodeCluster `json:"cluster,omitempty"`

	// Code Status of the execution
	Code string `json:"code,omitempty"`

	// Message If the Execution Request failed, this message might have more info about the error
	Message string `json:"message,omitempty"`

	// RequestId ID of the Execution Request
	RequestId string `json:"request_id,omitempty"`

	// Results List of unique results of the Execution Request
	Results AggregatedResults `json:"results,omitempty"`
}

ExecutionResponse defines model for ExecutionResponse.

type ExecutionResult

type ExecutionResult = execute.RuntimeOutput

ExecutionResult Actual outputs of the execution, like Standard Output, Standard Error, Exit Code etc..

type ExecutionResultJSONRequestBody

type ExecutionResultJSONRequestBody = FunctionResultRequest

ExecutionResultJSONRequestBody defines body for ExecutionResult for application/json ContentType.

type ExecutionResultResponse

type ExecutionResultResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *FunctionResultResponse
}

func ParseExecutionResultResponse

func ParseExecutionResultResponse(rsp *http.Response) (*ExecutionResultResponse, error)

ParseExecutionResultResponse parses an HTTP response from a ExecutionResultWithResponse call

func (ExecutionResultResponse) Status

func (r ExecutionResultResponse) Status() string

Status returns HTTPResponse.Status

func (ExecutionResultResponse) StatusCode

func (r ExecutionResultResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type FunctionInstallRequest

type FunctionInstallRequest struct {
	// Cid CID of the function
	Cid string `json:"cid"`

	// Topic In a scenario where workers form subgroups, you can target a specific subgroup by specifying its identifier
	Topic string `json:"topic,omitempty"`
	Uri   string `json:"uri,omitempty"`
}

FunctionInstallRequest defines model for FunctionInstallRequest.

func (FunctionInstallRequest) Valid

func (r FunctionInstallRequest) Valid() error

type FunctionInstallResponse

type FunctionInstallResponse struct {
	Code string `json:"code,omitempty"`
}

FunctionInstallResponse defines model for FunctionInstallResponse.

type FunctionResultRequest

type FunctionResultRequest struct {
	// Id ID of the Execution Request
	Id string `json:"id"`
}

FunctionResultRequest Get the result of an Execution Request, identified by the request ID

func (FunctionResultRequest) Valid

func (r FunctionResultRequest) Valid() error

type FunctionResultResponse

type FunctionResultResponse = ExecutionResponse

FunctionResultResponse defines model for FunctionResultResponse.

type HealthResponse

type HealthResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *HealthStatus
}

func ParseHealthResponse

func ParseHealthResponse(rsp *http.Response) (*HealthResponse, error)

ParseHealthResponse parses an HTTP response from a HealthWithResponse call

func (HealthResponse) Status

func (r HealthResponse) Status() string

Status returns HTTPResponse.Status

func (HealthResponse) StatusCode

func (r HealthResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HealthStatus

type HealthStatus struct {
	Code string `json:"code,omitempty"`
}

HealthStatus Node status

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type InstallFunctionJSONRequestBody

type InstallFunctionJSONRequestBody = FunctionInstallRequest

InstallFunctionJSONRequestBody defines body for InstallFunction for application/json ContentType.

type InstallFunctionResponse

type InstallFunctionResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *FunctionInstallResponse
}

func ParseInstallFunctionResponse

func ParseInstallFunctionResponse(rsp *http.Response) (*InstallFunctionResponse, error)

ParseInstallFunctionResponse parses an HTTP response from a InstallFunctionWithResponse call

func (InstallFunctionResponse) Status

func (r InstallFunctionResponse) Status() string

Status returns HTTPResponse.Status

func (InstallFunctionResponse) StatusCode

func (r InstallFunctionResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type NamedValue

type NamedValue = execute.EnvVar

NamedValue A key-value pair

type Node

type Node interface {
	ExecuteFunction(ctx context.Context, req execute.Request, subgroup string) (code codes.Code, requestID string, results execute.ResultMap, peers execute.Cluster, err error)
	ExecutionResult(id string) (execute.ResultMap, bool)
	PublishFunctionInstall(ctx context.Context, uri string, cid string, subgroup string) error
}

type NodeAttributes

type NodeAttributes = execute.Attributes

NodeAttributes Attributes that the executing Node should have

type NodeCluster

type NodeCluster = execute.Cluster

NodeCluster Information about the cluster of nodes that executed this request

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type ResultAggregation

type ResultAggregation = execute.ResultAggregation

ResultAggregation defines model for ResultAggregation.

type RuntimeConfig

type RuntimeConfig = execute.BLSRuntimeConfig

RuntimeConfig Configuration options for the Bless Runtime

type ServerInterface

type ServerInterface interface {
	// Execute a Bless Function
	// (POST /api/v1/functions/execute)
	ExecuteFunction(ctx echo.Context) error
	// Install a Bless Function
	// (POST /api/v1/functions/install)
	InstallFunction(ctx echo.Context) error
	// Get the result of an Execution Request
	// (POST /api/v1/functions/requests/result)
	ExecutionResult(ctx echo.Context) error
	// Check Node health
	// (GET /api/v1/health)
	Health(ctx echo.Context) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) ExecuteFunction

func (w *ServerInterfaceWrapper) ExecuteFunction(ctx echo.Context) error

ExecuteFunction converts echo context to params.

func (*ServerInterfaceWrapper) ExecutionResult

func (w *ServerInterfaceWrapper) ExecutionResult(ctx echo.Context) error

ExecutionResult converts echo context to params.

func (*ServerInterfaceWrapper) Health

func (w *ServerInterfaceWrapper) Health(ctx echo.Context) error

Health converts echo context to params.

func (*ServerInterfaceWrapper) InstallFunction

func (w *ServerInterfaceWrapper) InstallFunction(ctx echo.Context) error

InstallFunction converts echo context to params.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL