v1

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: GPL-3.0 Imports: 16 Imported by: 2

Documentation

Overview

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

Code generated by github.com/deepmap/oapi-codegen version v1.8.2 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGetPeerDiagnosticsRequest

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

NewGetPeerDiagnosticsRequest generates requests for GetPeerDiagnostics

func NewGetTransactionPayloadRequest

func NewGetTransactionPayloadRequest(server string, ref string) (*http.Request, error)

NewGetTransactionPayloadRequest generates requests for GetTransactionPayload

func NewGetTransactionRequest

func NewGetTransactionRequest(server string, ref string) (*http.Request, error)

NewGetTransactionRequest generates requests for GetTransaction

func NewListTransactionsRequest

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

NewListTransactionsRequest generates requests for ListTransactions

func NewRenderGraphRequest

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

NewRenderGraphRequest generates requests for RenderGraph

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

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

func (*Client) GetTransaction

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

func (*Client) GetTransactionPayload

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

func (*Client) ListTransactions

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

func (*Client) RenderGraph

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

type ClientInterface

type ClientInterface interface {
	// RenderGraph request
	RenderGraph(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

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

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

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

	// GetTransactionPayload request
	GetTransactionPayload(ctx context.Context, ref string, 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) GetPeerDiagnosticsWithResponse

func (c *ClientWithResponses) GetPeerDiagnosticsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetPeerDiagnosticsResponse, error)

GetPeerDiagnosticsWithResponse request returning *GetPeerDiagnosticsResponse

func (*ClientWithResponses) GetTransactionPayloadWithResponse

func (c *ClientWithResponses) GetTransactionPayloadWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*GetTransactionPayloadResponse, error)

GetTransactionPayloadWithResponse request returning *GetTransactionPayloadResponse

func (*ClientWithResponses) GetTransactionWithResponse

func (c *ClientWithResponses) GetTransactionWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*GetTransactionResponse, error)

GetTransactionWithResponse request returning *GetTransactionResponse

func (*ClientWithResponses) ListTransactionsWithResponse

func (c *ClientWithResponses) ListTransactionsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListTransactionsResponse, error)

ListTransactionsWithResponse request returning *ListTransactionsResponse

func (*ClientWithResponses) RenderGraphWithResponse

func (c *ClientWithResponses) RenderGraphWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*RenderGraphResponse, error)

RenderGraphWithResponse request returning *RenderGraphResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// RenderGraph request
	RenderGraphWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*RenderGraphResponse, error)

	// GetPeerDiagnostics request
	GetPeerDiagnosticsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetPeerDiagnosticsResponse, error)

	// ListTransactions request
	ListTransactionsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListTransactionsResponse, error)

	// GetTransaction request
	GetTransactionWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*GetTransactionResponse, error)

	// GetTransactionPayload request
	GetTransactionPayloadWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*GetTransactionPayloadResponse, error)
}

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

type EchoRouter

type EchoRouter interface {
	Add(method string, 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 ErrorStatusCodeResolver

type ErrorStatusCodeResolver interface {
	ResolveStatusCode(err error) int
}

type GetPeerDiagnosticsResponse

type GetPeerDiagnosticsResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		AdditionalProperties map[string]PeerDiagnostics `json:"-"`
	}
}

func ParseGetPeerDiagnosticsResponse

func ParseGetPeerDiagnosticsResponse(rsp *http.Response) (*GetPeerDiagnosticsResponse, error)

ParseGetPeerDiagnosticsResponse parses an HTTP response from a GetPeerDiagnosticsWithResponse call

func (GetPeerDiagnosticsResponse) Status

Status returns HTTPResponse.Status

func (GetPeerDiagnosticsResponse) StatusCode

