devicehive_go

package module
v0.0.0-...-afe3fbd Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

README

DeviceHive SDK for GO

Generally Golang SDK for DeviceHive consists of 2 APIs, feel free to choose yours:

  • client (a.k.a. high-level client) — provides synchronous API and ORM-like access to DeviceHive models
  • WS client (a.k.a. WS low-level client) — provides asynchronous API: just sends the request and returns an error only in case of request error, all raw response data and response errors are written to appropriate channels which are created after WS connection is established (for more details see documentation)

Installation

go get -u github.com/devicehive/devicehive-go

Documentation

Visit https://godoc.org/github.com/devicehive/devicehive-go for full API reference.

Usage

Connection
import (
    "github.com/devicehive/devicehive-go"
    "fmt"
)

func main() {
    client, err := devicehive_go.ConnectWithCreds("ws://devicehive-address.com/api/websocket", "login", "password")
    // OR
    client, err := devicehive_go.ConnectWithToken("ws://devicehive-address.com/api/websocket", "jwt.Access.Token", "jwt.Refresh.Token")
    if err != nil {
        fmt.Println(err)
        return
    }
}
Device creation
import (
	"github.com/devicehive/devicehive-go"
	"fmt"
)

func main() {
	client, err := devicehive_go.ConnectWithCreds("ws://devicehive-address.com/api/websocket", "login", "password")
	if err != nil {
		fmt.Println(err)
		return
	}

	device, err := client.PutDevice("my-device1", "", nil, 0, 0, false)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(device)
}
Command insert subscription
import (
    "github.com/devicehive/devicehive-go"
    "fmt"
    "time"
)

func main() {
    client, err := devicehive_go.ConnectWithCreds("ws://devicehive-address.com/api/websocket", "login", "password")
    if err != nil {
        fmt.Println(err)
        return
    }

    device, err := client.GetDevice("my-device")
    if err != nil {
        fmt.Println(err)
        return
    }

    subscription, err := device.SubscribeInsertCommands(nil, time.Time{})
    if err != nil {
        fmt.Println(err)
        return
    }

    for command := range subscription.CommandsChan {
        fmt.Println(command)
    }
}

Running tests

Integration tests of high-level DH client:

go test github.com/devicehive/devicehive-go/integrationtest/dh -serverAddress ws://devicehive-api.com/ -accessToken your.accessToken -refreshToken your.accessToken -userId 123

