Documentation
¶
Index ¶
- func ExtractFromMap(_map interface{}, key string) interface{}
- func ToMap(in interface{}, tag string) (map[string]interface{}, error)
- type ClientHTTP
- type ClientWS
- type CountErr
- type Credential
- type Device
- type DeviceErr
- type DeviceFilter
- type DeviceSection
- type DeviceService
- type DeviceTopic
- type DevicesErr
- type Event
- type GatewayService
- type OptionsHTTP
- type OptionsWS
- type ResponseErr
- type ResponseError
- type SchemaDevice
- type SchemaDeviceService
- type Subscriber
- type SubscriberService
- type SuccessErr
- type SuccessResponse
- type Webhook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractFromMap ¶
func ExtractFromMap(_map interface{}, key string) interface{}
Types ¶
type ClientHTTP ¶
type ClientHTTP interface {
GetHttpClient() *http.Client
SendHTTPRequest(method string, url string, data interface{}) chan ResponseErr
GetDeviceService() DeviceService
GetDeviceSchemaService() SchemaDeviceService
GetGatewayService() GatewayService
GetSubscriberService() SubscriberService
}
func NewClientHTTP ¶
func NewClientHTTP(urlStr string, options *OptionsHTTP) ClientHTTP
type ClientWS ¶
type ClientWS interface {
SetChanEvent(chanEvent chan map[string]interface{})
SetChanConnect(chanConnect chan bool)
IsConnected() bool
Connect() chan error
Close()
SendMessage(data interface{}) error
SendRequest(data requestWs) error
SendRequestResponse(resource string, id *string, method string, params map[string]interface{}, payload interface{}) chan ResponseErr
GetDeviceService() DeviceService
GetDeviceSchemaService() SchemaDeviceService
GetGatewayService() GatewayService
GetSubscriberService() SubscriberService
}
type CountErr ¶
type CountErr struct {
Count uint `json:"count"`
Err *ResponseError
}
type Credential ¶
type Device ¶
type Device struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Enable *bool `json:"enable,omitempty"`
Tags []string `json:"tags,omitempty"`
Sections map[string]interface{} `json:"sections,omitempty"`
}
Device representing device data
func ConvertToDevice ¶
func ConvertToDevice(src interface{}) *Device
func ConvertToDevices ¶
func ConvertToDevices(src interface{}) []*Device
ConvertToDevices Convert to []*Device
type DeviceErr ¶
type DeviceErr struct {
Data *Device
Err *ResponseError
}
type DeviceFilter ¶
type DeviceFilter struct {
Section string `json:"section,omitempty"`
}
func ConvertToDeviceFilter ¶
func ConvertToDeviceFilter(src interface{}) *DeviceFilter
type DeviceSection ¶
type DeviceSection struct {
Data map[string]interface{} `json:"data,omitempty"`
}
type DeviceService ¶
type DeviceService interface {
// Get all devices default max elements 200.
// offset
// limit -1 illimited, 0 default 200, otherwise # elements
// format "id", "short", "full"
// params optional example map[string]interface{}{
// "filter.type" : "iot.light.simple",
// "filter.sections.config.room.content" : "100",
// "view-config" : true,
// "sort-field" : "sections.config.room.content",
// "sort-asc" : true,
// }
// To convert result to []*Device, apply function ConvertToDevices.
GetDevices(offset int, limit int, format string, params map[string]interface{}) chan ResponseErr
// Get devices count with filters.
// params example map[string]interface{
// "filter.type" : "iot.light.simple" ,
// "filter.sections.config.room.content" : "100" ,
// }
GetDevicesCount(filters map[string]interface{}) chan CountErr
// Create device .
// data see Device struct.
// params optional example map[string]interface{
// "context.mykey" : "myvalue",
// }
CreateDevice(data interface{}, params map[string]interface{}) chan SuccessErr
// Update device .
// deviceID device identifier.
// data see Device struct.
// params optional example map[string]interface{
// "context.mykey" : "myvalue",
// }
UpdateDevice(deviceID string, data interface{}, params map[string]interface{}) chan SuccessErr
// Get device by Id.
// params optional example map[string]interface{}{
// "view-config" : true,
// }
// To convert result to Device, apply functions ConvertToDevice.
GetDevice(deviceID string, params map[string]interface{}) chan ResponseErr
// Delete device by Id.
// params optional example map[string]interface{
// "context.mykey" : "myvalue",
// }
DeleteDevice(deviceID string, params map[string]interface{}) chan SuccessErr
// Get device section by Id.
// params optional example map[string]interface{}{
// "view-config" : true,
// }
// To convert result to Device, apply functions ConvertToDevice.
GetDeviceSection(deviceID string, section string, params map[string]interface{}) chan ResponseErr
// Update device section.
// deviceID device identifier.
// section section name.
// data example map[string]interface{}{
// "data": map[string]interface{}{
// "light_on": lightOn,
// },
// or DeviceSection{
// Data : map[string]interface{}{
// "light_on": lightOn,
// },
// }
// params optional example map[string]interface{
// "context.mykey" : "myvalue",
// }
UpdateDeviceSection(deviceID string, section string, data interface{}, params map[string]interface{}) chan SuccessErr
}
DeviceService Device service
func NewDeviceHTTPService ¶
func NewDeviceHTTPService(ClientHTTP ClientHTTP) DeviceService
func NewDeviceService ¶
func NewDeviceService(ClientWS ClientWS) DeviceService
type DeviceTopic ¶
type DeviceTopic struct {
ID string `json:"id,omitempty"`
Selectors []map[string]interface{} `json:"selectors,omitempty"`
Filters []DeviceFilter `json:"filters,omitempty"`
Extras []string `json:"extras,omitempty"`
}
func ConvertToDeviceTopic ¶
func ConvertToDeviceTopic(src interface{}) *DeviceTopic
type DevicesErr ¶
type DevicesErr struct {
Data []*Device
Err *ResponseError
}
type Event ¶
type Event struct {
Date string `json:"date"`
Message string `json:"message"`
Event string `json:"event"`
RequestID string `json:"request_id"`
Resource string `json:"resource"`
ID string `json:"id"`
Section string `json:"section,omitempty"`
Method string `json:"method"`
Body interface{} `json:"body"`
SubscriberID string `json:"subscriber_id"`
Extras interface{} `json:"extras,omitempty"`
Context interface{} `json:"context,omitempty"`
}
func ConvertToEvent ¶
func ConvertToEvent(src interface{}) *Event
type GatewayService ¶
type GatewayService interface {
// Get all gateways default max elements 200.
// offset
// limit -1 illimited, 0 default 200, otherwise # elements
// format "id", "short", "full"
// params optional example map[string]interface{}{
// "sort-field" : "name",
// "sort-asc" : true,
// }
// To convert result to []*Gateway, apply function ConvertToGateways.
GetGateways(offset int, limit int, format string, params map[string]interface{}) chan ResponseErr
// Get gateways count.
GetGatewaysCount() chan CountErr
// Create gateway .
// data see Gateway struct.
CreateGateway(data interface{}) chan SuccessErr
// Update gateway .
// gatewayID device identifier.
// data see Gateway struct.
UpdateGateway(gatewayID string, data interface{}) chan SuccessErr
// Get gateway by Id.
// To convert result to Gateway, apply functions ConvertToGateway.
GetGateway(gatewayID string) chan ResponseErr
// Delete device by Id.
DeleteGateway(gatewayID string) chan SuccessErr
// Update gateway.
// gatewayID device identifier.
// path gateway document path.
// data to update.
UpdatePartialGateway(gatewayID string, path string, data map[string]interface{}) chan SuccessErr
// Update gateway contriller state.
// gatewayID device identifier.
// controllerURL controllerURL to update.
// data to update.
SendGatewayControllerStateToHub(gatewayID string, controllerURL string, stateData map[string]interface{}) chan SuccessErr
}
func NewGatewayHTTPService ¶
func NewGatewayHTTPService(ClientHTTP ClientHTTP) GatewayService
func NewGatewayService ¶
func NewGatewayService(ClientWS ClientWS) GatewayService
type OptionsHTTP ¶
type ResponseErr ¶
type ResponseErr struct {
Data interface{}
Err *ResponseError
}
type ResponseError ¶
func ConvertToResponseError ¶
func ConvertToResponseError(src interface{}) *ResponseError
type SchemaDevice ¶
type SchemaDeviceService ¶
type SchemaDeviceService interface {
// Get all schemas default max elements 200.
// offset
// limit -1 illimited, 0 default 200, otherwise # elements
// format "id", "short", "full"
// params optional example map[string]interface{}{
// "sort-field" : "name",
// "sort-asc" : true,
// }
// To convert result to []*Schema, apply function ConvertToSchemas.
GetSchemas(offset int, limit int, format string, params map[string]interface{}) chan ResponseErr
// Get schemas count.
GetSchemasCount() chan CountErr
// Create schema .
// data see Schema struct.
CreateSchema(data interface{}) chan SuccessErr
// Update schema .
// schemaID schema identifier.
// data see Schema struct.
UpdateSchema(schemaID string, data interface{}) chan SuccessErr
// Get schema by Id.
// To convert result to Schema, apply functions ConvertToSchema.
GetSchema(schemaID string) chan ResponseErr
// Delete schema by Id.
DeleteSchema(schemaID string) chan SuccessErr
}
func NewSchemaDeviceHTTPService ¶
func NewSchemaDeviceHTTPService(ClientHTTP ClientHTTP) SchemaDeviceService
func NewSchemaDeviceService ¶
func NewSchemaDeviceService(ClientWS ClientWS) SchemaDeviceService
type Subscriber ¶
type Subscriber struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
TTL int32 `json:"ttl,omitempty"`
Tags []string `json:"tags,omitempty"`
DeviceTopics []DeviceTopic `json:"device_topics,omitempty"`
DeviceCreated bool `json:"device_created,omitempty"`
GatewayTopics []string `json:"gateway_topics,omitempty"`
GatewayCreated bool `json:"gateway_created,omitempty"`
Webhooks []Webhook `json:"webhooks,omitempty"`
ExpireTime int64 `json:"expire_time,omitempty"`
}
func ConvertToSubscriber ¶
func ConvertToSubscriber(src interface{}) *Subscriber
func ConvertToSubscribers ¶
func ConvertToSubscribers(src interface{}) []*Subscriber
type SubscriberService ¶
type SubscriberService interface {
// Get all subscribers default max elements 200.
// offset
// limit -1 illimited, 0 default 200, otherwise # elements
// format "id", "short", "full"
// params optional example map[string]interface{}{
// "sort-field" : "name",
// "sort-asc" : true,
// }
// To convert result to []*Subscriber, apply function ConvertToSubscribers.
GetSubscribers(offset int, limit int, format string, params map[string]interface{}) chan ResponseErr
// Get subscribers count.
GetSubscribersCount() chan CountErr
// Create subscriber .
// subscription see Subscriber struct.
// subscriberID if empty create it otherwise if exist update it otherwise create it
CreateSubscriber(subscription interface{}, subscriberID string) chan SuccessErr
// Update subscriber .
// subscriberID subscriber identifier.
// data see Subscriber struct.
UpdateSubscriber(subscriberID string, data interface{}) chan SuccessErr
// Get subscriber by Id.
// To convert result to Subscriber, apply functions ConvertToSubscriber.
GetSubscriber(schemaID string) chan ResponseErr
// Delete subscriber by Id.
DeleteSubscriber(schemaID string) chan SuccessErr
}
func NewSubscriberHTTPService ¶
func NewSubscriberHTTPService(ClientHTTP ClientHTTP) SubscriberService
func NewSubscriberService ¶
func NewSubscriberService(ClientWS ClientWS) SubscriberService
type SuccessErr ¶
type SuccessErr struct {
Data *SuccessResponse
Err *ResponseError
}
type SuccessResponse ¶
type SuccessResponse struct {
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
}
func ConvertToSuccessResponse ¶
func ConvertToSuccessResponse(src interface{}) *SuccessResponse
type Webhook ¶
type Webhook struct {
URL string `json:"url,omitempty"`
Headers map[string]interface{} `json:"headers,omitempty"`
Credential *Credential `json:"credential,omitempty"`
}
func ConvertToWebhook ¶
func ConvertToWebhook(src interface{}) *Webhook
Source Files
¶
Click to show internal directories.
Click to hide internal directories.