func (r GetPeerDiagnosticsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetTransactionPayloadResponse

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

func ParseGetTransactionPayloadResponse

func ParseGetTransactionPayloadResponse(rsp *http.Response) (*GetTransactionPayloadResponse, error)

ParseGetTransactionPayloadResponse parses an HTTP response from a GetTransactionPayloadWithResponse call

func (GetTransactionPayloadResponse) Status

Status returns HTTPResponse.Status

func (GetTransactionPayloadResponse) StatusCode

func (r GetTransactionPayloadResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetTransactionResponse

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

func ParseGetTransactionResponse

func ParseGetTransactionResponse(rsp *http.Response) (*GetTransactionResponse, error)

ParseGetTransactionResponse parses an HTTP response from a GetTransactionWithResponse call

func (GetTransactionResponse) Status

func (r GetTransactionResponse) Status() string

Status returns HTTPResponse.Status

func (GetTransactionResponse) StatusCode

func (r GetTransactionResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HTTPClient

type HTTPClient struct {
	ServerAddress string
	Timeout       time.Duration
}

HTTPClient holds the server address and other basic settings for the http client

func (HTTPClient) GetPeerDiagnostics

func (hb HTTPClient) GetPeerDiagnostics() (map[transport.PeerID]PeerDiagnostics, error)

GetPeerDiagnostics retrieves diagnostic information on the node's peers.

func (HTTPClient) GetTransaction

func (hb HTTPClient) GetTransaction(transactionRef hash.SHA256Hash) (dag.Transaction, error)

GetTransaction retrieves the transaction for the given reference. If the transaction is not known, an error is returned.

func (HTTPClient) GetTransactionPayload

func (hb HTTPClient) GetTransactionPayload(transactionRef hash.SHA256Hash) ([]byte, error)

GetTransactionPayload retrieves the transaction payload for the given transaction. If the transaction or payload is not found nil is returned.

func (HTTPClient) ListTransactions

func (hb HTTPClient) ListTransactions() ([]dag.Transaction, error)

ListTransactions returns all transactions known to this network instance.

type HttpRequestDoer

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

type ListTransactionsResponse

type ListTransactionsResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *[]string
}

func ParseListTransactionsResponse

func ParseListTransactionsResponse(rsp *http.Response) (*ListTransactionsResponse, error)

ParseListTransactionsResponse parses an HTTP response from a ListTransactionsWithResponse call

func (ListTransactionsResponse) Status

func (r ListTransactionsResponse) Status() string

Status returns HTTPResponse.Status

func (ListTransactionsResponse) StatusCode

func (r ListTransactionsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type PeerDiagnostics

type PeerDiagnostics transport.Diagnostics

PeerDiagnostics defines the type for diagnostics of a peer

func (PeerDiagnostics) MarshalJSON

func (p PeerDiagnostics) MarshalJSON() ([]byte, error)

MarshalJSON is the custom JSON marshaler for PeerDiagnostics

func (*PeerDiagnostics) UnmarshalJSON

func (p *PeerDiagnostics) UnmarshalJSON(bytes []byte) error

UnmarshalJSON is the custom JSON unmarshaler for PeerDiagnostics

type Preprocessor

type Preprocessor interface {
	Preprocess(operationID string, context echo.Context)
}

type RenderGraphResponse

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

func ParseRenderGraphResponse

func ParseRenderGraphResponse(rsp *http.Response) (*RenderGraphResponse, error)

ParseRenderGraphResponse parses an HTTP response from a RenderGraphWithResponse call

func (RenderGraphResponse) Status

func (r RenderGraphResponse) Status() string

Status returns HTTPResponse.Status

func (RenderGraphResponse) StatusCode

func (r RenderGraphResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

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 {
	// Visualizes the DAG as a graph
	// (GET /internal/network/v1/diagnostics/graph)
	RenderGraph(ctx echo.Context) error
	// Gets diagnostic information about the node's peers
	// (GET /internal/network/v1/diagnostics/peers)
	GetPeerDiagnostics(ctx echo.Context) error
	// Lists the transactions on the DAG
	// (GET /internal/network/v1/transaction)
	ListTransactions(ctx echo.Context) error
	// Retrieves a transaction
	// (GET /internal/network/v1/transaction/{ref})
	GetTransaction(ctx echo.Context, ref string) error
	// Gets the transaction payload
	// (GET /internal/network/v1/transaction/{ref}/payload)
	GetTransactionPayload(ctx echo.Context, ref string) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) GetPeerDiagnostics

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

GetPeerDiagnostics converts echo context to params.

func (*ServerInterfaceWrapper) GetTransaction

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

GetTransaction converts echo context to params.

func (*ServerInterfaceWrapper) GetTransactionPayload

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

GetTransactionPayload converts echo context to params.

func (*ServerInterfaceWrapper) ListTransactions

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

ListTransactions converts echo context to params.

func (*ServerInterfaceWrapper) RenderGraph

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

RenderGraph converts echo context to params.

type Wrapper

type Wrapper struct {
	Service network.Transactions
}

Wrapper implements the ServerInterface for the network API.

func (Wrapper) GetPeerDiagnostics

func (a Wrapper) GetPeerDiagnostics(ctx echo.Context) error

GetPeerDiagnostics returns the diagnostics of the node's peers

func (Wrapper) GetTransaction

func (a Wrapper) GetTransaction(ctx echo.Context, hashAsString string) error

GetTransaction returns a specific transaction

func (Wrapper) GetTransactionPayload

func (a Wrapper) GetTransactionPayload(ctx echo.Context, hashAsString string) error

GetTransactionPayload returns the payload of a specific transaction

func (Wrapper) ListTransactions

func (a Wrapper) ListTransactions(ctx echo.Context) error

ListTransactions lists all transactions

func (*Wrapper) Preprocess

func (a *Wrapper) Preprocess(operationID string, context echo.Context)

Preprocess is called just before the API operation itself is invoked.

func (Wrapper) RenderGraph

func (a Wrapper) RenderGraph(ctx echo.Context) error

RenderGraph visualizes the DAG as Graphviz/dot graph

func (*Wrapper) Routes

func (a *Wrapper) Routes(router core.EchoRouter)

Jump to

Keyboard shortcuts

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