Documentation ¶
Overview ¶
Package api provides primitives to interact with the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen version v1.8.2 DO NOT EDIT.
Index ¶
- Constants
- Variables
- func GetSwagger() (swagger *openapi3.T, err error)
- func HTTPError(code ServiceErrorCode) error
- func HTTPErrorHandler(echoError error, c echo.Context)
- func HTTPErrorWithInternal(code ServiceErrorCode, internalErr error) error
- func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)
- func RegisterHandlers(router EchoRouter, si ServerInterface)
- func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)
- type EchoRouter
- type Error
- type GetJobResponse
- type ObjectReference
- type PostWorkersJSONBody
- type PostWorkersJSONRequestBody
- type PostWorkersRequest
- type PostWorkersResponse
- type RequestJobJSONBody
- type RequestJobJSONRequestBody
- type RequestJobRequest
- type RequestJobResponse
- type ServerInterface
- type ServerInterfaceWrapper
- func (w *ServerInterfaceWrapper) GetError(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GetJob(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GetOpenapi(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GetStatus(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) PostWorkerStatus(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) PostWorkers(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) RequestJob(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) UpdateJob(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) UploadJobArtifact(ctx echo.Context) error
- type ServiceErrorCode
- type StatusResponse
- type UpdateJobJSONBody
- type UpdateJobJSONRequestBody
- type UpdateJobRequest
- type UpdateJobResponse
Constants ¶
const (
BearerScopes = "Bearer.Scopes"
)
Variables ¶
var BasePath = "/api/worker/v1"
default basepath, can be overwritten
Functions ¶
func GetSwagger ¶
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 HTTPError ¶
func HTTPError(code ServiceErrorCode) error
Make an echo compatible error out of a service error
func HTTPErrorHandler ¶
func HTTPErrorHandler(echoError error, c echo.Context)
Convert an echo error into an AOC compliant one so we send a correct json error response
func HTTPErrorWithInternal ¶
func HTTPErrorWithInternal(code ServiceErrorCode, internalErr error) error
echo.HTTPError has a message interface{} field, which can be used to include the ServiceErrorCode
func PathToRawSpec ¶
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 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 Error ¶
type Error struct { // Embedded struct due to allOf(#/components/schemas/ObjectReference) ObjectReference `yaml:",inline"` // Embedded fields due to inline allOf schema Code string `json:"code"` // Backward compatibility with workers <= v33, equals reason Message string `json:"message"` OperationId string `json:"operation_id"` Reason string `json:"reason"` }
Error defines model for Error.
func APIError ¶
func APIError(code ServiceErrorCode, serviceError *serviceError, c echo.Context) *Error
Convert a ServiceErrorCode into an Error as defined in openapi.v2.yml serviceError is optional, prevents multiple find() calls
type GetJobResponse ¶
type GetJobResponse struct { // Embedded struct due to allOf(#/components/schemas/ObjectReference) ObjectReference `yaml:",inline"` // Embedded fields due to inline allOf schema Canceled bool `json:"canceled"` }
GetJobResponse defines model for GetJobResponse.
type ObjectReference ¶
type ObjectReference struct { Href string `json:"href"` Id string `json:"id"` Kind string `json:"kind"` }
ObjectReference defines model for ObjectReference.
type PostWorkersJSONBody ¶
type PostWorkersJSONBody PostWorkersRequest
PostWorkersJSONBody defines parameters for PostWorkers.
type PostWorkersJSONRequestBody ¶
type PostWorkersJSONRequestBody PostWorkersJSONBody
PostWorkersJSONRequestBody defines body for PostWorkers for application/json ContentType.
type PostWorkersRequest ¶
type PostWorkersRequest struct {
Arch string `json:"arch"`
}
PostWorkersRequest defines model for PostWorkersRequest.
type PostWorkersResponse ¶
type PostWorkersResponse struct { // Embedded struct due to allOf(#/components/schemas/ObjectReference) ObjectReference `yaml:",inline"` // Embedded fields due to inline allOf schema WorkerId string `json:"worker_id"` }
PostWorkersResponse defines model for PostWorkersResponse.
type RequestJobJSONBody ¶
type RequestJobJSONBody RequestJobRequest
RequestJobJSONBody defines parameters for RequestJob.
type RequestJobJSONRequestBody ¶
type RequestJobJSONRequestBody RequestJobJSONBody
RequestJobJSONRequestBody defines body for RequestJob for application/json ContentType.
type RequestJobRequest ¶
type RequestJobRequest struct { Arch string `json:"arch"` Types []string `json:"types"` WorkerId *string `json:"worker_id,omitempty"` }
RequestJobRequest defines model for RequestJobRequest.
type RequestJobResponse ¶
type RequestJobResponse struct { // Embedded struct due to allOf(#/components/schemas/ObjectReference) ObjectReference `yaml:",inline"` // Embedded fields due to inline allOf schema Args *json.RawMessage `json:"args,omitempty"` ArtifactLocation string `json:"artifact_location"` DynamicArgs *[]json.RawMessage `json:"dynamic_args,omitempty"` Location string `json:"location"` Type string `json:"type"` }
RequestJobResponse defines model for RequestJobResponse.
type ServerInterface ¶
type ServerInterface interface { // Get error description // (GET /errors/{id}) GetError(ctx echo.Context, id string) error // Request a job // (POST /jobs) RequestJob(ctx echo.Context) error // Get running job // (GET /jobs/{token}) GetJob(ctx echo.Context, token string) error // Update a running job // (PATCH /jobs/{token}) UpdateJob(ctx echo.Context, token string) error // Upload an artifact // (PUT /jobs/{token}/artifacts/{name}) UploadJobArtifact(ctx echo.Context, token string, name string) error // Get the openapi spec in json format // (GET /openapi) GetOpenapi(ctx echo.Context) error // status // (GET /status) GetStatus(ctx echo.Context) error // Create a new worker // (POST /workers) PostWorkers(ctx echo.Context) error // Refresh worker status // (POST /workers/{worker_id}/status) PostWorkerStatus(ctx echo.Context, workerId string) error }
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
ServerInterfaceWrapper converts echo contexts to parameters.
func (*ServerInterfaceWrapper) GetError ¶
func (w *ServerInterfaceWrapper) GetError(ctx echo.Context) error
GetError converts echo context to params.
func (*ServerInterfaceWrapper) GetJob ¶
func (w *ServerInterfaceWrapper) GetJob(ctx echo.Context) error
GetJob converts echo context to params.
func (*ServerInterfaceWrapper) GetOpenapi ¶
func (w *ServerInterfaceWrapper) GetOpenapi(ctx echo.Context) error
GetOpenapi converts echo context to params.
func (*ServerInterfaceWrapper) GetStatus ¶
func (w *ServerInterfaceWrapper) GetStatus(ctx echo.Context) error
GetStatus converts echo context to params.
func (*ServerInterfaceWrapper) PostWorkerStatus ¶
func (w *ServerInterfaceWrapper) PostWorkerStatus(ctx echo.Context) error
PostWorkerStatus converts echo context to params.
func (*ServerInterfaceWrapper) PostWorkers ¶
func (w *ServerInterfaceWrapper) PostWorkers(ctx echo.Context) error
PostWorkers converts echo context to params.
func (*ServerInterfaceWrapper) RequestJob ¶
func (w *ServerInterfaceWrapper) RequestJob(ctx echo.Context) error
RequestJob converts echo context to params.
func (*ServerInterfaceWrapper) UpdateJob ¶
func (w *ServerInterfaceWrapper) UpdateJob(ctx echo.Context) error
UpdateJob converts echo context to params.
func (*ServerInterfaceWrapper) UploadJobArtifact ¶
func (w *ServerInterfaceWrapper) UploadJobArtifact(ctx echo.Context) error
UploadJobArtifact converts echo context to params.
type ServiceErrorCode ¶
type ServiceErrorCode int
const ( ErrorCodePrefix = "IMAGE-BUILDER-WORKER-" ErrorUnsupportedMediaType ServiceErrorCode = 3 ErrorJobNotFound ServiceErrorCode = 5 ErrorJobNotRunning ServiceErrorCode = 6 ErrorMalformedJobId ServiceErrorCode = 7 ErrorMalformedJobToken ServiceErrorCode = 8 ErrorInvalidErrorId ServiceErrorCode = 9 ErrorBodyDecodingError ServiceErrorCode = 10 ErrorResourceNotFound ServiceErrorCode = 11 ErrorMethodNotAllowed ServiceErrorCode = 12 ErrorNotAcceptable ServiceErrorCode = 13 ErrorErrorNotFound ServiceErrorCode = 14 ErrorInvalidJobType ServiceErrorCode = 15 ErrorTenantNotFound ServiceErrorCode = 16 ErrorMalformedWorkerId ServiceErrorCode = 17 ErrorWorkerIdNotFound ServiceErrorCode = 18 // internal errors ErrorDiscardingArtifact ServiceErrorCode = 1000 ErrorCreatingArtifact ServiceErrorCode = 1001 ErrorWritingArtifact ServiceErrorCode = 1002 ErrorResolvingJobId ServiceErrorCode = 1003 ErrorFinishingJob ServiceErrorCode = 1004 ErrorRetrievingJobStatus ServiceErrorCode = 1005 ErrorRequestingJob ServiceErrorCode = 1006 ErrorFailedLoadingOpenAPISpec ServiceErrorCode = 1007 ErrorInsertingWorker ServiceErrorCode = 1008 ErrorUpdatingWorkerStatus ServiceErrorCode = 1009 // Errors contained within this file ErrorUnspecified ServiceErrorCode = 10000 ErrorNotHTTPError ServiceErrorCode = 10001 ErrorServiceErrorNotFound ServiceErrorCode = 10002 ErrorMalformedOperationID ServiceErrorCode = 10003 )
type StatusResponse ¶
type StatusResponse struct { // Embedded struct due to allOf(#/components/schemas/ObjectReference) ObjectReference `yaml:",inline"` // Embedded fields due to inline allOf schema Status string `json:"status"` }
StatusResponse defines model for StatusResponse.
type UpdateJobJSONBody ¶
type UpdateJobJSONBody UpdateJobRequest
UpdateJobJSONBody defines parameters for UpdateJob.
type UpdateJobJSONRequestBody ¶
type UpdateJobJSONRequestBody UpdateJobJSONBody
UpdateJobJSONRequestBody defines body for UpdateJob for application/json ContentType.
type UpdateJobRequest ¶
type UpdateJobRequest struct {
Result json.RawMessage `json:"result"`
}
UpdateJobRequest defines model for UpdateJobRequest.
type UpdateJobResponse ¶
type UpdateJobResponse ObjectReference
UpdateJobResponse defines model for UpdateJobResponse.