Documentation ¶
Overview ¶
Package client is a convenience package that provides methods to interface with the Freyr server's HTTP API.
Index ¶
- func DeleteReadings(s Signator, domain, coreid string, start, end time.Time) error
- func GetJobStatus(s Signator, domain, jobID string) (*bifrost.JobStatus, error)
- func GetLatest(s Signator, domain string) ([]models.Reading, error)
- func GetReadings(s Signator, domain, coreid string, start, end time.Time) ([]models.Reading, error)
- func GetSecret(s Signator, domain string) (models.Secret, error)
- func PostReading(s Signator, domain string, reading models.Reading) error
- func PostReadings(s Signator, domain string, readings []models.Reading) (string, error)
- func RotateSecret(s Signator, domain string) (models.Secret, error)
- func WaitForJob(s Signator, domain, jobID string, timeout time.Duration) error
- type APISignator
- type DeviceSignator
- type Signator
- type WebSignator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteReadings ¶
DeleteReadings deletes all readings within a specified time frame.
func GetReadings ¶
GetReadings gets all the readings stored in a specified time frame for a user.
func PostReading ¶
PostReading posts a new reading
func PostReadings ¶
PostReadings posts a list of readings
func RotateSecret ¶
RotateSecret requests the system rotate a user's secret. Request must be API signed.
Types ¶
type APISignator ¶
APISignator is used to sign requests in the method prescribed for API calls.
func NewAPISignator ¶
func NewAPISignator(userEmail, base64Secret string) (*APISignator, error)
NewAPISignator generates a new ApiSignator, conveniencing decoding the secret from base64.
func (APISignator) Sign ¶
func (s APISignator) Sign(r *http.Request)
Sign signs an http.Request by applying an API signature.
type DeviceSignator ¶
DeviceSignator is used to sign a request in the way prescribed for device requests.
func (*DeviceSignator) Sign ¶
func (s *DeviceSignator) Sign(r *http.Request)
Sign (incomplete) signs a request by applying the headers indicating which device signed the request for which user and providing a token signed with that user's secret.
type WebSignator ¶
type WebSignator struct {
Token string
}
WebSignator is used to sign requests in the same way they would be when a user is accessing the server through the web interface.
func (WebSignator) Sign ¶
func (s WebSignator) Sign(r *http.Request)
Sign is used to sign an http.Request by adding the signed token (signed by the server's key) as a header.