api

package
v0.0.0-...-7f3e7ba Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package api implements an interface to the Auklet backend API.

Index

Constants

View Source
const (
	ReleasesEP     = "/private/releases/"
	CertificatesEP = "/private/devices/certificates/"
	DevicesEP      = "/private/devices/"
	ConfigEP       = "/private/devices/config/"
	DataLimitEP    = "/private/devices/%s/app_config/" // app id
)

namespaces and endpoints for the API. All new endpoints should be entered here.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// BaseURL is the subdomain against which requests will be performed. It
	// should not assume any particular namespace.
	BaseURL string
	Key     string
	AppID   string
	MacHash string

	// for credentials
	CredsPath string // where to save/load credentials
	Fs        Fs     // filesystem for saving/loading

	ReleasesEP     string
	CertificatesEP string
	DevicesEP      string
	ConfigEP       string
	DataLimitEP    string
}

API provides an interface to the backend.

func (API) BrokerAddress

func (a API) BrokerAddress() (string, error)

BrokerAddress returns an address to which we can send broker messages.

func (API) Certificates

func (a API) Certificates() (*tls.Config, error)

Certificates retrieves CA certs.

func (API) Credentials

func (a API) Credentials() (*Credentials, error)

Credentials retrieves credentials from the filesystem, with a fallback to the API. If credentials are retrieved from the API, they are saved to the filesystem.

func (API) DataLimit

func (a API) DataLimit() (*DataLimit, error)

DataLimit retrieves DataLimit parameters from the backend.

func (API) Release

func (a API) Release(checksum string) error

Release is an API call that checks whether the given checksum has been released.

type CellularConfig

type CellularConfig struct {
	Date int // day of the month in [1,28]

	Defined bool
	Limit   int
}

CellularConfig holds parameters for a cellular plan.

type Credentialer

type Credentialer interface {
	Credentials() (*Credentials, error)
}

Credentialer provides a way to get Credentials.

type Credentials

type Credentials struct {
	Username string `json:"id"`
	Password string `json:"client_password"`
	Org      string `json:"organization"`
	ClientID string `json:"client_id"`
}

Credentials represents credentials required for sending broker messages.

type DataLimit

type DataLimit struct {
	Storage        *int64
	EmissionPeriod int
	Cellular       CellularConfig
}

DataLimit holds parameters controlling Auklet's data usage.

type Fs

type Fs interface {
	Open(string) (afero.File, error)
	OpenFile(string, int, os.FileMode) (afero.File, error)
}

Fs provides file system functions.

Jump to

Keyboard shortcuts

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