Documentation ¶
Index ¶
- type DefinitionID
- func (definitionId *DefinitionID) MarshalJSON() ([]byte, error)
- func (definitionId *DefinitionID) String() string
- func (definitionId *DefinitionID) UnmarshalJSON(data []byte) error
- func (definitionId *DefinitionID) WithName(name string) *DefinitionID
- func (definitionId *DefinitionID) WithNamespace(namespace string) *DefinitionID
- func (definitionId *DefinitionID) WithVersion(version string) *DefinitionID
- type Feature
- func (feature *Feature) WithDefinition(definition ...*DefinitionID) *Feature
- func (feature *Feature) WithDefinitionFrom(definition ...string) *Feature
- func (feature *Feature) WithDesiredProperties(properties map[string]interface{}) *Feature
- func (feature *Feature) WithDesiredProperty(id string, value interface{}) *Feature
- func (feature *Feature) WithProperties(properties map[string]interface{}) *Feature
- func (feature *Feature) WithProperty(id string, value interface{}) *Feature
- type NamespacedID
- type Thing
- func (thing *Thing) WithAttribute(id string, value interface{}) *Thing
- func (thing *Thing) WithAttributes(attrs map[string]interface{}) *Thing
- func (thing *Thing) WithDefinition(definition *DefinitionID) *Thing
- func (thing *Thing) WithDefinitionFrom(definitionID string) *Thing
- func (thing *Thing) WithFeature(id string, value *Feature) *Thing
- func (thing *Thing) WithFeatures(features map[string]*Feature) *Thing
- func (thing *Thing) WithID(id *NamespacedID) *Thing
- func (thing *Thing) WithIDFrom(id string) *Thing
- func (thing *Thing) WithPolicyID(policyID *NamespacedID) *Thing
- func (thing *Thing) WithPolicyIDFrom(policyID string) *Thing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefinitionID ¶
DefinitionID represents an ID of a given definition entity. Compliant with the Ditto specification it consists of a namespace, name and a version in the form of 'namespace:name:version'. The DefinitionID is used to declare a Thing's model also it is used in declare the different models a Feature represents via its properties.
func NewDefinitionID ¶
func NewDefinitionID(namespace string, name string, version string) *DefinitionID
NewDefinitionID creates a new DefinitionID instance with the namespace, name and version provided. Returns nil if the provided string doesn't match the form.
func NewDefinitionIDFrom ¶
func NewDefinitionIDFrom(full string) *DefinitionID
NewDefinitionIDFrom creates a new DefinitionID instance from a provided string in the form of 'namespace:name:version'. Returns nil if the provided string doesn't match the form.
func (*DefinitionID) MarshalJSON ¶
func (definitionId *DefinitionID) MarshalJSON() ([]byte, error)
MarshalJSON marshals definition ID.
func (*DefinitionID) String ¶
func (definitionId *DefinitionID) String() string
String provides the string representation of a DefinitionID in the Ditto's specified form of 'namespace:name:version'.
func (*DefinitionID) UnmarshalJSON ¶
func (definitionId *DefinitionID) UnmarshalJSON(data []byte) error
UnmarshalJSON marshals definition ID.
func (*DefinitionID) WithName ¶
func (definitionId *DefinitionID) WithName(name string) *DefinitionID
WithName sets the provided name to the current DefinitionID instance.
func (*DefinitionID) WithNamespace ¶
func (definitionId *DefinitionID) WithNamespace(namespace string) *DefinitionID
WithNamespace sets the provided namespace to the current DefinitionID instance.
func (*DefinitionID) WithVersion ¶
func (definitionId *DefinitionID) WithVersion(version string) *DefinitionID
WithVersion sets the provided version to the current DefinitionID instance.
type Feature ¶
type Feature struct { Definition []*DefinitionID `json:"definition,omitempty"` Properties map[string]interface{} `json:"properties,omitempty"` DesiredProperties map[string]interface{} `json:"desiredProperties,omitempty"` }
Feature represents the Feature entity defined by the Ditto's Things specification. It is used to manage all data and functionality of a Thing that can be clustered in an outlined technical context.
func (*Feature) WithDefinition ¶
func (feature *Feature) WithDefinition(definition ...*DefinitionID) *Feature
WithDefinition sets the definition of the current Feature instance to the provided set of DefinitionIDs.
func (*Feature) WithDefinitionFrom ¶
WithDefinitionFrom is an auxiliary method to set the Feature's definition from an array of strings converted into the proper DefinitionID instances.
func (*Feature) WithDesiredProperties ¶
WithDesiredProperties sets all desired properties of the current Feature instance.
func (*Feature) WithDesiredProperty ¶
WithDesiredProperty sets/adds a desired property to the current Feature instance.
func (*Feature) WithProperties ¶
WithProperties sets all properties of the current Feature instance.
func (*Feature) WithProperty ¶
WithProperty sets/adds a property to the current Feature instance.
type NamespacedID ¶
NamespacedID represents the namespaced entity ID defined by the Ditto specification. It is a unique identifier representing a Thing compliant with the Ditto requirements: - namespace and name separated by a : (colon) - have a maximum length of 256 characters.
func NewNamespacedID ¶
func NewNamespacedID(namespace string, name string) *NamespacedID
NewNamespacedID creates a new NamespacedID instance using the provided namespace and name. Returns nil if the provided string doesn't match the form.
func NewNamespacedIDFrom ¶
func NewNamespacedIDFrom(full string) *NamespacedID
NewNamespacedIDFrom creates a new NamespacedID instance using the provided string in the valid form of 'namespace:name'. Returns nil if the provided string doesn't match the form.
func (*NamespacedID) MarshalJSON ¶
func (nsID *NamespacedID) MarshalJSON() ([]byte, error)
MarshalJSON marshals namespace ID.
func (*NamespacedID) String ¶
func (nsID *NamespacedID) String() string
String provides the string representation of the NamespacedID entity in the form of 'namespace:name'.
func (*NamespacedID) UnmarshalJSON ¶
func (nsID *NamespacedID) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals namespace ID.
func (*NamespacedID) WithName ¶
func (nsID *NamespacedID) WithName(name string) *NamespacedID
WithName sets the provided name to the current NamespacedID instance.
func (*NamespacedID) WithNamespace ¶
func (nsID *NamespacedID) WithNamespace(namespace string) *NamespacedID
WithNamespace sets the provided namespace to the current NamespacedID instance.
type Thing ¶
type Thing struct { ID *NamespacedID `json:"thingId"` PolicyID *NamespacedID `json:"policyId,omitempty"` DefinitionID *DefinitionID `json:"definition,omitempty"` Attributes map[string]interface{} `json:"attributes,omitempty"` Features map[string]*Feature `json:"features,omitempty"` Revision int64 `json:"-"` Timestamp string `json:"-"` }
Thing represents the Thing entity model form the Ditto's specification. Things are very generic entities and are mostly used as a “handle” for multiple features belonging to this Thing.
func (*Thing) WithAttribute ¶
WithAttribute sets/add an attribute to the current Thing instance.
func (*Thing) WithAttributes ¶
WithAttributes sets all attributes to the current Thing instance.
func (*Thing) WithDefinition ¶
func (thing *Thing) WithDefinition(definition *DefinitionID) *Thing
WithDefinition sets the current Thing instance's definition to the provided value.
func (*Thing) WithDefinitionFrom ¶
WithDefinitionFrom is an auxiliary method to set the current Thing instance's definition to the provided one in the form of 'namespace:name:version'.
func (*Thing) WithFeature ¶
WithFeature sets/adds a Feature to the current features set of the Thing instance.
func (*Thing) WithFeatures ¶
WithFeatures sets all features to the current Thing instance.
func (*Thing) WithID ¶
func (thing *Thing) WithID(id *NamespacedID) *Thing
WithID sets the provided NamespacedID as the current Thing's instance ID value.
func (*Thing) WithIDFrom ¶
WithIDFrom is an auxiliary method that sets the ID value of the current Thing instance based on the provided string n the form of 'namespace:name'.
func (*Thing) WithPolicyID ¶
func (thing *Thing) WithPolicyID(policyID *NamespacedID) *Thing
WithPolicyID sets the provided Policy ID to the current Thing instance.
func (*Thing) WithPolicyIDFrom ¶
WithPolicyIDFrom is an auxiliary method that sets the Policy ID of the current Thing instance from a string NamespacedID representation in the form of 'namespace:name'.