api

package
v0.0.0-...-1aeea75 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFailedHTTPRequestError

func NewFailedHTTPRequestError(method, endpoint string, err error) error

func NewUnexpectedHTTPStatusCodeError

func NewUnexpectedHTTPStatusCodeError(method, endpoint string, statusCode int) error

Types

type DeviceState

type DeviceState struct {
	Version   string                 `json:"version"`
	Timestamp string                 `json:"timestamp"`
	Data      map[string]interface{} `json:"data"`
}

type DevicesStateRes

type DevicesStateRes struct {
	Result DevicesStateResult `json:"result"`
}

type DevicesStateResult

type DevicesStateResult struct {
	ReportedState DeviceState `json:"reportedState"`
}

type Handler

type Handler interface {
	GetNamespaces() (*NamespacesRes, error)
	GetObjects(namespaceID string) (*ObjectsRes, error)
	GetDevicesStateStream(deviceID string) (<-chan *DevicesStateRes, error)
}

func NewHandler

func NewHandler(tokenHandler TokenHandler, apiUrl string) Handler

type Namespace

type Namespace struct {
	DeleteInitiationTime string `json:"deleteinitiationtime"`
	ID                   string `json:"id"`
	MarkForDeletion      bool   `json:"markfordeletion"`
	Name                 string `json:"name"`
}

type NamespacesRes

type NamespacesRes struct {
	Namespaces []Namespace `json:"namespaces"`
}

type Object

type Object struct {
	UID  string `json:"uid"`
	Name string `json:"name"`
	Kind string `json:"kind"`
}

type ObjectsRes

type ObjectsRes struct {
	Objects []Object `json:"objects"`
}

type TokenHandler

type TokenHandler interface {
	RefreshToken() error
	GetToken() string
}

func NewTokenHandler

func NewTokenHandler(username, password, apiUrl string, refreshInterval time.Duration) TokenHandler

NewTokenHandler returns a new TokenHandler

Tokens are synchronously retrieved on init, and refreshed automatically per tick duration

If a token retrieval attempt fails, GetToken returns the previous token

Jump to

Keyboard shortcuts

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