GoSDK

package module
v2.5.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

README

Go-SDK

API Reference

Setup

newUserClient(systemkey, systemsecret, email, password string) *UserClient
	systemKey // string
		Required. The systemKey of the system to connect to. Retrievable from the Console's System Settings.
	systemSecret // string
		Required. The systemSecret of the system to connect to. Retrievable from the Console's System Settings.
	email // string
		Email of non-dev user to connect to system as. If registerUser key is not provided, the user must be registered through the Auth tab of the console, and given appropriate roles.
	password // string
		Password of non-dev user to connect to system as.

Authentication

userClient.Authenticate() error

Authenticates credentials set on userClient and sets session token

userClient.Register(username, password string) error

Register a new user with the platform.

	username // string
		Email of the new user
	password // string
		Password of the new user
userClient.RegisterUser(username, password string) (map[string]interface{}, error)

Register a new user with the platform, and return response with token

	username // string
		Email of the new user
	password // string
		Password of the new user
userClient.Logout() error

End session for current user

Data

userClient.InsertData(collection_id string, data interface{}) error

Insert new item in the collection

	collection_id // string
		ID assigned to the collection by the system
	data // interface
		Representatation of data object to be inserted
userClient.CreateData(collection_id string, data interface{}) ([]interface{}, error)

Insert new item in the collection and return the response

	collection_id // string
		ID assigned to the collection by the system
	data // interface
		Representation of data object to be inserted
userClient.GetData(collectionId string, query *GoSDK.Query) (map[string]interface{}, error)

Retrieve array of items from the collection using the collection ID

	collectionId // string
		ID assigned to the collection by the system
	query // *GoSDK.Query
		Custom query created using this SDK
userClient.GetDataByName(collectionName string, query *GoSDK.Query) (map[string]interface{}, error)

Retrieve array of items from the collection using the collection name

	collectionName // string
		Name assigned to the collection by the developer
	query // *GoSDK.Query
		Custom query created using this SDK
userClient.UpdateData(collection_id string, query *GoSDK.Query, changes map[string]interface{}) error

Updates existing items in the collection that match the provided query

	collectionId // string
		ID assigned to the collection by the system
	query // *GoSDK.Query
		Custom query created using this SDK
	changes // map[string]interface{}
		Key-value pairs representing column names to be updated and new values
userClient.DeleteData(collection_id string, query *GoSDK.Query) error

Removes every item in the collection that match the provided query

	collectionId // string
		ID assigned to the collection by the system
	query // *GoSDK.Query
		Custom query created using this SDK
userClient.GetColumns(collection_id string) ([]interface{}, error)

Retrieves column names, types and primary keys for a collection

	collectionId // string
		ID assigned to the collection by the system

Queries

query := NewQuery() *GoSDK.Query

Returns new Query to be used in Data operations

query.EqualTo(field string, value interface{})

Select where field is equal to value

	field // string
		Field / column name in collection
	value // interface{}
		Data to match in field
query.GreaterThan(field string, value interface{})

Select where field is > to value

	field // string
		Field / column name in collection
	value // interface{}
		Data to match in field
query.GreaterThanEqualTo(field string, value interface{})

Select where field is >= to value

	field // string
		Field / column name in collection
	value // interface{}
		Data to match in field
query.LessThan(field string, value interface{})

Select where field is < to value

	field // string
		Field / column name in collection
	value // interface{}
		Data to match in field
query.LessThanEqualTo(field string, value interface{})

Select where field is <= to value

	field // string
		Field / column name in collection
	value // interface{}
		Data to match in field
query.NotEqualTo(field string, value interface{})

Select where field is != to value

	field // string
		Field / column name in collection
	value // interface{}
		Data to match in field
query.Matches(field string, value interface{})

Query where field is ~ than value using regex

	field // string
		Field / column name in collection
	value // interface{}
		Data to match in field
query.Or(orQuery *GoSDK.Query)

Join two queries together with OR condition

	orQuery // *GoSDK.Query
		Second GoSDk.Query

Code Services

userClient.CallService(systemKey, name string, params map[string]interface{}) (map[string]interface{}, error)

Run a named code service that exists on the system with options, and returns the response object or an error

	systemKey // string
		Key to system that contains desired code service
	name // string
		Name of code service to be executed
	params // map[string]interface{}
		Request object to be passed to code service function on execution

Messaging

userClient.InitializeMQTT(clientid string, ignore string, timeout int) error

Set required MQTT options on user client

	clientid // string
		MQTT client id
	ignore // string
		Not used, default to ""
	timeout // int
		Timeout value for MQTT client in Seconds
userClient.ConnectMQTT(ssl *tls.Config, lastWill *GoSDK.LastWillPacket) error

Establish MQTT connection for set user

	clientid // *tls.Config,
	lastWill // *GoSDK.LastWillPacket, 
userClient.Publish(topic string, message []byte, qos int) error

Publish message on MQTT topic

	topic // string
		MQTT topic to publish on
	message // []byte
		Byte-seralized message
	qos // int
		QOS priority for message
userClient.Subscribe(topic string, qos int) (<-chan *mqtt.Publish, error)

Asynchronoulsy subscribe to MQTT topic and push messages onto channel as they arrive

	topic // string
		MQTT topic to subscribe
	qos // int
		QOS priority for message
userClient.Unsubscribe(topic string) error

Stop subscription to MQTT topic

	topic // string
		MQTT topic to unsusbcribe
userClient.Disconnect() error

End MQTT connection for set user

QuickStart

Download and Install Go

Follow the instructions for downloading and installing Go from https://golang.org/doc/install

Clone the ClearBlade Go-SDK repository

Do a git clone https://github.com/ClearBlade/Go-SDK.git to clone the Go-SDK for the ClearBlade Platform.

Import the Go-SDK package in your project

In order to use the Go-SDK in your project, you will need to import the Go-SDK package that you cloned from github, in your project.

GoDoc

The GoDoc for the Go API can be found at https://docs.clearblade.com/v/3/static/goapi/pkg/github.com/clearblade/Go-SDK/index.html

Documentation

Index

Constants

View Source
const (
	PERM_READ   = 1
	PERM_CREATE = 2
	PERM_UPDATE = 4
	PERM_DELETE = 8
)
View Source
const (
	ServiceSync = "service"
	LibrarySync = "library"
	TriggerSync = "trigger"
	TimerSync   = "timer"
)
View Source
const (
	//Mqtt QOS 0
	QOS_AtMostOnce = iota
	//Mqtt QOS 1
	QOS_AtLeastOnce
	//Mqtt QOS 2
	QOS_PreciselyOnce
	PUBLISH_HTTP_PREAMBLE = "/api/v/1/message/"
)

Variables

View Source
var (
	//CB_ADDR is the address of the ClearBlade Platform you are speaking with
	CB_ADDR = "https://platform.clearblade.com"
	//CB_MSG_ADDR is the messaging address you wish to speak to
	CB_MSG_ADDR = "platform.clearblade.com:1883"
)

Functions

func CreateNewEdge

func CreateNewEdge(e EdgeConfig) (*os.Process, error)

func CreateNewEdgeWithCmd

func CreateNewEdgeWithCmd(e EdgeConfig) (*exec.Cmd, *os.Process, error)

func GenerateConnectCollection

func GenerateConnectCollection(co map[string]interface{}) (connectCollection, error)

func GetServiceNames

func GetServiceNames(c cbClient, systemKey string) ([]string, error)

Types

type Callbacks

type Callbacks struct {
	OnConnectCallback        mqtt.OnConnectHandler
	OnConnectionLostCallback mqtt.ConnectionLostHandler
}

type CbReq

type CbReq struct {
	Body        interface{}
	Method      string
	Endpoint    string
	QueryString string
	Headers     map[string][]string
	HttpAddr    string
	MqttAddr    string
}

CbReq is a wrapper around an HTTP request

type CbResp

type CbResp struct {
	Body       interface{}
	StatusCode int
}

CbResp is a wrapper around an HTTP response

type Client

