Documentation ¶
Index ¶
- Constants
- func BadRequest(c *gin.Context, msg string)
- type API
- func (a *API) AuthChgPassPost(c *gin.Context)
- func (a *API) AuthForgotPost(c *gin.Context)
- func (a *API) AuthRegisterPost(c *gin.Context)
- func (a *API) EventCheck(c *gin.Context)
- func (a *API) EventCreatePost(c *gin.Context)
- func (a *API) EventDelete(c *gin.Context)
- func (a *API) EventGet(c *gin.Context)
- func (a *API) EventListGet(c *gin.Context)
- func (a *API) EventPut(c *gin.Context)
- func (a *API) GetStream(rid uuid.UUID) *Stream
- func (a *API) LogCheck(c *gin.Context)
- func (a *API) LogEntryDelete(c *gin.Context)
- func (a *API) LogListGet(c *gin.Context)
- func (a *API) NotImplemented(c *gin.Context)
- func (a *API) PhotoCheck(c *gin.Context)
- func (a *API) PhotoDelete(c *gin.Context)
- func (a *API) PhotoServeGet(c *gin.Context)
- func (a *API) PhotosListGet(c *gin.Context)
- func (a *API) PlantCheck(c *gin.Context)
- func (a *API) PlantCreatePost(c *gin.Context)
- func (a *API) PlantDelete(c *gin.Context)
- func (a *API) PlantGet(c *gin.Context)
- func (a *API) PlantListGet(c *gin.Context)
- func (a *API) PlantRenamePatch(c *gin.Context)
- func (a *API) RobotCheck(c *gin.Context)
- func (a *API) RobotDelete(c *gin.Context)
- func (a *API) RobotListGet(c *gin.Context)
- func (a *API) RobotMovePost(c *gin.Context)
- func (a *API) RobotRegisterPost(c *gin.Context)
- func (a *API) RobotSetStandby(c *gin.Context)
- func (a *API) RobotSettingsPatch(c *gin.Context)
- func (a *API) RobotStartDemoPost(c *gin.Context)
- func (a *API) RobotStatusGet(c *gin.Context)
- func (a *API) RobotVideoGet(c *gin.Context)
- func (a *API) Shutdown(ctx context.Context) error
- func (a *API) Start() error
- func (a *API) StreamRobot(ctx *gin.Context)
- func (a *API) StreamRobotVideo(ctx *gin.Context)
- func (a *API) StreamUser(ctx *gin.Context)
- type LogEntry
- type Stream
Constants ¶
const ( LogSeverityInfo int = iota LogSeveritySuccess LogSeverityWarning LogSeverityDanger )
const VideoDeathFrequency = time.Second
VideoDeathFrequency is the frequency of which we send the "dead"
const VideoDeathThreshold = time.Second * 5
VideoDeathThreshold is the duration we wait before we show the "dead" image
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
Types ¶
type API ¶
type API struct { Config *config.Config Log *logrus.Logger Gin *gin.Engine DB *sqlx.DB Bucket *blob.Bucket Server *http.Server // contains filtered or unexported fields }
API contains all the dependencies of the API server
func (*API) AuthChgPassPost ¶
func (*API) AuthForgotPost ¶
func (*API) AuthRegisterPost ¶
AuthRegisterPost takes: - forename - surname - email address - password (in plaintext)
Usually returns:
- HTTP Status OK (200) At this point the user should receive a verification token in their inbox. This will be done later.
Otherwise, complains about: - Bad email format - Email address already existing - Shitty password (min 8 characters please)
func (*API) EventCheck ¶
EventCheck is a middleware to check whether the passed event id exists, and (if logged in) confirms whether the currently logged in user owns that event
func (*API) EventCreatePost ¶
EventCreatePost gets the plant object
func (*API) EventDelete ¶
EventDelete gets the plant object
func (*API) EventListGet ¶
EventListGet gets the plant object
func (*API) LogCheck ¶
LogCheck is a middleware to check whether the passed entry id exists, and (if logged in) confirms whether the currently logged in user owns that entry
func (*API) LogEntryDelete ¶
func (*API) LogListGet ¶
LogListGet returns a list of log entries
func (*API) NotImplemented ¶
func (*API) PhotoCheck ¶
PhotoCheck is a middleware to check whether the passed photo uuid exists, and (if logged in) confirms whether the currently logged in user owns that robot
func (*API) PhotoDelete ¶
PhotoDelete deletes the associated photo
func (*API) PhotoServeGet ¶
PhotoServeGet serves the associated photo
func (*API) PhotosListGet ¶
PhotosListGet requires you to be logged in. It lists all photos of plants the user owns
func (*API) PlantCheck ¶
PlantCheck is a middleware to check whether the passed plant uuid exists, and (if logged in) confirms whether the currently logged in user owns that plant
func (*API) PlantCreatePost ¶
PlantCreatePost gets the plant object
func (*API) PlantDelete ¶
PlantDelete deletes the plant object
func (*API) PlantListGet ¶
PlantListGet requires you to be logged in. It lists all plants the user owns
func (*API) PlantRenamePatch ¶
PlantRenamePatch gets the plant object
func (*API) RobotCheck ¶
RobotCheck is a middleware to check whether the passed robot uuid exists, and (if logged in) confirms whether the currently logged in user owns that robot
func (*API) RobotDelete ¶
RobotDelete disassociates the robot from the current user
func (*API) RobotListGet ¶
RobotListGet requires you to be logged in. It lists all robots the user owns + the robot state.
func (*API) RobotMovePost ¶
func (*API) RobotRegisterPost ¶
RobotRegisterPost takes a "robot_id" in the JSON body. It registers the robot corresponding to the UUID to the currently logged in user.
Usually returns HTTP Status OK. Otherwise complains.
func (*API) RobotSetStandby ¶
func (*API) RobotSettingsPatch ¶
func (*API) RobotStartDemoPost ¶
func (*API) RobotStatusGet ¶
RobotStatusGet returns the state of the robot + whether or not it is currently connected
func (*API) RobotVideoGet ¶
RobotVideoGet streams the video
func (*API) StreamRobot ¶
func (*API) StreamRobotVideo ¶
func (*API) StreamUser ¶
type LogEntry ¶
type LogEntry struct { ID int `json:"id" db:"id"` UserID int `json:"user_id" db:"user_id"` Type string `json:"type" db:"type"` Message string `json:"message" db:"message"` Severity int `json:"severity" db:"severity"` RobotID *uuid.UUID `json:"robot_id,omitempty" db:"robot_id"` PlantID *int `json:"plant_id,omitempty" db:"plant_id"` CreatedAt time.Time `json:"created_at" db:"created_at"` }