api

package
v0.0.0-...-00d9010 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 18 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.15.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 NewGetV1DolusExpectationsRequest

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

NewGetV1DolusExpectationsRequest generates requests for GetV1DolusExpectations

func NewGetV1DolusLogsRequest

func NewGetV1DolusLogsRequest(server string, params *GetV1DolusLogsParams) (*http.Request, error)

NewGetV1DolusLogsRequest generates requests for GetV1DolusLogs

func NewGetV1DolusLogsWsRequest

func NewGetV1DolusLogsWsRequest(server string, params *GetV1DolusLogsWsParams) (*http.Request, error)

NewGetV1DolusLogsWsRequest generates requests for GetV1DolusLogsWs

func NewGetV1DolusRoutesRequest

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

NewGetV1DolusRoutesRequest generates requests for GetV1DolusRoutes

func NewPostV1DolusExpectationsRequest

func NewPostV1DolusExpectationsRequest(server string, body PostV1DolusExpectationsJSONRequestBody) (*http.Request, error)

NewPostV1DolusExpectationsRequest calls the generic PostV1DolusExpectations builder with application/json body

func NewPostV1DolusExpectationsRequestWithBody

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

NewPostV1DolusExpectationsRequestWithBody generates requests for PostV1DolusExpectations 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 Callback

type Callback struct {
	HttpMethod  string                  `json:"httpMethod"`
	RequestBody *map[string]interface{} `json:"requestBody,omitempty"`
	Timeout     int                     `json:"timeout"`
	Url         string                  `json:"url"`
}

Callback defines model for Callback.

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

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

func (*Client) GetV1DolusLogs

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

func (*Client) GetV1DolusLogsWs

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

func (*Client) GetV1DolusRoutes

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

func (*Client) PostV1DolusExpectations

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

func (*Client) PostV1DolusExpectationsWithBody

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

type ClientInterface

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

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

	PostV1DolusExpectations(ctx context.Context, body PostV1DolusExpectationsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetV1DolusLogs request
	GetV1DolusLogs(ctx context.Context, params *GetV1DolusLogsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetV1DolusLogsWs request
	GetV1DolusLogsWs(ctx context.Context, params *GetV1DolusLogsWsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetV1DolusRoutes request
	GetV1DolusRoutes(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) GetV1DolusExpectationsWithResponse

func (c *ClientWithResponses) GetV1DolusExpectationsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetV1DolusExpectationsResponse, error)

GetV1DolusExpectationsWithResponse request returning *GetV1DolusExpectationsResponse

func (*ClientWithResponses) GetV1DolusLogsWithResponse

func (c *ClientWithResponses) GetV1DolusLogsWithResponse(ctx context.Context, params *GetV1DolusLogsParams, reqEditors ...RequestEditorFn) (*GetV1DolusLogsResponse, error)

GetV1DolusLogsWithResponse request returning *GetV1DolusLogsResponse

func (*ClientWithResponses) GetV1DolusLogsWsWithResponse

func (c *ClientWithResponses) GetV1DolusLogsWsWithResponse(ctx context.Context, params *GetV1DolusLogsWsParams, reqEditors ...RequestEditorFn) (*GetV1DolusLogsWsResponse, error)

GetV1DolusLogsWsWithResponse request returning *GetV1DolusLogsWsResponse

func (*ClientWithResponses) GetV1DolusRoutesWithResponse

func (c *ClientWithResponses) GetV1DolusRoutesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetV1DolusRoutesResponse, error)

GetV1DolusRoutesWithResponse request returning *GetV1DolusRoutesResponse

func (*ClientWithResponses) PostV1DolusExpectationsWithBodyWithResponse

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

PostV1DolusExpectationsWithBodyWithResponse request with arbitrary body returning *PostV1DolusExpectationsResponse

func (*ClientWithResponses) PostV1DolusExpectationsWithResponse

func (c *ClientWithResponses) PostV1DolusExpectationsWithResponse(ctx context.Context, body PostV1DolusExpectationsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostV1DolusExpectationsResponse, error)

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// GetV1DolusExpectationsWithResponse request
	GetV1DolusExpectationsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetV1DolusExpectationsResponse, error)

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

	PostV1DolusExpectationsWithResponse(ctx context.Context, body PostV1DolusExpectationsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostV1DolusExpectationsResponse, error)

	// GetV1DolusLogsWithResponse request
	GetV1DolusLogsWithResponse(ctx context.Context, params *GetV1DolusLogsParams, reqEditors ...RequestEditorFn) (*GetV1DolusLogsResponse, error)

	// GetV1DolusLogsWsWithResponse request
	GetV1DolusLogsWsWithResponse(ctx context.Context, params *GetV1DolusLogsWsParams, reqEditors ...RequestEditorFn) (*GetV1DolusLogsWsResponse, error)

	// GetV1DolusRoutesWithResponse request
	GetV1DolusRoutesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetV1DolusRoutesResponse, error)
}

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