type Client interface {
	//session bookkeeping calls
	Authenticate() error
	Logout() error

	//data calls
	CreateData(string, interface{}) ([]interface{}, error)
	InsertData(string, interface{}) error
	UpdateData(string, *Query, map[string]interface{}) error
	GetData(string, *Query) (map[string]interface{}, error)
	GetDataByName(string, *Query) (map[string]interface{}, error)
	GetDataByKeyAndName(string, string, *Query) (map[string]interface{}, error)
	DeleteData(string, *Query) error
	GetItemCount(string) (int, error)
	GetDataTotal(string, *Query) (map[string]interface{}, error)
	GetColumns(string, string, string) ([]interface{}, error)

	//mqtt calls
	SetMqttClient(MqttClient)
	InitializeMQTT(string, string, int, *tls.Config, *LastWillPacket) error
	Publish(string, []byte, int) error
	Subscribe(string, int) (<-chan *mqttTypes.Publish, error)
	Unsubscribe(string) error
	Disconnect() error

	// Device calls
	GetDevices(string, *Query) ([]interface{}, error)
	GetDevice(string, string) (map[string]interface{}, error)
	CreateDevice(string, string, map[string]interface{}) (map[string]interface{}, error)
	UpdateDevice(string, string, map[string]interface{}) (map[string]interface{}, error)
	DeleteDevice(string, string) error
	UpdateDevices(string, *Query, map[string]interface{}) ([]interface{}, error)
	DeleteDevices(string, *Query) error

	// Adaptor calls
	GetAdaptors(string) ([]interface{}, error)
	GetAdaptor(string, string) (map[string]interface{}, error)
	CreateAdaptor(string, string, map[string]interface{}) (map[string]interface{}, error)
	UpdateAdaptor(string, string, map[string]interface{}) (map[string]interface{}, error)
	DeleteAdaptor(string, string) error
	DeployAdaptor(string, string, map[string]interface{}) (map[string]interface{}, error)
	ControlAdaptor(string, string, map[string]interface{}) (map[string]interface{}, error)

	// Adaptor File calls
	GetAdaptorFiles(string, string) ([]interface{}, error)
	GetAdaptorFile(string, string, string) (map[string]interface{}, error)
	CreateAdaptorFile(string, string, string, map[string]interface{}) (map[string]interface{}, error)
	UpdateAdaptorFile(string, string, string, map[string]interface{}) (map[string]interface{}, error)
	DeleteAdaptorFile(string, string, string) error
}

Client is a convience interface for API consumers, if they want to use the same functions for both developer users and unprivleged users

type CodeLog

type CodeLog struct {
	Log  string
	Time string
}

CodeLog provides structure to the code log return value

type DevClient

type DevClient struct {
	DevToken string

	MQTTClient MqttClient
	Email      string
	Password   string
	HttpAddr   string
	MqttAddr   string
	// contains filtered or unexported fields
}

DevClient is the type for developers

func NewDevClient

func NewDevClient(email, password string) *DevClient

NewDevClient allocates a new DevClient struct

func NewDevClientWithAddrs

func NewDevClientWithAddrs(httpAddr, mqttAddr, email, password string) *DevClient

func NewDevClientWithToken

func NewDevClientWithToken(token, email string) *DevClient

func NewDevClientWithTokenAndAddrs

func NewDevClientWithTokenAndAddrs(httpAddr, mqttAddr, token, email string) *DevClient

func NewEdgeProxyDevClient

func NewEdgeProxyDevClient(email, password, systemKey, edgeName string) (*DevClient, error)

func (*DevClient) AddCollectionToRole

func (d *DevClient) AddCollectionToRole(systemKey, collection_id, role_id string, level int) error

AddCollectionToRole associates some kind of permission regarding the collection to the role.

func (*DevClient) AddColumn

func (d *DevClient) AddColumn(collection_id, column_name, column_type string) error

AddColumn adds a column to a collection. Note that this does not apply to collections backed by a non-default datastore.

func (*DevClient) AddDeviceToRoles

func (d *DevClient) AddDeviceToRoles(systemKey, deviceName string, roles []string) error

AddDeviceToRoles assigns a role to a device

func (*DevClient) AddGenericPermissionToRole

func (d *DevClient) AddGenericPermissionToRole(systemKey, roleId, permission string, level int) error

func (*DevClient) AddPortalToRole

func (d *DevClient) AddPortalToRole(systemKey, portalName, roleId string, level int) error

func (*DevClient) AddServiceToRole

func (d *DevClient) AddServiceToRole(systemKey, service, roleId string, level int) error

AddServiceToRole associates some kind of permission dealing with the specified service to the role

func (*DevClient) AddTopicToRole

func (d *DevClient) AddTopicToRole(systemKey, topic, roleId string, level int) error

AddTopicToRole associates some kind of permission dealing with the specified topic to the role

func (*DevClient) AddUserToRoles

func (d *DevClient) AddUserToRoles(systemKey, userId string, roles []string) error

AddUserToRoles assigns a role to a user

func (*DevClient) AlterConnectionDetails

func (d *DevClient) AlterConnectionDetails(systemkey string, connectConfig connectCollection) error

AlterConnectionDetails allows the developer to change or add connection information, such as updating a username

func (*DevClient) AreServiceLogsEnabled

func (d *DevClient) AreServiceLogsEnabled(systemKey, name string) (bool, error)

AreServiceLogsEnabled allows the developer to query the state of logging

func (*DevClient) Authenticate

func (d *DevClient) Authenticate() error

Authenticate retrieves a token from the specified Clearblade Platform

func (*DevClient) CallService

func (d *DevClient) CallService(systemKey, name string, params map[string]interface{}, log bool) (map[string]interface{}, error)

CallService performs a call against the specific service with the specified parameters. The logging argument will allow the developer to call the service with logging enabled for just that run. The return value is a map[string]interface{} where the results will be stored in the key "results". If logs were enabled, they'll be in "log".

func (*DevClient) CheckAuth

func (d *DevClient) CheckAuth() error

Check Auth of Developer

func (*DevClient) ControlAdaptor

func (d *DevClient) ControlAdaptor(systemKey, adaptorName string, controlSpec map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) CreateAdaptor

func (d *DevClient) CreateAdaptor(systemKey, name string,
	data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) CreateAdaptorFile

func (d *DevClient) CreateAdaptorFile(systemKey, adaptorName, fileName string,
	data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) CreateData

func (d *DevClient) CreateData(collection_id string, data interface{}) ([]interface{}, error)

CreateData is an alias for InsertData, but returns a response value, it should be a slice of strings representing the item ids (if not using an external datastore)

func (*DevClient) CreateDeployResourcesForSystem

func (d *DevClient) CreateDeployResourcesForSystem(systemKey, resourceName, resourceType string, platform bool, edgeQueryInfo interface{}) (map[string]interface{}, error)

func (*DevClient) CreateDeploymentByName

func (d *DevClient) CreateDeploymentByName(systemKey, name string, info map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) CreateDevice

func (d *DevClient) CreateDevice(systemKey, name string,
	data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) CreateDeviceColumn

func (d *DevClient) CreateDeviceColumn(systemKey, columnName, columnType string) error

func (*DevClient) CreateEdge

func (d *DevClient) CreateEdge(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) CreateEdgeColumn

func (d *DevClient) CreateEdgeColumn(systemKey, colName, colType string) error

func (*DevClient) CreateEdgeGroup

func (d *DevClient) CreateEdgeGroup(systemKey, name string,
	data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) CreateEventHandler

