api

package
v0.0.0-...-9fc8000 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlertDisabled = errors.New("alert is disabled in turing-api")

Functions

This section is empty.

Types

type AlertsController

type AlertsController struct {
	BaseController
}

func (AlertsController) CreateAlert

func (c AlertsController) CreateAlert(r *http.Request, vars RequestVars, body interface{}) *Response

func (AlertsController) DeleteAlert

func (c AlertsController) DeleteAlert(r *http.Request, vars RequestVars, _ interface{}) *Response

func (AlertsController) GetAlert

func (c AlertsController) GetAlert(_ *http.Request, vars RequestVars, _ interface{}) *Response

func (AlertsController) ListAlerts

func (c AlertsController) ListAlerts(_ *http.Request, vars RequestVars, _ interface{}) *Response

func (AlertsController) Routes

func (c AlertsController) Routes() []Route

func (AlertsController) UpdateAlert

func (c AlertsController) UpdateAlert(r *http.Request, vars RequestVars, body interface{}) *Response

type AppContext

type AppContext struct {
	Authorizer *middleware.Authorizer
	// DAO
	DeploymentService     service.DeploymentService
	RoutersService        service.RoutersService
	RouterVersionsService service.RouterVersionsService
	EventService          service.EventService
	EnsemblersService     service.EnsemblersService
	EnsemblingJobService  service.EnsemblingJobService
	AlertService          service.AlertService

	// Default configuration for routers
	RouterDefaults *config.RouterDefaults

	BatchRunners       []batchrunner.BatchJobRunner
	CryptoService      service.CryptoService
	MLPService         service.MLPService
	ExperimentsService service.ExperimentsService
	PodLogService      service.PodLogService
	MlflowService      mlflow.Service
}

AppContext stores the entities relating to the application's context

func NewAppContext

func NewAppContext(
	db *gorm.DB,
	cfg *config.Config,
	authorizer *middleware.Authorizer,
) (*AppContext, error)

NewAppContext is a creator for the app context

type BaseController

type BaseController struct {
	*AppContext
	// contains filtered or unexported fields
}

BaseController implements common methods that may be shared by all API controllers

func NewBaseController

func NewBaseController(ctx *AppContext, validator *val.Validate) BaseController

NewBaseController returns a new instance of BaseController

func (BaseController) ParseVars

func (c BaseController) ParseVars(dst interface{}, vars RequestVars) error

type Controller

type Controller interface {
	// Routes returns the list of routes of this controller
	Routes() []Route
}

type EnsemblersController

type EnsemblersController struct {
	BaseController
}

func (EnsemblersController) CreateEnsembler

func (c EnsemblersController) CreateEnsembler(
	_ *http.Request,
	vars RequestVars,
	body interface{},
) *Response

func (EnsemblersController) DeleteEnsembler

