Documentation ¶
Overview ¶
Golang client for the creatordev.io deviceserver REST API.
Index ¶
- Variables
- func ParseVerify(serialized []byte, signingKey interface{}) ([]byte, error)
- func TokenFromPSK(psk string, orgID int) (token string, err error)
- type AccessKey
- type AccessKeys
- type Client
- type Clients
- type EntryPoint
- type Error
- type JwtSigner
- type OAuthToken
- type ObjectDefinition
- type ObjectDefinitionProperties
- type ObjectDefinitionProperty
- type ObjectDefinitionRegistry
- type ObjectInstance
- type ObjectInstances
- type ObjectType
- type ObjectTypes
- type OrgClaim
- type PageInfo
- type RESTClient
- func (d *RESTClient) Authenticate(credentials *AccessKey) error
- func (d *RESTClient) Close()
- func (d *RESTClient) CreateAccessKey(name string) (*AccessKey, error)
- func (d *RESTClient) Delete(endpoint string) error
- func (d *RESTClient) DeleteAccessKey(key *AccessKey) error
- func (d *RESTClient) DeleteSelf(links *h.Links) error
- func (d *RESTClient) GetAccessKeys(previous *AccessKeys) (*AccessKeys, error)
- func (d *RESTClient) GetClients(previous *Clients) (*Clients, error)
- func (d *RESTClient) GetObjectInstances(o *ObjectType) (*ObjectInstances, error)
- func (d *RESTClient) GetObjectTypes(c *Client) (*ObjectTypes, error)
- func (d *RESTClient) GetSubscriptions(endpoint string, previous *Subscriptions) (*Subscriptions, error)
- func (d *RESTClient) HATEOAS() *h.Client
- func (d *RESTClient) RefreshAuth(refreshToken string) error
- func (d *RESTClient) SetBearerToken(token string)
- func (d *RESTClient) Subscribe(endpoint string, req *SubscriptionRequest, resp *SubscriptionResponse) error
- func (d *RESTClient) Unsubscribe(subscription *SubscriptionResponse) error
- type SubscriptionAttributes
- type SubscriptionRequest
- type SubscriptionResponse
- type Subscriptions
- type Webhook
- type WebhookItem
Constants ¶
This section is empty.
Variables ¶
var (
// ErrorInvalidKeyName can be sent in response to CreateAccessKey
ErrorInvalidKeyName = "Invalid key name"
)
Functions ¶
func ParseVerify ¶
ParseVerify performs signature validation and returns byte string
Types ¶
type AccessKeys ¶
type EntryPoint ¶
type JwtSigner ¶
type JwtSigner struct {
// contains filtered or unexported fields
}
JwtSigner is the main object for simplified JWT operations
func (*JwtSigner) MarshallSignSerialize ¶
MarshallSignSerialize returns a compacted serialised JWT from a claims structure
type OAuthToken ¶
type ObjectDefinition ¶
type ObjectDefinition struct { ObjectDefinitionID string `json:"ObjectDefinitionID"` ObjectID string `json:"ObjectID"` Name string `json:"Name"` MIMEType string `json:"MIMEType"` Description string `json:"Description"` SerialisationName string `json:"SerialisationName"` Singleton bool `json:"Singleton"` Properties ObjectDefinitionProperties `json:"Properties"` Links hateoas.Links `json:"Links"` }
type ObjectDefinitionProperties ¶
type ObjectDefinitionProperties []ObjectDefinitionProperty
func (ObjectDefinitionProperties) Get ¶
func (p ObjectDefinitionProperties) Get(nameOrID string) *ObjectDefinitionProperty
func (ObjectDefinitionProperties) String ¶
func (p ObjectDefinitionProperties) String() string
type ObjectDefinitionProperty ¶
type ObjectDefinitionProperty struct { PropertyDefinitionID string `json:"PropertyDefinitionID"` PropertyID string `json:"PropertyID"` Name string `json:"Name"` Description string `json:"Description"` DataType string `json:"DataType"` Units string `json:"Units"` IsCollection bool `json:"IsCollection"` IsMandatory bool `json:"IsMandatory"` Access string `json:"Access"` SerialisationName string `json:"SerialisationName"` }
type ObjectDefinitionRegistry ¶
type ObjectDefinitionRegistry struct {
// contains filtered or unexported fields
}
func CreateObjectDefinitionRegistry ¶
func CreateObjectDefinitionRegistry() *ObjectDefinitionRegistry
func (*ObjectDefinitionRegistry) GetByHref ¶
func (r *ObjectDefinitionRegistry) GetByHref(href string) *ObjectDefinition
func (*ObjectDefinitionRegistry) GetByID ¶
func (r *ObjectDefinitionRegistry) GetByID(id int) *ObjectDefinition
func (*ObjectDefinitionRegistry) Set ¶
func (r *ObjectDefinitionRegistry) Set(href string, def *ObjectDefinition)
type ObjectInstance ¶
type ObjectInstance map[string]interface{}
func (ObjectInstance) InstanceID ¶
func (i ObjectInstance) InstanceID() int
func (ObjectInstance) Links ¶
func (i ObjectInstance) Links() *hateoas.Links
type ObjectInstances ¶
type ObjectInstances struct { // see https://github.com/CreatorDev/DeviceServer/issues/25 // PageInfo PageInfo `json:"PageInfo"` Items []ObjectInstance `json:"Items"` Links hateoas.Links `json:"Links"` }
type ObjectType ¶
type ObjectTypes ¶
type ObjectTypes struct { PageInfo PageInfo `json:"PageInfo"` Items []ObjectType `json:"Items"` }
type RESTClient ¶
type RESTClient struct {
// contains filtered or unexported fields
}
Client is the main object for interacting with the deviceserver
func Create ¶
func Create(hclient *h.Client) (*RESTClient, error)
Create constructs a deviceserver client from a provided hateoas client. If you want logging/caching etc, you should set those options during hateoas client initialisation
func (*RESTClient) Authenticate ¶
func (d *RESTClient) Authenticate(credentials *AccessKey) error
Authenticate uses the provided key/secret to obtain an access_token/refresh_token
func (*RESTClient) CreateAccessKey ¶
func (d *RESTClient) CreateAccessKey(name string) (*AccessKey, error)
CreateAccessKey does what it says on the tin. The client should already be authenticated somehow, by calling either Authenticate/RefreshAuth/SetBearerToken
func (*RESTClient) Delete ¶
func (d *RESTClient) Delete(endpoint string) error
Delete performs DELETE on the specified resource
func (*RESTClient) DeleteAccessKey ¶
func (d *RESTClient) DeleteAccessKey(key *AccessKey) error
DeleteAccessKey does what it says on the tin
func (*RESTClient) DeleteSelf ¶
func (d *RESTClient) DeleteSelf(links *h.Links) error
DeleteSelf will find the "self" link and DELETE that
func (*RESTClient) GetAccessKeys ¶
func (d *RESTClient) GetAccessKeys(previous *AccessKeys) (*AccessKeys, error)
GetAccessKeys returns the list of accesskeys in this organisation
func (*RESTClient) GetClients ¶
func (d *RESTClient) GetClients(previous *Clients) (*Clients, error)
func (*RESTClient) GetObjectInstances ¶
func (d *RESTClient) GetObjectInstances(o *ObjectType) (*ObjectInstances, error)
func (*RESTClient) GetObjectTypes ¶
func (d *RESTClient) GetObjectTypes(c *Client) (*ObjectTypes, error)
func (*RESTClient) GetSubscriptions ¶
func (d *RESTClient) GetSubscriptions(endpoint string, previous *Subscriptions) (*Subscriptions, error)
func (*RESTClient) HATEOAS ¶
func (d *RESTClient) HATEOAS() *h.Client
HATEOAS exposes the underlying hateoas client so that you can use that where necessary. Shouldn't be needed often.
func (*RESTClient) RefreshAuth ¶
func (d *RESTClient) RefreshAuth(refreshToken string) error
RefreshAuth uses the provided refresh_token obtain an access_token/refresh_token
func (*RESTClient) SetBearerToken ¶
func (d *RESTClient) SetBearerToken(token string)
SetBearerToken sets the Authorization header on the underlying hateoas client
func (*RESTClient) Subscribe ¶
func (d *RESTClient) Subscribe(endpoint string, req *SubscriptionRequest, resp *SubscriptionResponse) error
Subscribe sets up webhook subscriptions, i.e. COAP observations. The `endpoint` can be - "" (=entrypoint) to subscribe to ClientConnected/ClientDisconnected events - a specific resource "self" URL to subscribe to observations on that resource
func (*RESTClient) Unsubscribe ¶
func (d *RESTClient) Unsubscribe(subscription *SubscriptionResponse) error
type SubscriptionAttributes ¶
type SubscriptionRequest ¶
type SubscriptionRequest struct { SubscriptionType string `json:"SubscriptionType"` URL string `json:"Url"` AcceptContentType string `json:"AcceptContentType,omitempty"` Property string `json:"Property,omitempty"` Attributes *SubscriptionAttributes `json:"Attributes,omitempty"` Links hateoas.Links `json:"Links"` }
type SubscriptionResponse ¶
type Subscriptions ¶
type Subscriptions struct { PageInfo PageInfo `json:"PageInfo"` Items []SubscriptionRequest `json:"Items"` Links hateoas.Links `json:"Links"` }
type Webhook ¶
type Webhook struct {
Items []WebhookItem `json:"Items"`
}