client

package
v0.0.0-...-721f978 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package client is a convenience package that provides methods to interface with the Freyr server's HTTP API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteReadings

func DeleteReadings(s Signator, domain, coreid string, start, end time.Time) error

DeleteReadings deletes all readings within a specified time frame.

func GetJobStatus

func GetJobStatus(s Signator, domain, jobID string) (*bifrost.JobStatus, error)

func GetLatest

func GetLatest(s Signator, domain string) ([]models.Reading, error)

GetLatest gets the latest readings, per device, for a user.

func GetReadings

func GetReadings(s Signator, domain, coreid string, start, end time.Time) ([]models.Reading, error)

GetReadings gets all the readings stored in a specified time frame for a user.

func GetSecret

func GetSecret(s Signator, domain string) (models.Secret, error)

GetSecret requests the system to generate a new secret for the user.

func PostReading

func PostReading(s Signator, domain string, reading models.Reading) error

PostReading posts a new reading

func PostReadings

func PostReadings(s Signator, domain string, readings []models.Reading) (string, error)

PostReadings posts a list of readings

func RotateSecret

func RotateSecret(s Signator, domain string) (models.Secret, error)

RotateSecret requests the system rotate a user's secret. Request must be API signed.

func WaitForJob

func WaitForJob(s Signator, domain, jobID string, timeout time.Duration) error

Types

type APISignator

type APISignator struct {
	UserEmail string
	Secret    models.Secret
}

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

type DeviceSignator struct {
	UserEmail string
	Token     string
}

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 Signator

type Signator interface {
	Sign(r *http.Request)
}

Signator is an interface representing a type that is capable of signing requests.

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.

Jump to

Keyboard shortcuts

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