things

package
v0.0.0-...-3e6e175 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2023 License: EPL-2.0 Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Topic   *protocol.Topic
	Path    string
	Payload interface{}
}

Command represents a message entity defined by the Ditto protocol for the Things group that defines the execution of a certain action. This is a special Message that is always bound to a specific Thing instance along with providing the capabilities to configure:

  • the type of the action it will signal for execution - Create, Modify, Retrieve, Delete
  • the channel it will be sent - Twin, Live
  • the entity it will affect - the whole Thing (the default), all features of the Thing (Features), a single Feature of the Thing (Feature), all attributes of the Thing (Attributes) or a single attribute of the Thing (Attribute), the Thing's policy (PolicyID) or the Thing's definition (Definition).

Note: Only one action can be configured to the command - if using the methods for configuring it - only the last one applies. Note: Only one channel can be configured to the command - if using the methods for configuring it - only the last one applies. Note: Only one entity that will b affected by the command can be configured - if using the methods for configuring it - only the last one applies.

func NewCommand

func NewCommand(thingID *model.NamespacedID) *Command

NewCommand creates a new Command instance for the defined by the provided NamespacedID Thing.

func (*Command) Attribute

func (cmd *Command) Attribute(attributePath string) *Command

Attribute configures the command to affect a specified attribute of the Thing, defined by the attributePath as JSON pointer path (https://tools.ietf.org/html/rfc6901).

func (*Command) Attributes

func (cmd *Command) Attributes() *Command

Attributes configures the command to affect the Thing's attributes.

func (*Command) Create

func (cmd *Command) Create(thing *model.Thing) *Command

Create creates a new Thing entity based on the provided information.

func (*Command) Definition

func (cmd *Command) Definition() *Command

Definition configures the command to affect the Thing's definition.

func (*Command) Delete

func (cmd *Command) Delete() *Command

Delete sets the action of the command instance accordingly.

func (*Command) Envelope

func (cmd *Command) Envelope(headerOpts ...protocol.HeaderOpt) *protocol.Envelope

Envelope generates the Ditto envelope with command's data applying all configurations and optionally all Headers provided.

func (*Command) Feature

func (cmd *Command) Feature(featureID string) *Command

Feature configures the command to affect a specified by the provided featureID feature of the Thing.

func (*Command) FeatureDefinition

func (cmd *Command) FeatureDefinition(featureID string) *Command

FeatureDefinition configures the command to affect the definition of a specified by the provided featureID feature of the Thing.

func (*Command) FeatureDesiredProperties

func (cmd *Command) FeatureDesiredProperties(featureID string) *Command

FeatureDesiredProperties configures the command to affect all desired properties of a specified by the provided featureID feature of the Thing.

func (*Command) FeatureDesiredProperty

func (cmd *Command) FeatureDesiredProperty(featureID, propertyPath string) *Command

FeatureDesiredProperty configures the command to affect a specified desired property via the provided featureID feature of the Thing and the propertyPath as JSON pointer path (https://tools.ietf.org/html/rfc6901).

func (*Command) FeatureProperties

func (cmd *Command) FeatureProperties(featureID string) *Command

FeatureProperties configures the command to affect all properties of a specified by the provided featureID feature of the Thing.

func (*Command) FeatureProperty

func (cmd *Command) FeatureProperty(featureID, propertyPath string) *Command

FeatureProperty configures the command to affect a specified property via the provided featureID feature of the Thing and the propertyPath as JSON pointer path (https://tools.ietf.org/html/rfc6901).

func (*Command) Features

func (cmd *Command) Features() *Command

Features configures the command to affect all the features of the Thing.

func (*Command) Live

func (cmd *Command) Live() *Command

Live configures the channel of the command accordingly.

func (*Command) Merge

func (cmd *Command) Merge(payload interface{}) *Command

Merge sets the action of the command instance accordingly. For all merge commands the provided partial payload data is expected to match the defined JSON merge patch format (https://tools.ietf.org/html/rfc7396). In case of conflicts with the existing thing, the value provided in the patch overwrites the existing value. Any provided nil values will be used to remove the referenced thing data.

func (*Command) Modify

func (cmd *Command) Modify(payload interface{}) *Command

Modify sets the action of the command instance accordingly. The provided payload must be the new value to be used for modification compliant with the (part of) the Thing it is to be applied to.

func (*Command) PolicyID

func (cmd *Command) PolicyID() *Command

PolicyID configures the command to affect the Thing's Policy.

func (*Command) Retrieve

func (cmd *Command) Retrieve(thingIDs ...model.NamespacedID) *Command

Retrieve sets the action of the command instance accordingly. If thingIDs are provided the response will contain the information for these Things only. Further Headers can be added via the Message method to adjust the response even more. The topic placeholder for the Thing ID's namespace and/or name can be used to perform the multiple Things request, e.g.: '_:_', '_:thing.id' are valid Thing NamespacedIDs to perform the multiple Things retrieve call.

func (*Command) Twin

func (cmd *Command) Twin() *Command

Twin configures the channel of the command accordingly.

type Event

type Event struct {
	Topic   *protocol.Topic
	Path    string
	Payload interface{}
}

Event represents a message entity defined by the Ditto protocol for the Things group that defines a notification for a change that happened. This is a special Message that is always bound to a specific Thing instance along with providing the capabilities to configure:

  • the type of the change that happened - Created, Modified, Deleted
  • the channel used for the notification - Twin, Live
  • the entity that was affected - the whole Thing (the default), all features of the Thing (Features), a single Feature of the Thing (Feature), all attributes of the Thing (Attributes) or a single attribute of the Thing (Attribute), the Thing's policy (PolicyID) or the Thing's definition (Definition).

Note: Only one change type can be configured to the event - if using the methods for configuring it - only the last one applies. Note: Only one channel can be configured to the event - if using the methods for configuring it - only the last one applies. Note: Only one entity that will b affected by the event can be configured - if using the methods for configuring it - only the last one applies.

func NewEvent

func NewEvent(thingID *model.NamespacedID) *Event

NewEvent creates a new Event instance for the defined by the provided NamespacedID Thing.

func (*Event) Attribute

func (event *Event) Attribute(attributePath string) *Event

Attribute configures the Event to notify for a change in the Thing's attribute defined by the provided attributePath as JSON pointer path (https://tools.ietf.org/html/rfc6901).

func (*Event) Attributes

func (event *Event) Attributes() *Event

Attributes configures the Event to notify for a change in the Thing's attributes.

func (*Event) Created

func (event *Event) Created(thing *model.Thing) *Event

Created configures the Event to notify for a Thing that has been created using the provided payload instance.

func (*Event) Definition

func (event *Event) Definition() *Event

Definition configures the Event to notify for a change in the Thing's definition.

func (*Event) Deleted

func (event *Event) Deleted() *Event

Deleted configures the Event to notify for a deletion of a Thing or parts of the content it holds.

func (*Event) Envelope

func (event *Event) Envelope(headerOpts ...protocol.HeaderOpt) *protocol.Envelope

Envelope generates the Ditto envelope with event's data applying all configurations and optionally all Headers provided.

func (*Event) Feature

func (event *Event) Feature(featureID string) *Event

Feature configures the Event to notify for a change in the Thing's feature defined by the provided featureID.

func (*Event) FeatureDefinition

func (event *Event) FeatureDefinition(featureID string) *Event

FeatureDefinition configures the Event to notify for a change in the Thing's feature's definition for the feature defined by the provided featureID.

func (*Event) FeatureDesiredProperties

func (event *Event) FeatureDesiredProperties(featureID string) *Event

FeatureDesiredProperties configures the Event to notify for a change in the Thing's feature's desired properties of the feature defined by the provided featureID.

func (*Event) FeatureDesiredProperty

func (event *Event) FeatureDesiredProperty(featureID, propertyPath string) *Event

FeatureDesiredProperty configures the Event to notify for a change in the Thing's feature's desired property defined by the provided featureID and propertyPath as JSON pointer path (https://tools.ietf.org/html/rfc6901).

func (*Event) FeatureProperties

func (event *Event) FeatureProperties(featureID string) *Event

FeatureProperties configures the Event to notify for a change in the Thing's feature's properties of the feature defined by the provided featureID.

func (*Event) FeatureProperty

func (event *Event) FeatureProperty(featureID, propertyPath string) *Event

FeatureProperty configures the Event to notify for a change in the Thing's feature's property defined by the provided featureID and propertyPath as JSON pointer path (https://tools.ietf.org/html/rfc6901).

func (*Event) Features

func (event *Event) Features() *Event

Features configures the Event to notify for a change in the Thing's features.

func (*Event) Live

func (event *Event) Live() *Event

Live configures the channel of the Event accordingly.

func (*Event) Merged

func (event *Event) Merged(payload interface{}) *Event

Merged configures the Event to notify for a modification with a merge patch defined by the provided payload.

func (*Event) Modified

func (event *Event) Modified(payload interface{}) *Event

Modified configures the Event to notify for a modification with a new value applied defined by the provided payload.

func (*Event) PolicyID

func (event *Event) PolicyID() *Event

PolicyID configures the Event to notify for a change in the Thing's policy.

func (*Event) Twin

func (event *Event) Twin() *Event

Twin configures the channel of the Event accordingly.

type Message

type Message struct {
	Topic                *protocol.Topic
	Subject              string
	Mailbox              string
	AddressedPartOfThing string
	Payload              interface{}
}

Message represents a message entity defined by the Ditto protocol for the Things group that defines an instant communication with the underlying device/implementation. This is a special Message that is always bound to a specific Thing instance, it's always exchanged vie the Live communication channel and it provides the capabilities to configure: - the type of the communication - Inbox, Outbox - the entity that was affected - the whole Thing (the default) or a single Feature of the Thing (Feature). Note: Only one communication type can be configured to the live message - if using the methods for configuring it - only the last one applies. Note: Only one entity that the message targets can be configured to the live message - if using the methods for configuring it - only the last one applies.

func NewMessage

func NewMessage(thingID *model.NamespacedID) *Message

NewMessage creates a new Message instance for the defined by the provided NamespacedID Thing.

func (*Message) Envelope

func (msg *Message) Envelope(headerOpts ...protocol.HeaderOpt) *protocol.Envelope

Envelope generates the Ditto envelope with message's data applying all configurations and optionally all Headers provided.

func (*Message) Feature

func (msg *Message) Feature(featureID string) *Message

Feature configures the Message's target to be the specified by the featureID Thing's Feature.

func (*Message) Inbox

func (msg *Message) Inbox(subject string) *Message

Inbox configures the live Message to be sent to the inbox of the target entity, i.e. it defines an incoming communication. The Message is configured to serve only one subject - the one provided.

func (*Message) Outbox

func (msg *Message) Outbox(subject string) *Message

Outbox configures the live Message to be sent to the outbox of the target entity, i.e. it defines an outgoing communication. The Message is configured to serve only one subject - the one provided.

func (*Message) WithPayload

func (msg *Message) WithPayload(payload interface{}) *Message

WithPayload sets the data to be sent in the message, i.e. its content.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL