api

package
v0.0.0-...-ceb5cd5 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func NewRouter

func NewRouter(appCtx *AppContext) *mux.Router

NewRouter instantiates a mux.Router for this application.

Types

type AlertsController

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

func (*AlertsController) CreateAlert

func (c *AlertsController) CreateAlert(r *http.Request, vars map[string]string, body interface{}) *Response

func (*AlertsController) DeleteAlert

func (c *AlertsController) DeleteAlert(r *http.Request, vars map[string]string, _ interface{}) *Response

func (*AlertsController) GetAlert

func (c *AlertsController) GetAlert(r *http.Request, vars map[string]string, _ interface{}) *Response

func (*AlertsController) ListAlerts

func (c *AlertsController) ListAlerts(r *http.Request, vars map[string]string, _ interface{}) *Response

func (*AlertsController) UpdateAlert

func (c *AlertsController) UpdateAlert(r *http.Request, vars map[string]string, body interface{}) *Response

type AppContext

type AppContext struct {
	Authorizer        *middleware.Authorizer
	OpenAPIValidation *middleware.OpenAPIValidation

	// DAO
	DeploymentService     service.DeploymentService
	RoutersService        service.RoutersService
	RouterVersionsService service.RouterVersionsService
	EventService          service.EventService
	AlertService          service.AlertService

	// Default configuration for routers
	RouterDefaults *config.RouterDefaults

	CryptoService      service.CryptoService
	MLPService         service.MLPService
	ExperimentsService service.ExperimentsService
	PodLogService      service.PodLogService
}

AppContext stores the entities relating to the application's context

func NewAppContext

func NewAppContext(
	db *gorm.DB,
	cfg *config.Config,
	authEnforcer *enforcer.Enforcer,
	vaultClient vault.VaultClient,
) (*AppContext, error)

NewAppContext is a creator for the app context

type ExperimentsController

type ExperimentsController struct {
	*AppContext
}

ExperimentsController implements the handlers for experiment related APIs

func (ExperimentsController) ListExperimentEngineClients

func (c ExperimentsController) ListExperimentEngineClients(
	r *http.Request,
	vars map[string]string,
	_ interface{},
) *Response

ListExperimentEngineClients returns a list of clients on the given experiment engine

func (ExperimentsController) ListExperimentEngineExperiments

func (c ExperimentsController) ListExperimentEngineExperiments(
	r *http.Request,
	vars map[string]string,
	_ 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(
	r *http.Request,
	vars map[string]string,
	_ interface{},
) *Response

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

func (ExperimentsController) ListExperimentEngines

func (c ExperimentsController) ListExperimentEngines(
	_ *http.Request,
	_ map[string]string,
	_ interface{},
) *Response

ListExperimentEngines returns a list of available experiment engines

type Handler

type Handler func(r *http.Request, vars map[string]string, body interface{}) *Response

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

type PodLogController

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

func (*PodLogController) ListPodLogs

func (c *PodLogController) ListPodLogs(r *http.Request, vars map[string]string, body interface{}) *Response

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 an 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 *val.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.

type RouterVersionsController

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

func (RouterVersionsController) DeleteRouterVersion

func (c RouterVersionsController) DeleteRouterVersion(
	r *http.Request,
	vars map[string]string,
	_ interface{},
) *Response

DeleteRouterVersion deletes the config for the given version number.

func (RouterVersionsController) DeployRouterVersion

func (c RouterVersionsController) DeployRouterVersion(
	r *http.Request,
	vars map[string]string,
	body interface{},
) *Response

DeployRouterVersion deploys the given router version into the associated kubernetes cluster

func (RouterVersionsController) GetRouterVersion

func (c RouterVersionsController) GetRouterVersion(
	r *http.Request,
	vars map[string]string, _ interface{},
) *Response

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

func (RouterVersionsController) ListRouterVersions

func (c RouterVersionsController) ListRouterVersions(
	r *http.Request,
	vars map[string]string, _ interface{},
) *Response

ListRouterVersions lists the router versions of the provided router.

type RoutersController

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

func (RoutersController) CreateRouter

func (c RoutersController) CreateRouter(
	r *http.Request,
	vars map[string]string,
	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(
	r *http.Request,
	vars map[string]string,
	_ interface{},
) *Response

DeleteRouter deletes a router and all its associated versions.

func (RoutersController) DeployRouter

func (c RoutersController) DeployRouter(
	r *http.Request,
	vars map[string]string,
	body 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(
	r *http.Request,
	vars map[string]string, _ interface{},
) *Response

GetRouter gets a router matching the provided routerID.

func (RoutersController) ListRouterEvents

func (c RoutersController) ListRouterEvents(r *http.Request,
	vars map[string]string,
	body interface{},
) *Response

func (RoutersController) ListRouters

func (c RoutersController) ListRouters(
	r *http.Request,
	vars map[string]string, _ interface{},
) *Response

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

func (RoutersController) UndeployRouter

func (c RoutersController) UndeployRouter(
	r *http.Request,
	vars map[string]string,
	body interface{},
) *Response

UndeployRouter deletes the given router specs from the associated kubernetes cluster

func (RoutersController) UpdateRouter

func (c RoutersController) UpdateRouter(r *http.Request, vars map[string]string, 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