
This is made with plain sqlite. It's probably a good idea to move to something like GORM instead.
127 lines
4.2 KiB
Go
127 lines
4.2 KiB
Go
// Package api provides primitives to interact with the openapi HTTP API.
|
|
//
|
|
// Code generated by github.com/deepmap/oapi-codegen version v1.9.0 DO NOT EDIT.
|
|
package api
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/deepmap/oapi-codegen/pkg/runtime"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// ServerInterface represents all server handlers.
|
|
type ServerInterface interface {
|
|
// Submit a new job for Flamenco Manager to execute.
|
|
// (POST /api/jobs)
|
|
SubmitJob(ctx echo.Context) error
|
|
// Get list of job types and their parameters.
|
|
// (GET /api/jobs/types)
|
|
GetJobTypes(ctx echo.Context) error
|
|
// Fetch info about the job.
|
|
// (GET /api/jobs/{job_id})
|
|
FetchJob(ctx echo.Context, jobId string) error
|
|
// Register a new worker
|
|
// (POST /api/worker/register-worker)
|
|
RegisterWorker(ctx echo.Context) error
|
|
// Obtain a new task to execute
|
|
// (POST /api/worker/task)
|
|
ScheduleTask(ctx echo.Context) error
|
|
}
|
|
|
|
// ServerInterfaceWrapper converts echo contexts to parameters.
|
|
type ServerInterfaceWrapper struct {
|
|
Handler ServerInterface
|
|
}
|
|
|
|
// SubmitJob converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) SubmitJob(ctx echo.Context) error {
|
|
var err error
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.SubmitJob(ctx)
|
|
return err
|
|
}
|
|
|
|
// GetJobTypes converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetJobTypes(ctx echo.Context) error {
|
|
var err error
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.GetJobTypes(ctx)
|
|
return err
|
|
}
|
|
|
|
// FetchJob converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) FetchJob(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "job_id" -------------
|
|
var jobId string
|
|
|
|
err = runtime.BindStyledParameterWithLocation("simple", false, "job_id", runtime.ParamLocationPath, ctx.Param("job_id"), &jobId)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter job_id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.FetchJob(ctx, jobId)
|
|
return err
|
|
}
|
|
|
|
// RegisterWorker converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) RegisterWorker(ctx echo.Context) error {
|
|
var err error
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.RegisterWorker(ctx)
|
|
return err
|
|
}
|
|
|
|
// ScheduleTask converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) ScheduleTask(ctx echo.Context) error {
|
|
var err error
|
|
|
|
ctx.Set(Worker_authScopes, []string{""})
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.ScheduleTask(ctx)
|
|
return err
|
|
}
|
|
|
|
// 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 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
|
|
}
|
|
|
|
// RegisterHandlers adds each server route to the EchoRouter.
|
|
func RegisterHandlers(router EchoRouter, si ServerInterface) {
|
|
RegisterHandlersWithBaseURL(router, si, "")
|
|
}
|
|
|
|
// Registers handlers, and prepends BaseURL to the paths, so that the paths
|
|
// can be served under a prefix.
|
|
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
|
|
|
|
wrapper := ServerInterfaceWrapper{
|
|
Handler: si,
|
|
}
|
|
|
|
router.POST(baseURL+"/api/jobs", wrapper.SubmitJob)
|
|
router.GET(baseURL+"/api/jobs/types", wrapper.GetJobTypes)
|
|
router.GET(baseURL+"/api/jobs/:job_id", wrapper.FetchJob)
|
|
router.POST(baseURL+"/api/worker/register-worker", wrapper.RegisterWorker)
|
|
router.POST(baseURL+"/api/worker/task", wrapper.ScheduleTask)
|
|
|
|
}
|