func (d *DevClient) CreateEventHandler(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

CreateEventHandler creates an event handler, otherwise known as a trigger Returns the same object as GetEventHandler corresponding to the created event

func (*DevClient) CreateLibrary

func (d *DevClient) CreateLibrary(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

CreateLibrary allows the developer to create a library to be called by other service functions returns a single object following the pattern specified in GetLibraries for the newly-created library

func (*DevClient) CreatePlugin

func (d *DevClient) CreatePlugin(systemKey string, plugin map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) CreatePortal

func (d *DevClient) CreatePortal(systemKey, name string, dash map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) CreateRole

func (d *DevClient) CreateRole(systemKey, role_id string) (interface{}, error)

CreateRole creates a new role returns a JSON object shaped like {"role_id":"role id goes here"}

func (*DevClient) CreateService

func (u *DevClient) CreateService(systemKey, name, code string, params []string) error

func (*DevClient) CreateTimer

func (d *DevClient) CreateTimer(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

CreateTimer allows the user to create the timer with code Returns a single instance of the object described in GetTimers for the newly created timer

func (*DevClient) CreateTrigger

func (d *DevClient) CreateTrigger(systemKey, name string,
	data map[string]interface{}) (map[string]interface{}, error)

Alias for CreateEventHandler() to better match up with Console terminology

func (*DevClient) CreateUserColumn

func (d *DevClient) CreateUserColumn(systemKey, columnName, columnType string) error

CreateUserColumn creates a new column in the user table

func (*DevClient) DeleteAdaptor

func (d *DevClient) DeleteAdaptor(systemKey, name string) error

func (*DevClient) DeleteAdaptorFile

func (d *DevClient) DeleteAdaptorFile(systemKey, adaptorName, fileName string) error

func (*DevClient) DeleteCollection

func (d *DevClient) DeleteCollection(colID string) error

DeleteCollection deletes the collection. Note that this does not apply to collections backed by a non-default datastore.

func (*DevClient) DeleteColumn

func (d *DevClient) DeleteColumn(collection_id, column_name string) error

DeleteColumn removes a column from a collection. Note that this does not apply to collections backed by a non-default datastore.

func (*DevClient) DeleteData

func (d *DevClient) DeleteData(collection_id string, query *Query) error

DeleteData removes data from a collection according to what matches the query. If the query is nil, then all data will be removed.

func (*DevClient) DeleteDeployResourcesForSystem

func (d *DevClient) DeleteDeployResourcesForSystem(systemKey, resourceName, resourceType string) error

func (*DevClient) DeleteDeploymentByName

func (d *DevClient) DeleteDeploymentByName(systemKey, name string) error

func (*DevClient) DeleteDevice

func (d *DevClient) DeleteDevice(systemKey, name string) error

func (*DevClient) DeleteDeviceColumn

func (d *DevClient) DeleteDeviceColumn(systemKey, columnName string) error

func (*DevClient) DeleteDeviceSession

func (d *DevClient) DeleteDeviceSession(systemKey string, query *Query) error

func (*DevClient) DeleteDevices

func (d *DevClient) DeleteDevices(systemKey string, query *Query) error

func (*DevClient) DeleteEdge

func (d *DevClient) DeleteEdge(systemKey, name string) error

func (*DevClient) DeleteEdgeColumn

func (d *DevClient) DeleteEdgeColumn(systemKey, colName string) error

func (*DevClient) DeleteEdgeGroup

func (d *DevClient) DeleteEdgeGroup(systemKey, name string) error

func (*DevClient) DeleteEventHandler

func (d *DevClient) DeleteEventHandler(systemKey, name string) error

DeleteEventHandler removes the event handler

func (*DevClient) DeleteFailedServices

func (d *DevClient) DeleteFailedServices(systemKey string, ids []string) ([]map[string]interface{}, error)

func (*DevClient) DeleteKeyset

func (d *DevClient) DeleteKeyset(systemKey, name string) error

func (*DevClient) DeleteLibrary

func (d *DevClient) DeleteLibrary(systemKey, name string) error

DeleteLibrary allows the developer to remove library content

func (*DevClient) DeletePlugin

func (d *DevClient) DeletePlugin(systemKey, name string) (map[string]interface{}, error)

func (*DevClient) DeletePortal

func (d *DevClient) DeletePortal(systemKey, name string) error

func (*DevClient) DeleteRole

func (d *DevClient) DeleteRole(systemKey, roleId string) error

DeleteRole removes a role

func (*DevClient) DeleteService

func (d *DevClient) DeleteService(systemKey, name string) error

func (*DevClient) DeleteSystem

func (d *DevClient) DeleteSystem(s string) error

DeleteSystem removes the system

func (*DevClient) DeleteTimer

func (d *DevClient) DeleteTimer(systemKey, name string) error

DeleteTimer removes the timer

func (*DevClient) DeleteTrigger

func (d *DevClient) DeleteTrigger(systemKey, name string) error

Alias for DeleteEventHandler() to better match up with Console terminology

func (*DevClient) DeleteUser

func (d *DevClient) DeleteUser(systemKey, userId string) error

DeleteUser removes a specific user

func (*DevClient) DeleteUserColumn

func (d *DevClient) DeleteUserColumn(systemKey, columnName string) error

func (*DevClient) DeleteUserSession

func (d *DevClient) DeleteUserSession(systemKey string, query *Query) error

func (*DevClient) DeployAdaptor

func (d *DevClient) DeployAdaptor(systemKey, adaptorName string, deploySpec map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) DevUserInfo

func (d *DevClient) DevUserInfo() (map[string]interface{}, error)

DevUserInfo gets the user information for the developer

func (*DevClient) DisableLogsForService

func (d *DevClient) DisableLogsForService(systemKey, name string) error

DisableLogsForService turns logging off for that service

func (*DevClient) Disconnect

func (d *DevClient) Disconnect() error

Disconnect stops the TCP connection and unsubscribes the client from any remaining topics

func (*DevClient) EnableLogsForService

func (d *DevClient) EnableLogsForService(systemKey, name string) error

EnableLogsForService activates logging for execution of a service

func (*DevClient) EnterProvisioningMode

func (d *DevClient) EnterProvisioningMode() (map[string]interface{}, error)

func (*DevClient) EnterRuntimeMode

func (d *DevClient) EnterRuntimeMode(info map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) GenerateKeyset

func (d *DevClient) GenerateKeyset(systemKey, name string, count int) (map[string]interface{}, error)

func (*DevClient) GetAdaptor

func (d *DevClient) GetAdaptor(systemKey, name string) (map[string]interface{}, error)

func (*DevClient) GetAdaptorFile

func (d *DevClient) GetAdaptorFile(systemKey, adaptorName, fileName string) (map[string]interface{}, error)

func (*DevClient) GetAdaptorFiles

func (d *DevClient) GetAdaptorFiles(systemKey, adaptorName string) ([]interface{}, error)

func (*DevClient) GetAdaptors

func (d *DevClient) GetAdaptors(systemKey string) ([]interface{}, error)

func (*DevClient) GetAllCollections

func (d *DevClient) GetAllCollections(systemKey string) ([]interface{}, error)

GetAllCollections retrieves a list of every collection in the system The return value is a slice of strings

func (*DevClient) GetAllDeployments

func (d *DevClient) GetAllDeployments(systemKey string) ([]interface{}, error)

func (*DevClient) GetAllRoles

func (d *DevClient) GetAllRoles(SystemKey string) ([]interface{}, error)

GetAllRoles returns a slice of all roles, including their permissions the return value is a slice of [{"ID":"roleid","Name":"rolename","Description":"role description", "Permissions":{"Collections":[{"ID":"collectionid","Columns":[{"Name":"columnname","Level":0}],"Items":[{"Name":"itemid","Level":2}],"Name":"collectionname"}], "Topics":[{"Name":"topic/path","Level":1}],"CodeServices":[{"Name":"service name","SystemKey":"syskey","Level":4}],"UsersList":{"Name":"users","Level":8},"Push":{"Name":"push","Level":0},"MsgHistory":{"Name":"messagehistory","Level":1}}},...]

func (*DevClient) GetAllUsers

func (d *DevClient) GetAllUsers(systemKey string) ([]map[string]interface{}, error)

func (*DevClient) GetAssetClassDeployments

func (d *DevClient) GetAssetClassDeployments(systemKey, assetClass string) (map[string]interface{}, error)

func (*DevClient) GetAssetDeployments

func (d *DevClient) GetAssetDeployments(systemKey, assetClass, assetId string) (map[string]interface{}, error)

func (*DevClient) GetAssetPlatformDeploymentStatus

func (d *DevClient) GetAssetPlatformDeploymentStatus(systemKey, assetClass, assetId string) (map[string]interface{}, error)

func (*DevClient) GetAssetsDeployedToEntity

func (d *DevClient) GetAssetsDeployedToEntity(systemKey, entityType, entityName string) (map[string]interface{}, error)

func (*DevClient) GetAssetsNotDeployedOnPlatform

func (d *DevClient) GetAssetsNotDeployedOnPlatform(systemKey string, query *Query) ([]interface{}, error)

func (*DevClient) GetCollectionInfo

func (d *DevClient) GetCollectionInfo(collection_id string) (map[string]interface{}, error)

GetCollectionInfo retrieves some describing information on the specified collection Keys "name","collectoinID","appID", and much, much more!

func (*DevClient) GetColumns

func (d *DevClient) GetColumns(collectionId, systemKey, systemSecret string) ([]interface{}, error)

GetColumns gets a slice of map[string]interface{} of the column names and values. As map[string]interface{}{"ColumnName":"name","ColumnType":"typename in string", "PK":bool}

func (*DevClient) GetCurrentTopics

func (d *DevClient) GetCurrentTopics(systemKey string) ([]string, error)

func (*DevClient) GetCurrentTopicsCount

func (d *DevClient) GetCurrentTopicsCount(systemKey string) (map[string]interface{}, error)

func (*DevClient) GetCurrentTopicsWithQuery

func (d *DevClient) GetCurrentTopicsWithQuery(systemKey string, columns []string, pageSize, pageNum int, descending bool) ([]map[string]interface{}, error)

func (*DevClient) GetData

func (d *DevClient) GetData(collection_id string, query *Query) (map[string]interface{}, error)

GetData performs a query against a collection. The query object is discussed elsewhere. If the query object is nil, then it will return all of the data. The return value is a key-value of the types. Note that due to the transport mechanism being JSON, ints will be turned into float64s.

func (*DevClient) GetDataByKeyAndName

func (d *DevClient) GetDataByKeyAndName(string, string, *Query) (map[string]interface{}, error)

GetDataByKeyAndName is unimplemented

func (*DevClient) GetDataByName

func (d *DevClient) GetDataByName(collectionName string, query *Query) (map[string]interface{}, error)

func (*DevClient) GetDataTotal

func (d *DevClient) GetDataTotal(collection_id string, query *Query) (map[string]interface{}, error)

func (*DevClient) GetDeployResourcesForSystem

func (d *DevClient) GetDeployResourcesForSystem(systemKey string) ([]map[string]interface{}, error)

func (*DevClient) GetDeploymentByName

func (d *DevClient) GetDeploymentByName(systemKey, name string) (map[string]interface{}, error)

func (*DevClient) GetDevelopersForSystem

func (d *DevClient) GetDevelopersForSystem(systemKey string) (map[string]interface{}, error)

func (*DevClient) GetDevice

func (d *DevClient) GetDevice(systemKey, name string) (map[string]interface{}, error)

func (*DevClient) GetDeviceColumns

func (d *DevClient) GetDeviceColumns(systemKey string) ([]interface{}, error)

func (*DevClient) GetDeviceRoles

func (d *DevClient) GetDeviceRoles(systemKey, deviceName string) ([]string, error)

func (*DevClient) GetDeviceSession

func (d *DevClient) GetDeviceSession(systemKey string, query *Query) ([]interface{}, error)

func (*DevClient) GetDevices

func (d *DevClient) GetDevices(systemKey string, query *Query) ([]interface{}, error)

func (*DevClient) GetEdge

func (d *DevClient) GetEdge(systemKey, name string) (map[string]interface{}, error)

func (*DevClient) GetEdgeColumns

func (d *DevClient) GetEdgeColumns(systemKey string) ([]interface{}, error)

func (*DevClient) GetEdgeGroup

func (d *DevClient) GetEdgeGroup(systemKey, name string, recursive bool) (map[string]interface{}, error)

func (*DevClient) GetEdgeGroups

func (d *DevClient) GetEdgeGroups(systemKey string, query *Query) ([]interface{}, error)

func (*DevClient) GetEdges

func (d *DevClient) GetEdges(systemKey string) ([]interface{}, error)

func (*DevClient) GetEdgesWithQuery

func (d *DevClient) GetEdgesWithQuery(systemKey string, query *Query) ([]interface{}, error)

func (*DevClient) GetEventDefinitions

func (d *DevClient) GetEventDefinitions() ([]interface{}, error)

GetEventDefinitions returns a slice of the different kinds of events that can be handled. Returns a slice of strings

func (*DevClient) GetEventHandler

func (d *DevClient) GetEventHandler(systemKey, name string) (map[string]interface{}, error)

GetEventHandler reuturns a single event handler Returns an object shaped map[string]interface{}{"system_key":"associated system key","system_secret":"secret","name":"event name","event_definition":map[string]interface{}{"def_module":"module","def_name":"definition name","event_keys":[]string{"event","keys"},"visibility":false|true}, KeyVals:map[string]interface{}{"keys":"values"},"service_name":"corresponding service name"}

func (*DevClient) GetEventHandlers

func (d *DevClient) GetEventHandlers(systemKey string) ([]interface{}, error)

GetEventHandlers returns a slice of the event handlers for a system

func (*DevClient) GetFailedServices

func (d *DevClient) GetFailedServices(systemKey string) ([]map[string]interface{}, error)

func (*DevClient) GetItemCount

func (d *DevClient) GetItemCount(collection_id string) (int, error)

func (*DevClient) GetKeyset

func (d *DevClient) GetKeyset(systemKey, name string) (map[string]interface{}, error)

func (*DevClient) GetLibraries

func (d *DevClient) GetLibraries(systemKey string) ([]interface{}, error)

GetLibrary returns a list of libraries for a system Returns an object of the following []map[string]interface{}{map[string]interface{}{"system_key":"associated system key","name":"the name of the library","description":"library description","version":1,"code":"function blabla(){return "blahbla"}","dependencies":"clearblade"}, ...}

func (*DevClient) GetLibrary

func (d *DevClient) GetLibrary(systemKey, name string) (map[string]interface{}, error)

GetLibrary returns information about a specific library Returns a single object following the pattern specified in GetLibraries

func (*DevClient) GetLogsForService

func (d *DevClient) GetLogsForService(systemKey, name string) ([]CodeLog, error)

GetLogsForService retrieves the logs for the service

func (*DevClient) GetPlatformDBConnections

func (d *DevClient) GetPlatformDBConnections(systemKey string, query *Query) (map[string]interface{}, error)

func (*DevClient) GetPlatformLogs

func (d *DevClient) GetPlatformLogs(systemKey string, query *Query) (map[string]interface{}, error)

func (*DevClient) GetPlatformStatistics

func (d *DevClient) GetPlatformStatistics(systemKey string, query *Query) (map[string]interface{}, error)

func (*DevClient) GetPlugin

func (d *DevClient) GetPlugin(systemKey, name string) (map[string]interface{}, error)

func (*DevClient) GetPlugins

func (d *DevClient) GetPlugins(systemKey string) ([]interface{}, error)

func (*DevClient) GetPortal

func (d *DevClient) GetPortal(systemKey, name string) (map[string]interface{}, error)

func (*DevClient) GetPortals

func (d *DevClient) GetPortals(systemKey string) ([]interface{}, error)

func (*DevClient) GetService

func (d *DevClient) GetService(systemKey, name string) (*Service, error)

GetService returns information about a specified service

func (*DevClient) GetServiceNames

func (d *DevClient) GetServiceNames(systemKey string) ([]string, error)

GetServiceNames retrieves the service names for a particular system

func (*DevClient) GetServiceRaw

func (d *DevClient) GetServiceRaw(systemKey, name string) (map[string]interface{}, error)

func (*DevClient) GetSyncResourcesForEdge

func (d *DevClient) GetSyncResourcesForEdge(systemKey string) (map[string]interface{}, error)

func (*DevClient) GetSystem

func (d *DevClient) GetSystem(key string) (*System, error)

GetSystem retrieves information about the system specified.

func (*DevClient) GetSystemAssetDeployments

func (d *DevClient) GetSystemAssetDeployments(systemKey string, query *Query) ([]interface{}, error)

func (*DevClient) GetSystemsForDeveloper

func (d *DevClient) GetSystemsForDeveloper(devId string) (map[string]interface{}, error)

func (*DevClient) GetTimer

func (d *DevClient) GetTimer(systemKey, name string) (map[string]interface{}, error)

GetTimer returns the definition of a single timer Returns a single instance of the object described in GetTimers

func (*DevClient) GetTimers

func (d *DevClient) GetTimers(systemKey string) ([]interface{}, error)

Returns a slice of timer descriptions Return value looks like []interface{}[map[string]interface{}{"timer_key":"clearblade generated timer identifier","name":"the name of the timer","start_time":"rfc3339 formatted date string","repeats":0,"frequency":5,"service_name":"name of service executed","system_key":"system key associated with timer","user_id":"userid associated with timer","user_token":"a token the timer runs with"},...]

func (*DevClient) GetTrigger

func (d *DevClient) GetTrigger(systemKey, name string) (map[string]interface{}, error)

Alias for GetEventHandler() to better match up with Console terminology

func (*DevClient) GetTriggers

func (d *DevClient) GetTriggers(systemKey string) ([]interface{}, error)

Alias for GetEventHandlers() to better match up with Console terminology

func (*DevClient) GetUserColumns

func (d *DevClient) GetUserColumns(systemKey string) ([]interface{}, error)

GetUserColumns returns the description of the columns in the user table Returns a structure shaped []map[string]interface{}{map[string]interface{}{"ColumnName":"blah","ColumnType":"int"}}

func (*DevClient) GetUserInfo

func (d *DevClient) GetUserInfo(systemKey, email string) (map[string]interface{}, error)

func (*DevClient) GetUserRoles

func (d *DevClient) GetUserRoles(systemKey, userId string) ([]string, error)

func (*DevClient) GetUserSession

func (d *DevClient) GetUserSession(systemKey string, query *Query) ([]interface{}, error)

func (*DevClient) GetVersion

func (d *DevClient) GetVersion(systemKey, name string, version int) (map[string]interface{}, error)

GetVersion gets the current version of a library Returns an object with the same shape as that of GetLibrariesForSystem, but a specific version thereof

func (*DevClient) GetVersionHistory

func (d *DevClient) GetVersionHistory(systemKey, name string) ([]interface{}, error)

GetVersionHistory returns a slice of library descriptions corresponding to each library Returns an object with the same shape as that of GetLibrariesForSystem, but with each version of the specified library

func (*DevClient) InitializeMQTT

func (d *DevClient) InitializeMQTT(clientid, systemkey string, timeout int, ssl *tls.Config, lastWill *LastWillPacket) error

InitializeMQTT allocates the mqtt client for the developer. the second argument is a the systemkey you wish to use for authenticating with the message broker topics are isolated across systems, so in order to communicate with a specific system, you must supply the system key

func (*DevClient) InitializeMQTTWithCallback

func (d *DevClient) InitializeMQTTWithCallback(clientid, systemkey string, timeout int, ssl *tls.Config, lastWill *LastWillPacket, callbacks *Callbacks) error

func (*DevClient) InsertData

func (d *DevClient) InsertData(collection_id string, data interface{}) error

Inserts data into the platform. The interface is either a map[string]interface{} representing a row, or a []map[string]interface{} representing many rows.

func (*DevClient) Logout

func (d *DevClient) Logout() error

Logout ends the session

func (*DevClient) MessageHistory

func (d *DevClient) MessageHistory(systemKey string) (interface{}, error)

MessageHistory allows the developer to retrieve the message history Returns a slice of []map[string]interface{}{map[string]interface{}{"topicid":"/topic/path", "ip":"127.0.0.1", "time":123141244, "payloadsize":12,"payload":"hello world\n","userid":"8675309","qos":0 }}

func (*DevClient) NewClientID

func (b *DevClient) NewClientID() string

func (*DevClient) NewCollection

func (d *DevClient) NewCollection(systemKey, name string) (string, error)

func (*DevClient) NewConnectCollection

func (d *DevClient) NewConnectCollection(systemkey string, connectConfig connectCollection) (string, error)

NewConnectCollection creates a new collection that is backed by a datastore of your own choosing.

func (*DevClient) NewService

func (d *DevClient) NewService(systemKey, name, code string, params []string) error

NewService creates a new service with a new name, code and params

func (*DevClient) NewServiceWithLibraries

func (d *DevClient) NewServiceWithLibraries(systemKey, name, code, deps string, params []string) error

NewServiceWithLibraries creates a new service with the specified code, params, and libraries/dependencies. Parameters is a slice of strings of parameter names

func (*DevClient) NewSystem

func (d *DevClient) NewSystem(name, description string, users bool) (string, error)

NewSystem creates a new system. The users parameter has been depreciated. Returned is the systemid.

func (*DevClient) Publish

func (d *DevClient) Publish(topic string, message []byte, qos int) error

Publish publishes a message to the specified mqtt topic

func (*DevClient) PublishHttp

func (d *DevClient) PublishHttp(systemKey, topic string, message []byte, qos int) error

func (*DevClient) Register

func (d *DevClient) Register(username, password, fname, lname, org string) error

Registers a new developer

func (*DevClient) RegisterDevUser

func (d *DevClient) RegisterDevUser(username, password, fname, lname, org string) (map[string]interface{}, error)

Register creates a new developer user

func (*DevClient) RegisterDevUserWithKey

func (d *DevClient) RegisterDevUserWithKey(username, password, fname, lname, org, key string) (map[string]interface{}, error)

Register creates a new developer user

func (*DevClient) RegisterNewUser

func (d *DevClient) RegisterNewUser(username, password, systemkey, systemsecret string) (map[string]interface{}, error)

func (*DevClient) RetryFailedServices

func (d *DevClient) RetryFailedServices(systemKey string, ids []string) ([]string, error)

func (*DevClient) RotateKeyset

func (d *DevClient) RotateKeyset(systemKey, name string) (map[string]interface{}, error)

func (*DevClient) SetLongRunningServiceParams

func (d *DevClient) SetLongRunningServiceParams(systemKey, name string, autoRestart bool, concurrency int) error

func (*DevClient) SetMqttClient

func (d *DevClient) SetMqttClient(c MqttClient)

func (*DevClient) SetServiceEffectiveUser

func (d *DevClient) SetServiceEffectiveUser(systemKey, name, userid string) error

SetServiceEffectiveUser allows the developer to set the userid that a service executes under.

func (*DevClient) SetSystemAuthOff

func (d *DevClient) SetSystemAuthOff(system_key string) error

SetSystemAuthOff is depreciated

func (*DevClient) SetSystemAuthOn

func (d *DevClient) SetSystemAuthOn(system_key string) error

SetSystemAuthOn is depreciated

func (*DevClient) SetSystemDescription

func (d *DevClient) SetSystemDescription(system_key, system_description string) error

SetSystemDescription can change the content of the system's description

func (*DevClient) SetSystemName

func (d *DevClient) SetSystemName(system_key, system_name string) error

SetSystemName can change the name of the system

func (*DevClient) SetSystemTokenTTL

func (d *DevClient) SetSystemTokenTTL(system_key string, token_ttl int) error

SetSystemTokenTTL can change the value for the system's token TTL

func (*DevClient) Subscribe

func (d *DevClient) Subscribe(topic string, qos int) (<-chan *mqttTypes.Publish, error)

Subscribe subscribes a user to a topic. Incoming messages will be sent over the channel.

func (*DevClient) SyncResourceToEdge

func (d *DevClient) SyncResourceToEdge(systemKey, edgeName string, add map[string][]string, remove map[string][]string) (map[string]interface{}, error)

func (*DevClient) Unsubscribe

func (d *DevClient) Unsubscribe(topic string) error

Unsubscribe stops the flow of messages over the corresponding subscription chan

func (*DevClient) UpdateAdaptor

func (d *DevClient) UpdateAdaptor(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdateAdaptorFile

func (d *DevClient) UpdateAdaptorFile(systemKey, adaptorName, fileName string, data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdateAssetClassDeployments

func (d *DevClient) UpdateAssetClassDeployments(systemKey, assetClass string, data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdateAssetDeployments

func (d *DevClient) UpdateAssetDeployments(systemKey, assetClass, assetId string, data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdateAssetPlatformDeploymentStatus

func (d *DevClient) UpdateAssetPlatformDeploymentStatus(systemKey, assetClass, assetId string, deploy bool) (map[string]interface{}, error)

func (*DevClient) UpdateAutoDelete

func (d *DevClient) UpdateAutoDelete(systemKey string, preamble string, size_limit int, expiry_messages int64, time_interval int, truncateStat int, panic_truncate int, autoDelete int) (bool, error)

update the parameters of AutoDelete using the endpoint

func (*DevClient) UpdateData

func (d *DevClient) UpdateData(collection_id string, query *Query, changes map[string]interface{}) error

UpdateData mutates the values in extant rows, selecting them via a query. If the query is nil, it updates all rows changes should be a map of the names of the columns, and the value you want them updated to

func (*DevClient) UpdateDeployResourcesForSystem

func (d *DevClient) UpdateDeployResourcesForSystem(systemKey, resourceName, resourceType string, platform bool, edgeQuery *Query) (map[string]interface{}, error)

func (*DevClient) UpdateDeploymentByName

func (d *DevClient) UpdateDeploymentByName(systemKey, name string, changes map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdateDevelopersForSystem

func (d *DevClient) UpdateDevelopersForSystem(systemKey string, changes map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdateDevice

func (d *DevClient) UpdateDevice(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdateDeviceRoles

func (d *DevClient) UpdateDeviceRoles(systemKey, deviceName string, rolesAdd, rolesRemove []string) error

func (*DevClient) UpdateDevices

func (d *DevClient) UpdateDevices(systemKey string, query *Query, changes map[string]interface{}) ([]interface{}, error)

func (*DevClient) UpdateEdge

func (d *DevClient) UpdateEdge(systemKey string, name string, changes map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdateEdgeGroup

func (d *DevClient) UpdateEdgeGroup(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdateEventHandler

func (d *DevClient) UpdateEventHandler(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

UpdateEventHandler allows the developer to alter the code executed by the event handler Returns an object corresponding to GetEventHandler with the altered values

func (*DevClient) UpdateLibrary

func (d *DevClient) UpdateLibrary(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

UpdateLibrary allows the developer to change the content of the library returns a single object following the pattern specified in GetLibraries with the updated details

func (*DevClient) UpdatePlugin

func (d *DevClient) UpdatePlugin(systemKey, name string, dash map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdatePortal

func (d *DevClient) UpdatePortal(systemKey, name string, dash map[string]interface{}) (map[string]interface{}, error)

func (*DevClient) UpdateRole

func (d *DevClient) UpdateRole(systemKey, roleName string, role map[string]interface{}) error

func (*DevClient) UpdateService

func (d *DevClient) UpdateService(systemKey, name, code string, params []string) (error, map[string]interface{})

UpdateService facillitates changes to the service's code

func (*DevClient) UpdateServiceWithLibraries

func (d *DevClient) UpdateServiceWithLibraries(systemKey, name, code, deps string, params []string) (error, map[string]interface{})

func (*DevClient) UpdateTimer

func (d *DevClient) UpdateTimer(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

UpdateTimer allows the developer to change the code executed with the timer Returns an updated version of the timer as described in GetTimer

func (*DevClient) UpdateTrigger

func (d *DevClient) UpdateTrigger(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

Alias for UpdateEventHandler() to better match up with Console terminology

func (*DevClient) UpdateUser

func (d *DevClient) UpdateUser(systemKey, userId string, info map[string]interface{}) error

func (*DevClient) UpdateUserRoles

func (d *DevClient) UpdateUserRoles(systemKey, userId string, rolesAdd, rolesRemove []string) error

type DeviceClient

type DeviceClient struct {
	DeviceName  string
	ActiveKey   string
	DeviceToken string

	MQTTClient   MqttClient
	SystemKey    string
	SystemSecret string
	HttpAddr     string
	MqttAddr     string
	// contains filtered or unexported fields
}

func NewDeviceClient

func NewDeviceClient(systemkey, systemsecret, deviceName, activeKey string) *DeviceClient

func NewDeviceClientWithAddrs

func NewDeviceClientWithAddrs(httpAddr, mqttAddr, systemkey, systemsecret, deviceName, activeKey string) *DeviceClient

func NewEdgeProxyDeviceClient

func NewEdgeProxyDeviceClient(systemkey, systemsecret, deviceName, activeKey, edgeName string) (*DeviceClient, error)

func (*DeviceClient) Authenticate

func (dvc *DeviceClient) Authenticate() error

"Login and logout"

func (*DeviceClient) AuthenticateDeviceWithKey

func (d *DeviceClient) AuthenticateDeviceWithKey(systemKey, name, activeKey string) (map[string]interface{}, error)

func (*DeviceClient) ControlAdaptor

func (d *DeviceClient) ControlAdaptor(systemKey, adaptorName string, controlSpec map[string]interface{}) (map[string]interface{}, error)

func (*DeviceClient) CreateAdaptor

func (d *DeviceClient) CreateAdaptor(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*DeviceClient) CreateAdaptorFile

func (d *DeviceClient) CreateAdaptorFile(systemKey, adaptorName, fileName string, data map[string]interface{}) (map[string]interface{}, error)

func (*DeviceClient) CreateData

func (d *DeviceClient) CreateData(collection_id string, data interface{}) ([]interface{}, error)

CreateData is an alias for InsertData, but returns a response value, it should be a slice of strings representing the item ids (if not using an external datastore)

func (*DeviceClient) CreateDevice

func (d *DeviceClient) CreateDevice(systemKey, name string,
	data map[string]interface{}) (map[string]interface{}, error)

func (*DeviceClient) DeleteAdaptor

func (d *DeviceClient) DeleteAdaptor(systemKey, name string) error

func (*DeviceClient) DeleteAdaptorFile

func (d *DeviceClient) DeleteAdaptorFile(systemKey, adaptorName, fileName string) error

func (*DeviceClient) DeleteData

func (d *DeviceClient) DeleteData(collection_id string, query *Query) error

DeleteData removes data from a collection according to what matches the query. If the query is nil, then all data will be removed.

func (*DeviceClient) DeleteDevice

func (d *DeviceClient) DeleteDevice(systemKey, name string) error

func (*DeviceClient) DeleteDevices

func (u *DeviceClient) DeleteDevices(systemKey string, query *Query) error

func (*DeviceClient) DeployAdaptor

func (d *DeviceClient) DeployAdaptor(systemKey, adaptorName string, deploySpec map[string]interface{}) (map[string]interface{}, error)

func (*DeviceClient) Disconnect

func (d *DeviceClient) Disconnect() error

Disconnect stops the TCP connection and unsubscribes the client from any remaining topics

func (*DeviceClient) GetAdaptor

func (d *DeviceClient) GetAdaptor(systemKey, name string) (map[string]interface{}, error)

func (*DeviceClient) GetAdaptorFile

func (d *DeviceClient) GetAdaptorFile(systemKey, adaptorName, fileName string) (map[string]interface{}, error)

func (*DeviceClient) GetAdaptorFiles

func (d *DeviceClient) GetAdaptorFiles(systemKey, adaptorName string) ([]interface{}, error)

func (*DeviceClient) GetAdaptors

func (d *DeviceClient) GetAdaptors(systemKey string) ([]interface{}, error)

func (*DeviceClient) GetColumns

func (d *DeviceClient) GetColumns(collection_id, systemKey, systemSecret string) ([]interface{}, error)

GetColumns gets a slice of map[string]interface{} of the column names and values. As map[string]interface{}{"ColumnName":"name","ColumnType":"typename in string", "PK":bool}

func (*DeviceClient) GetData

func (d *DeviceClient) GetData(collection_id string, query *Query) (map[string]interface{}, error)

GetData performs a query against a collection. The query object is discussed elsewhere. If the query object is nil, then it will return all of the data. The return value is a key-value of the types. Note that due to the transport mechanism being JSON, ints will be turned into float64s.

func (*DeviceClient) GetDataByKeyAndName

func (d *DeviceClient) GetDataByKeyAndName(string, string, *Query) (map[string]interface{}, error)

GetDataByKeyAndName is unimplemented

func (*DeviceClient) GetDataByName

func (d *DeviceClient) GetDataByName(collectionName string, query *Query) (map[string]interface{}, error)

GetDataByName performs a query against a collection, using the collection's name, rather than the ID. The query object is discussed elsewhere. If the query object is nil, then it will return all of the data. The return value is a key-value of the types. Note that due to the transport mechanism being JSON, ints will be turned into float64s.

func (*DeviceClient) GetDataTotal

func (d *DeviceClient) GetDataTotal(collection_id string, query *Query) (map[string]interface{}, error)

func (*DeviceClient) GetDevice

func (d *DeviceClient) GetDevice(systemKey, name string) (map[string]interface{}, error)

func (*DeviceClient) GetDevices

func (u *DeviceClient) GetDevices(systemKey string, query *Query) ([]interface{}, error)

func (*DeviceClient) GetItemCount

func (d *DeviceClient) GetItemCount(collection_id string) (int, error)

func (*DeviceClient) InitializeMQTT

func (d *DeviceClient) InitializeMQTT(clientid string, ignore string, timeout int, ssl *tls.Config, lastWill *LastWillPacket) error

InitializeMQTT allocates the mqtt client for the user. an empty string can be passed as the second argument for the user client

func (*DeviceClient) InitializeMQTTWithCallback

func (d *DeviceClient) InitializeMQTTWithCallback(clientid string, ignore string, timeout int, ssl *tls.Config, lastWill *LastWillPacket, callbacks *Callbacks) error

func (*DeviceClient) InsertData

func (d *DeviceClient) InsertData(collection_id string, data interface{}) error

Inserts data into the platform. The interface is either a map[string]interface{} representing a row, or a []map[string]interface{} representing many rows.

func (*DeviceClient) Logout

func (dvc *DeviceClient) Logout() error

func (*DeviceClient) NewClientID

func (b *DeviceClient) NewClientID() string

func (*DeviceClient) Publish

func (d *DeviceClient) Publish(topic string, message []byte, qos int) error

Publish publishes a message to the specified mqtt topic

func (*DeviceClient) SetMqttClient

func (d *DeviceClient) SetMqttClient(c MqttClient)

func (*DeviceClient) Subscribe

func (d *DeviceClient) Subscribe(topic string, qos int) (<-chan *mqttTypes.Publish, error)

Subscribe subscribes a device to a topic. Incoming messages will be sent over the channel.

func (*DeviceClient) Unsubscribe

func (d *DeviceClient) Unsubscribe(topic string) error

Unsubscribe stops the flow of messages over the corresponding subscription chan

func (*DeviceClient) UpdateAdaptor

func (d *DeviceClient) UpdateAdaptor(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*DeviceClient) UpdateAdaptorFile

func (d *DeviceClient) UpdateAdaptorFile(systemKey, adaptorName, fileName string, data map[string]interface{}) (map[string]interface{}, error)

func (*DeviceClient) UpdateData

func (d *DeviceClient) UpdateData(collection_id string, query *Query, changes map[string]interface{}) error

func (*DeviceClient) UpdateDevice

func (u *DeviceClient) UpdateDevice(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*DeviceClient) UpdateDevices

func (u *DeviceClient) UpdateDevices(systemKey string, query *Query, changes map[string]interface{}) ([]interface{}, error)

type EdgeConfig

type EdgeConfig struct {
	EdgeName       string
	EdgeToken      string
	PlatformIP     string
	PlatformPort   string
	ParentSystem   string
	HttpPort       string
	MqttPort       string
	MqttTlsPort    string
	WsPort         string
	WssPort        string
	AuthPort       string
	AuthWsPort     string
	AdapterRootDir string
	Lean           bool
	Cache          bool
	LogLevel       string
	Insecure       bool
	DevMode        bool
	Stdout         *os.File
	Stderr         *os.File
}

type EdgeProxy

type EdgeProxy struct {
	SystemKey string
	EdgeName  string
}

type Filter

type Filter struct {
	Field    string
	Value    interface{}
	Operator string
}

Filter is the atomic structure inside a query it contains A field a value and an operator

type LastWillPacket

type LastWillPacket struct {
	Topic  string
	Body   string
	Qos    int
	Retain bool
}

LastWillPacket is a type to represent the Last Will and Testament packet

type MSSqlConfig

type MSSqlConfig struct {
	Name, User, Password, Host, Port, DBName, Tablename string
}

MSSqlConfig houses configuration information for an MSSql-backed collection

type MqttClient

type MqttClient interface {
	mqtt.Client
}

type MySqlConfig

type MySqlConfig struct {
	Name, User, Password, Host, Port, DBName, Tablename string
}

MySqlConfig houses configuration information for an MySql-backed collection

type Ordering

type Ordering struct {
	SortOrder bool
	OrderKey  string
}

Ordering dictates the order the query values are returned in. True is Ascending, False is Descending

type PostgresqlConfig

type PostgresqlConfig struct {
	Name, User, Password, Host, Port, DBName, Tablename string
}

PostgresqlConfig houses configuration information for an Postgresql-backed collection

type Query

type Query struct {
	Filters    [][]Filter
	PageSize   int
	PageNumber int
	Order      []Ordering
	Columns    []string
}

Query contains configuration information for the request against a collection. It creates a subset of results for the operation to be performed upon

func NewQuery

func NewQuery() *Query

NewQuery allocates a new query

func (*Query) EqualTo

func (q *Query) EqualTo(field string, value interface{})

EqualTo adds an equality constraint to the query. Similar to "WHERE foo = 'bar'"

func (*Query) GreaterThan

func (q *Query) GreaterThan(field string, value interface{})

GreaterThan adds the corresponding constraint to the query. Similar to "WHERE foo > 3"

func (*Query) GreaterThanEqualTo

func (q *Query) GreaterThanEqualTo(field string, value interface{})

GreaterThanEqualTo adds the corresponding constraint to the query. Similar to "WHERE foo >= 3"

func (*Query) LessThan

func (q *Query) LessThan(field string, value interface{})

LessThan adds the corresponding constraint to the query. Similar to "WHERE foo < 3"

func (*Query) LessThanEqualTo

func (q *Query) LessThanEqualTo(field string, value interface{})

LessThanEqualTo adds the corresponding constraint to the query. Similar to "WHERE foo <= 3"

func (*Query) Matches

func (q *Query) Matches(field, regex string)

Matches allows fuzzy matching on string columns. Use PCRE syntax.

func (*Query) NotEqualTo

func (q *Query) NotEqualTo(field string, value interface{})

NotEqualTo adds the corresponding constraint to the query. Similar to "WHERE foo != 'bar'"

func (*Query) Or

func (q *Query) Or(orQuery *Query)

Or applies an or constraint to the query.

type Service

type Service struct {
	Name    string
	Code    string
	Version int
	Params  []string
	System  string
}

Service is a helper struct for grouping facts about a code service

type System

type System struct {
	Key         string
	Secret      string
	Name        string
	Description string
	Users       bool
	TokenTTL    int32
}

System is a collection of facts about a system

type UserClient

type UserClient struct {
	UserToken string

	MQTTClient   MqttClient
	SystemKey    string
	SystemSecret string
	Email        string
	Password     string
	HttpAddr     string
	MqttAddr     string
	// contains filtered or unexported fields
}

UserClient is the type for users

func NewEdgeProxyUserClient

func NewEdgeProxyUserClient(email, password, systemKey, systemSecret, edgeName string) (*UserClient, error)

func NewUserClient

func NewUserClient(systemkey, systemsecret, email, password string) *UserClient

NewUserClient allocates a new UserClient struct

func NewUserClientWithAddrs

func NewUserClientWithAddrs(httpAddr, mqttAddr, systemKey, systemSecret, email, password string) *UserClient

func (*UserClient) AddColumn

func (u *UserClient) AddColumn(collection_id, column_name, column_type string) error

func (*UserClient) AuthAnon

func (u *UserClient) AuthAnon() error

func (*UserClient) Authenticate

func (u *UserClient) Authenticate() error

Authenticate retrieves a token from the specified Clearblade Platform

func (*UserClient) CallService

func (u *UserClient) CallService(systemKey, name string, params map[string]interface{}) (map[string]interface{}, error)

CallService performs a call against the specific service with the specified parameters. The return value is a map[string]interface{} where the results will be stored in the key "results". If logs were enabled, they'll be in "log".

func (*UserClient) ControlAdaptor

func (u *UserClient) ControlAdaptor(systemKey, adaptorName string, controlSpec map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) CreateAdaptor

func (u *UserClient) CreateAdaptor(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) CreateAdaptorFile

func (u *UserClient) CreateAdaptorFile(systemKey, adaptorName, fileName string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) CreateData

func (u *UserClient) CreateData(collection_id string, data interface{}) ([]interface{}, error)

CreateData is an alias for InsertData, but returns a response value, it should be a slice of strings representing the item ids (if not using an external datastore)

func (*UserClient) CreateDeploymentByName

func (u *UserClient) CreateDeploymentByName(systemKey, name string, info map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) CreateDevice

func (u *UserClient) CreateDevice(systemKey, name string,
	data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) CreateEdge

func (u *UserClient) CreateEdge(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) CreateEventHandler

func (u *UserClient) CreateEventHandler(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) CreateService

func (u *UserClient) CreateService(systemKey, name, code string, params []string) error

func (*UserClient) CreateTimer

func (u *UserClient) CreateTimer(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) CreateTrigger

func (u *UserClient) CreateTrigger(systemKey, name string,
	data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) DeleteAdaptor

func (u *UserClient) DeleteAdaptor(systemKey, name string) error

func (*UserClient) DeleteAdaptorFile

func (u *UserClient) DeleteAdaptorFile(systemKey, adaptorName, fileName string) error

func (*UserClient) DeleteCollection

func (u *UserClient) DeleteCollection(colID string) error

func (*UserClient) DeleteColumn

func (u *UserClient) DeleteColumn(collection_id, column_name string) error

func (*UserClient) DeleteData

func (u *UserClient) DeleteData(collection_id string, query *Query) error

DeleteData removes data from a collection according to what matches the query. If the query is nil, then all data will be removed.

func (*UserClient) DeleteDeploymentByName

func (u *UserClient) DeleteDeploymentByName(systemKey, name string) error

func (*UserClient) DeleteDevice

func (u *UserClient) DeleteDevice(systemKey, name string) error

func (*UserClient) DeleteDevices

func (u *UserClient) DeleteDevices(systemKey string, query *Query) error

func (*UserClient) DeleteEdge

func (u *UserClient) DeleteEdge(systemKey, name string) error

func (*UserClient) DeleteEventHandler

func (u *UserClient) DeleteEventHandler(systemKey, name string) error

func (*UserClient) DeleteService

func (u *UserClient) DeleteService(systemKey, name string) error

func (*UserClient) DeleteTimer

func (u *UserClient) DeleteTimer(systemKey, name string) error

func (*UserClient) DeleteTrigger

func (u *UserClient) DeleteTrigger(systemKey, name string) error

func (*UserClient) DeployAdaptor

func (u *UserClient) DeployAdaptor(systemKey, adaptorName string, deploySpec map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) Disconnect

func (u *UserClient) Disconnect() error

Disconnect stops the TCP connection and unsubscribes the client from any remaining topics

func (*UserClient) GetAdaptor

func (u *UserClient) GetAdaptor(systemKey, name string) (map[string]interface{}, error)

func (*UserClient) GetAdaptorFile

func (u *UserClient) GetAdaptorFile(systemKey, adaptorName, fileName string) (map[string]interface{}, error)

func (*UserClient) GetAdaptorFiles

func (u *UserClient) GetAdaptorFiles(systemKey, adaptorName string) ([]interface{}, error)

func (*UserClient) GetAdaptors

func (u *UserClient) GetAdaptors(systemKey string) ([]interface{}, error)

func (*UserClient) GetAllCollections

func (u *UserClient) GetAllCollections(systemKey string) ([]interface{}, error)

func (*UserClient) GetAllDeployments

func (u *UserClient) GetAllDeployments(systemKey string) (map[string]interface{}, error)

func (*UserClient) GetCollectionInfo

func (u *UserClient) GetCollectionInfo(collection_id string) (map[string]interface{}, error)

func (*UserClient) GetColumns

func (u *UserClient) GetColumns(collection_id, systemKey, systemSecret string) ([]interface{}, error)

GetColumns gets a slice of map[string]interface{} of the column names and values. As map[string]interface{}{"ColumnName":"name","ColumnType":"typename in string", "PK":bool}

func (*UserClient) GetCurrentTopics

func (u *UserClient) GetCurrentTopics(systemKey string) ([]string, error)

func (*UserClient) GetCurrentTopicsCount

func (u *UserClient) GetCurrentTopicsCount(systemKey string) (map[string]interface{}, error)

func (*UserClient) GetCurrentTopicsWithQuery

func (u *UserClient) GetCurrentTopicsWithQuery(systemKey string, columns []string, pageSize, pageNum int, descending bool) ([]map[string]interface{}, error)

func (*UserClient) GetData

func (u *UserClient) GetData(collection_id string, query *Query) (map[string]interface{}, error)

GetData performs a query against a collection. The query object is discussed elsewhere. If the query object is nil, then it will return all of the data. The return value is a key-value of the types. Note that due to the transport mechanism being JSON, ints will be turned into float64s.

func (*UserClient) GetDataByKeyAndName

func (u *UserClient) GetDataByKeyAndName(string, string, *Query) (map[string]interface{}, error)

GetDataByKeyAndName is unimplemented

func (*UserClient) GetDataByName

func (u *UserClient) GetDataByName(collectionName string, query *Query) (map[string]interface{}, error)

GetDataByName performs a query against a collection, using the collection's name, rather than the ID. The query object is discussed elsewhere. If the query object is nil, then it will return all of the data. The return value is a key-value of the types. Note that due to the transport mechanism being JSON, ints will be turned into float64s.

func (*UserClient) GetDataTotal

func (u *UserClient) GetDataTotal(collection_id string, query *Query) (map[string]interface{}, error)

func (*UserClient) GetDeploymentByName

func (u *UserClient) GetDeploymentByName(systemKey, name string) (map[string]interface{}, error)

func (*UserClient) GetDevice

func (u *UserClient) GetDevice(systemKey, name string) (map[string]interface{}, error)

func (*UserClient) GetDevices

func (u *UserClient) GetDevices(systemKey string, query *Query) ([]interface{}, error)

func (*UserClient) GetEdge

func (u *UserClient) GetEdge(systemKey, name string) (map[string]interface{}, error)

func (*UserClient) GetEdges

func (u *UserClient) GetEdges(systemKey string) ([]interface{}, error)

func (*UserClient) GetEdgesWithQuery

func (u *UserClient) GetEdgesWithQuery(systemKey string, query *Query) ([]interface{}, error)

func (*UserClient) GetEventHandler

func (u *UserClient) GetEventHandler(systemKey, name string) (map[string]interface{}, error)

func (*UserClient) GetEventHandlers

func (u *UserClient) GetEventHandlers(systemKey string) ([]interface{}, error)

func (*UserClient) GetItemCount

func (u *UserClient) GetItemCount(collection_id string) (int, error)

func (*UserClient) GetPlatformDBConnections

func (u *UserClient) GetPlatformDBConnections(systemKey string, query *Query) (map[string]interface{}, error)

func (*UserClient) GetPlatformLogs

func (u *UserClient) GetPlatformLogs(systemKey string, query *Query) (map[string]interface{}, error)

func (*UserClient) GetPlatformStatistics

func (u *UserClient) GetPlatformStatistics(systemKey string, query *Query) (map[string]interface{}, error)

func (*UserClient) GetService

func (u *UserClient) GetService(systemKey, name string) (*Service, error)

GetService returns information about a specified service

func (*UserClient) GetServiceNames

func (u *UserClient) GetServiceNames(systemKey string) ([]string, error)

GetServiceNames retrieves the service names for a particular system

func (*UserClient) GetTimer

func (u *UserClient) GetTimer(systemKey, name string) (map[string]interface{}, error)

func (*UserClient) GetTimers

func (u *UserClient) GetTimers(systemKey string) ([]interface{}, error)

func (*UserClient) GetTrigger

func (u *UserClient) GetTrigger(systemKey, name string) (map[string]interface{}, error)

func (*UserClient) GetUserCount

func (u *UserClient) GetUserCount(systemKey string) (int, error)

func (*UserClient) InitializeMQTT

func (u *UserClient) InitializeMQTT(clientid string, ignore string, timeout int, ssl *tls.Config, lastWill *LastWillPacket) error

InitializeMQTT allocates the mqtt client for the user. an empty string can be passed as the second argument for the user client

func (*UserClient) InitializeMQTTWithCallback

func (u *UserClient) InitializeMQTTWithCallback(clientid string, ignore string, timeout int, ssl *tls.Config, lastWill *LastWillPacket, callbacks *Callbacks) error

func (*UserClient) InsertData

func (u *UserClient) InsertData(collection_id string, data interface{}) error

Inserts data into the platform. The interface is either a map[string]interface{} representing a row, or a []map[string]interface{} representing many rows.

func (*UserClient) Logout

func (u *UserClient) Logout() error

Logout ends the session

func (*UserClient) NewClientID

func (b *UserClient) NewClientID() string

func (*UserClient) NewCollection

func (u *UserClient) NewCollection(systemKey, name string) (string, error)

func (*UserClient) Publish

func (u *UserClient) Publish(topic string, message []byte, qos int) error

Publish publishes a message to the specified mqtt topic

func (*UserClient) Register

func (u *UserClient) Register(username, password string) error

Register creates a new user

func (*UserClient) RegisterUser

func (u *UserClient) RegisterUser(username, password string) (map[string]interface{}, error)

RegisterUser creates a new user, returning the body of the response.

func (*UserClient) SetMqttClient

func (u *UserClient) SetMqttClient(c MqttClient)

func (*UserClient) Subscribe

func (u *UserClient) Subscribe(topic string, qos int) (<-chan *mqttTypes.Publish, error)

Subscribe subscribes a user to a topic. Incoming messages will be sent over the channel.

func (*UserClient) Unsubscribe

func (u *UserClient) Unsubscribe(topic string) error

Unsubscribe stops the flow of messages over the corresponding subscription chan

func (*UserClient) UpdateAdaptor

func (u *UserClient) UpdateAdaptor(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) UpdateAdaptorFile

func (u *UserClient) UpdateAdaptorFile(systemKey, adaptorName, fileName string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) UpdateAutoDelete

func (d *UserClient) UpdateAutoDelete(systemKey string, preamble string, size_limit int, expiry_messages int, time_interval int, truncateStat int, panic_truncate int, autoDelete int) (bool, error)

update the parameters of AutoDelete using the endpoint

func (*UserClient) UpdateData

func (u *UserClient) UpdateData(collection_id string, query *Query, changes map[string]interface{}) error

func (*UserClient) UpdateDeploymentByName

func (u *UserClient) UpdateDeploymentByName(systemKey, name string, changes map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) UpdateDevice

func (u *UserClient) UpdateDevice(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) UpdateDevices

func (u *UserClient) UpdateDevices(systemKey string, query *Query, changes map[string]interface{}) ([]interface{}, error)

func (*UserClient) UpdateEdge

func (u *UserClient) UpdateEdge(systemKey string, name string, changes map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) UpdateEventHandler

func (u *UserClient) UpdateEventHandler(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) UpdateService

func (u *UserClient) UpdateService(systemKey, name, code string, params []string) (error, map[string]interface{})

func (*UserClient) UpdateTimer

func (u *UserClient) UpdateTimer(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) UpdateTrigger

func (u *UserClient) UpdateTrigger(systemKey, name string, data map[string]interface{}) (map[string]interface{}, error)

func (*UserClient) UpdateUser

func (u *UserClient) UpdateUser(userQuery *Query, changes map[string]interface{}) error

Jump to

Keyboard shortcuts

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