func (c EnsemblersController) DeleteEnsembler(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

func (EnsemblersController) GetEnsembler

func (c EnsemblersController) GetEnsembler(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

func (EnsemblersController) ListEnsemblers

func (c EnsemblersController) ListEnsemblers(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

func (EnsemblersController) Routes

func (c EnsemblersController) Routes() []Route

func (EnsemblersController) UpdateEnsembler

func (c EnsemblersController) UpdateEnsembler(
	_ *http.Request,
	vars RequestVars,
	body interface{},
) *Response

type EnsemblersPathOptions

type EnsemblersPathOptions struct {
	ProjectID   *models.ID `schema:"project_id" validate:"required"`
	EnsemblerID *models.ID `schema:"ensembler_id" validate:"required"`
}

type EnsemblingJobController

type EnsemblingJobController struct {
	BaseController
}

EnsemblingJobController is the HTTP controller that handles the orchestration of ensembling jobs.

func (EnsemblingJobController) Create

func (c EnsemblingJobController) Create(
	_ *http.Request,
	vars RequestVars,
	body interface{},
) *Response

Create is a HTTP Post Method that creates an Ensembling job. This method will only return the acceptance/rejection of the job rather than the actual result of the job.

func (EnsemblingJobController) DeleteEnsemblingJob

func (c EnsemblingJobController) DeleteEnsemblingJob(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

DeleteEnsemblingJob deletes and ensembling job and cancels any ongoing process.

func (EnsemblingJobController) GetEnsemblingJob

func (c EnsemblingJobController) GetEnsemblingJob(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

GetEnsemblingJob is HTTP handler that will get a single EnsemblingJob

func (EnsemblingJobController) ListEnsemblingJobs

func (c EnsemblingJobController) ListEnsemblingJobs(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

ListEnsemblingJobs is HTTP handler that will get a list of EnsemblingJobs

func (EnsemblingJobController) Routes

func (c EnsemblingJobController) Routes() []Route

Routes returns all the HTTP routes given by the EnsemblingJobController.

type ExperimentsController

type ExperimentsController struct {
	BaseController
}

ExperimentsController implements the handlers for experiment related APIs

func (ExperimentsController) ListExperimentEngineClients

func (c ExperimentsController) ListExperimentEngineClients(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

ListExperimentEngineClients returns a list of clients on the given experiment engine

func (ExperimentsController) ListExperimentEngineExperiments

func (c ExperimentsController) ListExperimentEngineExperiments(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

ListExperimentEngineExperiments returns a list of experiments on the given experiment engine, optionally tied to the given client id

func (ExperimentsController) ListExperimentEngineVariables

func (c ExperimentsController) ListExperimentEngineVariables(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

ListExperimentEngineVariables returns a list of variables for the given client and/or experiments

func (ExperimentsController) ListExperimentEngines

func (c ExperimentsController) ListExperimentEngines(
	_ *http.Request,
	_ RequestVars,
	_ interface{},
) *Response

ListExperimentEngines returns a list of available experiment engines

func (ExperimentsController) Routes

func (c ExperimentsController) Routes() []Route

type GetEnsemblingJobOptions

type GetEnsemblingJobOptions struct {
	ProjectID *models.ID `schema:"project_id" validate:"required"`
	ID        *models.ID `schema:"job_id" validate:"required"`
}

GetEnsemblingJobOptions is the options that can be parsed from query params for the GET ensembling job method

type Handler

type Handler func(r *http.Request, vars RequestVars, body interface{}) *Response

Handler is a function that returns a Response given the request.

type PodLogController

type PodLogController struct {
	BaseController
}

func (PodLogController) ListEnsemblingJobPodLogs

func (c PodLogController) ListEnsemblingJobPodLogs(_ *http.Request, vars RequestVars, _ interface{}) *Response

ListEnsemblingJobPodLogs handles the HTTP request for getting Ensembling Pod Logs It supports 3 types of pods:

  1. Image Builder
  2. Spark Driver
  3. Spark Executor

func (PodLogController) ListRouterPodLogs

func (c PodLogController) ListRouterPodLogs(_ *http.Request, vars RequestVars, _ interface{}) *Response

ListRouterPodLogs handles the HTTP request for getting Router Pod Logs It supports 3 types of pods:

  1. Router
  2. Enricher
  3. Ensembler

func (PodLogController) Routes

func (c PodLogController) Routes() []Route

type ProjectsController

type ProjectsController struct {
	BaseController
}

func (ProjectsController) ListProjects

func (c ProjectsController) ListProjects(
	r *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

func (ProjectsController) Routes

func (c ProjectsController) Routes() []Route

type RequestVars

type RequestVars map[string][]string

RequestVars is an alias of map[string][]string This is done to make it compatible with *http.Request.URL.Query() return type and also to make it possible to use it with gorilla/schema Decoder

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response contains the return code and data to return to the caller.

func Accepted

func Accepted(data interface{}) *Response

Accepted returns an Response with status code 202.

func BadRequest

func BadRequest(description, msg string) *Response

BadRequest returns an Response with the error code 400.

func Created

func Created(data interface{}) *Response

Created returns an Response with status code 201.

func Error

func Error(code int, description string, msg string) *Response

Error returns an Response with the provided status code and error message.

func InternalServerError

func InternalServerError(description, msg string) *Response

InternalServerError returns an Response with the error code 500.

func NotFound

func NotFound(description, msg string) *Response

NotFound returns an Response with the error code 404.

func Ok

func Ok(data interface{}) *Response

Ok returns an Response with status code 200.

func (*Response) MarshalJSON

func (r *Response) MarshalJSON() ([]byte, error)

MarshalJSON is a custom marshaler for the unexported fields

func (*Response) WriteTo

func (r *Response) WriteTo(w http.ResponseWriter)

WriteTo writes a Response to the provided http.ResponseWriter.

type Route

type Route struct {
	// contains filtered or unexported fields
}

Route is a http route for the API.

func (Route) HandlerFunc

func (route Route) HandlerFunc(validator *validator.Validate) http.HandlerFunc

HandlerFunc returns the HandlerFunc for this route, which validates the request and executes the route's Handler on the request, returning its response.

func (Route) Method

func (route Route) Method() string

Method returns HTTP method of this route

func (Route) Name

func (route Route) Name() string

Name returns the name of the route by either using Route's property `name` or if it's empty – then by inferring it from the Route's `handler` function name

func (Route) Path

func (route Route) Path() string

Path returns path associated with this route

type RouterDeploymentController

type RouterDeploymentController struct {
	BaseController
}

RouterDeploymentController handles the deployment of routers

type RouterVersionsController

type RouterVersionsController struct {
	RouterDeploymentController
}

func (RouterVersionsController) CreateRouterVersion

func (c RouterVersionsController) CreateRouterVersion(_ *http.Request, vars RequestVars, body interface{}) *Response

CreateRouterVersion creates a router version from the provided configuration. If no router exists within the provided project with the provided id, this method will throw an error. If the update is valid, a new RouterVersion will be created but NOT deployed.

func (RouterVersionsController) DeleteRouterVersion

func (c RouterVersionsController) DeleteRouterVersion(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

DeleteRouterVersion deletes the config for the given version number.

func (RouterVersionsController) DeployRouterVersion

func (c RouterVersionsController) DeployRouterVersion(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

DeployRouterVersion deploys the given router version into the associated kubernetes cluster

func (RouterVersionsController) GetRouterVersion

func (c RouterVersionsController) GetRouterVersion(
	_ *http.Request,
	vars RequestVars, _ interface{},
) *Response

GetRouterVersion gets the router version for the provided router id and version number.

func (RouterVersionsController) ListRouterVersions

func (c RouterVersionsController) ListRouterVersions(
	_ *http.Request,
	vars RequestVars, _ interface{},
) *Response

ListRouterVersions lists the router versions of the provided router.

func (RouterVersionsController) ListRouterVersionsWithFilter

func (c RouterVersionsController) ListRouterVersionsWithFilter(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

func (RouterVersionsController) Routes

func (c RouterVersionsController) Routes() []Route

type RoutersController

type RoutersController struct {
	RouterDeploymentController
}

func (RoutersController) CreateRouter

func (c RoutersController) CreateRouter(
	_ *http.Request,
	vars RequestVars,
	body interface{},
) *Response

CreateRouter creates a router from the provided configuration. If there already exists a router within the provided project with the same name, this method will throw an error. If not, a new Router and associated RouterVersion will be created and deployed.

func (RoutersController) DeleteRouter

func (c RoutersController) DeleteRouter(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

DeleteRouter deletes a router and all its associated versions.

func (RoutersController) DeployRouter

func (c RoutersController) DeployRouter(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

DeployRouter deploys the current version of the given router into the associated kubernetes cluster. If there is no current version, an error is returned.

func (RoutersController) GetRouter

func (c RoutersController) GetRouter(
	_ *http.Request,
	vars RequestVars, _ interface{},
) *Response

GetRouter gets a router matching the provided routerID.

func (RoutersController) ListRouterEvents

func (c RoutersController) ListRouterEvents(_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

func (RoutersController) ListRouters

func (c RoutersController) ListRouters(
	_ *http.Request,
	vars RequestVars, _ interface{},
) *Response

ListRouters lists all routers configured in the provided project. If none are found, an error will be thrown.

func (RoutersController) Routes

func (c RoutersController) Routes() []Route

func (RoutersController) UndeployRouter

func (c RoutersController) UndeployRouter(
	_ *http.Request,
	vars RequestVars,
	_ interface{},
) *Response

UndeployRouter deletes the given router specs from the associated kubernetes cluster

func (RoutersController) UpdateRouter

func (c RoutersController) UpdateRouter(_ *http.Request, vars RequestVars, body interface{}) *Response

UpdateRouter updates a router from the provided configuration. If no router exists within the provided project with the provided id, this method will throw an error. If the update is valid, a new RouterVersion will be created and deployed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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