api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: GPL-3.0 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.13.4 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 NewGetLatestRoundIDRequest

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

NewGetLatestRoundIDRequest generates requests for GetLatestRoundID

func NewGetRoundRoundIDRequest

func NewGetRoundRoundIDRequest(server string, roundID string) (*http.Request, error)

NewGetRoundRoundIDRequest generates requests for GetRoundRoundID

func NewPostRoundRequest

func NewPostRoundRequest(server string, body PostRoundJSONRequestBody) (*http.Request, error)

NewPostRoundRequest calls the generic PostRound builder with application/json body

func NewPostRoundRequestWithBody

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

NewPostRoundRequestWithBody generates requests for PostRound with any type of body

func NewPutRoundRoundIDScoreRequest

func NewPutRoundRoundIDScoreRequest(server string, roundID string, body PutRoundRoundIDScoreJSONRequestBody) (*http.Request, error)

NewPutRoundRoundIDScoreRequest calls the generic PutRoundRoundIDScore builder with application/json body

func NewPutRoundRoundIDScoreRequestWithBody

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

NewPutRoundRoundIDScoreRequestWithBody generates requests for PutRoundRoundIDScore 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 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) CreateRound

func (c *Client) CreateRound(ctx context.Context, req RoundRequest) (*CreatedRound, error)

func (*Client) GetLatestRoundID

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

func (*Client) GetRound

func (c *Client) GetRound(ctx context.Context, id uuid.UUID) (*Round, error)

func (*Client) GetRoundRoundID

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

func (*Client) PostRound

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

func (*Client) PostRoundWithBody

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

func (*Client) PutRoundRoundIDScore

func (c *Client) PutRoundRoundIDScore(ctx context.Context, roundID string, body PutRoundRoundIDScoreJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) PutRoundRoundIDScoreWithBody

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

type ClientInterface

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

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

	PostRound(ctx context.Context, body PostRoundJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

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

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

	PutRoundRoundIDScore(ctx context.Context, roundID string, body PutRoundRoundIDScoreJSONRequestBody, 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) GetLatestRoundIDWithResponse

func (c *ClientWithResponses) GetLatestRoundIDWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetLatestRoundIDResponse, error)

GetLatestRoundIDWithResponse request returning *GetLatestRoundIDResponse

func (*ClientWithResponses) GetRoundRoundIDWithResponse

func (c *ClientWithResponses) GetRoundRoundIDWithResponse(ctx context.Context, roundID string, reqEditors ...RequestEditorFn) (*GetRoundRoundIDResponse, error)

GetRoundRoundIDWithResponse request returning *GetRoundRoundIDResponse

func (*ClientWithResponses) PostRoundWithBodyWithResponse

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

PostRoundWithBodyWithResponse request with arbitrary body returning *PostRoundResponse

func (*ClientWithResponses) PostRoundWithResponse

func (c *ClientWithResponses) PostRoundWithResponse(ctx context.Context, body PostRoundJSONRequestBody, reqEditors ...RequestEditorFn) (*PostRoundResponse, error)

func (*ClientWithResponses) PutRoundRoundIDScoreWithBodyWithResponse

func (c *ClientWithResponses) PutRoundRoundIDScoreWithBodyWithResponse(ctx context.Context, roundID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutRoundRoundIDScoreResponse, error)

PutRoundRoundIDScoreWithBodyWithResponse request with arbitrary body returning *PutRoundRoundIDScoreResponse

func (*ClientWithResponses) PutRoundRoundIDScoreWithResponse

func (c *ClientWithResponses) PutRoundRoundIDScoreWithResponse(ctx context.Context, roundID string, body PutRoundRoundIDScoreJSONRequestBody, reqEditors ...RequestEditorFn) (*PutRoundRoundIDScoreResponse, error)

type ClientWithResponsesInterface

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

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

	PostRoundWithResponse(ctx context.Context, body PostRoundJSONRequestBody, reqEditors ...RequestEditorFn) (*PostRoundResponse, error)

	// GetRoundRoundIDWithResponse request
	GetRoundRoundIDWithResponse(ctx context.Context, roundID string, reqEditors ...RequestEditorFn) (*GetRoundRoundIDResponse, error)

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

	PutRoundRoundIDScoreWithResponse(ctx context.Context, roundID string, body PutRoundRoundIDScoreJSONRequestBody, reqEditors ...RequestEditorFn) (*PutRoundRoundIDScoreResponse, error)
}

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

type Course

type Course struct {
	Holes []Hole  `dynamodbav:"h" json:"holes"`
	Name  string  `dynamodbav:"n" json:"name"`
	Tees  *string `dynamodbav:"t" json:"tees,omitempty"`
}

Course defines model for Course.

type CreatedRound

type CreatedRound struct {
	Id RoundID `dynamodbav:"id" json:"id"`
}

CreatedRound defines model for CreatedRound.

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 GetLatestRoundIDResponse

type GetLatestRoundIDResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *RoundID
}

func ParseGetLatestRoundIDResponse

func ParseGetLatestRoundIDResponse(rsp *http.Response) (*GetLatestRoundIDResponse, error)

ParseGetLatestRoundIDResponse parses an HTTP response from a GetLatestRoundIDWithResponse call

func (GetLatestRoundIDResponse) Status

func (r GetLatestRoundIDResponse) Status() string

Status returns HTTPResponse.Status

func (GetLatestRoundIDResponse) StatusCode

func (r GetLatestRoundIDResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetRoundRoundIDResponse

type GetRoundRoundIDResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Round
}

