Documentation
¶
Index ¶
- func ContentTypeToMediaType(contentType string) (message.MediaType, error)
- func DecodeContentWithCodec(codec coap.Codec, contentType string, data []byte, response interface{}) error
- type ApplicationCallback
- type Client
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) FactoryReset(ctx context.Context, deviceID string) error
- func (c *Client) GetAccessTokenURL(ctx context.Context) (string, error)
- func (c *Client) GetDevice(ctx context.Context, deviceID string) (DeviceDetails, error)
- func (c *Client) GetDevices(ctx context.Context, opts ...GetDevicesOption) (map[string]DeviceDetails, error)
- func (c *Client) GetDevicesIterator(ctx context.Context, deviceIDs []string, resourceTypes ...string) *kitNetGrpc.Iterator
- func (c *Client) GetDevicesViaCallback(ctx context.Context, deviceIDs, resourceTypes []string, ...) error
- func (c *Client) GetResource(ctx context.Context, deviceID string, href string, response interface{}, ...) error
- func (c *Client) GetResourceLinksIterator(ctx context.Context, deviceIDs []string, resourceTypes ...string) *kitNetGrpc.Iterator
- func (c *Client) GetResourceLinksViaCallback(ctx context.Context, deviceIDs, resourceTypes []string, ...) error
- func (c *Client) GrpcGatewayClient() pb.GrpcGatewayClient
- func (c *Client) NewDeviceSubscription(ctx context.Context, deviceID string, handle SubscriptionHandler) (*DeviceSubscription, error)
- func (c *Client) NewDevicesSubscription(ctx context.Context, handle SubscriptionHandler) (*DevicesSubscription, error)
- func (c *Client) NewResourceSubscription(ctx context.Context, resourceID pb.ResourceId, handle SubscriptionHandler) (*ResourceSubscription, error)
- func (c *Client) ObserveDeviceResources(ctx context.Context, deviceID string, ...) (string, error)
- func (c *Client) ObserveDevices(ctx context.Context, handler DevicesObservationHandler) (string, error)
- func (c *Client) ObserveResource(ctx context.Context, deviceID string, href string, ...) (observationID string, _ error)
- func (c *Client) Reboot(ctx context.Context, deviceID string) error
- func (c *Client) RetrieveResourcesByResourceIDs(ctx context.Context, resourceIDsCallbacks ...ResourceIDCallback) error
- func (c *Client) RetrieveResourcesByType(ctx context.Context, deviceIDs []string, typeCallbacks ...TypeCallback) error
- func (c *Client) RetrieveResourcesIterator(ctx context.Context, resourceIDs []*pb.ResourceId, deviceIDs []string, ...) *kitNetGrpc.Iterator
- func (c *Client) StopObservingDeviceResources(ctx context.Context, observationID string) error
- func (c *Client) StopObservingDevices(ctx context.Context, observationID string) error
- func (c *Client) StopObservingResource(ctx context.Context, observationID string) error
- func (c *Client) UpdateResource(ctx context.Context, deviceID string, href string, request interface{}, ...) error
- type CloseErrorHandler
- type CodecOption
- type Config
- type DeviceDetails
- type DeviceIDsOption
- type DeviceOfflineHandler
- type DeviceOnlineHandler
- type DeviceRegisteredHandler
- type DeviceResourcesObservationEvent
- type DeviceResourcesObservationEvent_type
- type DeviceResourcesObservationHandler
- type DeviceSubscription
- type DeviceUnregisteredHandler
- type DevicesObservationEvent
- type DevicesObservationEvent_type
- type DevicesObservationHandler
- type DevicesSubscription
- type GetDevicesOption
- type GetOption
- type ObserveOption
- type OnboardOption
- type ResourceContentChangedHandler
- type ResourceIDCallback
- type ResourceInterfaceOption
- type ResourcePublishedHandler
- type ResourceRetrievePendingHandler
- type ResourceRetrievedHandler
- type ResourceSubscription
- type ResourceTypesOption
- type ResourceUnpublishedHandler
- type ResourceUpdatePendingHandler
- type ResourceUpdatedHandler
- type SkipShadowOption
- type SubscriptionHandler
- type TypeCallback
- type UpdateOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentTypeToMediaType ¶
Types ¶
type ApplicationCallback ¶
type ApplicationCallback interface {
GetRootCertificateAuthorities() ([]*x509.Certificate, error)
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for interacting with the client.
func NewClient ¶
func NewClient(accessTokenURL string, client pb.GrpcGatewayClient) (*Client, error)
NewClient constructs a new client client. For every call there is expected jwt token for grpc stored in context.
func NewClientFromConfig ¶
NewClientFromConfig constructs a new client client. For every call there is expected jwt token for grpc stored in context.
func (*Client) FactoryReset ¶
FactoryReset makes factory reset on device. JWT token must be stored in context for grpc call.
func (*Client) GetAccessTokenURL ¶
func (*Client) GetDevices ¶
func (c *Client) GetDevices( ctx context.Context, opts ...GetDevicesOption, ) (map[string]DeviceDetails, error)
GetDevices retrieves device details from the client.
func (*Client) GetDevicesIterator ¶
func (c *Client) GetDevicesIterator(ctx context.Context, deviceIDs []string, resourceTypes ...string) *kitNetGrpc.Iterator
GetDevicesIterator gets devices. JWT token must be stored in context for grpc call. Next queries the next resource value. Returns false when failed or having no more items. Check it.Err for errors. Usage:
for { var v MyStruct if !it.Next(ctx, &v) { break } } if it.Err != nil { }
func (*Client) GetDevicesViaCallback ¶
func (c *Client) GetDevicesViaCallback(ctx context.Context, deviceIDs, resourceTypes []string, callback func(pb.Device)) error
GetDevicesViaCallback returns devices. JWT token must be stored in context for grpc call.
func (*Client) GetResource ¶
func (c *Client) GetResource( ctx context.Context, deviceID string, href string, response interface{}, opts ...GetOption, ) error
GetResourceWithCodec retrieves content of a resource from the client.
func (*Client) GetResourceLinksIterator ¶
func (c *Client) GetResourceLinksIterator(ctx context.Context, deviceIDs []string, resourceTypes ...string) *kitNetGrpc.Iterator
GetResourceLinksIterator gets devices. JWT token must be stored in context for grpc call. Next queries the next resource value. Returns false when failed or having no more items. Check it.Err for errors. Usage:
for { var v MyStruct if !it.Next(ctx, &v) { break } } if it.Err != nil { }
func (*Client) GetResourceLinksViaCallback ¶
func (c *Client) GetResourceLinksViaCallback(ctx context.Context, deviceIDs, resourceTypes []string, callback func(*pb.ResourceLink)) error
GetResourceLinksViaCallback returns resource links of devices. JWT token must be stored in context for grpc call.
func (*Client) GrpcGatewayClient ¶
func (c *Client) GrpcGatewayClient() pb.GrpcGatewayClient
func (*Client) NewDeviceSubscription ¶
func (c *Client) NewDeviceSubscription(ctx context.Context, deviceID string, handle SubscriptionHandler) (*DeviceSubscription, error)
NewDeviceSubscription creates new devices subscriptions to listen events: resource published, resource unpublished. JWT token must be stored in context for grpc call.
func (*Client) NewDevicesSubscription ¶
func (c *Client) NewDevicesSubscription(ctx context.Context, handle SubscriptionHandler) (*DevicesSubscription, error)
NewDevicesSubscription creates new devices subscriptions to listen events: device online, device offline, device registered, device unregistered. JWT token must be stored in context for grpc call.
func (*Client) NewResourceSubscription ¶
func (c *Client) NewResourceSubscription(ctx context.Context, resourceID pb.ResourceId, handle SubscriptionHandler) (*ResourceSubscription, error)
NewResourceSubscription creates new resource content changed subscription. JWT token must be stored in context for grpc call.
func (*Client) ObserveDeviceResources ¶
func (*Client) ObserveDevices ¶
func (*Client) ObserveResource ¶
func (c *Client) ObserveResource( ctx context.Context, deviceID string, href string, handler core.ObservationHandler, opts ...ObserveOption, ) (observationID string, _ error)
func (*Client) Reboot ¶
Reboot makes reboot on device. JWT token must be stored in context for grpc call.
func (*Client) RetrieveResourcesByResourceIDs ¶
func (c *Client) RetrieveResourcesByResourceIDs( ctx context.Context, resourceIDsCallbacks ...ResourceIDCallback, ) error
RetrieveResourcesByResourceIDs gets resources contents by resourceIDs. JWT token must be stored in context for grpc call.
func (*Client) RetrieveResourcesByType ¶
func (c *Client) RetrieveResourcesByType( ctx context.Context, deviceIDs []string, typeCallbacks ...TypeCallback, ) error
RetrieveResourcesByType gets contents of resources by resource types. JWT token must be stored in context for grpc call.
func (*Client) RetrieveResourcesIterator ¶
func (c *Client) RetrieveResourcesIterator(ctx context.Context, resourceIDs []*pb.ResourceId, deviceIDs []string, resourceTypes ...string) *kitNetGrpc.Iterator
RetrieveResourcesIterator gets resources contents. JWT token must be stored in context for grpc call. Next queries the next resource value. Returns false when failed or having no more items. Check it.Err for errors. Usage:
for { var v MyStruct if !it.Next(ctx, &v) { break } } if it.Err != nil { }
func (*Client) StopObservingDeviceResources ¶
func (*Client) StopObservingDevices ¶
func (*Client) StopObservingResource ¶
func (*Client) UpdateResource ¶
func (c *Client) UpdateResource( ctx context.Context, deviceID string, href string, request interface{}, response interface{}, opts ...UpdateOption, ) error
UpdateResource updates content in OCF-CBOR format.
type CloseErrorHandler ¶
type CloseErrorHandler struct {
// contains filtered or unexported fields
}
func NewCloseErrorHandler ¶
func NewCloseErrorHandler(onClose func(), onError func(err error)) *CloseErrorHandler
func (*CloseErrorHandler) Error ¶
func (s *CloseErrorHandler) Error(err error)
func (*CloseErrorHandler) OnClose ¶
func (s *CloseErrorHandler) OnClose()
type CodecOption ¶
type CodecOption struct {
// contains filtered or unexported fields
}
func WithCodec ¶
func WithCodec(codec kitNetCoap.Codec) CodecOption
type DeviceDetails ¶
type DeviceDetails struct { // ID of the device ID string // Device basic content(oic.wk.d) of /oic/d resource. Device pb.Device // Resources list of the device resources. Resources []*pb.ResourceLink }
DeviceDetails describes a device.
type DeviceIDsOption ¶
type DeviceIDsOption struct {
// contains filtered or unexported fields
}
func WithDeviceIDs ¶
func WithDeviceIDs(deviceIDs ...string) DeviceIDsOption
type DeviceOfflineHandler ¶
type DeviceOfflineHandler = interface {
HandleDeviceOffline(ctx context.Context, val *pb.Event_DeviceOffline) error
}
DeviceOfflineHandler handler of events.
type DeviceOnlineHandler ¶
type DeviceOnlineHandler = interface {
HandleDeviceOnline(ctx context.Context, val *pb.Event_DeviceOnline) error
}
DeviceOnlineHandler handler of events.
type DeviceRegisteredHandler ¶
type DeviceRegisteredHandler = interface {
HandleDeviceRegistered(ctx context.Context, val *pb.Event_DeviceRegistered) error
}
DeviceRegisteredHandler handler of events.
type DeviceResourcesObservationEvent ¶
type DeviceResourcesObservationEvent struct { Links []*pb.ResourceLink Event DeviceResourcesObservationEvent_type }
type DeviceResourcesObservationEvent_type ¶
type DeviceResourcesObservationEvent_type uint8
const DeviceResourcesObservationEvent_ADDED DeviceResourcesObservationEvent_type = 0
const DeviceResourcesObservationEvent_REMOVED DeviceResourcesObservationEvent_type = 1
type DeviceResourcesObservationHandler ¶
type DeviceResourcesObservationHandler = interface { Handle(ctx context.Context, event DeviceResourcesObservationEvent) error OnClose() Error(err error) }
type DeviceSubscription ¶
type DeviceSubscription struct {
// contains filtered or unexported fields
}
DeviceSubscription subscription.
func NewDeviceSubscription ¶
func NewDeviceSubscription(ctx context.Context, deviceID string, closeErrorHandler SubscriptionHandler, handle interface{}, gwClient pb.GrpcGatewayClient) (*DeviceSubscription, error)
NewDeviceSubscription creates new devices subscriptions to listen events: resource published, resource unpublished. JWT token must be stored in context for grpc call.
func ToDeviceSubscription ¶
func ToDeviceSubscription(v interface{}, ok bool) (*DeviceSubscription, bool)
func (*DeviceSubscription) Cancel ¶
func (s *DeviceSubscription) Cancel() (wait func(), err error)
Cancel cancels subscription.
func (*DeviceSubscription) ID ¶
func (s *DeviceSubscription) ID() string
ID returns subscription id.
type DeviceUnregisteredHandler ¶
type DeviceUnregisteredHandler = interface {
HandleDeviceUnregistered(ctx context.Context, val *pb.Event_DeviceUnregistered) error
}
DeviceUnregisteredHandler handler of events.
type DevicesObservationEvent ¶
type DevicesObservationEvent struct { DeviceIDs []string Event DevicesObservationEvent_type }
type DevicesObservationEvent_type ¶
type DevicesObservationEvent_type uint8
const DevicesObservationEvent_OFFLINE DevicesObservationEvent_type = 1
const DevicesObservationEvent_ONLINE DevicesObservationEvent_type = 0
const DevicesObservationEvent_REGISTERED DevicesObservationEvent_type = 2
const DevicesObservationEvent_UNREGISTERED DevicesObservationEvent_type = 3
type DevicesObservationHandler ¶
type DevicesObservationHandler = interface { Handle(ctx context.Context, event DevicesObservationEvent) error OnClose() Error(err error) }
type DevicesSubscription ¶
type DevicesSubscription struct {
// contains filtered or unexported fields
}
DevicesSubscription subscription.
func NewDevicesSubscription ¶
func NewDevicesSubscription(ctx context.Context, closeErrorHandler SubscriptionHandler, handle interface{}, gwClient pb.GrpcGatewayClient) (*DevicesSubscription, error)
NewDevicesSubscription creates new devices subscriptions to listen events: device online, device offline, device registered, device unregistered. JWT token must be stored in context for grpc call.
func (*DevicesSubscription) Cancel ¶
func (s *DevicesSubscription) Cancel() (wait func(), err error)
Cancel cancels subscription.
func (*DevicesSubscription) ID ¶
func (s *DevicesSubscription) ID() string
ID returns subscription id.
type GetDevicesOption ¶
type GetDevicesOption = interface {
// contains filtered or unexported methods
}
UpdateOption option definition.
type GetOption ¶
type GetOption = interface {
// contains filtered or unexported methods
}
GetOption option definition.
type ObserveOption ¶
type ObserveOption = interface {
// contains filtered or unexported methods
}
ObserveOption option definition.
type OnboardOption ¶
type OnboardOption = func() interface{}
type ResourceContentChangedHandler ¶
type ResourceContentChangedHandler = interface {
HandleResourceContentChanged(ctx context.Context, val *pb.Event_ResourceChanged) error
}
ResourceContentChangedHandler handler of events.
type ResourceIDCallback ¶
type ResourceIDCallback struct { ResourceID *pb.ResourceId Callback func(pb.ResourceValue) }
func MakeResourceIDCallback ¶
func MakeResourceIDCallback(deviceID, href string, callback func(pb.ResourceValue)) ResourceIDCallback
type ResourceInterfaceOption ¶
type ResourceInterfaceOption struct {
// contains filtered or unexported fields
}
func WithInterface ¶
func WithInterface(resourceInterface string) ResourceInterfaceOption
WithInterface updates/gets resource with interface directly from a device.
type ResourcePublishedHandler ¶
type ResourcePublishedHandler = interface {
HandleResourcePublished(ctx context.Context, val *pb.Event_ResourcePublished) error
}
ResourcePublishedHandler handler of events.
type ResourceRetrievePendingHandler ¶
type ResourceRetrievePendingHandler = interface {
HandleResourceRetrievePending(ctx context.Context, val *pb.Event_ResourceRetrievePending) error
}
ResourceRetrievePendingHandler handler of events
type ResourceRetrievedHandler ¶
type ResourceRetrievedHandler = interface {
HandleResourceRetrieved(ctx context.Context, val *pb.Event_ResourceRetrieved) error
}
ResourceRetrievedHandler handler of events
type ResourceSubscription ¶
type ResourceSubscription struct {
// contains filtered or unexported fields
}
ResourceSubscription subscription.
func NewResourceSubscription ¶
func NewResourceSubscription(ctx context.Context, resourceID pb.ResourceId, closeErrorHandler SubscriptionHandler, handle interface{}, gwClient pb.GrpcGatewayClient) (*ResourceSubscription, error)
NewResourceSubscription creates new resource content changed subscription. JWT token must be stored in context for grpc call.
func ToResourceSubscription ¶
func ToResourceSubscription(v interface{}, ok bool) (*ResourceSubscription, bool)
func (*ResourceSubscription) Cancel ¶
func (s *ResourceSubscription) Cancel() (wait func(), err error)
Cancel cancels subscription.
func (*ResourceSubscription) ID ¶
func (s *ResourceSubscription) ID() string
ID returns subscription id.
type ResourceTypesOption ¶
type ResourceTypesOption struct {
// contains filtered or unexported fields
}
func WithResourceTypes ¶
func WithResourceTypes(resourceTypes ...string) ResourceTypesOption
type ResourceUnpublishedHandler ¶
type ResourceUnpublishedHandler = interface {
HandleResourceUnpublished(ctx context.Context, val *pb.Event_ResourceUnpublished) error
}
ResourceUnpublishedHandler handler of events.
type ResourceUpdatePendingHandler ¶
type ResourceUpdatePendingHandler = interface {
HandleResourceUpdatePending(ctx context.Context, val *pb.Event_ResourceUpdatePending) error
}
ResourceUpdatePendingHandler handler of events
type ResourceUpdatedHandler ¶
type ResourceUpdatedHandler = interface {
HandleResourceUpdated(ctx context.Context, val *pb.Event_ResourceUpdated) error
}
ResourceUpdatedHandler handler of events
type SkipShadowOption ¶
type SkipShadowOption struct { }
func WithSkipShadow ¶
func WithSkipShadow() SkipShadowOption
WithSkipShadow gets resource directly from a device without using interface for client client.
type SubscriptionHandler ¶
type SubscriptionHandler = interface { OnClose() Error(err error) }
SubscriptionHandler handler of events.
type TypeCallback ¶
type TypeCallback struct { Type string Callback func(pb.ResourceValue) }
func MakeTypeCallback ¶
func MakeTypeCallback(resourceType string, callback func(pb.ResourceValue)) TypeCallback
type UpdateOption ¶
type UpdateOption = interface {
// contains filtered or unexported methods
}
UpdateOption option definition.