api

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 22 Imported by: 2

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 added in v0.6.0

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 added in v0.6.0

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

NewExecuteFunctionRequest calls the generic ExecuteFunction builder with application/json body

func NewExecuteFunctionRequestWithBody added in v0.6.0

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

NewExecuteFunctionRequestWithBody generates requests for ExecuteFunction with any type of body

func NewExecutionResultRequest added in v0.6.0

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

NewExecutionResultRequest calls the generic ExecutionResult builder with application/json body

func NewExecutionResultRequestWithBody added in v0.6.0

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

NewExecutionResultRequestWithBody generates requests for ExecutionResult with any type of body

func NewHealthRequest added in v0.6.0

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

NewHealthRequest generates requests for Health

func NewInstallFunctionRequest added in v0.6.0

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

NewInstallFunctionRequest calls the generic InstallFunction builder with application/json body

func NewInstallFunctionRequestWithBody added in v0.6.0

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

NewInstallFunctionRequestWithBody generates requests for InstallFunction with any type of body

func PathToRawSpec added in v0.6.0

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

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

func RegisterHandlers added in v0.6.0

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL added in v0.6.0

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 Blockless head node.

func New

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

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

func (*API) ExecuteFunction added in v0.6.0

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 added in v0.6.0

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

type AggregatedResult added in v0.6.0

type AggregatedResult = aggregate.Result

AggregatedResult Result of an Execution Request

type AggregatedResults added in v0.6.0

type AggregatedResults = aggregate.Results

AggregatedResults List of unique results of the Execution Request

type AttributeAttestors added in v0.6.0

type AttributeAttestors = execute.AttributeAttestors

AttributeAttestors Require specific attestors as vouchers

type Client added in v0.6.0

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 added in v0.6.0

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

Creates a new Client, with reasonable defaults

func (*Client) ExecuteFunction added in v0.6.0

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

func (*Client) ExecuteFunctionWithBody added in v0.6.0

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

func (*Client) ExecutionResult added in v0.6.0

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

func (*Client) ExecutionResultWithBody added in v0.6.0

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

func (*Client) Health added in v0.6.0

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

func (*Client) InstallFunction added in v0.6.0

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

func (*Client) InstallFunctionWithBody added in v0.6.0

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

type ClientInterface added in v0.6.0

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 added in v0.6.0

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL added in v0.6.0

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient added in v0.6.0

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 added in v0.6.0

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 added in v0.6.0

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses added in v0.6.0

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

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

func (*ClientWithResponses) ExecuteFunctionWithBodyWithResponse added in v0.6.0

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 added in v0.6.0

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

func (*ClientWithResponses) ExecutionResultWithBodyWithResponse added in v0.6.0

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 added in v0.6.0

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

func (*ClientWithResponses) HealthWithResponse added in v0.6.0

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

HealthWithResponse request returning *HealthResponse

func (*ClientWithResponses) InstallFunctionWithBodyWithResponse added in v0.6.0

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 added in v0.6.0

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

type ClientWithResponsesInterface added in v0.6.0

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 added in v0.6.0

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 added in v0.6.0

type ExecuteFunctionJSONRequestBody = ExecutionRequest

ExecuteFunctionJSONRequestBody defines body for ExecuteFunction for application/json ContentType.

type ExecuteFunctionResponse added in v0.6.0

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

func ParseExecuteFunctionResponse added in v0.6.0

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

ParseExecuteFunctionResponse parses an HTTP response from a ExecuteFunctionWithResponse call

func (ExecuteFunctionResponse) Status added in v0.6.0

func (r ExecuteFunctionResponse) Status() string

Status returns HTTPResponse.Status

func (ExecuteFunctionResponse) StatusCode added in v0.6.0

func (r ExecuteFunctionResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ExecutionConfig added in v0.6.0

type ExecutionConfig = execute.Config

ExecutionConfig Configuration options for the Execution Request

type ExecutionParameter added in v0.6.0

type ExecutionParameter = execute.Parameter

ExecutionParameter defines model for ExecutionParameter.

type ExecutionRequest added in v0.6.0

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 Blockless 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 added in v0.6.0

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 added in v0.6.0

type ExecutionResult = execute.RuntimeOutput

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

type ExecutionResultJSONRequestBody added in v0.6.0

type ExecutionResultJSONRequestBody = FunctionResultRequest

ExecutionResultJSONRequestBody defines body for ExecutionResult for application/json ContentType.

type ExecutionResultResponse added in v0.6.0

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

func ParseExecutionResultResponse added in v0.6.0

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

ParseExecutionResultResponse parses an HTTP response from a ExecutionResultWithResponse call

func (ExecutionResultResponse) Status added in v0.6.0

func (r ExecutionResultResponse) Status() string

Status returns HTTPResponse.Status

func (ExecutionResultResponse) StatusCode added in v0.6.0

func (r ExecutionResultResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type FunctionInstallRequest added in v0.6.0

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.

type FunctionInstallResponse added in v0.6.0

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

FunctionInstallResponse defines model for FunctionInstallResponse.

type FunctionResultRequest added in v0.6.0

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

type FunctionResultResponse added in v0.6.0

type FunctionResultResponse = ExecutionResponse

FunctionResultResponse defines model for FunctionResultResponse.

type HealthResponse added in v0.6.0

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

func ParseHealthResponse added in v0.6.0

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

ParseHealthResponse parses an HTTP response from a HealthWithResponse call

func (HealthResponse) Status added in v0.6.0

func (r HealthResponse) Status() string

Status returns HTTPResponse.Status

func (HealthResponse) StatusCode added in v0.6.0

func (r HealthResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HealthStatus added in v0.6.0

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

HealthStatus Node status

type HttpRequestDoer added in v0.6.0

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

type InstallFunctionJSONRequestBody added in v0.6.0

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 added in v0.6.0

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

ParseInstallFunctionResponse parses an HTTP response from a InstallFunctionWithResponse call

func (InstallFunctionResponse) Status added in v0.6.0

func (r InstallFunctionResponse) Status() string

Status returns HTTPResponse.Status

func (InstallFunctionResponse) StatusCode added in v0.6.0

func (r InstallFunctionResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type NamedValue added in v0.6.0

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.Result, bool)
	PublishFunctionInstall(ctx context.Context, uri string, cid string, subgroup string) error
}

type NodeAttributes added in v0.6.0

type NodeAttributes = execute.Attributes

NodeAttributes Attributes that the executing Node should have

type NodeCluster added in v0.6.0

type NodeCluster = execute.Cluster

NodeCluster Information about the cluster of nodes that executed this request

type RequestEditorFn added in v0.6.0

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

RequestEditorFn is the function signature for the RequestEditor callback function

type ResultAggregation added in v0.6.0

type ResultAggregation = execute.ResultAggregation

ResultAggregation defines model for ResultAggregation.

type RuntimeConfig added in v0.6.0

type RuntimeConfig = execute.BLSRuntimeConfig

RuntimeConfig Configuration options for the Blockless Runtime

type ServerInterface added in v0.6.0

type ServerInterface interface {
	// Execute a Blockless Function
	// (POST /api/v1/functions/execute)
	ExecuteFunction(ctx echo.Context) error
	// Install a Blockless 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 added in v0.6.0

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) ExecuteFunction added in v0.6.0

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

ExecuteFunction converts echo context to params.

func (*ServerInterfaceWrapper) ExecutionResult added in v0.6.0

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

ExecutionResult converts echo context to params.

func (*ServerInterfaceWrapper) Health added in v0.6.0

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

Health converts echo context to params.

func (*ServerInterfaceWrapper) InstallFunction added in v0.6.0

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