import "github.com/CreatorKit/go-deviceserver-client"
Golang client for the creatordev.io deviceserver REST API.
- 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
- func Create(hclient *h.Client) (*Client, error)
- func (d *Client) Authenticate(credentials *AccessKey) error
- func (d *Client) Close()
- func (d *Client) CreateAccessKey(name string) (*AccessKey, error)
- func (d *Client) Delete(endpoint string) error
- func (d *Client) DeleteAccessKey(key *AccessKey) error
- func (d *Client) DeleteSelf(links *h.Links) error
- func (d *Client) GetAccessKeys(previous *AccessKeys) (*AccessKeys, error)
- func (d *Client) HATEOAS() *h.Client
- func (d *Client) RefreshAuth(refreshToken string) error
- func (d *Client) SetBearerToken(token string)
- func (d *Client) Subscribe(endpoint string, req *SubscriptionRequest, resp *SubscriptionResponse) error
- func (d *Client) Unsubscribe(subscription *SubscriptionResponse) error
- type EntryPoint
- type Error
- type JwtSigner
- type OAuthToken
- type OrgClaim
- type PageInfo
- type SubscriptionRequest
- type SubscriptionResponse
deviceserver.go jwt.go struct.go
var (
// ErrorInvalidKeyName can be sent in response to CreateAccessKey
ErrorInvalidKeyName = errors.New("Invalid key name")
)
func ParseVerify(serialized []byte, signingKey interface{}) ([]byte, error)
ParseVerify performs signature validation and returns byte string
func TokenFromPSK(psk string, orgID int) (token string, err error)
TokenFromPSK generates an JWT with signed OrgClaim
type AccessKey struct {
Links hateoas.Links `json:"Links"`
Name string `json:"Name,omitempty"`
Key string `json:"Key,omitempty"`
Secret string `json:"Secret,omitempty"`
}
type AccessKeys struct {
PageInfo PageInfo `json:"PageInfo"`
Items []AccessKey `json:"Items"`
Links hateoas.Links `json:"Links"`
}
type Client struct {
// contains filtered or unexported fields
}
Client is the main object for interacting with the deviceserver
func Create(hclient *h.Client) (*Client, 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 (*Client) Authenticate
func (d *Client) Authenticate(credentials *AccessKey) error
Authenticate uses the provided key/secret to obtain an access_token/refresh_token
func (d *Client) Close()
Close will clean things up as required
func (*Client) CreateAccessKey
func (d *Client) 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 (d *Client) Delete(endpoint string) error
Delete performs DELETE on the specified resource
func (*Client) DeleteAccessKey
func (d *Client) DeleteAccessKey(key *AccessKey) error
DeleteAccessKey does what it says on the tin
func (*Client) DeleteSelf
func (d *Client) DeleteSelf(links *h.Links) error
DeleteSelf will find the "self" link and DELETE that
func (*Client) GetAccessKeys
func (d *Client) GetAccessKeys(previous *AccessKeys) (*AccessKeys, error)
GetAccessKeys returns the list of accesskeys in this organisation
func (d *Client) HATEOAS() *h.Client
HATEOAS exposes the underlying hateoas client so that you can use that where necessary. Shouldn't be needed often.
func (*Client) RefreshAuth
func (d *Client) RefreshAuth(refreshToken string) error
RefreshAuth uses the provided refresh_token obtain an access_token/refresh_token
func (*Client) SetBearerToken
func (d *Client) SetBearerToken(token string)
SetBearerToken sets the Authorization header on the underlying hateoas client
func (d *Client) 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 (*Client) Unsubscribe
func (d *Client) Unsubscribe(subscription *SubscriptionResponse) error
type EntryPoint struct {
Links hateoas.Links `json:"Links"`
}
type Error struct {
ErrorCode string `json:"ErrorCode"`
ErrorMessage string `json:"ErrorMessage"`
ErrorDetails string `json:"ErrorDetails"`
}
type JwtSigner struct {
// contains filtered or unexported fields
}
JwtSigner is the main object for simplified JWT operations
func (s *JwtSigner) Init(alg jose.SignatureAlgorithm, signingKey interface{}) error
Init creates JOSE signer
func (*JwtSigner) MarshallSignSerialize
func (s *JwtSigner) MarshallSignSerialize(in interface{}) (string, error)
MarshallSignSerialize returns a compacted serialised JWT from a claims structure
type OAuthToken struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
RefreshToken string `json:"refresh_token"`
}
type OrgClaim struct {
OrgID int `json:"OrgID"`
Exp int74 `json:"exp"`
}
type PageInfo struct {
TotalCount int `json:"TotalCount"`
ItemsCount int `json:"ItemsCount"`
StartIndex int `json:"StartIndex"`
Links hateoas.Links `json:"Links,omitempty"`
}
type SubscriptionRequest struct {
SubscriptionType string `json:"SubscriptionType"`
URL string `json:"Url"`
AcceptContentType string `json:"AcceptContentType,omitempty"`
Property string `json:"Property,omitempty"`
Attributes *struct {
Pmin string `json:"Pmin,omitempty"`
Pmax string `json:"Pmax,omitempty"`
Step string `json:"Step,omitempty"`
LessThan string `json:"LessThan,omitempty"`
GreaterThan string `json:"GreaterThan,omitempty"`
} `json:"Attributes,omitempty"`
}
type SubscriptionResponse struct {
ID string `json:"ID"`
Links hateoas.Links `json:"Links"`
}
Generated by godoc12md