api

package
v0.0.0-...-b535dc5 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

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

Code generated by github.com/deepmap/oapi-codegen version v1.11.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 NewCreateAccountRequest

func NewCreateAccountRequest(server string, body CreateAccountJSONRequestBody) (*http.Request, error)

NewCreateAccountRequest calls the generic CreateAccount builder with application/json body

func NewCreateAccountRequestWithBody

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

NewCreateAccountRequestWithBody generates requests for CreateAccount with any type of body

func NewDisableAccountRequest

func NewDisableAccountRequest(server string, externalRef string) (*http.Request, error)

NewDisableAccountRequest generates requests for DisableAccount

func NewListAccountRequest

func NewListAccountRequest(server string, externalRef string) (*http.Request, error)

NewListAccountRequest generates requests for ListAccount

func NewOnCommandRequest

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

NewOnCommandRequest generates requests for OnCommand

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 AccountContext

type AccountContext struct {
	ExternalRef string `json:"externalRef"`
}

AccountContext defines model for AccountContext.

type AccountDetailedResponse

type AccountDetailedResponse struct {
	Active  bool            `json:"active"`
	Address string          `json:"address"`
	Context *AccountContext `json:"context,omitempty"`
	Id      string          `json:"id"`
	Kind    AccountKind     `json:"kind"`
}

AccountDetailedResponse defines model for AccountDetailedResponse.

type AccountKind

type AccountKind string

AccountKind defines model for AccountKind.

const (
	Kms AccountKind = "kms"
	Pk  AccountKind = "pk"
)

Defines values for AccountKind.

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) CreateAccount

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

func (*Client) CreateAccountWithBody

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

func (*Client) DisableAccount

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

func (*Client) ListAccount

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

func (*Client) OnCommand

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

type ClientInterface

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

	CreateAccount(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ListAccount request
	ListAccount(ctx context.Context, externalRef string, reqEditors ...RequestEditorFn) (*http.Response, error)

	// DisableAccount request
	DisableAccount(ctx context.Context, externalRef string, reqEditors ...RequestEditorFn) (*http.Response, error)

	// OnCommand request
	OnCommand(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) CreateAccountWithBodyWithResponse

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

CreateAccountWithBodyWithResponse request with arbitrary body returning *CreateAccountResponse

func (*ClientWithResponses) CreateAccountWithResponse

func (c *ClientWithResponses) CreateAccountWithResponse(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAccountResponse, error)

func (*ClientWithResponses) DisableAccountWithResponse

func (c *ClientWithResponses) DisableAccountWithResponse(ctx context.Context, externalRef string, reqEditors ...RequestEditorFn) (*DisableAccountResponse, error)

DisableAccountWithResponse request returning *DisableAccountResponse

func (*ClientWithResponses) ListAccountWithResponse

func (c *ClientWithResponses) ListAccountWithResponse(ctx context.Context, externalRef string, reqEditors ...RequestEditorFn) (*ListAccountResponse, error)

ListAccountWithResponse request returning *ListAccountResponse

func (*ClientWithResponses) OnCommandWithResponse

func (c *ClientWithResponses) OnCommandWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*OnCommandResponse, error)

OnCommandWithResponse request returning *OnCommandResponse

type ClientWithResponsesInterface

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

	CreateAccountWithResponse(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAccountResponse, error)

	// ListAccount request
	ListAccountWithResponse(ctx context.Context, externalRef string, reqEditors ...RequestEditorFn) (*ListAccountResponse, error)

	// DisableAccount request
	DisableAccountWithResponse(ctx context.Context, externalRef string, reqEditors ...RequestEditorFn) (*DisableAccountResponse, error)

	// OnCommand request
	OnCommandWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*OnCommandResponse, error)
}

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

type CreateAccountJSONBody

type CreateAccountJSONBody = CreateAccountRequest

CreateAccountJSONBody defines parameters for CreateAccount.

type CreateAccountJSONRequestBody

type CreateAccountJSONRequestBody = CreateAccountJSONBody

