Documentation ¶
Index ¶
- func CommonMiddleware(next http.Handler) http.Handler
- func FromJSON(i interface{}, r io.Reader) error
- func LoggingMiddleware(logger log.Logger) func(http.Handler) http.Handler
- func ToJSON(i interface{}, w io.Writer) error
- func ValidateEID(fl validator.FieldLevel) bool
- type Controller
- func (c *Controller) AllFirmwares(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) AllNetworks(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) AllSchedules(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) BroadcastByID(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) Broadcasts(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) CreateFirmware(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) CreateSchedule(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) DeviceByID(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) DeviceByName(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) FirmwareByID(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) FirmwareByName(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) NetworkByName(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) NetworkDevices(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) PublishNetworkMessage(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) RemoveBroadcastID(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) RemoveDeviceID(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) RemoveFirmwareID(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) RemoveSchedule(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) Run() error
- func (c *Controller) ScheduleByDeviceID(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) ScheduleByID(rw http.ResponseWriter, r *http.Request)
- func (c *Controller) Shutdown() error
- type CreateFirmwareRequest
- type CreateFirmwareResponse
- type CreateScheduleRequest
- type CreateScheduleResponse
- type CtxKeyOne
- type GenericError
- type NetworkMessageRequest
- type NoContent
- type Validation
- type ValidationErrorMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommonMiddleware ¶
CommonMiddleware inserts json header in all exchanges
func FromJSON ¶
FromJSON deserializes the object from JSON string in an io.Reader to the given interface
func LoggingMiddleware ¶
LoggingMiddleware logs the incoming HTTP request & its duration.
func ValidateEID ¶
func ValidateEID(fl validator.FieldLevel) bool
ValidateEID verify EID uuid-like field key: eid
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller handler for getting and updating API Items
func NewApiProvider ¶
func NewApiProvider(cfg *cc.Config, s *dc.CoreService, l *log.Logger) *Controller
NewApiProvider returns a fully configured http api engine
func (*Controller) AllFirmwares ¶
func (c *Controller) AllFirmwares(rw http.ResponseWriter, r *http.Request)
AllFirmwares a list of []Firmware
func (*Controller) AllNetworks ¶
func (c *Controller) AllNetworks(rw http.ResponseWriter, r *http.Request)
AllNetworks List all SiteNetworks
func (*Controller) AllSchedules ¶
func (c *Controller) AllSchedules(rw http.ResponseWriter, r *http.Request)
AllSchedules []Schedule
func (*Controller) BroadcastByID ¶
func (c *Controller) BroadcastByID(rw http.ResponseWriter, r *http.Request)
BroadcastByID (broadcastID string) (Broadcast, error)
func (*Controller) Broadcasts ¶
func (c *Controller) Broadcasts(rw http.ResponseWriter, r *http.Request)
Broadcasts () []Broadcast
func (*Controller) CreateFirmware ¶
func (c *Controller) CreateFirmware(rw http.ResponseWriter, r *http.Request)
CreateFirmware (srcFile, dstFile string) (EID, error)
func (*Controller) CreateSchedule ¶
func (c *Controller) CreateSchedule(rw http.ResponseWriter, r *http.Request)
CreateSchedule (networkName string, deviceID string, transport OTATransport, firmwareID EID) (string, error)
func (*Controller) DeviceByID ¶
func (c *Controller) DeviceByID(rw http.ResponseWriter, r *http.Request)
DeviceByID (deviceID string, networkName string) (Device, error)
func (*Controller) DeviceByName ¶
func (c *Controller) DeviceByName(rw http.ResponseWriter, r *http.Request)
DeviceByName (deviceName, networkName string) (Device, error)
func (*Controller) FirmwareByID ¶
func (c *Controller) FirmwareByID(rw http.ResponseWriter, r *http.Request)
FirmwareByID (firmwareID EID) (Firmware, error)
func (*Controller) FirmwareByName ¶
func (c *Controller) FirmwareByName(rw http.ResponseWriter, r *http.Request)
FirmwareByName (firmwareName string) (Firmware, error)
func (*Controller) NetworkByName ¶
func (c *Controller) NetworkByName(rw http.ResponseWriter, r *http.Request)
NetworkByName (networkName string) Network
func (*Controller) NetworkDevices ¶
func (c *Controller) NetworkDevices(rw http.ResponseWriter, r *http.Request)
NetworkDevices (networkName string) (map[string]Device)
func (*Controller) PublishNetworkMessage ¶
func (c *Controller) PublishNetworkMessage(rw http.ResponseWriter, r *http.Request)
PublishNetworkMessage (dm DeviceMessage) topic, payload, qos, bRetained
func (*Controller) RemoveBroadcastID ¶
func (c *Controller) RemoveBroadcastID(rw http.ResponseWriter, r *http.Request)
RemoveBroadcastID (broadcastID string)
func (*Controller) RemoveDeviceID ¶
func (c *Controller) RemoveDeviceID(rw http.ResponseWriter, r *http.Request)
RemoveDeviceID (deviceID string, networkName string) error
func (*Controller) RemoveFirmwareID ¶
func (c *Controller) RemoveFirmwareID(rw http.ResponseWriter, r *http.Request)
RemoveFirmwareID (firmwareID EID)
func (*Controller) RemoveSchedule ¶
func (c *Controller) RemoveSchedule(rw http.ResponseWriter, r *http.Request)
RemoveSchedule (scheduleID string)
func (*Controller) ScheduleByDeviceID ¶
func (c *Controller) ScheduleByDeviceID(rw http.ResponseWriter, r *http.Request)
ScheduleByDeviceID (deviceID string) Schedule
func (*Controller) ScheduleByID ¶
func (c *Controller) ScheduleByID(rw http.ResponseWriter, r *http.Request)
ScheduleByID (scheduleID string) Schedule
type CreateFirmwareRequest ¶
type CreateFirmwareRequest struct { SrcFile string `json:"srcFile" validate:"required,fwfn"` DstFile string `json:"dstFile" validate:"required,fwfn"` }
CreateFirmwareRequest upload a new firmware
type CreateFirmwareResponse ¶
type CreateFirmwareResponse struct {
FirmwareID string `json:"firmwareID"`
}
CreateFirmwareResponse id of newly created firmware
type CreateScheduleRequest ¶
type CreateScheduleRequest struct { NetworkName string `json:"networkName" validate:"required"` DeviceID string `json:"deviceID" validate:"required,eid"` Transport int `json:"transportType" validate:"required"` FirmwareID string `json:"firmwareID" validate:"required,eid"` }
CreateScheduleRequest create a new firmware OTA schedule
type CreateScheduleResponse ¶
type CreateScheduleResponse struct {
ScheduleID string `json:"scheduleID"`
}
CreateScheduleResponse returns id of created schedule
type CtxKeyOne ¶
type CtxKeyOne struct{}
CtxKeyOne is a key used for the Product object in the context
type GenericError ¶
type GenericError struct {
Message string `json:"message"`
}
GenericError is a generic error message returned by a server
type NetworkMessageRequest ¶
type NetworkMessageRequest struct { Topic string `json:"topic" validate:"required"` Qos int `json:"qos" validate:"required"` Retained string `json:"retained" validate:"required"` Value string `json:"value"` }
NetworkMessageRequest send any message over MQTT
type Validation ¶
type Validation struct {
// contains filtered or unexported fields
}
Validation contains
func (*Validation) ValidateParam ¶
func (v *Validation) ValidateParam(param interface{}, tag string) ValidationErrorMessage
ValidateParam validates individual params example: ValidateParam(email, "required,email") returns: []string
func (*Validation) ValidateStruct ¶
func (v *Validation) ValidateStruct(i interface{}) ValidationErrorMessage
ValidateStruct verify contents of a structure object
if ve, ok := err.(validator.ValidationErrors); ok { fmt.Println(ve.Namespace()) fmt.Println(ve.Field()) fmt.Println(ve.StructNamespace()) fmt.Println(ve.StructField()) fmt.Println(ve.Tag()) fmt.Println(ve.ActualTag()) fmt.Println(ve.Kind()) fmt.Println(ve.Type()) fmt.Println(ve.Value()) fmt.Println(ve.Param()) fmt.Println() }
type ValidationErrorMessage ¶
type ValidationErrorMessage struct {
Messages []string `json:"messages"`
}
ValidationErrorMessage is a collection of validation error messages