Documentation ¶
Index ¶
- func ApiToTimeline(tl Timeline) data.Timeline
- func ApiVersionMiddleware(next http.Handler) http.Handler
- func NewRouter(apiService Service) http.Handler
- type ErrorResponse
- type FadeMeta
- type GradientMeta
- type LightningMeta
- type MetaColor
- type SequenceMeta
- type Service
- func (service Service) AddTimeline(rw http.ResponseWriter, req *http.Request)
- func (service Service) DeleteTimeline(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetAllTimelines(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetAllTimelinesWithTag(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetSystemConfig(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetTimeline(rw http.ResponseWriter, req *http.Request)
- func (service Service) RequestAllTimelinesStop(rw http.ResponseWriter, req *http.Request)
- func (service Service) RequestTimelinePlay(rw http.ResponseWriter, req *http.Request)
- func (service Service) RequestTimelineStop(rw http.ResponseWriter, req *http.Request)
- func (service Service) ShowUI(rw http.ResponseWriter, req *http.Request)
- func (service Service) UpdateTags(rw http.ResponseWriter, req *http.Request)
- type SolidMeta
- type SystemConfig
- type SystemResponse
- type Timeline
- type TimelineStep
- type TriggerMeta
- type UpdateConfigValueRequest
- type UpdateTagsRequest
- type ZipMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApiToTimeline ¶
ApiToTimeline converts api format to internal data model
func ApiVersionMiddleware ¶
ApiVersionMiddleware adds the API version information to the response header
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
}
ErrorResponse represents an API response
type GradientMeta ¶
type LightningMeta ¶
type SequenceMeta ¶
type SequenceMeta struct {
Sequence []MetaColor `json:"sequence"`
}
type Service ¶
type Service struct { // DB is the system datastore reference DB data.AppDataService // StartTime is the service start time. We can calculate uptime based on this StartTime time.Time // PlayTimeline signals a timeline should be played PlayTimeline chan leds.PlayTimelineRequest // StopTimeline signals a timeline should stop playing StopTimeline chan string // StopAllTimelines signals all timelines should stop playing StopAllTimelines chan bool }
Service encapsulates API service operations
func (Service) AddTimeline ¶
func (service Service) AddTimeline(rw http.ResponseWriter, req *http.Request)
AddTimeline godoc @Summary Adds a timeline to the system @Description Adds a timeline to the system @Tags timeline @Accept json @Produce json @Param endpoint body api.Timeline true "The timeline to add" @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /timelines [put]
func (Service) DeleteTimeline ¶
func (service Service) DeleteTimeline(rw http.ResponseWriter, req *http.Request)
DeleteTimeline godoc @Summary Delete a single timeline @Description Delete a single timeline @Tags timeline @Accept json @Produce json @Param id path string true "The timeline id to delete" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /timelines/{id} [delete]
func (Service) GetAllTimelines ¶
func (service Service) GetAllTimelines(rw http.ResponseWriter, req *http.Request)
GetAllTimelines godoc @Summary List all timelines in the system @Description List all timelines in the system @Tags timeline @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /timelines [get]
func (Service) GetAllTimelinesWithTag ¶
func (service Service) GetAllTimelinesWithTag(rw http.ResponseWriter, req *http.Request)
GetAllTimelinesWithTag godoc @Summary Gets timelines that have a tag @Description Gets timelines that have a tag @Tags timeline @Accept json @Produce json @Param tag path string true "The tag to use when fetching timelines" @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /timelines/tag/{tag} [get]
func (Service) GetSystemConfig ¶
func (service Service) GetSystemConfig(rw http.ResponseWriter, req *http.Request)
GetSystemConfig godoc @Summary Get the system configuration information @Description Get the system configuration information @Tags config @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /config [get]
func (Service) GetTimeline ¶
func (service Service) GetTimeline(rw http.ResponseWriter, req *http.Request)
GetTimeline godoc @Summary Gets a single timeline @Description Gets a single timeline @Tags timeline @Accept json @Produce json @Param id path string true "The timeline id to get" @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /timelines/{id} [get]
func (Service) RequestAllTimelinesStop ¶
func (service Service) RequestAllTimelinesStop(rw http.ResponseWriter, req *http.Request)
RequestAllTimelinesStop godoc @Summary Stops all timeline 'play' processes @Description Stops all timeline 'play' processes @Tags process @Accept json @Produce json @Success 200 {object} api.SystemResponse @Router /timeline/stop [post]
func (Service) RequestTimelinePlay ¶
func (service Service) RequestTimelinePlay(rw http.ResponseWriter, req *http.Request)
RequestTimelinePlay godoc @Summary Plays a timeline in the system @Description Plays a timeline in the system @Tags process @Accept json @Produce json @Param id path string true "The timeline id to play" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /timeline/run/{id} [post]
func (Service) RequestTimelineStop ¶
func (service Service) RequestTimelineStop(rw http.ResponseWriter, req *http.Request)
RequestTimelineStop godoc @Summary Stops a specific timeline 'play' process @Description Stops a specific timeline 'play' process @Tags process @Accept json @Produce json @Param pid path string true "The process id to stop" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Router /timeline/stop/{pid} [post]
func (Service) ShowUI ¶
func (service Service) ShowUI(rw http.ResponseWriter, req *http.Request)
ShowUI redirects to the /ui/ url path
func (Service) UpdateTags ¶
func (service Service) UpdateTags(rw http.ResponseWriter, req *http.Request)
UpdateTags godoc @Summary Updates tags for a timeline @Description Updates tags for a timeline @Tags timeline @Accept json @Produce json @Param id path string true "The timeline id to update tags for" @Param endpoint body api.UpdateTagsRequest true "The tags to set for the timeline" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /timelines/{id} [post]
type SystemConfig ¶
SystemConfig represents the system configuration information
type SystemResponse ¶
type SystemResponse struct { Message string `json:"message"` Data interface{} `json:"data"` }
SystemResponse is a response for a system request
type Timeline ¶
type Timeline struct { ID string `json:"id,omitempty"` // Unique Timeline ID Enabled bool `json:"enabled,omitempty"` // Timeline enabled or not Created string `json:"created,omitempty"` // Timeline create time Name string `json:"name"` // Timeline name GPIO int `json:"gpio,omitempty"` // The GPIO device to play the timeline on. Optional. If not set, uses the default Steps []TimelineStep `json:"steps"` // Steps for the timeline Tags []string `json:"tags,omitempty"` // List of Tags to associate with this timeline }
Timeline represents a series of event frames to be shown in order
func TimelineToApi ¶
TimelineToApi converts internal data model to api format
type TimelineStep ¶
type TimelineStep struct { ID string `json:"id"` // The timeline step id Type string `json:"type"` // Timeline frame type (effect/sleep/trigger/loop) Effect string `json:"effect,omitempty"` // The Effect type (if Type=effect) Leds string `json:"leds,omitempty"` // Leds to use for the scene (optional) If not set and is required for the type, defaults to entire strip Time int `json:"time,omitempty"` // Time (in milliseconds). Some things (like trigger) don't require time MetaInfo any `json:"meta-info,omitempty"` // Additional information required for specific types Number int `json:"number"` // The step number (ordinal position in the timeline) }
TimelineStep represents a single step in a timeline
type TriggerMeta ¶
type UpdateConfigValueRequest ¶
type UpdateConfigValueRequest struct {
Value int `json:"value"`
}
UpdateConfigValueRequest represents a request to update a system config value
type UpdateTagsRequest ¶
type UpdateTagsRequest struct {
Tags []string `json:"tags"`
}
UpdateTagsRequest represents a request to update tags for a file