Documentation ¶
Index ¶
- func NormalizePayload(payload interface{}, encodeBytes bool) interface{}
- func ValidateAggregateMessage(astarteInterface AstarteInterface, interfacePath string, ...) error
- func ValidateIndividualMessage(astarteInterface AstarteInterface, path string, value interface{}) error
- func ValidateInterfacePath(astarteInterface AstarteInterface, interfacePath string) error
- func ValidateQuery(astarteInterface AstarteInterface, queryPath string) error
- type AstarteInterface
- type AstarteInterfaceAggregation
- type AstarteInterfaceMapping
- type AstarteInterfaceOwnership
- type AstarteInterfaceType
- type AstarteMappingDatabaseRetentionPolicy
- type AstarteMappingReliability
- type AstarteMappingRetention
- type AstarteMappingType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizePayload ¶
func NormalizePayload(payload interface{}, encodeBytes bool) interface{}
NormalizePayload returns a normalized payload, ready to be used for calling APIs or, in general, interact with Astarte. encodeBytes controls whether []byte types should be encoded in base64, used for data structures which do not support bytes (e.g.: JSON)
func ValidateAggregateMessage ¶
func ValidateAggregateMessage(astarteInterface AstarteInterface, interfacePath string, values map[string]interface{}) error
ValidateAggregateMessage validates an aggregate message prepended by a path. values must be a map containing the last tip of the endpoint, without slashes
func ValidateIndividualMessage ¶
func ValidateIndividualMessage(astarteInterface AstarteInterface, path string, value interface{}) error
ValidateIndividualMessage validates an individual message
func ValidateInterfacePath ¶
func ValidateInterfacePath(astarteInterface AstarteInterface, interfacePath string) error
ValidateInterfacePath validates path against the structure of astarteInterface, and returns a meaningful error the path cannot be resolved.
func ValidateQuery ¶
func ValidateQuery(astarteInterface AstarteInterface, queryPath string) error
ValidateQuery validates whether a query path on an interface is valid or not. Ideally, this will match paths which are identical to at least a portion of an existing mapping in the interface for individual interfaces, and will match paths which are equal to all endpoints for all depth levels below `(endpoint levels)-1` for aggregate interfaces
Types ¶
type AstarteInterface ¶
type AstarteInterface struct { Name string `json:"interface_name"` MajorVersion int `json:"version_major"` MinorVersion int `json:"version_minor"` Type AstarteInterfaceType `json:"type"` Ownership AstarteInterfaceOwnership `json:"ownership"` Aggregation AstarteInterfaceAggregation `json:"aggregation,omitempty"` ExplicitTimestamp bool `json:"explicit_timestamp,omitempty"` HasMetadata bool `json:"has_metadata,omitempty"` Description string `json:"description,omitempty"` Documentation string `json:"doc,omitempty"` Mappings []AstarteInterfaceMapping `json:"mappings"` }
AstarteInterface represents an Astarte Interface
func EnsureInterfaceDefaults ¶
func EnsureInterfaceDefaults(astarteInterface AstarteInterface) AstarteInterface
EnsureInterfaceDefaults makes sure a JSON-parsed interface will have all defaults set. Usually, you should never call this method - ParseInterface does the right thing. It might become useful in case you're dealing with a json.Decoder to parse interface information
func ParseInterface ¶
func ParseInterface(interfaceContent []byte) (AstarteInterface, error)
ParseInterface parses an interface from a JSON string and returns an AstarteInterface object when successful. Please use this method rather than calling json.Unmarshal on an interface, as this will set any missing field to the correct, expected default value
func ParseInterfaceFrom ¶ added in v0.91.0
func ParseInterfaceFrom[T interfaceProvider](provider T) (AstarteInterface, error)
ParseInterfaceFrom is a convenience function to call ParseInterface with an input. The input can be either a string, that is interpreted as a file path, or a byteslice.
func (*AstarteInterface) IsParametric ¶
func (a *AstarteInterface) IsParametric() bool
IsParametric returns whether the interface has at least one parametric mapping
type AstarteInterfaceAggregation ¶
type AstarteInterfaceAggregation string
AstarteInterfaceAggregation represents the type of Aggregation of an Interface.
const ( // IndividualAggregation represents an interface with individual endpoints IndividualAggregation AstarteInterfaceAggregation = "individual" // ObjectAggregation represents an interface with aggregated endpoints ObjectAggregation AstarteInterfaceAggregation = "object" )
func (AstarteInterfaceAggregation) IsValid ¶
func (a AstarteInterfaceAggregation) IsValid() error
IsValid returns an error if AstarteInterfaceAggregation does not represent a valid Astarte Interface Aggregation
func (*AstarteInterfaceAggregation) UnmarshalJSON ¶
func (a *AstarteInterfaceAggregation) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type AstarteInterfaceMapping ¶
type AstarteInterfaceMapping struct { Endpoint string `json:"endpoint"` Type AstarteMappingType `json:"type"` Reliability AstarteMappingReliability `json:"reliability,omitempty"` Retention AstarteMappingRetention `json:"retention,omitempty"` DatabaseRetentionPolicy AstarteMappingDatabaseRetentionPolicy `json:"database_retention_policy,omitempty"` DatabaseRetentionTTL int `json:"database_retention_ttl,omitempty"` Expiry int `json:"expiry,omitempty"` ExplicitTimestamp bool `json:"explicit_timestamp,omitempty"` AllowUnset bool `json:"allow_unset,omitempty"` Description string `json:"description,omitempty"` Documentation string `json:"doc,omitempty"` }
AstarteInterfaceMapping represents an individual Mapping in an Astarte Interface
func InterfaceMappingFromPath ¶
func InterfaceMappingFromPath(astarteInterface AstarteInterface, interfacePath string) (AstarteInterfaceMapping, error)
InterfaceMappingFromPath retrieves the corresponding interface mapping given a path, and returns a meaningful error the path cannot be resolved.
type AstarteInterfaceOwnership ¶
type AstarteInterfaceOwnership string
AstarteInterfaceOwnership represents the owner of an interface.
const ( // DeviceOwnership represents a Device-owned interface DeviceOwnership AstarteInterfaceOwnership = "device" // ServerOwnership represents a Server-owned interface ServerOwnership AstarteInterfaceOwnership = "server" )
func (AstarteInterfaceOwnership) IsValid ¶
func (o AstarteInterfaceOwnership) IsValid() error
IsValid returns an error if AstarteInterfaceOwnership does not represent a valid Astarte Ownership Type
func (*AstarteInterfaceOwnership) UnmarshalJSON ¶
func (o *AstarteInterfaceOwnership) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type AstarteInterfaceType ¶
type AstarteInterfaceType string
AstarteInterfaceType represents which kind of Astarte interface the object represents
const ( // PropertiesType represents a properties Interface PropertiesType AstarteInterfaceType = "properties" // DatastreamType represents a datastream Interface DatastreamType AstarteInterfaceType = "datastream" )
func (AstarteInterfaceType) IsValid ¶
func (t AstarteInterfaceType) IsValid() error
IsValid returns an error if AstarteInterfaceType does not represent a valid Astarte Interface Type
func (*AstarteInterfaceType) UnmarshalJSON ¶
func (t *AstarteInterfaceType) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type AstarteMappingDatabaseRetentionPolicy ¶
type AstarteMappingDatabaseRetentionPolicy string
AstarteMappingDatabaseRetentionPolicy represents database retention policy for a single mapping
const ( // NoTTL means that there is no expiry (TTL) NoTTL AstarteMappingDatabaseRetentionPolicy = "no_ttl" // UseTTL means that database retention TTL is used UseTTL AstarteMappingDatabaseRetentionPolicy = "use_ttl" )
func (AstarteMappingDatabaseRetentionPolicy) IsValid ¶
func (r AstarteMappingDatabaseRetentionPolicy) IsValid() error
IsValid returns an error if AstarteMappingDatabaseRetentionPolicy does not represent a valid Astarte Mapping Database Retention Policy
func (*AstarteMappingDatabaseRetentionPolicy) UnmarshalJSON ¶
func (r *AstarteMappingDatabaseRetentionPolicy) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type AstarteMappingReliability ¶
type AstarteMappingReliability string
AstarteMappingReliability represents the reliability of a mapping
const ( // UnreliableReliability represents a QoS 0-like reliability on the wire UnreliableReliability AstarteMappingReliability = "unreliable" // GuaranteedReliability represents a QoS 1-like reliability on the wire GuaranteedReliability AstarteMappingReliability = "guaranteed" // UniqueReliability represents a QoS 2-like reliability on the wire UniqueReliability AstarteMappingReliability = "unique" )
func (AstarteMappingReliability) IsValid ¶
func (r AstarteMappingReliability) IsValid() error
IsValid returns an error if AstarteMappingReliability does not represent a valid Astarte Mapping Reliability
func (*AstarteMappingReliability) UnmarshalJSON ¶
func (r *AstarteMappingReliability) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type AstarteMappingRetention ¶
type AstarteMappingRetention string
AstarteMappingRetention represents retention for a single mapping
const ( // DiscardRetention means the sample will be discarded if it cannot be sent DiscardRetention AstarteMappingRetention = "discard" // VolatileRetention means the sample will be stored in RAM until possible if it cannot be sent VolatileRetention AstarteMappingRetention = "volatile" // StoredRetention means the sample will be stored on Disk until expiration if it cannot be sent StoredRetention AstarteMappingRetention = "stored" )
func (AstarteMappingRetention) IsValid ¶
func (r AstarteMappingRetention) IsValid() error
IsValid returns an error if AstarteMappingRetention does not represent a valid Astarte Mapping Retention
func (*AstarteMappingRetention) UnmarshalJSON ¶
func (r *AstarteMappingRetention) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type AstarteMappingType ¶
type AstarteMappingType string
AstarteMappingType represents the type of a single mapping. Astarte Types are natively inferred from golang native types, as long as the conversion does not lose precision, e.g.: an `int32` value will be accepted as a "double" type, but a `float64` value won't be accepted as a "integer" type
const ( // Double represents the "double" type in Astarte. It maps to golang `float64` type, // but also accepts implicit conversions from any int or float type Double AstarteMappingType = "double" // Integer represents the "integer" type in Astarte. It maps to golang `int` type, // but also accepts implicit conversions from any int type < 64bit Integer AstarteMappingType = "integer" // Boolean represents the "boolean" type in Astarte. It maps to golang `bool` type Boolean AstarteMappingType = "boolean" // LongInteger represents the "longinteger" type in Astarte. It maps to golang `int64` type, // but also accepts implicit conversions from any int type LongInteger AstarteMappingType = "longinteger" // String represents the "string" type in Astarte. It maps to golang `string` type String AstarteMappingType = "string" // BinaryBlob represents the "binaryblob" type in Astarte. It maps to golang `[]byte` type BinaryBlob AstarteMappingType = "binaryblob" // DateTime represents the "datetime" type in Astarte. It maps to golang `time.Time` type DateTime AstarteMappingType = "datetime" // DoubleArray represents the "doublearray" type in Astarte. It maps to golang `[]float` type, // but also accepts implicit conversions from any int or float type array DoubleArray AstarteMappingType = "doublearray" // IntegerArray represents the "integerarray" type in Astarte. It maps to golang `[]int` type, // but also accepts implicit conversions from any int type < 64bit IntegerArray AstarteMappingType = "integerarray" // BooleanArray represents the "booleanarray" type in Astarte. It maps to golang `[]bool` type BooleanArray AstarteMappingType = "booleanarray" // LongIntegerArray represents the "longintegerarray" type in Astarte. It maps to golang `[]int64` type, // but also accepts implicit conversions from any int type LongIntegerArray AstarteMappingType = "longintegerarray" // StringArray represents the "stringarray" type in Astarte. It maps to golang `[]string` type StringArray AstarteMappingType = "stringarray" // BinaryBlobArray represents the "binaryblobarray" type in Astarte. It maps to golang `[]byte` type BinaryBlobArray AstarteMappingType = "binaryblobarray" // DateTimeArray represents the "datetimearray" type in Astarte. It maps to golang `[]time.Time` type DateTimeArray AstarteMappingType = "datetimearray" )
func (AstarteMappingType) IsValid ¶
func (m AstarteMappingType) IsValid() error
IsValid returns an error if AstarteMappingType does not represent a valid Astarte Mapping Type
func (*AstarteMappingType) UnmarshalJSON ¶
func (m *AstarteMappingType) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value