api

package module
v0.0.0-...-f7ffe9b Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

README

go-api

Client for the Cacophony API server.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPermanentError

func IsPermanentError(err error) bool

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

func ParseConfig(buf []byte) (*Config, error)

ParseConfig takes supplied bytes and returns a parsed Config struct

func ParseConfigFile

func ParseConfigFile(filename string) (*Config, error)

ParseConfig takes supplied filename and returns a parsed Config struct

func (*Config) Validate

func (conf *Config) Validate() error

Validate checks supplied Config contains the required data

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.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Permanent

func (e *Error) Permanent() bool

Permanent returns true if the error is permanent. Operations resulting in non-permanent/temporary errors may be retried.

type FileDetails

type FileDetails struct {
	Name         string
	OriginalName string
}

type FileInfo

type FileInfo struct {
	Details FileDetails
	Type    string
}

type FileResponse

type FileResponse struct {
	File FileInfo
	Jwt  string
}

type PrivateConfig

type PrivateConfig struct {
	Password string `yaml:"password"`
}

Jump to

Keyboard shortcuts

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