thingsboard

package module
v0.0.0-...-5754b5b Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

README

Thingsboard

Thingsboard Go Library

https://gitlab.com/asenasystem-opensource/go/thingsboard

Thingsboard Entity structure

  • System admin (ONE global TB administrator account)
    • Tenant Adminsrators
      • Customers
        • Users
      • Assets
      • Devices
      • Dashboards
      • Entity Views
      • Rule Chains
Tenant Administrator is able to do following actions:
* Provision and Manage Devices.
* Provision and Manage Assets.
* Create and Manage Customers.
* Create and Manage Dashboards.
* Configure Rule Engine
* Add or modify default widgets using Widget Library.

Customer
Customer may be a separate business-entity: individual or organization who purchase or uses tenant devices and/or assets. Customer may also be a division within Tenant organization. Customer may have multiple users, inner customers and millions of devices and/or assets.

User
Users are able to login to ThingsBoard web interface, execute REST API calls, access devices and assets if allowed. User is also an Entity in ThingsBoard.

Go

UML Diagram

Before every commit Git pre-commit script is run in order to generate below UML diagram for this project. Please check https://github.com/jfeliu007/goplantuml project for tools needed.

UML Diagram

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Customer

type Customer struct{}

Customer structure

type Device

type Device struct {
	ID             entityID `json:"id"`
	TenantID       entityID `json:"tenantId"`
	CustomerID     entityID `json:"customerId"`
	CreatedTime    int64    `json:"createdTime"`
	AdditionalInfo struct {
		Gateway     bool   `json:"gateway"`
		Description string `json:"description"`
	} `json:"additionalInfo"`
	Name  string `json:"name"`
	Type  string `json:"type"`
	Label string `json:"label"`
}

Device structure to hold information about devices

type DeviceCredentials

type DeviceCredentials struct {
	CreatedTime   int    `json:"createdTime"`
	CredentialsID string `json:"credentialsId"`
	// ['ACCESS_TOKEN', 'X509_CERTIFICATE']stringEnum:"ACCESS_TOKEN", "X509_CERTIFICATE",
	CredentialsType  string   `json:"credentialsType"`
	CredentialsValue string   `json:"credentialsValue"`
	DeviceID         entityID `json:"deviceId"`
	ID               entityID `json:"id"` // DeviceCredentialsId
}

DeviceCredentials struct to hold getDeviceCredentialsByDeviceId() repsponse

type GetTenantDevices

type GetTenantDevices struct {
	Data          []Device `json:"data"`
	TotalPages    int      `json:"totalPages"`
	TotalElements int      `json:"totalElements"`
	HasNext       bool     `json:"hasNext"`
}

GetTenantDevices represents structure for GetTenantDevices() method

type TBError

type TBError struct {
	Timestamp string `json:"timestamp"` // *
	Status    int    `json:"status"`    // *
	Message   string `json:"message"`   // *
	Code      int    `json:"errorCode"`
	Type      string `json:"error"`
	Path      string `json:"path"`
}

TBError holds and parses Thingboard JSON error response * - Field is always present in JSON error response

func (*TBError) Error

func (e *TBError) Error() string

type Thingsboard

type Thingsboard struct {
	Auth *jsonAuth
	User *jsonUser
	// contains filtered or unexported fields
}

Thingsboard ...

func New

func New(host string, user string, pass string) (*Thingsboard, error)

New returns new Thingsboard instance

func (*Thingsboard) Connect

func (tb *Thingsboard) Connect() error

Connect is used by New() method to connect to Thingsboard server.

func (*Thingsboard) Disconnect

func (tb *Thingsboard) Disconnect() error

Disconnect should logout, remove currently authenticated user (authorization for token should be removed). But it dosn't work at all on Thingsboard.

func (*Thingsboard) GetDeviceAccessTokenByID

func (tb *Thingsboard) GetDeviceAccessTokenByID(deviceID string) (string, error)

GetDeviceAccessTokenByID returns Acccess Token for Device with specified name

func (*Thingsboard) GetDeviceAccessTokenByName

func (tb *Thingsboard) GetDeviceAccessTokenByName(deviceName string) (string, error)

GetDeviceAccessTokenByName returns Acccess Token for Device with specified name

func (*Thingsboard) GetDeviceByID

func (tb *Thingsboard) GetDeviceByID(deviceID string) (*Device, error)

GetDeviceByID GET /api/device/{deviceId} TODO: HTTP Request codes

func (*Thingsboard) GetDeviceByName

func (tb *Thingsboard) GetDeviceByName(name string) (*Device, error)

GetDeviceByName (by Name!) GET /api/tenant/devices{?deviceName}

func (*Thingsboard) GetDeviceCredentialsByDeviceID

func (tb *Thingsboard) GetDeviceCredentialsByDeviceID(deviceID string) (*DeviceCredentials, error)

GetDeviceCredentialsByDeviceID returns device credentials structure GET /api/device/{deviceId}/credentials

func (*Thingsboard) GetDeviceCredentialsByDeviceName

func (tb *Thingsboard) GetDeviceCredentialsByDeviceName(name string) (*DeviceCredentials, error)

GetDeviceCredentialsByDeviceName returns Access Token for Device (by name)

func (*Thingsboard) GetDevicesByIds

func (tb *Thingsboard) GetDevicesByIds(deviceIDs string) ([]Device, error)

GetDevicesByIds GET /api/devices{?deviceIds}

func (*Thingsboard) GetTenantDevice

func (tb *Thingsboard) GetTenantDevice(name string) (*Device, error)

GetTenantDevice is an alias of GetDeviceByName() - compatibility with TB Swagger

func (*Thingsboard) GetTenantDevices

func (tb *Thingsboard) GetTenantDevices(pageSize int, page int) (GetTenantDevices, error)

GetTenantDevices downloads information about currently logged user devices available in his Tenant GET /api/tenant/devices{?type,textSearch,sortProperty,sortOrder,*pageSize,*page} 401 Unauthorized 403 Forbidden 404 Not Found

func (*Thingsboard) SaveTelemetry

func (tb *Thingsboard) SaveTelemetry(deviceToken string, telemetryData interface{}) error

SaveTelemetry uploads Telemetry to ThingsBoard, by deviceID

Jump to

Keyboard shortcuts

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