api

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package api contains the handlers and types that support nerd's REST API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartupCheck

func StartupCheck(c *gin.Context)

StartupCheck godoc @Summary Kubernetes startup probe endpoint @Description Will return a 200 as long as the API is up @Produce plain @Success 200 {object} types.SimpleRes @Router /health/startup [get]

Types

type Handler

type Handler struct {
	Conf   config.Config
	NPS    paramstores.NetParamStore
	PS     pointstores.PointStore
	Router *gin.Engine
	TServ  chan types.TrainRequest
}

Handler holds the API's state

func New

func New(tServ chan types.TrainRequest, conf config.Config) (*Handler, error)

New initializes the Gin rest api and returns a handler

func (*Handler) DeleteNet

func (h *Handler) DeleteNet(c *gin.Context)

DeleteNet godoc @Summary Network deletion endpoint @Description Will delete the net with the specified ID @Produce json @Param id path string true "Net ID" @Success 200 {object} types.SimpleRes @Failure 500 {object} types.SimpleRes "When there is an error deleting the net" @Router /nets/{id} [delete]

func (*Handler) DeleteSeries

func (h *Handler) DeleteSeries(c *gin.Context)

DeleteSeries godoc @Summary Series deletion endpoint @Description Will delete the series with the specified ID @Produce json @Param id path string true "Series ID" @Success 200 {object} types.SimpleRes @Failure 404 {object} types.SimpleRes "When the series doesn't exist" @Failure 500 {object} types.SimpleRes "When there is an error deleting the series" @Router /series/{id} [delete]

func (*Handler) Evaluate

func (h *Handler) Evaluate(c *gin.Context)

Evaluate godoc @Summary Input evaluation endpoint @Description Will return the output produced by the given net for the given input @Accept json @Produce json @Param id path string true "Net ID" @Success 200 {object} map[string]float32 @Failure 400 {object} types.SimpleRes "When the request body is formatted incorrectly" @Failure 404 {object} types.SimpleRes "When the provided net ID isn't found" @Failure 500 {object} types.SimpleRes "When there is an error loading the net or evaluating the inputs" @Router /nets/{id}/evaluate [post]

func (*Handler) ListNets

func (h *Handler) ListNets(c *gin.Context)

ListNets godoc @Summary Nets endpoint @Description Will return the paginated list of neural nets in the system @Produce json @Param offset query int false "Offset to fetch" default(0) @Param limit query int false "How many networks to fetch, the service might return more in some cases" default(10) maximum(50) @Param seriesID query string false "Filter by series ID" @Success 200 {object} types.PagedRes @Failure 400 {object} types.SimpleRes "When the request params are formatted incorrectly" @Failure 500 {object} types.SimpleRes "When there is an error retrieving the list of nets" @Router /nets [get]

func (*Handler) ListPoints

func (h *Handler) ListPoints(c *gin.Context)

ListPoints godoc @Summary Retrieve points from series @Description Will return the last N points for the given series @Produce json @Param id path string true "Series ID" @Param limit query int false "How many points to fetch" default(10) maximum(500) @Success 200 {array} pointstores.Point @Failure 404 {object} types.SimpleRes "When the series doesn't exist" @Failure 500 {object} types.SimpleRes "When there is an error fetching the points" @Router /series/{id}/points [get]

func (*Handler) ListSeries

func (h *Handler) ListSeries(c *gin.Context)

ListSeries godoc @Summary Retrieve list of series @Description Will return the list of series in the system @Produce json @Success 200 {array} types.BriefSeries @Failure 500 {object} types.SimpleRes "When there is an error fetching the list of series" @Router /series [get]

func (*Handler) ListSeriesNets added in v0.4.0

func (h *Handler) ListSeriesNets(c *gin.Context)

ListSeriesNets godoc @Summary Alias for retrieving the nets for the given series @Description Will return the list of nets in the system trained with the given series @Produce json @Param id path string true "Series ID" @Param offset query int false "Offset to fetch" default(0) @Param limit query int false "How many networks to fetch, the service might return more in some cases" default(10) maximum(50) @Success 200 {object} types.PagedRes @Failure 400 {object} types.SimpleRes "When the request params are formatted incorrectly" @Failure 500 {object} types.SimpleRes "When there is an error fetching the list of nets" @Router /series/{id}/nets [get]

func (*Handler) ProcessEvent added in v0.3.0

func (h *Handler) ProcessEvent(c *gin.Context)

ProcessEvent godoc @Summary Metric ingestion endpoint @Description Will process the provided metrics update @Accept json @Produce json @Success 202 {object} types.SimpleRes @Failure 400 {object} types.SimpleRes "When the request body is formatted incorrectly" @Failure 500 {object} types.SimpleRes "When there is an error processing the update" @Router /series/process [post]

func (*Handler) ShowWelcomeMsg added in v0.3.0

func (h *Handler) ShowWelcomeMsg(c *gin.Context)

ShowWelcomeMsg is a simple handler method for showing a helpful message at the root of the HTTP server

func (*Handler) Train

func (h *Handler) Train(c *gin.Context)

Train godoc @Summary Net training endpoint @Description Used for training new or existing networks with the points from an existing series @Accept json @Produce json @Success 200 {object} types.SimpleRes @Failure 400 {object} types.SimpleRes "When the request body is formatted incorrectly" @Failure 404 {object} types.SimpleRes "When the provided series ID isn't found" @Failure 500 {object} types.SimpleRes "When there is an error processing the request" @Router /nets [post]

Directories

Path Synopsis
Package types contains most of the objects that the API reads or writes
Package types contains most of the objects that the API reads or writes

Jump to

Keyboard shortcuts

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