func ParseGetRoundRoundIDResponse

func ParseGetRoundRoundIDResponse(rsp *http.Response) (*GetRoundRoundIDResponse, error)

ParseGetRoundRoundIDResponse parses an HTTP response from a GetRoundRoundIDWithResponse call

func (GetRoundRoundIDResponse) Status

func (r GetRoundRoundIDResponse) Status() string

Status returns HTTPResponse.Status

func (GetRoundRoundIDResponse) StatusCode

func (r GetRoundRoundIDResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Hole

type Hole struct {
	DistanceYards *int       `dynamodbav:"d" json:"distanceYards,omitempty"`
	Hole          HoleNumber `dynamodbav:"n" json:"hole"`
	Par           int        `dynamodbav:"p" json:"par"`
	StrokeIndex   *int       `dynamodbav:"si" json:"strokeIndex,omitempty"`
}

Hole defines model for Hole.

type HoleNumber

type HoleNumber = int

HoleNumber defines model for HoleNumber.

type HoleScore

type HoleScore struct {
	Hole  HoleNumber `dynamodbav:"n" json:"hole"`
	Score int        `dynamodbav:"s" json:"score"`
}

HoleScore defines model for HoleScore.

type HttpRequestDoer

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

type PlayerData

type PlayerData struct {
	Name string `dynamodbav:"n" json:"name"`
}

PlayerData defines model for PlayerData.

type PlayerGroup

type PlayerGroup = []PlayerData

PlayerGroup defines model for PlayerGroup.

type PlayerScore

type PlayerScore = []HoleScore

PlayerScore defines model for PlayerScore.

type PlayerScoreEvent

type PlayerScoreEvent struct {
	Hole        HoleNumber `dynamodbav:"n" json:"hole"`
	PlayerIndex int        `json:"playerIndex"`
	Score       int        `dynamodbav:"s" json:"score"`
}

PlayerScoreEvent defines model for PlayerScoreEvent.

type PostRoundJSONRequestBody

type PostRoundJSONRequestBody = RoundRequest

PostRoundJSONRequestBody defines body for PostRound for application/json ContentType.

type PostRoundResponse

type PostRoundResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON201      *CreatedRound
}

func ParsePostRoundResponse

func ParsePostRoundResponse(rsp *http.Response) (*PostRoundResponse, error)

ParsePostRoundResponse parses an HTTP response from a PostRoundWithResponse call

func (PostRoundResponse) Status

func (r PostRoundResponse) Status() string

Status returns HTTPResponse.Status

func (PostRoundResponse) StatusCode

func (r PostRoundResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type PutRoundRoundIDScoreJSONRequestBody

type PutRoundRoundIDScoreJSONRequestBody = PlayerScoreEvent

PutRoundRoundIDScoreJSONRequestBody defines body for PutRoundRoundIDScore for application/json ContentType.

type PutRoundRoundIDScoreResponse

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

func ParsePutRoundRoundIDScoreResponse

func ParsePutRoundRoundIDScoreResponse(rsp *http.Response) (*PutRoundRoundIDScoreResponse, error)

ParsePutRoundRoundIDScoreResponse parses an HTTP response from a PutRoundRoundIDScoreWithResponse call

func (PutRoundRoundIDScoreResponse) Status

Status returns HTTPResponse.Status

func (PutRoundRoundIDScoreResponse) StatusCode

func (r PutRoundRoundIDScoreResponse) 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 Round

type Round struct {
	Course  Course       `dynamodbav:"c" json:"course"`
	Id      RoundID      `dynamodbav:"id" json:"id"`
	Players RoundPlayers `dynamodbav:"rp" json:"players"`
	Title   RoundTitle   `dynamodbav:"t" json:"title"`
}

Round defines model for Round.

type RoundID

type RoundID = uuid.UUID

RoundID defines model for RoundID.

type RoundPlayerData

type RoundPlayerData struct {
	Name   string      `dynamodbav:"n" json:"name"`
	Scores PlayerScore `dynamodbav:"ps" json:"scores"`
}

RoundPlayerData defines model for RoundPlayerData.

type RoundPlayers

type RoundPlayers = []RoundPlayerData

RoundPlayers defines model for RoundPlayers.

type RoundRequest

type RoundRequest struct {
	Course  Course      `dynamodbav:"c" json:"course"`
	Players PlayerGroup `dynamodbav:"pg" json:"players"`
	Title   *RoundTitle `dynamodbav:"t" json:"title,omitempty"`
}

RoundRequest defines model for RoundRequest.

type RoundTitle

type RoundTitle = string

RoundTitle defines model for RoundTitle.

type ServerInterface

type ServerInterface interface {

	// (GET /latest/roundID)
	GetLatestRoundID(ctx echo.Context) error

	// (POST /round)
	PostRound(ctx echo.Context) error

	// (GET /round/{roundID})
	GetRoundRoundID(ctx echo.Context, roundID string) error

	// (PUT /round/{roundID}/score)
	PutRoundRoundIDScore(ctx echo.Context, roundID string) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) GetLatestRoundID

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

GetLatestRoundID converts echo context to params.

func (*ServerInterfaceWrapper) GetRoundRoundID

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

GetRoundRoundID converts echo context to params.

func (*ServerInterfaceWrapper) PostRound

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

PostRound converts echo context to params.

func (*ServerInterfaceWrapper) PutRoundRoundIDScore

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

PutRoundRoundIDScore converts echo context to params.

Jump to

Keyboard shortcuts

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