Integration tests of low-level DH WS client (only ws:// URL is acceptable for this tests as server address):

go test github.com/devicehive/devicehive-go/integrationtest/dh_wsclient -serverAddress ws://devicehive-api.com/ -accessToken your.accessToken -refreshToken your.accessToken -userId 123

Unit tests:

go test github.com/devicehive/devicehive-go/test/...

Technical description

Overview

There are three layers under the hood of DeviceHive Go SDK: Client layer, Transport adapter layer and Transport layer. Overall architecture of DeviceHive Go SDK
Client layer is responsible for all high level business logic (request parameters, models etc.). It knows nothing about protocol in use.
Transport adapter layer orchestrates a few components:

  • Transport (Transporter interface on diagram): low level component
  • AuthManager: responsible for token creation; holds credentials, used for tracking last token refresh and authentication
  • Requester: responsible for composing request data, URLs for HTTP and actions for WS, handles responses using responsehandler package
  • responsehandler: parses responses and returns payload in common format

Transport adapter has two implementations so far: WSAdapter and HTTPAdapter.
Transport layer is responsible for doing basic requests and subscriptions. Has two implementations: WS and HTTP.

Resolving request resources

Since DeviceHive Go SDK supports HTTP and WS through single interface there is the mapping between custom resource names and URL pattern (for HTTP) or action (for WS). Similar mapping is present for response parsing.

Subscriptions

Each layer (Client, Transport adapter and Transport) handles subscriptions in some way so there is a pipeline constructed from 3 go routines, one on each level. The generic functionality for subscriptions is implemented on Transport layer. In case of WS connection Transport just sends subscription request and then sends each message with subscription ID to corresponding subscription channel. In case of HTTP it creates go routine with polling for each subscription.
On Transport adapter layer there is another go routine for each subscription to parse and transform subscription data, identify errors. Finally on Client layer there is go routine for each subscription to populate models with raw JSON data and send that object to client-facing channel.

Documentation

Overview

Package devicehive-go provides access to DeviceHive API through WebSocket or REST. Error handling is omitted to simplify examples:

client, _ := devicehive_go.ConnectWithCreds("ws://devicehive-address.com/api/websocket", "login", "password")
// or
client, _ := devicehive_go.ConnectWithCreds("http://devicehive-address.com/api/rest", "login", "password")

device, _ := client.PutDevice("my-device", "", nil, 0, 0, false)
subscription, _ := device.SubscribeInsertCommands(nil, time.Time{})

done := make(chan struct{})
go func() {
	for command := range subscription.CommandsChan {
		fmt.Printf("Received command with id %d\n", command.Id)
		close(done)
	}
}()

command, _ := device.SendCommand("my-command", nil, 120, time.Time{}, "", nil)

fmt.Printf("Command with id %d has been sent\n", command.Id)

<-done

In addition there is an ability to connect with tokens.

client, err := devicehive_go.ConnectWithToken("ws://devicehive-address.com/api/websocket", "some.JWT.accessToken", "some.JWT.refreshToken")

The client will be automatically reauthenticated by credentials or refresh token in case of access token expiration.

The SDK has an ability to send requests in non-blocking manner, writing each response and error to separate channels that you can read in a separate go routine. This API is called WebSocket low-level API. WS low-level API usage example:

wsclient, err := devicehive_go.WSConnect("ws://devicehive-address.com/api/websocket")
...

done := make(chan struct{})
go func() {
	for {
		select {
		case d := <- wsclient.DataChan:
			res := make(map[string]interface{})
			action := ""
			status := ""
			json.Unmarshal(d, &res) // If message was written to DataChan it must be valid JSON

			if a, ok := res["action"].(string); ok {
				action = a
			}

			if s, ok := res["status"].(string); ok {
				status = s
			}

			if action == "authenticate" && status == "success" {
				wsclient.SubscribeCommands(nil)
			} else {
				fmt.Println(string(d))
			}
		case err := <- wsclient.ErrorChan:
			fmt.Println("Error", err)
		}
	}

	close(done)
}()

err = wsclient.Authenticate("some.JWT.accessToken")
...

<-done
fmt.Println("Done")

Index

Constants

View Source
const (
	Timeout                          = 5 * time.Second
	UserStatusActive                 = 0
	UserStatusLocked                 = 1
	UserStatusDisabled               = 2
	UserRoleAdmin                    = 0
	UserRoleClient                   = 1
	InvalidResponseErr               = "invalid response"
	InvalidRequestErr                = "invalid request"
	InvalidSubscriptionEventData     = "invalid subscription event data"
	ServiceErr                       = "service error"
	ConnectionFailedErr              = "connection failed"
	DefaultPollingWaitTimeoutSeconds = 30
	WrongURLErr                      = "wrong url"
	TokenExpiredErr                  = "401 token expired"
)

Variables

This section is empty.

Functions

func ConnectWithCreds

func ConnectWithCreds(url, login, password string, p *ConnectionParams) (*Client, *Error)

Method obtains access token by credentials and then connects It will recreate access token on expiration by given credentials

func ConnectWithToken

func ConnectWithToken(url, accessToken, refreshToken string, p *ConnectionParams) (*Client, *Error)

Method uses access token directly to connect If access token is empty it will get access token by refresh token It will recreate access token on expiration by given refresh token

func WSConnect

func WSConnect(url string, p *ConnectionParams) (*WSClient, *Error)

Creates low-level WS API which sends requests concurrently and writes all responses to a single channel. This might be useful in case of non-blocking writes (i.e. sending sensor data, subscribing for commands).

Types

type Client

type Client struct {
	PollingWaitTimeoutSeconds int
	// contains filtered or unexported fields
}

Main struct which serves as entry point to DeviceHive API

func (*Client) CreateDeviceType

func (c *Client) CreateDeviceType(name, description string) (*DeviceType, *Error)

func (*Client) CreateNetwork

func (c *Client) CreateNetwork(name, description string) (*Network, *Error)

func (*Client) CreateToken

func (c *Client) CreateToken(userId int, expiration, refreshExpiration time.Time, actions, networkIds, deviceTypeIds []string) (accessToken, refreshToken string, err *Error)

func (*Client) CreateUser

func (c *Client) CreateUser(login, password string, role int, data map[string]interface{}, allDevTypesAvail bool) (*User, *Error)

func (*Client) DeleteProperty

func (c *Client) DeleteProperty(name string) *Error

func (*Client) GetClusterInfo

func (c *Client) GetClusterInfo() (*ClusterInfo, *Error)

func (*Client) GetCurrentUser

func (c *Client) GetCurrentUser() (*User, *Error)

func (*Client) GetDevice

func (c *Client) GetDevice(deviceId string) (device *Device, err *Error)

func (*Client) GetDeviceType

func (c *Client) GetDeviceType(deviceTypeId int) (*DeviceType, *Error)

func (*Client) GetInfo

func (c *Client) GetInfo() (*ServerInfo, *Error)

Gets information about DeviceHive server

func (*Client) GetNetwork

func (c *Client) GetNetwork(networkId int) (*Network, *Error)

func (*Client) GetProperty

func (c *Client) GetProperty(name string) (*Configuration, *Error)

func (*Client) GetUser

func (c *Client) GetUser(userId int) (*User, *Error)

func (*Client) ListDeviceTypes

func (c *Client) ListDeviceTypes(params *ListParams) ([]*DeviceType, *Error)

In case params is nil default values defined at DeviceHive take place

func (*Client) ListDevices

func (c *Client) ListDevices(params *ListParams) (list []*Device, err *Error)

In case params is nil default values defined at DeviceHive take place

func (*Client) ListNetworks

func (c *Client) ListNetworks(params *ListParams) ([]*Network, *Error)

In case params is nil default values defined at DeviceHive take place

func (*Client) ListUsers

func (c *Client) ListUsers(params *ListParams) ([]*User, *Error)

func (*Client) NewCommand

func (c *Client) NewCommand() *Command

Constructor, doesn't create command at DH

func (*Client) NewDevice

func (c *Client) NewDevice() *Device

Constructor, doesn't create device at DH

func (*Client) NewDeviceType

func (c *Client) NewDeviceType() *DeviceType

Constructor, doesn't create device type at DH

func (*Client) NewNetwork

func (c *Client) NewNetwork() *Network

Constructor, doesn't create network at DH

func (*Client) NewNotification

func (c *Client) NewNotification() *Notification

Constructor, doesn't create notification at DH

func (*Client) NewUser

func (c *Client) NewUser() *User

Constructor, doesn't create user at DH

func (*Client) PutDevice

func (c *Client) PutDevice(id, name string, data map[string]interface{}, networkId, deviceTypeId int, blocked bool) (*Device, *Error)

Id property of device must be non empty

func (*Client) RefreshToken

func (c *Client) RefreshToken() (accessToken string, err *Error)

func (*Client) SetProperty

func (c *Client) SetProperty(name, value string) (entityVersion int, err *Error)

func (*Client) SubscribeCommands

func (c *Client) SubscribeCommands(params *SubscribeParams) (*CommandSubscription, *Error)

Subscribes to commands by custom filter In case params is nil returns subscription for all commands

func (*Client) SubscribeNotifications

func (c *Client) SubscribeNotifications(params *SubscribeParams) (*NotificationSubscription, *Error)

Subscribes to notifications by custom filter In case params is nil returns subscription for all notifications

type ClusterInfo

type ClusterInfo struct {
	BootstrapServers string `json:"bootstrap.servers"`
	ZookeeperConnect string `json:"zookeeper.connect"`
}

type Command

type Command struct {
	Id          int         `json:"id,omitempty"`
	Command     string      `json:"command,omitempty"`
	Timestamp   ISO8601Time `json:"timestamp,omitempty"`
	LastUpdated ISO8601Time `json:"lastUpdated,omitempty"`
	UserId      int         `json:"userId,omitempty"`
	DeviceId    string      `json:"deviceId,omitempty"`
	NetworkId   int         `json:"networkId,omitempty"`
	Parameters  interface{} `json:"parameters,omitempty"`
	Lifetime    int         `json:"lifetime,omitempty"`
	Status      string      `json:"status,omitempty"`
	Result      interface{} `json:"result,omitempty"`
	// contains filtered or unexported fields
}

func (*Command) Save

func (comm *Command) Save() *Error

Sends request to modify command at DeviceHive

type CommandSubscription

type CommandSubscription struct {
	CommandsChan chan *Command
	ErrorChan    chan *Error
	// contains filtered or unexported fields
}

func (*CommandSubscription) Remove

func (cs *CommandSubscription) Remove() *Error

Sends request to unsubscribe from current commands subscription

type Configuration

type Configuration struct {
	Name          string `json:"name"`
	Value         string `json:"value"`
	EntityVersion int    `json:"entityVersion"`
}

type ConnectionParams

type ConnectionParams struct {
	ReconnectionTries    int
	ReconnectionInterval time.Duration
	RequestTimeout       time.Duration
}

func (*ConnectionParams) Timeout

func (p *ConnectionParams) Timeout() time.Duration

type Device

type Device struct {
	Id           string                 `json:"id,omitempty"`
	Name         string                 `json:"name,omitempty"`
	Data         map[string]interface{} `json:"data,omitempty"`
	NetworkId    int                    `json:"networkId,omitempty"`
	DeviceTypeId int                    `json:"deviceTypeId,omitempty"`
	IsBlocked    bool                   `json:"isBlocked,omitempty"`
	// contains filtered or unexported fields
}

func (*Device) ListCommands

func (d *Device) ListCommands(params *ListParams) ([]*Command, *Error)

In case params is nil default values defined at DeviceHive take place

func (*Device) ListNotifications

func (d *Device) ListNotifications(params *ListParams) ([]*Notification, *Error)

In case params is nil default values defined at DeviceHive take place

func (*Device) Remove

func (d *Device) Remove() *Error

func (*Device) Save

func (d *Device) Save() *Error

func (*Device) SendCommand

func (d *Device) SendCommand(name string, params map[string]interface{}, lifetime int, timestamp time.Time,
	status string, result map[string]interface{}) (*Command, *Error)

func (*Device) SendNotification

func (d *Device) SendNotification(name string, params map[string]interface{}, timestamp time.Time) (*Notification, *Error)

func (*Device) SubscribeInsertCommands

func (d *Device) SubscribeInsertCommands(names []string, timestamp time.Time) (*CommandSubscription, *Error)

func (*Device) SubscribeNotifications

func (d *Device) SubscribeNotifications(names []string, timestamp time.Time) (*NotificationSubscription, *Error)

func (*Device) SubscribeUpdateCommands

func (d *Device) SubscribeUpdateCommands(names []string, timestamp time.Time) (*CommandSubscription, *Error)

type DeviceType

type DeviceType struct {
	Id          int    `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	// contains filtered or unexported fields
}

func (*DeviceType) ForceRemove

func (dt *DeviceType) ForceRemove() *Error

func (*DeviceType) Remove

func (dt *DeviceType) Remove() *Error

func (*DeviceType) Save

func (dt *DeviceType) Save() *Error

func (*DeviceType) SubscribeInsertCommands

func (dt *DeviceType) SubscribeInsertCommands(names []string, timestamp time.Time) (*CommandSubscription, *Error)

func (*DeviceType) SubscribeNotifications

func (dt *DeviceType) SubscribeNotifications(names []string, timestamp time.Time) (*NotificationSubscription, *Error)

func (*DeviceType) SubscribeUpdateCommands

func (dt *DeviceType) SubscribeUpdateCommands(names []string, timestamp time.Time) (*CommandSubscription, *Error)

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Name

func (e *Error) Name() string

Method serves as name getter to classify the type of error

type ISO8601Time

type ISO8601Time struct {
	time.Time
}

Custom timestamp in ISO8601 format

func (*ISO8601Time) MarshalJSON

func (t *ISO8601Time) MarshalJSON() (b []byte, err error)

func (*ISO8601Time) String

func (t *ISO8601Time) String() string

func (*ISO8601Time) UnmarshalJSON

func (t *ISO8601Time) UnmarshalJSON(b []byte) (err error)

type ListParams

type ListParams struct {
	DeviceId     string    `json:"deviceId,omitempty"`
	Start        time.Time `json:"start,omitempty"`
	End          time.Time `json:"end,omitempty"`
	Notification string    `json:"notification,omitempty"`
	Command      string    `json:"command,omitempty"`
	Status       string    `json:"status,omitempty"`
	SortField    string    `json:"sortField,omitempty"`
	SortOrder    string    `json:"sortOrder,omitempty"`
	Take         int       `json:"take,omitempty"`
	Skip         int       `json:"skip,omitempty"`
	Name         string    `json:"name,omitempty"`
	NamePattern  string    `json:"namePattern,omitempty"`
	Login        string    `json:"login,omitempty"`
	LoginPattern string    `json:"loginPattern,omitempty"`
	NetworkId    string    `json:"networkId,omitempty"`
	NetworkName  string    `json:"networkName,omitempty"`
	UserRole     int       `json:"role,omitempty"`
	UserStatus   int       `json:"status,omitempty"`
}

func (*ListParams) Map

func (p *ListParams) Map() (map[string]interface{}, error)

type Network

type Network struct {
	Id          int    `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	// contains filtered or unexported fields
}

func (*Network) ForceRemove

func (n *Network) ForceRemove() *Error

func (*Network) Remove

func (n *Network) Remove() *Error

func (*Network) Save

func (n *Network) Save() *Error

func (*Network) SubscribeInsertCommands

func (n *Network) SubscribeInsertCommands(names []string, timestamp time.Time) (*CommandSubscription, *Error)

func (*Network) SubscribeNotifications

func (n *Network) SubscribeNotifications(names []string, timestamp time.Time) (*NotificationSubscription, *Error)

func (*Network) SubscribeUpdateCommands

func (n *Network) SubscribeUpdateCommands(names []string, timestamp time.Time) (*CommandSubscription, *Error)

type Notification

type Notification struct {
	Id           int                    `json:"id"`
	Notification string                 `json:"notification"`
	Timestamp    ISO8601Time            `json:"timestamp"`
	DeviceId     string                 `json:"deviceId"`
	NetworkId    int                    `json:"networkId"`
	Parameters   map[string]interface{} `json:"parameters"`
}

type NotificationSubscription

type NotificationSubscription struct {
	NotificationChan chan *Notification
	ErrorChan        chan *Error
	// contains filtered or unexported fields
}

func (*NotificationSubscription) Remove

func (ns *NotificationSubscription) Remove() *Error

Sends request to unsubscribe from current notifications subscription

type ServerInfo

type ServerInfo struct {
	APIVersion         string      `json:"apiVersion"`
	ServerTimestamp    ISO8601Time `json:"serverTimestamp"`
	RestServerURL      string      `json:"restServerUrl"`
	WebSocketServerURL string      `json:"webSocketServerUrl"`
}

type SubscribeParams

type SubscribeParams struct {
	DeviceId              string    `json:"deviceId,omitempty"`
	NetworkIds            []int     `json:"networkIds,omitempty"`
	DeviceTypeIds         []int     `json:"deviceTypeIds,omitempty"`
	Names                 []string  `json:"names,omitempty"`
	Timestamp             time.Time `json:"timestamp,omitempty"`
	ReturnUpdatedCommands bool      `json:"returnUpdatedCommands,omitempty"`
	Limit                 int       `json:"limit,omitempty"`
	WaitTimeout           int       `json:"waitTimeout,omitempty"`
}

func (*SubscribeParams) Map

func (p *SubscribeParams) Map() (map[string]interface{}, error)

type User

type User struct {
	Id                      int                    `json:"id,omitempty"`
	Login                   string                 `json:"login,omitempty"`
	Role                    int                    `json:"role,omitempty"`
	Status                  int                    `json:"status,omitempty"`
	LastLogin               ISO8601Time            `json:"lastLogin,omitempty"`
	Data                    map[string]interface{} `json:"data,omitempty"`
	IntroReviewed           bool                   `json:"introReviewed,omitempty"`
	AllDeviceTypesAvailable bool                   `json:"allDeviceTypesAvailable,omitempty"`
	// contains filtered or unexported fields
}

func (*User) AllowAllDeviceTypes

func (u *User) AllowAllDeviceTypes() *Error

func (*User) AssignDeviceType

func (u *User) AssignDeviceType(deviceTypeId int) *Error

func (*User) AssignNetwork

func (u *User) AssignNetwork(networkId int) *Error

func (*User) DisallowAllDeviceTypes

func (u *User) DisallowAllDeviceTypes() *Error

func (*User) ListDeviceTypes

func (u *User) ListDeviceTypes() (list []*DeviceType, err *Error)

func (*User) ListNetworks

func (u *User) ListNetworks() (list []*Network, err *Error)

func (*User) Remove

func (u *User) Remove() *Error

func (*User) Save

func (u *User) Save() *Error

func (*User) UnassignDeviceType

func (u *User) UnassignDeviceType(deviceTypeId int) *Error

func (*User) UnassignNetwork

func (u *User) UnassignNetwork(networkId int) *Error

func (*User) UpdatePassword

func (u *User) UpdatePassword(password string) *Error

type WSClient

type WSClient struct {

	// Channel for receiving responses
	DataChan chan []byte
	// Channel for receiving errors
	ErrorChan chan error
	// contains filtered or unexported fields
}

func (*WSClient) AccessTokenByCreds

func (wsc *WSClient) AccessTokenByCreds(login, password string) *Error

func (*WSClient) AccessTokenByRefresh

func (wsc *WSClient) AccessTokenByRefresh(refreshToken string) *Error

func (*WSClient) AllowAllDeviceTypes

func (wsc *WSClient) AllowAllDeviceTypes(userId int) *Error

func (*WSClient) Authenticate

func (wsc *WSClient) Authenticate(accessToken string) *Error

func (*WSClient) CreateDeviceType

func (wsc *WSClient) CreateDeviceType(name, description string) *Error

func (*WSClient) CreateNetwork

func (wsc *WSClient) CreateNetwork(name, description string) *Error

func (*WSClient) CreateToken

func (wsc *WSClient) CreateToken(userId int, expiration time.Time, actions, networkIds, deviceTypeIds []string) *Error

func (*WSClient) CreateUser

func (wsc *WSClient) CreateUser(login, password string, role int, data map[string]interface{}, allDevTypesAvail bool) *Error

func (*WSClient) DeleteDevice

func (wsc *WSClient) DeleteDevice(deviceId string) *Error

func (*WSClient) DeleteDeviceType

func (wsc *WSClient) DeleteDeviceType(deviceTypeId int) *Error

func (*WSClient) DeleteNetwork

func (wsc *WSClient) DeleteNetwork(networkId int) *Error

func (*WSClient) DeleteProperty

func (wsc *WSClient) DeleteProperty(name string) *Error

func (*WSClient) DeleteUser

func (wsc *WSClient) DeleteUser(userId int) *Error

func (*WSClient) DisallowAllDeviceTypes

func (wsc *WSClient) DisallowAllDeviceTypes(userId int) *Error

func (*WSClient) GetClusterInfo

func (wsc *WSClient) GetClusterInfo() *Error

func (*WSClient) GetCurrentUser

func (wsc *WSClient) GetCurrentUser() *Error

func (*WSClient) GetDevice

func (wsc *WSClient) GetDevice(deviceId string) *Error

func (*WSClient) GetDeviceType

func (wsc *WSClient) GetDeviceType(deviceTypeId int) *Error

func (*WSClient) GetInfo

func (wsc *WSClient) GetInfo() *Error

func (*WSClient) GetNetwork

func (wsc *WSClient) GetNetwork(networkId int) *Error

func (*WSClient) GetProperty

func (wsc *WSClient) GetProperty(name string) *Error

func (*WSClient) GetUser

func (wsc *WSClient) GetUser(userId int) *Error

func (*WSClient) ListDeviceCommands

func (wsc *WSClient) ListDeviceCommands(deviceId string, params *ListParams) *Error

In case params is nil default values defined at DeviceHive take place

func (*WSClient) ListDeviceNotifications

func (wsc *WSClient) ListDeviceNotifications(deviceId string, params *ListParams) *Error

In case params is nil default values defined at DeviceHive take place

func (*WSClient) ListDeviceTypes

func (wsc *WSClient) ListDeviceTypes(params *ListParams) *Error

In case params is nil default values defined at DeviceHive take place

func (*WSClient) ListDevices

func (wsc *WSClient) ListDevices(params *ListParams) *Error

In case params is nil default values defined at DeviceHive take place

func (*WSClient) ListNetworks

func (wsc *WSClient) ListNetworks(params *ListParams) *Error

In case params is nil default values defined at DeviceHive take place

func (*WSClient) ListUserDeviceTypes

func (wsc *WSClient) ListUserDeviceTypes(userId int) *Error

func (*WSClient) ListUsers

func (wsc *WSClient) ListUsers(params *ListParams) *Error

In case params is nil default values defined at DeviceHive take place

func (*WSClient) PutDevice

func (wsc *WSClient) PutDevice(device Device) *Error

func (*WSClient) SendDeviceCommand

func (wsc *WSClient) SendDeviceCommand(deviceId, name string, params map[string]interface{}, lifetime int, timestamp time.Time,
	status string, result map[string]interface{}) *Error

func (*WSClient) SendDeviceNotification

func (wsc *WSClient) SendDeviceNotification(deviceId, name string, params map[string]interface{}, timestamp time.Time) *Error

func (*WSClient) SetProperty

func (wsc *WSClient) SetProperty(name, value string) *Error

func (*WSClient) SubscribeCommands

func (wsc *WSClient) SubscribeCommands(params *SubscribeParams) *Error

Subscribes for commands with given params. If params is nil then default values take place. After successful subscription JSON object with only property "subscriptionId" is sent to the main data channel.

func (*WSClient) SubscribeNotifications

func (wsc *WSClient) SubscribeNotifications(params *SubscribeParams) *Error

Subscribes for notifications with given params. If params is nil then default values take place. After successful subscription JSON object with only property "subscriptionId" is sent to the main data channel.

func (*WSClient) UnsubscribeCommands

func (wsc *WSClient) UnsubscribeCommands(subscriptionId string)

func (*WSClient) UnsubscribeNotifications

func (wsc *WSClient) UnsubscribeNotifications(subscriptionId string)

func (*WSClient) UpdateDevice

func (wsc *WSClient) UpdateDevice(deviceId string, device *Device) *Error

func (*WSClient) UpdateUser

func (wsc *WSClient) UpdateUser(userId int, user User) *Error

func (*WSClient) UserAssignDeviceType

func (wsc *WSClient) UserAssignDeviceType(userId, deviceTypeId int) *Error

func (*WSClient) UserAssignNetwork

func (wsc *WSClient) UserAssignNetwork(userId, networkId int) *Error

func (*WSClient) UserUnassignDeviceType

func (wsc *WSClient) UserUnassignDeviceType(userId, deviceTypeId int) *Error

func (*WSClient) UserUnassignNetwork

func (wsc *WSClient) UserUnassignNetwork(userId, networkId int) *Error

Jump to

Keyboard shortcuts

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