api

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 26 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

View Source
const DynamicBadgeResponseName = "r"

Variables

View Source
var (
	ErrPredefinedBadgeNotFound = errors.New("Predefined badge name not found")
)
View Source
var OpenAPISpec []byte

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 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 ClientError

type ClientError struct {
	Description string `json:"description"`
	Error       string `json:"error"`
}

error object for client errors

type Config

type Config struct {
	BadgeService     badges.BadgeService
	HTTPClient       *resty.Client
	PredefinedBadges *badgeconfig.Config
}

Config provides the up-front configuration necessary to launch an API.

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 GetBadgeDynamicParams

type GetBadgeDynamicParams struct {
	// URL of the server to fetch dynamic data from.
	Target string `form:"target" json:"target"`

	// Pongo2 format string to display for fo the badge label
	Label *string `form:"label,omitempty" json:"label,omitempty"`

	// Pongo2 format string to display for fo the badge message
	Message *string `form:"message,omitempty" json:"message,omitempty"`

	// Pongo2 format string to select a badge color by
	Color *string `form:"color,omitempty" json:"color,omitempty"`
}

GetBadgeDynamicParams defines parameters for GetBadgeDynamic.

type GetBadgePredefinedPredefinedNameParams

type GetBadgePredefinedPredefinedNameParams struct {
	// Predefined badges may define custom parameters to control templating.
	Params *GetBadgePredefinedPredefinedNameParams_Params `form:"params,omitempty" json:"params,omitempty"`
}

GetBadgePredefinedPredefinedNameParams defines parameters for GetBadgePredefinedPredefinedName.

type GetBadgePredefinedPredefinedNameParams_Params

type GetBadgePredefinedPredefinedNameParams_Params struct {
	AdditionalProperties map[string]interface{} `json:"-"`
}

GetBadgePredefinedPredefinedNameParams_Params defines parameters for GetBadgePredefinedPredefinedName.

func (GetBadgePredefinedPredefinedNameParams_Params) Get

func (a GetBadgePredefinedPredefinedNameParams_Params) Get(fieldName string) (value interface{}, found bool)

Getter for additional properties for GetBadgePredefinedPredefinedNameParams_Params. Returns the specified element and whether it was found

func (GetBadgePredefinedPredefinedNameParams_Params) MarshalJSON

Override default JSON handling for GetBadgePredefinedPredefinedNameParams_Params to handle AdditionalProperties

func (*GetBadgePredefinedPredefinedNameParams_Params) Set

func (a *GetBadgePredefinedPredefinedNameParams_Params) Set(fieldName string, value interface{})

Setter for additional properties for GetBadgePredefinedPredefinedNameParams_Params

func (*GetBadgePredefinedPredefinedNameParams_Params) UnmarshalJSON

Override default JSON handling for GetBadgePredefinedPredefinedNameParams_Params to handle AdditionalProperties

type GetBadgeStaticParams

type GetBadgeStaticParams struct {
	// Pongo2 format string to display for fo the badge label
	Label *string `form:"label,omitempty" json:"label,omitempty"`

	// Pongo2 format string to display for fo the badge message
	Message *string `form:"message,omitempty" json:"message,omitempty"`

	// Pongo2 format string to select a badge color by
	Color *string `form:"color,omitempty" json:"color,omitempty"`
}

GetBadgeStaticParams defines parameters for GetBadgeStatic.

type PingResponse

type PingResponse struct {
	RespondedAt *time.Time          `json:"responded_at,omitempty"`
	Status      *PingResponseStatus `json:"status,omitempty"`
	Version     *string             `json:"version,omitempty"`
}

API availability response endpoint

type PingResponseStatus

type PingResponseStatus string

PingResponseStatus defines model for PingResponse.Status.

const (
	Ok PingResponseStatus = "ok"
)

Defines values for PingResponseStatus.

type ServerInterface

type ServerInterface interface {

	// (GET /badge/dynamic)
	GetBadgeDynamic(ctx echo.Context, params GetBadgeDynamicParams) error

	// (GET /badge/predefined)
	GetBadgePredefined(ctx echo.Context) error

	// (GET /badge/predefined/{predefined_name}/)
	GetBadgePredefinedPredefinedName(ctx echo.Context, predefinedName string, params GetBadgePredefinedPredefinedNameParams) error

	// (GET /badge/static)
	GetBadgeStatic(ctx echo.Context, params GetBadgeStaticParams) error

	// (GET /openapi.yaml)
	GetOpenapiYaml(ctx echo.Context) error

	// (GET /ping)
	GetPing(ctx echo.Context) error
}

ServerInterface represents all server handlers.

func NewAPI

func NewAPI(apiConfig *Config) (ServerInterface, string)

NewAPI returns the API server instance and the version prefix.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) GetBadgeDynamic

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

GetBadgeDynamic converts echo context to params.

func (*ServerInterfaceWrapper) GetBadgePredefined

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

GetBadgePredefined converts echo context to params.

func (*ServerInterfaceWrapper) GetBadgePredefinedPredefinedName

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

GetBadgePredefinedPredefinedName converts echo context to params.

func (*ServerInterfaceWrapper) GetBadgeStatic

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

GetBadgeStatic converts echo context to params.

func (*ServerInterfaceWrapper) GetOpenapiYaml

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

GetOpenapiYaml converts echo context to params.

func (*ServerInterfaceWrapper) GetPing

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

GetPing converts echo context to params.

Jump to

Keyboard shortcuts

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