api

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRetryable

func IsRetryable(err error) bool

func IsUnauthorized

func IsUnauthorized(err error) bool

Types

type Authz

type Authz struct {
	Token     string
	ServerURL string
}

func (Authz) Equal

func (state Authz) Equal(other Authz) bool

func (*Authz) IsZero

func (state *Authz) IsZero() bool

type BackoffClient

type BackoffClient interface {
	Client
	NextAttempt() (time.Time, int)
}

func ExpBackoff

func ExpBackoff(client Client) BackoffClient

type Client

type Client interface {
	SocketClient
	// GetAuthState returns the authentication state
	Authenticate(ctx context.Context) (*Authz, error)
	// SendInventory sends the inventory attributes to the server
	SendInventory(ctx context.Context, authz *Authz, inv Inventory) error
}

Client is the interface for API

type Error

type Error struct {
	Code int
}

func (*Error) Error

func (e *Error) Error() string

type Identity

type Identity struct {
	Data        string `json:"id_data"`
	PublicKey   string `json:"pubkey"`
	ExternalID  string `json:"external_id,omitempty"`
	TenantToken string `json:"tenant_token,omitempty"`
}

Identity is the device's identity

type Inventory

type Inventory map[string]InventoryValue

func NewInventoryFromStream

func NewInventoryFromStream(r io.Reader) (Inventory, error)

func (Inventory) Digest

func (inv Inventory) Digest() []byte

func (Inventory) MarshalJSON

func (inv Inventory) MarshalJSON() ([]byte, error)

type InventoryValue

type InventoryValue []string

func (InventoryValue) MarshalJSON

func (v InventoryValue) MarshalJSON() ([]byte, error)

type Sender

type Sender interface {
	Send(ws.ProtoMsg) error
}

type Socket

type Socket interface {
	Sender
	ReceiveChan() <-chan ws.ProtoMsg
	ErrorChan() <-chan error
	Close() error
}

type SocketClient

type SocketClient interface {
	// OpenSocket connects to the deviceconnect service and pipes the messages
	// to the channel.
	OpenSocket(ctx context.Context, authz *Authz) (Socket, error)
}

SocketClient implements the socket part of the API

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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