CreateAccountJSONRequestBody defines body for CreateAccount for application/json ContentType.

type CreateAccountRequest

type CreateAccountRequest struct {
	Blockchain *string        `json:"blockchain,omitempty"`
	Context    AccountContext `json:"context"`
	Details    interface{}    `json:"details"`
	Kind       AccountKind    `json:"kind"`
}

CreateAccountRequest defines model for CreateAccountRequest.

type CreateAccountResponse

type CreateAccountResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON201      *AccountDetailedResponse
	JSONDefault  *ModelError
}

func ParseCreateAccountResponse

func ParseCreateAccountResponse(rsp *http.Response) (*CreateAccountResponse, error)

ParseCreateAccountResponse parses an HTTP response from a CreateAccountWithResponse call

func (CreateAccountResponse) Status

func (r CreateAccountResponse) Status() string

Status returns HTTPResponse.Status

func (CreateAccountResponse) StatusCode

func (r CreateAccountResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type DisableAccountResponse

type DisableAccountResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSONDefault  *ModelError
}

func ParseDisableAccountResponse

func ParseDisableAccountResponse(rsp *http.Response) (*DisableAccountResponse, error)

ParseDisableAccountResponse parses an HTTP response from a DisableAccountWithResponse call

func (DisableAccountResponse) Status

func (r DisableAccountResponse) Status() string

Status returns HTTPResponse.Status

func (DisableAccountResponse) StatusCode

func (r DisableAccountResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

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 HttpRequestDoer

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

type KmsAccountDetails

type KmsAccountDetails = map[string]interface{}

KmsAccountDetails defines model for KmsAccountDetails.

type ListAccountResponse

type ListAccountResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *AccountDetailedResponse
	JSONDefault  *ModelError
}

func ParseListAccountResponse

func ParseListAccountResponse(rsp *http.Response) (*ListAccountResponse, error)

ParseListAccountResponse parses an HTTP response from a ListAccountWithResponse call

func (ListAccountResponse) Status

func (r ListAccountResponse) Status() string

Status returns HTTPResponse.Status

func (ListAccountResponse) StatusCode

func (r ListAccountResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ModelError

type ModelError struct {
	Code    int32  `json:"code"`
	Key     string `json:"key"`
	Message string `json:"message"`
}

ModelError defines model for ModelError.

type OnCommandResponse

type OnCommandResponse struct {
	Body         []byte
	HTTPResponse *http.Response
}

func ParseOnCommandResponse

func ParseOnCommandResponse(rsp *http.Response) (*OnCommandResponse, error)

ParseOnCommandResponse parses an HTTP response from a OnCommandWithResponse call

func (OnCommandResponse) Status

func (r OnCommandResponse) Status() string

Status returns HTTPResponse.Status

func (OnCommandResponse) StatusCode

func (r OnCommandResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type PKAccountDetails

type PKAccountDetails struct {
	Key string `json:"key"`
}

PKAccountDetails defines model for PKAccountDetails.

type RequestEditorFn

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

RequestEditorFn is the function signature for the RequestEditor callback function

type ServerInterface

type ServerInterface interface {
	// Create executor account for the given tenant
	// (POST /account)
	CreateAccount(ctx echo.Context) error
	// Get account info
	// (GET /account/{externalRef})
	ListAccount(ctx echo.Context, externalRef string) error
	// Get account info
	// (PUT /account/{externalRef}/disable)
	DisableAccount(ctx echo.Context, externalRef string) error

	// (GET /ws)
	OnCommand(ctx echo.Context) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) CreateAccount

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

CreateAccount converts echo context to params.

func (*ServerInterfaceWrapper) DisableAccount

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

DisableAccount converts echo context to params.

func (*ServerInterfaceWrapper) ListAccount

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

ListAccount converts echo context to params.

func (*ServerInterfaceWrapper) OnCommand

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

OnCommand converts echo context to params.

Directories

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

Jump to

Keyboard shortcuts

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