Documentation ¶
Index ¶
- Constants
- func DefaultClientOptions() *models.ClientOptions
- func FromJSON(raw []byte, i interface{}) error
- func LoadModelFromFile(src string, m interface{}) error
- func LoadModelFromString(json string, m interface{}) error
- func ToJSON(i interface{}) ([]byte, error)
- type Action
- type Admin
- type App
- func (i *App) Create(app *models.App) error
- func (i *App) Delete(app *models.App) error
- func (i *App) DeleteByID(id string) error
- func (i *App) GetClient() models.Client
- func (i *App) GetConfig() models.Config
- func (i *App) List() (*models.AppPager, error)
- func (i *App) Load(ID string) (*models.App, error)
- func (i *App) NewApp() *models.App
- func (i *App) NewAppQuery() *models.AppQuery
- func (i *App) Search(q *models.AppQuery) (*models.AppPager, error)
- func (i *App) Update(app *models.App) error
- type Auth
- type BrokerConnection
- type Config
- type DefaultClient
- func (c *DefaultClient) Delete(url string, opts *models.ClientOptions) error
- func (c *DefaultClient) FromJSON(raw []byte, i interface{}) error
- func (c *DefaultClient) Get(url string, opts *models.ClientOptions) ([]byte, error)
- func (c *DefaultClient) GetBrokerClient() (mqtt.Client, error)
- func (c *DefaultClient) GetClient() models.Client
- func (c *DefaultClient) GetConfig() *Config
- func (c *DefaultClient) Post(url string, json interface{}, opts *models.ClientOptions) ([]byte, error)
- func (c *DefaultClient) Put(url string, json interface{}, opts *models.ClientOptions) ([]byte, error)
- func (c *DefaultClient) Subscribe(topic string, cb func(event models.Payload)) error
- func (c *DefaultClient) ToJSON(i interface{}) ([]byte, error)
- func (c *DefaultClient) Unsubscribe(topic string, cb func(event models.Payload)) error
- type GenericPermission
- type Inventory
- func (i *Inventory) Create(dev *models.Device) error
- func (i *Inventory) Delete(dev *models.Device) error
- func (i *Inventory) DeleteByID(id string) error
- func (i *Inventory) GetClient() models.Client
- func (i *Inventory) GetConfig() models.Config
- func (i *Inventory) List() (*models.DevicePager, error)
- func (i *Inventory) Load(ID string) (*models.Device, error)
- func (i *Inventory) NewDevice() *models.Device
- func (i *Inventory) NewDeviceFromFile(src string) (*models.Device, error)
- func (i *Inventory) NewDeviceQuery() *models.DeviceQuery
- func (i *Inventory) Permission() Permission
- func (i *Inventory) Search(q *models.DeviceQuery) (*models.DevicePager, error)
- func (i *Inventory) Update(dev *models.Device) error
- type Permission
- type Profile
- type Raptor
- func (r *Raptor) Action() *Action
- func (r *Raptor) Admin() *Admin
- func (r *Raptor) App() *App
- func (r *Raptor) Auth() *Auth
- func (r *Raptor) GetClient() models.Client
- func (r *Raptor) GetConfig() *Config
- func (r *Raptor) Inventory() *Inventory
- func (r *Raptor) LoadModelFromFile(src string, m interface{}) error
- func (r *Raptor) LoadModelFromString(src string, m interface{}) error
- func (r *Raptor) Profile() *Profile
- func (r *Raptor) SetConfig(config *Config) error
- func (r *Raptor) SetCredentials(username string, password string) error
- func (r *Raptor) SetToken(token string) error
- func (r *Raptor) Stream() *Stream
- func (r *Raptor) Tree() *Tree
- type Stream
- func (s *Stream) Delete(stream *models.Stream) error
- func (s *Stream) GetClient() models.Client
- func (s *Stream) GetConfig() models.Config
- func (s *Stream) LastUpdate(stream *models.Stream) (*models.Record, error)
- func (s *Stream) Pull(stream *models.Stream, offset int, size int) ([]models.Record, error)
- func (s *Stream) Push(r *models.Record) error
- func (s *Stream) Search(stream *models.Stream, q *models.DataQuery) ([]models.Record, error)
- type SubjectType
- type Token
- func (s *Token) Create(token *models.Token) error
- func (s *Token) Delete(token *models.Token) error
- func (s *Token) GetClient() models.Client
- func (s *Token) GetConfig() models.Config
- func (s *Token) List() ([]models.Token, error)
- func (s *Token) ListByID(uuid string) ([]models.Token, error)
- func (s *Token) Permission() Permission
- func (s *Token) Read(id int) (*models.Token, error)
- func (s *Token) Update(token *models.Token) error
- type Tree
- func (s *Tree) Add(node *models.TreeNode, childs []models.TreeNode) error
- func (s *Tree) Children(node *models.TreeNode) (*models.TreeNode, error)
- func (s *Tree) Create(node *models.TreeNode) (*models.TreeNode, error)
- func (s *Tree) Delete(node *models.TreeNode) error
- func (s *Tree) GetClient() models.Client
- func (s *Tree) GetConfig() models.Config
- func (s *Tree) List() ([]models.TreeNode, error)
- func (s *Tree) Permission() Permission
- func (s *Tree) Tree(node *models.TreeNode) (*models.TreeNode, error)
- type User
- func (s *User) Create(user *models.User) error
- func (s *User) Delete(user *models.User) error
- func (s *User) GetClient() models.Client
- func (s *User) GetConfig() models.Config
- func (s *User) List() ([]models.User, error)
- func (s *User) Me() (*models.User, error)
- func (s *User) Read(id string) (*models.User, error)
- func (s *User) Update(user *models.User) error
Constants ¶
const ( //SubjectTypeDevice device type subject SubjectTypeDevice SubjectType = "device" //SubjectTypeToken token type subject SubjectTypeToken = "token" //SubjectTypeTreeNode tree node type subject SubjectTypeTreeNode = "tree" )
const ( STREAM_LIST string = "/stream/%s/%s" STREAM_PUSH = STREAM_LIST STREAM_LAST_UPDATE = STREAM_PUSH + "/lastUpdate" STREAM_PULL = STREAM_PUSH STREAM_SEARCH = STREAM_PUSH ACTION_INVOKE = "/action/%s/%s" ACTION_STATUS = ACTION_INVOKE PERMISSION_CHECK = "/auth/check" LOGIN = "/auth/login" LOGOUT = LOGIN REFRESH_TOKEN = "/auth/refresh" USER_CREATE = "/auth/user" USER_LIST = USER_CREATE USER_GET = USER_CREATE + "/%s" USER_IMPERSONATE = USER_GET + "/impersonate" USER_UPDATE = USER_GET USER_DELETE = USER_GET USER_GET_ME = "/auth/me" USER_UPDATE_ME = USER_GET_ME TOKEN_CREATE = "/auth/token" TOKEN_UPDATE = TOKEN_CREATE + "/%s" TOKEN_DELETE = TOKEN_UPDATE TOKEN_GET = TOKEN_UPDATE TOKEN_LIST = TOKEN_CREATE + "?uuid=%s" ROLE_CREATE = "/auth/role" ROLE_UPDATE = TOKEN_CREATE + "/%s" ROLE_DELETE = TOKEN_UPDATE ROLE_LIST = TOKEN_CREATE PROFILE_GET_ALL = "/profile/%s" PROFILE_GET = PROFILE_GET_ALL + "/%s" PROFILE_SET = PROFILE_GET PREFERENCES_DELETE = PROFILE_GET PERMISSION_GET = "/auth/permission/%s/%s" PERMISSION_BY_USER = PERMISSION_GET + "/%s" PERMISSION_SET = PERMISSION_GET TOKEN_PERMISSION_GET = "/auth/permission/token/%s" TOKEN_PERMISSION_BY_USER = TOKEN_PERMISSION_GET + "/%s" TOKEN_PERMISSION_SET = TOKEN_PERMISSION_GET INVENTORY_LIST = "/inventory/" INVENTORY_SEARCH = INVENTORY_LIST + "search" INVENTORY_CREATE = INVENTORY_LIST INVENTORY_UPDATE = INVENTORY_LIST + "%s" INVENTORY_LOAD = INVENTORY_UPDATE INVENTORY_DELETE = INVENTORY_UPDATE TREE_LIST = "/tree/" TREE_CREATE = TREE_LIST TREE_GET = TREE_LIST + "%s" TREE_CHILDREN = TREE_GET + "/children" TREE_ADD = TREE_GET TREE_REMOVE = TREE_GET TREE_REMOVE_TREE = TREE_GET + "tree" APP_LIST = "/app/" APP_CREATE = APP_LIST APP_SEARCH = APP_LIST + "/search" APP_GET = APP_LIST + "%s" APP_UPDATE = APP_GET APP_DELETE = APP_GET )
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() *models.ClientOptions
DefaultClientOptions create default client options
func LoadModelFromFile ¶
LoadModelFromFile load a model from a JSON file
func LoadModelFromString ¶
LoadModelFromString load a config from a JSON string
Types ¶
type Action ¶
type Action struct {
Raptor *Raptor
}
Action API client
type Admin ¶
type Admin struct { Raptor *Raptor // contains filtered or unexported fields }
Admin API client
type App ¶
type App struct {
Raptor *Raptor
}
App API client
func (*App) NewAppQuery ¶
NewAppQuery return a new AppQuery instance
type Auth ¶
type Auth struct { Raptor *Raptor // contains filtered or unexported fields }
Auth API client
type BrokerConnection ¶
type BrokerConnection struct {
// contains filtered or unexported fields
}
BrokerConnection track connection status to the broker
type Config ¶
type Config struct { URL string `json:"url"` Username string `json:"username"` Password string `json:"password"` Token string `json:"token"` }
Config a client configuration
func NewConfigFromFile ¶
NewConfigFromFile load a config from a JSON file
func NewConfigFromString ¶
NewConfigFromString load a config from a JSON string
type DefaultClient ¶
type DefaultClient struct { Raptor *Raptor // contains filtered or unexported fields }
DefaultClient IClient default implementation
func NewDefaultClient ¶
func NewDefaultClient(c *Raptor) *DefaultClient
NewDefaultClient initialize a default client
func (*DefaultClient) Delete ¶
func (c *DefaultClient) Delete(url string, opts *models.ClientOptions) error
Delete request
func (*DefaultClient) FromJSON ¶
func (c *DefaultClient) FromJSON(raw []byte, i interface{}) error
FromJSON convert a raw value to a model
func (*DefaultClient) Get ¶
func (c *DefaultClient) Get(url string, opts *models.ClientOptions) ([]byte, error)
Get request
func (*DefaultClient) GetBrokerClient ¶
func (c *DefaultClient) GetBrokerClient() (mqtt.Client, error)
GetBrokerClient return a MQTT client
func (*DefaultClient) GetClient ¶
func (c *DefaultClient) GetClient() models.Client
GetClient return a client instance
func (*DefaultClient) GetConfig ¶
func (c *DefaultClient) GetConfig() *Config
GetConfig return the configuration
func (*DefaultClient) Post ¶
func (c *DefaultClient) Post(url string, json interface{}, opts *models.ClientOptions) ([]byte, error)
Post request
func (*DefaultClient) Put ¶
func (c *DefaultClient) Put(url string, json interface{}, opts *models.ClientOptions) ([]byte, error)
Put request
func (*DefaultClient) Subscribe ¶
func (c *DefaultClient) Subscribe(topic string, cb func(event models.Payload)) error
Subscribe to topic
func (*DefaultClient) ToJSON ¶
func (c *DefaultClient) ToJSON(i interface{}) ([]byte, error)
ToJSON convert the model to JSON string
func (*DefaultClient) Unsubscribe ¶
func (c *DefaultClient) Unsubscribe(topic string, cb func(event models.Payload)) error
Unsubscribe from topic
type GenericPermission ¶
type GenericPermission struct { Raptor *Raptor // contains filtered or unexported fields }
GenericPermission API client abstract per subject ACL permission management
func (*GenericPermission) Get ¶
func (s *GenericPermission) Get(subjectID int) ([]string, error)
Get the available device permissions
func (*GenericPermission) GetClient ¶
func (s *GenericPermission) GetClient() models.Client
GetClient return a client instance
func (*GenericPermission) GetConfig ¶
func (s *GenericPermission) GetConfig() models.Config
GetConfig return the configuration
type Inventory ¶
type Inventory struct { Raptor *Raptor // contains filtered or unexported fields }
Inventory API client
func CreateInventory ¶
CreateInventory instantiate a new API client
func (*Inventory) DeleteByID ¶
DeleteByID a device by ID
func (*Inventory) List ¶
func (i *Inventory) List() (*models.DevicePager, error)
List devices accessible by an user
func (*Inventory) NewDeviceFromFile ¶
NewDeviceFromFile load a Device definition from a file
func (*Inventory) NewDeviceQuery ¶
func (i *Inventory) NewDeviceQuery() *models.DeviceQuery
NewDeviceQuery return a new DeviceQuery instance
func (*Inventory) Permission ¶
func (i *Inventory) Permission() Permission
Permission return the Permission API
func (*Inventory) Search ¶
func (i *Inventory) Search(q *models.DeviceQuery) (*models.DevicePager, error)
Search for devices
type Permission ¶
type Permission interface { GetConfig() models.Config GetClient() models.Client Get(subjectID int) ([]string, error) Set(subjectID int, userID string, permissions []string) ([]string, error) }
Permission API client interface
func CreateDevicePermission ¶
func CreateDevicePermission(r *Raptor) Permission
CreateDevicePermission instantiate a new API client
func CreatePermission ¶
func CreatePermission(r *Raptor, subjectType SubjectType) Permission
CreatePermission instantiate a new API client specifying a subject
func CreateTokenPermission ¶
func CreateTokenPermission(r *Raptor) Permission
CreateTokenPermission instantiate a new API client
func CreateTreeNodePermission ¶
func CreateTreeNodePermission(r *Raptor) Permission
CreateTreeNodePermission instantiate a new API client
type Profile ¶
type Profile struct {
Raptor *Raptor
}
Profile API client
func CreateProfile ¶
CreateProfile instantiate a new API client
type Raptor ¶
type Raptor struct {
// contains filtered or unexported fields
}
Raptor the SDK API wrapper
func NewFromConfig ¶
NewFromConfig create a new Raptor instance from a provided Config
func NewFromCredentials ¶
NewFromCredentials create a new Raptor instance using username & password authentication
func NewFromToken ¶
NewFromToken create a new Raptor instance using token authentication
func (*Raptor) LoadModelFromFile ¶
LoadModelFromFile load a model from a JSON file
func (*Raptor) LoadModelFromString ¶
LoadModelFromString load a config from a JSON string
func (*Raptor) SetCredentials ¶
SetCredentials set username and password
type Stream ¶
type Stream struct {
Raptor *Raptor
}
Stream API client
func (*Stream) LastUpdate ¶
LastUpdate fetch the last record stored
type Token ¶
type Token struct { Raptor *Raptor // contains filtered or unexported fields }
Token API client
func (*Token) Permission ¶
func (s *Token) Permission() Permission
Permission return the Permission API
type Tree ¶
type Tree struct { Raptor *Raptor // contains filtered or unexported fields }
Tree API client
func (*Tree) Permission ¶
func (s *Tree) Permission() Permission
Permission return the Permission API