server

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

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

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Package server provides Web API for launchr actions.

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 Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func Run

func Run(ctx context.Context, app launchr.App, opts *RunOptions) error

Run starts http server.

Types

type ActionFull

type ActionFull struct {
	Description string                 `json:"description"`
	ID          string                 `json:"id"`
	JSONSchema  jsonschema.Schema      `json:"jsonschema"`
	Title       string                 `json:"title"`
	UISchema    map[string]interface{} `json:"uischema,omitempty"`
}

ActionFull defines model for ActionFull.

type ActionId

type ActionId = string

ActionId defines model for ActionId.

type ActionRunInfo

type ActionRunInfo struct {
	ID     string `json:"id"`
	Status string `json:"status"`
}

ActionRunInfo defines model for ActionRunInfo.

type ActionRunInfoId

type ActionRunInfoId = string

ActionRunInfoId defines model for ActionRunInfoId.

type ActionRunParams

type ActionRunParams struct {
	Arguments action.TypeArgs `json:"arguments"`
	Options   action.TypeOpts `json:"options"`
}

ActionRunParams defines model for ActionRunParams.

type ActionRunStreamData

type ActionRunStreamData struct {
	Content string                  `json:"content"`
	Count   int                     `json:"count"`
	Offset  int                     `json:"offset"`
	Type    ActionRunStreamDataType `json:"type"`
}

ActionRunStreamData defines model for ActionRunStreamData.

type ActionRunStreamDataType

type ActionRunStreamDataType string

ActionRunStreamDataType defines model for ActionRunStreamData.Type.

const (
	StdErr ActionRunStreamDataType = "stdErr"
	StdIn  ActionRunStreamDataType = "stdIn"
	StdOut ActionRunStreamDataType = "stdOut"
)

Defines values for ActionRunStreamDataType.

type ActionShort

type ActionShort struct {
	Description string `json:"description"`
	ID          string `json:"id"`
	Title       string `json:"title"`
}

ActionShort defines model for ActionShort.

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type DefaultError

type DefaultError = Error

DefaultError defines model for DefaultError.

type Error

type Error struct {
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

Error defines model for Error.

type GetRunningActionStreamsParams

type GetRunningActionStreamsParams struct {
	// Offset number of elements to skip
	Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"`

	// Limit number of elements to return
	Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}

GetRunningActionStreamsParams defines parameters for GetRunningActionStreams.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type JSONSchema

type JSONSchema = map[string]interface{}

JSONSchema defines model for JSONSchema.

type Limit

type Limit = int

Limit defines model for Limit.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type Offset

type Offset = int

Offset defines model for Offset.

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type RunActionJSONRequestBody

type RunActionJSONRequestBody = ActionRunParams

RunActionJSONRequestBody defines body for RunAction for application/json ContentType.

type RunOptions

type RunOptions struct {
	// Addr optionally specifies the TCP address in form "host:port" for the server to listen on.
	// If empty, :80 is used.
	Addr string
	// APIPrefix specifies subpath where Api is served.
	APIPrefix string
	// SwaggerJSON enables serving of swagger.json for swagger ui.
	SwaggerJSON bool
	SwaggerUIFS fs.FS
	// Client server.
	ClientFS    fs.FS
	ProxyClient string
}

RunOptions is a set of options for running openapi http server.

type ServerInterface

type ServerInterface interface {
	// Lists all actions
	// (GET /actions)
	GetActions(w http.ResponseWriter, r *http.Request)
	// Returns action by id
	// (GET /actions/{id})
	GetActionByID(w http.ResponseWriter, r *http.Request, id ActionId)
	// runs action
	// (POST /actions/{id})
	RunAction(w http.ResponseWriter, r *http.Request, id ActionId)
	// Returns running actions
	// (GET /actions/{id}/running)
	GetRunningActionsByID(w http.ResponseWriter, r *http.Request, id ActionId)
	// Returns action run info
	// (GET /actions/{id}/running/{runId})
	GetOneRunningActionByID(w http.ResponseWriter, r *http.Request, id ActionId, runId ActionRunInfoId)
	// Returns running action streams
	// (GET /actions/{id}/running/{runId}/streams)
	GetRunningActionStreams(w http.ResponseWriter, r *http.Request, id ActionId, runId ActionRunInfoId, params GetRunningActionStreamsParams)
	// Returns action json schema
	// (GET /actions/{id}/schema.json)
	GetActionJSONSchema(w http.ResponseWriter, r *http.Request, id ActionId)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) GetActionByID

func (siw *ServerInterfaceWrapper) GetActionByID(w http.ResponseWriter, r *http.Request)

GetActionByID operation middleware

func (*ServerInterfaceWrapper) GetActionJSONSchema

func (siw *ServerInterfaceWrapper) GetActionJSONSchema(w http.ResponseWriter, r *http.Request)

GetActionJSONSchema operation middleware

func (*ServerInterfaceWrapper) GetActions

func (siw *ServerInterfaceWrapper) GetActions(w http.ResponseWriter, r *http.Request)

GetActions operation middleware

func (*ServerInterfaceWrapper) GetOneRunningActionByID

func (siw *ServerInterfaceWrapper) GetOneRunningActionByID(w http.ResponseWriter, r *http.Request)

GetOneRunningActionByID operation middleware

func (*ServerInterfaceWrapper) GetRunningActionStreams

func (siw *ServerInterfaceWrapper) GetRunningActionStreams(w http.ResponseWriter, r *http.Request)

GetRunningActionStreams operation middleware

func (*ServerInterfaceWrapper) GetRunningActionsByID

func (siw *ServerInterfaceWrapper) GetRunningActionsByID(w http.ResponseWriter, r *http.Request)

GetRunningActionsByID operation middleware

func (*ServerInterfaceWrapper) RunAction

func (siw *ServerInterfaceWrapper) RunAction(w http.ResponseWriter, r *http.Request)

RunAction operation middleware

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type Unimplemented

type Unimplemented struct{}

func (Unimplemented) GetActionByID

func (_ Unimplemented) GetActionByID(w http.ResponseWriter, r *http.Request, id ActionId)

Returns action by id (GET /actions/{id})

func (Unimplemented) GetActionJSONSchema

func (_ Unimplemented) GetActionJSONSchema(w http.ResponseWriter, r *http.Request, id ActionId)

Returns action json schema (GET /actions/{id}/schema.json)

func (Unimplemented) GetActions

func (_ Unimplemented) GetActions(w http.ResponseWriter, r *http.Request)

Lists all actions (GET /actions)

func (Unimplemented) GetOneRunningActionByID

func (_ Unimplemented) GetOneRunningActionByID(w http.ResponseWriter, r *http.Request, id ActionId, runId ActionRunInfoId)

Returns action run info (GET /actions/{id}/running/{runId})

func (Unimplemented) GetRunningActionStreams

func (_ Unimplemented) GetRunningActionStreams(w http.ResponseWriter, r *http.Request, id ActionId, runId ActionRunInfoId, params GetRunningActionStreamsParams)

Returns running action streams (GET /actions/{id}/running/{runId}/streams)

func (Unimplemented) GetRunningActionsByID

func (_ Unimplemented) GetRunningActionsByID(w http.ResponseWriter, r *http.Request, id ActionId)

Returns running actions (GET /actions/{id}/running)

func (Unimplemented) RunAction

func (_ Unimplemented) RunAction(w http.ResponseWriter, r *http.Request, id ActionId)

runs action (POST /actions/{id})

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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