Documentation
¶
Overview ¶
Package api provides primitives to interact the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.
Index ¶
- func NewAddDocumentRequest(server string, body AddDocumentJSONRequestBody) (*http.Request, error)
- func NewAddDocumentRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
- func NewGetDocumentContentsRequest(server string, hash string) (*http.Request, error)
- func NewGetDocumentRequest(server string, hash string) (*http.Request, error)
- func NewListDocumentsRequest(server string) (*http.Request, error)
- func ParseAddDocumentResponse(rsp *http.Response) (*addDocumentResponse, error)
- func ParseGetDocumentContentsResponse(rsp *http.Response) (*getDocumentContentsResponse, error)
- func ParseGetDocumentResponse(rsp *http.Response) (*getDocumentResponse, error)
- func ParseListDocumentsResponse(rsp *http.Response) (*listDocumentsResponse, error)
- func RegisterHandlers(router EchoRouter, si ServerInterface)
- type AddDocumentJSONBody
- type AddDocumentJSONRequestBody
- type ApiWrapper
- type Client
- func (c *Client) AddDocument(ctx context.Context, body AddDocumentJSONRequestBody) (*http.Response, error)
- func (c *Client) AddDocumentWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)
- func (c *Client) GetDocument(ctx context.Context, hash string) (*http.Response, error)
- func (c *Client) GetDocumentContents(ctx context.Context, hash string) (*http.Response, error)
- func (c *Client) ListDocuments(ctx context.Context) (*http.Response, error)
- type ClientInterface
- type ClientOption
- type ClientWithResponses
- func (c *ClientWithResponses) AddDocumentWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*addDocumentResponse, error)
- func (c *ClientWithResponses) AddDocumentWithResponse(ctx context.Context, body AddDocumentJSONRequestBody) (*addDocumentResponse, error)
- func (c *ClientWithResponses) GetDocumentContentsWithResponse(ctx context.Context, hash string) (*getDocumentContentsResponse, error)
- func (c *ClientWithResponses) GetDocumentWithResponse(ctx context.Context, hash string) (*getDocumentResponse, error)
- func (c *ClientWithResponses) ListDocumentsWithResponse(ctx context.Context) (*listDocumentsResponse, error)
- type Document
- type DocumentWithContents
- type EchoRouter
- type HttpClient
- func (hb HttpClient) AddDocumentWithContents(timestamp time.Time, docType string, contents []byte) (*model.Document, error)
- func (hb HttpClient) GetDocument(hash model.Hash) (*model.DocumentDescriptor, error)
- func (hb HttpClient) GetDocumentContents(hash model.Hash) (io.ReadCloser, error)
- func (hb HttpClient) ListDocuments() ([]model.DocumentDescriptor, error)
- func (hb HttpClient) Subscribe(documentType string) documentlog.DocumentQueue
- type HttpRequestDoer
- type RequestEditorFn
- type ServerInterface
- type ServerInterfaceWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAddDocumentRequest ¶
func NewAddDocumentRequest(server string, body AddDocumentJSONRequestBody) (*http.Request, error)
NewAddDocumentRequest calls the generic AddDocument builder with application/json body
func NewAddDocumentRequestWithBody ¶
func NewAddDocumentRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
NewAddDocumentRequestWithBody generates requests for AddDocument with any type of body
func NewGetDocumentContentsRequest ¶
NewGetDocumentContentsRequest generates requests for GetDocumentContents
func NewGetDocumentRequest ¶
NewGetDocumentRequest generates requests for GetDocument
func NewListDocumentsRequest ¶
NewListDocumentsRequest generates requests for ListDocuments
func ParseAddDocumentResponse ¶
ParseAddDocumentResponse parses an HTTP response from a AddDocumentWithResponse call
func ParseGetDocumentContentsResponse ¶
ParseGetDocumentContentsResponse parses an HTTP response from a GetDocumentContentsWithResponse call
func ParseGetDocumentResponse ¶
ParseGetDocumentResponse parses an HTTP response from a GetDocumentWithResponse call
func ParseListDocumentsResponse ¶
ParseListDocumentsResponse parses an HTTP response from a ListDocumentsWithResponse call
func RegisterHandlers ¶
func RegisterHandlers(router EchoRouter, si ServerInterface)
RegisterHandlers adds each server route to the EchoRouter.
Types ¶
type AddDocumentJSONBody ¶
type AddDocumentJSONBody DocumentWithContents
AddDocumentJSONBody defines parameters for AddDocument.
type AddDocumentJSONRequestBody ¶
type AddDocumentJSONRequestBody AddDocumentJSONBody
AddDocumentRequestBody defines body for AddDocument for application/json ContentType.
type ApiWrapper ¶
type ApiWrapper struct {
Service pkg.NetworkClient
}
ApiWrapper is needed to connect the implementation to the echo ServiceWrapper
func (ApiWrapper) AddDocument ¶
func (a ApiWrapper) AddDocument(ctx echo.Context) error
func (ApiWrapper) GetDocument ¶
func (a ApiWrapper) GetDocument(ctx echo.Context, hashAsString string) error
func (ApiWrapper) GetDocumentContents ¶
func (a ApiWrapper) GetDocumentContents(ctx echo.Context, hashAsString string) error
func (ApiWrapper) ListDocuments ¶
func (a ApiWrapper) ListDocuments(ctx echo.Context) error
type Client ¶
type Client struct {
// The endpoint of the server conforming to this interface, with scheme,
// https://api.deepmap.com for example.
Server string
// Doer for performing requests, typically a *http.Client with any
// customized settings, such as certificate chains.
Client HttpRequestDoer
// A callback for modifying requests which are generated before sending over
// the network.
RequestEditor 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) AddDocument ¶
func (*Client) AddDocumentWithBody ¶
func (*Client) GetDocument ¶
func (*Client) GetDocumentContents ¶
type ClientInterface ¶
type ClientInterface interface {
// ListDocuments request
ListDocuments(ctx context.Context) (*http.Response, error)
// AddDocument request with any body
AddDocumentWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)
AddDocument(ctx context.Context, body AddDocumentJSONRequestBody) (*http.Response, error)
// GetDocument request
GetDocument(ctx context.Context, hash string) (*http.Response, error)
// GetDocumentContents request
GetDocumentContents(ctx context.Context, hash string) (*http.Response, error)
}
The interface specification for the client above.
type ClientOption ¶
ClientOption allows setting custom parameters during construction
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) AddDocumentWithBodyWithResponse ¶
func (c *ClientWithResponses) AddDocumentWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*addDocumentResponse, error)
AddDocumentWithBodyWithResponse request with arbitrary body returning *AddDocumentResponse
func (*ClientWithResponses) AddDocumentWithResponse ¶
func (c *ClientWithResponses) AddDocumentWithResponse(ctx context.Context, body AddDocumentJSONRequestBody) (*addDocumentResponse, error)
func (*ClientWithResponses) GetDocumentContentsWithResponse ¶
func (c *ClientWithResponses) GetDocumentContentsWithResponse(ctx context.Context, hash string) (*getDocumentContentsResponse, error)
GetDocumentContentsWithResponse request returning *GetDocumentContentsResponse
func (*ClientWithResponses) GetDocumentWithResponse ¶
func (c *ClientWithResponses) GetDocumentWithResponse(ctx context.Context, hash string) (*getDocumentResponse, error)
GetDocumentWithResponse request returning *GetDocumentResponse
func (*ClientWithResponses) ListDocumentsWithResponse ¶
func (c *ClientWithResponses) ListDocumentsWithResponse(ctx context.Context) (*listDocumentsResponse, error)
ListDocumentsWithResponse request returning *ListDocumentsResponse
type Document ¶
type Document struct {
// Hex-encoded hash of the document
Hash string `json:"hash"`
// Timestamp at which the document was created in nanoseconds (since Unix epoch)
Timestamp int64 `json:"timestamp"`
// type of the document
Type string `json:"type"`
}
Document defines model for Document.
type DocumentWithContents ¶
type DocumentWithContents struct {
// Actual contents of the document
Contents []byte `json:"contents"`
// Timestamp at which the document was created in nanoseconds (since Unix epoch)
Timestamp int64 `json:"timestamp"`
// type of the document
Type string `json:"type"`
}
DocumentWithContents defines model for DocumentWithContents.
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 HttpClient ¶
HttpClient holds the server address and other basic settings for the http client
func (HttpClient) AddDocumentWithContents ¶
func (HttpClient) GetDocument ¶
func (hb HttpClient) GetDocument(hash model.Hash) (*model.DocumentDescriptor, error)
func (HttpClient) GetDocumentContents ¶
func (hb HttpClient) GetDocumentContents(hash model.Hash) (io.ReadCloser, error)
func (HttpClient) ListDocuments ¶
func (hb HttpClient) ListDocuments() ([]model.DocumentDescriptor, error)
func (HttpClient) Subscribe ¶
func (hb HttpClient) Subscribe(documentType string) documentlog.DocumentQueue
type HttpRequestDoer ¶
Doer performs HTTP requests.
The standard http.Client implements this interface.
type RequestEditorFn ¶
RequestEditorFn is the function signature for the RequestEditor callback function
type ServerInterface ¶
type ServerInterface interface {
// Lists the documents on the log
// (GET /api/document)
ListDocuments(ctx echo.Context) error
// Adds a document to the document log
// (POST /api/document)
AddDocument(ctx echo.Context) error
// Retrieves a document
// (GET /api/document/{hash})
GetDocument(ctx echo.Context, hash string) error
// Gets the document contents
// (GET /api/document/{hash}/contents)
GetDocumentContents(ctx echo.Context, hash string) error
}
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
ServerInterfaceWrapper converts echo contexts to parameters.
func (*ServerInterfaceWrapper) AddDocument ¶
func (w *ServerInterfaceWrapper) AddDocument(ctx echo.Context) error
AddDocument converts echo context to params.
func (*ServerInterfaceWrapper) GetDocument ¶
func (w *ServerInterfaceWrapper) GetDocument(ctx echo.Context) error
GetDocument converts echo context to params.
func (*ServerInterfaceWrapper) GetDocumentContents ¶
func (w *ServerInterfaceWrapper) GetDocumentContents(ctx echo.Context) error
GetDocumentContents converts echo context to params.
func (*ServerInterfaceWrapper) ListDocuments ¶
func (w *ServerInterfaceWrapper) ListDocuments(ctx echo.Context) error
ListDocuments converts echo context to params.