Documentation ¶
Index ¶
- type API
- type Client
- func (c Client) ConfigureDevice(ctx context.Context, uuid string, name string, config string) (device Device, err error)
- func (c Client) GetDeviceConfig(ctx context.Context) (device Device, err error)
- func (c Client) GetDeviceConfigFor(ctx context.Context, uuid string) (device Device, err error)
- func (c Client) GetDeviceTokenFor(ctx context.Context, uuid string) (device Device, err error)
- func (c Client) InsertReading(ctx context.Context, tCelcius float64, rh float64) (reading Reading, err error)
- func (c Client) RegisterDevice(ctx context.Context, name string, config string) (device Device, err error)
- type ConfigureDeviceRequest
- type Device
- type Doer
- type GetDeviceConfigRequest
- type GetDeviceTokenRequest
- type InsertReadingRequest
- type Reading
- type RegistrationRequest
- type RoundTripHandler
- type RoundTripper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { //device endpoints - device UUID is inferred from token GetDeviceConfig(ctx context.Context) (Device, error) InsertReading(ctx context.Context, tCelcius float64, rh float64) (Reading, error) //admin endpoints RegisterDevice(ctx context.Context, name string, config string) (Device, error) ConfigureDevice(ctx context.Context, uuid string, name string, config string) (Device, error) GetDeviceTokenFor(ctx context.Context, uuid string) (Device, error) GetDeviceConfigFor(ctx context.Context, uuid string) (device Device, err error) }
API is the client interface
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements API over HTTPs
func NewDefaultClient ¶
func NewDefaultClient( host string, transport http.RoundTripper, token string, ) Client
NewDefaultClient creates a client with default middlewares
func (Client) ConfigureDevice ¶
func (c Client) ConfigureDevice(ctx context.Context, uuid string, name string, config string) (device Device, err error)
ConfigureDevice configures the specified device
func (Client) GetDeviceConfig ¶
GetDeviceConfig gets the current config text for current the device
func (Client) GetDeviceConfigFor ¶
GetDeviceConfigFor gets the current config text for the specified device
func (Client) GetDeviceTokenFor ¶
GetDeviceTokenFor generates a token for the device
type ConfigureDeviceRequest ¶
type ConfigureDeviceRequest struct { DeviceUUID string `json:"device_uuid" binding:"required"` Name string `json:"name"` Config json.RawMessage `json:"config" binding:"required"` }
ConfigureDeviceRequest encodes a single request for user registration
type Device ¶
type Device struct { DeviceUUID string `json:"device_uuid,omitempty"` Name *string `json:"name,omitempty"` Token *string `json:"token,omitempty"` Config *json.RawMessage `json:"config,omitempty"` }
Device represents the response to a device-related endpoint
type GetDeviceConfigRequest ¶
type GetDeviceConfigRequest struct {
DeviceUUID *string `uri:"uuid"`
}
GetDeviceConfigRequest encodes a single request for user registration
type GetDeviceTokenRequest ¶
type GetDeviceTokenRequest struct {
DeviceUUID string `json:"device_uuid" binding:"required"`
}
GetDeviceTokenRequest encodes a single request for user registration
type InsertReadingRequest ¶
type InsertReadingRequest struct { TemperatureCelcius json.Number `json:"temperature_celcius" binding:"required"` RelativeHumidity json.Number `json:"relative_humidity" binding:"required"` }
InsertReadingRequest encodes a single request for user registration
type Reading ¶
type Reading struct { DeviceUUID string `json:"device_uuid,omitempty"` ReadingUUID string `json:"reading_uuid,omitempty"` TemperatureCelcius *json.Number `json:"temperature_celcius,omitempty"` RelativeHumidity *json.Number `json:"relative_humidity,omitempty"` }
Reading represents the response to a reading-related endpoint
type RegistrationRequest ¶
type RegistrationRequest struct { Name string `json:"name" binding:"required"` Config json.RawMessage `json:"config" binding:"required"` }
RegistrationRequest encodes a single request for user registration
type RoundTripHandler ¶
RoundTripHandler is a helper type for building RoundTrippers
type RoundTripper ¶
RoundTripper impelments the http RoundTrip method
func DefaultAuthorizer ¶
func DefaultAuthorizer(next RoundTripper, token string) RoundTripper
DefaultAuthorizer returns a roundtripper to attach a bearer token to each request
func DefaultRetryer ¶
func DefaultRetryer(next RoundTripper) RoundTripper
DefaultRetryer returns a roundtripper to retry certain response codes