type DolusApi

type DolusApi interface {
	ServerInterface
	AddRoute(pathMethod schema.Route) error
}

type DolusApiImpl

type DolusApiImpl struct {
	ExpectationEngine engine.ExpectationEngine
	Mapper            Mapper
	// contains filtered or unexported fields
}

func NewDolusApi

func NewDolusApi(expectationEngine engine.ExpectationEngine,
	mapper Mapper,
) *DolusApiImpl

func (*DolusApiImpl) AddRoute

func (d *DolusApiImpl) AddRoute(route schema.Route) error

func (*DolusApiImpl) GetV1DolusExpectations

func (d *DolusApiImpl) GetV1DolusExpectations(ctx echo.Context) error

GetV1DolusExpectations implements server.ServerInterface.

func (*DolusApiImpl) GetV1DolusLogs

func (*DolusApiImpl) GetV1DolusLogs(ctx echo.Context, params GetV1DolusLogsParams) error

GetV1DolusLogs implements DolusApi.

func (*DolusApiImpl) GetV1DolusLogsWs

func (*DolusApiImpl) GetV1DolusLogsWs(
	ctx echo.Context,
	params GetV1DolusLogsWsParams,
) error

GetV1DolusLogsWs implements DolusApi.

func (*DolusApiImpl) GetV1DolusRoutes

func (d *DolusApiImpl) GetV1DolusRoutes(ctx echo.Context) error

GetV1DolusRoutes implements server.ServerInterface.

func (*DolusApiImpl) PostV1DolusExpectations

func (d *DolusApiImpl) PostV1DolusExpectations(ctx echo.Context) error

PostV1DolusExpectations implements server.ServerInterface.

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 Expectation

type Expectation struct {
	Callback *Callback `json:"callback,omitempty"`
	Priority int       `json:"priority"`
	Request  Request   `json:"request"`
	Response Response  `json:"response"`
}

Expectation defines model for Expectation.

type Expectations

type Expectations struct {
	Expectations []Expectation `json:"expectations"`
}

Expectations defines model for Expectations.

type GeneralError

type GeneralError struct {
	Path     string
	Method   string
	ErrorMsg string
}

TODO: make this error part of api spec

type GetV1DolusExpectationsResponse

type GetV1DolusExpectationsResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Expectations
}

func ParseGetV1DolusExpectationsResponse

func ParseGetV1DolusExpectationsResponse(rsp *http.Response) (*GetV1DolusExpectationsResponse, error)

ParseGetV1DolusExpectationsResponse parses an HTTP response from a GetV1DolusExpectationsWithResponse call

func (GetV1DolusExpectationsResponse) Status

Status returns HTTPResponse.Status

func (GetV1DolusExpectationsResponse) StatusCode

