Documentation
¶
Index ¶
- func IsPermanentError(err error) bool
- type CacophonyAPI
- func (api *CacophonyAPI) DownloadFile(fileResponse *FileResponse, filePath string) error
- func (api *CacophonyAPI) GetFileDetails(fileID int) (*FileResponse, error)
- func (api *CacophonyAPI) GetSchedule() ([]byte, error)
- func (api *CacophonyAPI) JustRegistered() bool
- func (api *CacophonyAPI) Password() string
- func (api *CacophonyAPI) ReportEvent(jsonDetails []byte, times []time.Time) error
- func (api *CacophonyAPI) UploadThermalRaw(r io.Reader) error
- type CacophonyDevice
- type Config
- type ConfigPassword
- type Error
- type FileDetails
- type FileInfo
- type FileResponse
- type PrivateConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPermanentError ¶
IsPermanentError examines the supplied error and returns true if it is permanent.
Types ¶
type CacophonyAPI ¶
type CacophonyAPI struct {
// contains filtered or unexported fields
}
func NewAPI ¶
func NewAPI(serverURL, group, deviceName, password string) (*CacophonyAPI, error)
createAPI creates a CacophonyAPI instance and obtains a fresh JSON Web Token. If no password is given then the device is registered.
func NewAPIFromConfig ¶
func NewAPIFromConfig(configFile string) (*CacophonyAPI, error)
NewAPIFromConfig prases the supplied configFile and creates a new CacophonyAPI with the configFile information and saves the generated password to privConfigFileName(configFile)
func (*CacophonyAPI) DownloadFile ¶
func (api *CacophonyAPI) DownloadFile(fileResponse *FileResponse, filePath string) error
DownloadFile specified by fileResponse and save it to filePath
func (*CacophonyAPI) GetFileDetails ¶
func (api *CacophonyAPI) GetFileDetails(fileID int) (*FileResponse, error)
GetFileDetails of the supplied fileID from the Cacophony API and return FileResponse info. This can then be parsed into DownloadFile to download the file
func (*CacophonyAPI) GetSchedule ¶
func (api *CacophonyAPI) GetSchedule() ([]byte, error)
GetSchedule will get the audio schedule
func (*CacophonyAPI) JustRegistered ¶
func (api *CacophonyAPI) JustRegistered() bool
func (*CacophonyAPI) Password ¶
func (api *CacophonyAPI) Password() string
func (*CacophonyAPI) ReportEvent ¶
func (api *CacophonyAPI) ReportEvent(jsonDetails []byte, times []time.Time) error
ReportEvent described by jsonDetails and timestamps to the Cacophony API
func (*CacophonyAPI) UploadThermalRaw ¶
func (api *CacophonyAPI) UploadThermalRaw(r io.Reader) error
UploadThermalRaw uploads the file to Cacophony API as a multipartmessage with data of type thermalRaw specified
type CacophonyDevice ¶
type CacophonyDevice struct {
// contains filtered or unexported fields
}
type Config ¶
type Config struct { ServerURL string `yaml:"server-url"` Group string `yaml:"group"` DeviceName string `yaml:"device-name"` }
func ParseConfig ¶
ParseConfig takes supplied bytes and returns a parsed Config struct
func ParseConfigFile ¶
ParseConfig takes supplied filename and returns a parsed Config struct
type ConfigPassword ¶
type ConfigPassword struct {
// contains filtered or unexported fields
}
func NewConfigPassword ¶
func NewConfigPassword(filename string) *ConfigPassword
func (*ConfigPassword) GetExLock ¶
func (confPassword *ConfigPassword) GetExLock() (bool, error)
GetExLock acquires an exclusive lock on confPassword
func (*ConfigPassword) ReadPassword ¶
func (confPassword *ConfigPassword) ReadPassword() (string, error)
ReadPassword acquires a readlock and reads the password
func (*ConfigPassword) Unlock ¶
func (confPassword *ConfigPassword) Unlock()
func (*ConfigPassword) WritePassword ¶
func (confPassword *ConfigPassword) WritePassword(password string) error
WritePassword checks the file is locked and writes the password
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is returned by API calling methods. As well as an error message, it includes whether the error is permanent or not.
type FileDetails ¶
type FileInfo ¶
type FileInfo struct { Details FileDetails Type string }
type FileResponse ¶
type PrivateConfig ¶
type PrivateConfig struct {
Password string `yaml:"password"`
}