func (r GetV1DolusExpectationsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetV1DolusLogsParams

type GetV1DolusLogsParams struct {
	// Lines number of log lines to return
	Lines *int `form:"lines,omitempty" json:"lines,omitempty"`
}

GetV1DolusLogsParams defines parameters for GetV1DolusLogs.

type GetV1DolusLogsResponse

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

func ParseGetV1DolusLogsResponse

func ParseGetV1DolusLogsResponse(rsp *http.Response) (*GetV1DolusLogsResponse, error)

ParseGetV1DolusLogsResponse parses an HTTP response from a GetV1DolusLogsWithResponse call

func (GetV1DolusLogsResponse) Status

func (r GetV1DolusLogsResponse) Status() string

Status returns HTTPResponse.Status

func (GetV1DolusLogsResponse) StatusCode

func (r GetV1DolusLogsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetV1DolusLogsWsParams

type GetV1DolusLogsWsParams struct {
	// Lines number of log lines to return
	Lines *string `form:"lines,omitempty" json:"lines,omitempty"`
}

GetV1DolusLogsWsParams defines parameters for GetV1DolusLogsWs.

type GetV1DolusLogsWsResponse

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

func ParseGetV1DolusLogsWsResponse

func ParseGetV1DolusLogsWsResponse(rsp *http.Response) (*GetV1DolusLogsWsResponse, error)

ParseGetV1DolusLogsWsResponse parses an HTTP response from a GetV1DolusLogsWsWithResponse call

func (GetV1DolusLogsWsResponse) Status

func (r GetV1DolusLogsWsResponse) Status() string

Status returns HTTPResponse.Status

func (GetV1DolusLogsWsResponse) StatusCode

func (r GetV1DolusLogsWsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetV1DolusRoutesResponse

type GetV1DolusRoutesResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *[]Route
}

func ParseGetV1DolusRoutesResponse

func ParseGetV1DolusRoutesResponse(rsp *http.Response) (*GetV1DolusRoutesResponse, error)

ParseGetV1DolusRoutesResponse parses an HTTP response from a GetV1DolusRoutesWithResponse call

func (GetV1DolusRoutesResponse) Status

func (r GetV1DolusRoutesResponse) Status() string

Status returns HTTPResponse.Status

func (GetV1DolusRoutesResponse) StatusCode

func (r GetV1DolusRoutesResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

type Mapper

type Mapper interface {
	MapCueExpectations(
		expectations []expectation.Expectation,
	) ([]Expectation, error)
	MapCueExpectation(expectation expectation.Expectation) (*Expectation, error)
}

type MapperImpl

type MapperImpl struct{}

func NewMapper

func NewMapper() *MapperImpl

func (*MapperImpl) MapCueExpectation

func (mi *MapperImpl) MapCueExpectation(expectation expectation.Expectation) (*Expectation, error)

func (*MapperImpl) MapCueExpectations

func (mi *MapperImpl) MapCueExpectations(
	expectations []expectation.Expectation,
) ([]Expectation, error)

type PostV1DolusExpectationsJSONRequestBody

type PostV1DolusExpectationsJSONRequestBody = Expectation

PostV1DolusExpectationsJSONRequestBody defines body for PostV1DolusExpectations for application/json ContentType.

type PostV1DolusExpectationsResponse

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

func ParsePostV1DolusExpectationsResponse

func ParsePostV1DolusExpectationsResponse(rsp *http.Response) (*PostV1DolusExpectationsResponse, error)

ParsePostV1DolusExpectationsResponse parses an HTTP response from a PostV1DolusExpectationsWithResponse call

func (PostV1DolusExpectationsResponse) Status

Status returns HTTPResponse.Status

func (PostV1DolusExpectationsResponse) StatusCode

func (r PostV1DolusExpectationsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Request

type Request struct {
	Body   *map[string]interface{} `json:"body,omitempty"`
	Method string                  `json:"method"`
	Path   string                  `json:"path"`
}

Request defines model for Request.

type RequestEditorFn

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

RequestEditorFn is the function signature for the RequestEditor callback function

type Response

type Response struct {
	Body   *map[string]interface{} `json:"body,omitempty"`
	Status int                     `json:"status"`
}

Response defines model for Response.

type Route

type Route struct {
	Operation string `json:"operation"`
	Path      string `json:"path"`
}

Route defines model for Route.

type ServerInterface

type ServerInterface interface {
	// Fetch expectations
	// (GET /v1/dolus/expectations)
	GetV1DolusExpectations(ctx echo.Context) error

	// (POST /v1/dolus/expectations)
	PostV1DolusExpectations(ctx echo.Context) error
	// Your GET endpoint
	// (GET /v1/dolus/logs)
	GetV1DolusLogs(ctx echo.Context, params GetV1DolusLogsParams) error
	// Your GET endpoint
	// (GET /v1/dolus/logs/ws)
	GetV1DolusLogsWs(ctx echo.Context, params GetV1DolusLogsWsParams) error
	// Your GET endpoint
	// (GET /v1/dolus/routes)
	GetV1DolusRoutes(ctx echo.Context) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) GetV1DolusExpectations

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

GetV1DolusExpectations converts echo context to params.

func (*ServerInterfaceWrapper) GetV1DolusLogs

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

GetV1DolusLogs converts echo context to params.

func (*ServerInterfaceWrapper) GetV1DolusLogsWs

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

GetV1DolusLogsWs converts echo context to params.

func (*ServerInterfaceWrapper) GetV1DolusRoutes

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

GetV1DolusRoutes converts echo context to params.

func (*ServerInterfaceWrapper) PostV1DolusExpectations

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

PostV1DolusExpectations converts echo context to params.

Jump to

Keyboard shortcuts

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