Documentation ¶
Index ¶
- Variables
- func AppendSchema(m SchemaMapping)
- type ActionConstraint
- type BooleanNode
- type BooleanValue
- type DataPropertyConstraint
- type ExpandedActionAffordance
- type ExpandedDataProperty
- type ExpandedDataSchema
- type ExpandedDataSchemaNode
- type ExpandedForm
- type ExpandedFormNode
- type ExpandedPropertyAffordance
- type ExpandedThingDescription
- func (e *ExpandedThingDescription) Compact() (json.RawMessage, error)
- func (t ExpandedThingDescription) Fulfills(c ThingConstraint) bool
- func (t *ExpandedThingDescription) GetActionAffordances(constraint ActionConstraint) []ExpandedActionAffordance
- func (t *ExpandedThingDescription) GetPropertyAffordances(constraint PropertyConstraint) []ExpandedPropertyAffordance
- type ExpandedThingDescriptionSet
- func (s *ExpandedThingDescriptionSet) Append(td ExpandedThingDescription)
- func (s *ExpandedThingDescriptionSet) Get(id string) ExpandedThingDescription
- func (s *ExpandedThingDescriptionSet) GetActionAffordances(constraint ThingConstraint) []ExpandedActionAffordance
- func (s *ExpandedThingDescriptionSet) GetPropertyAffordances(constraint ThingConstraint) []ExpandedPropertyAffordance
- func (s *ExpandedThingDescriptionSet) Remove(id string)
- type IDNode
- type IDValue
- type InputConstraint
- type PropertyConstraint
- type SchemaMapping
- type SchemaPrefix
- type StringNode
- type StringValue
- type ThingConstraint
Constants ¶
This section is empty.
Variables ¶
var ( SchemaWoT = SchemaMapping{ Prefix: SchemaPrefix("wot"), IRI: "https://www.w3.org/2019/wot/td#", } SchemaHypermedia = SchemaMapping{ Prefix: SchemaPrefix("hypermedia"), IRI: "https://www.w3.org/2019/wot/hypermedia#", } SchemaRdfType = SchemaMapping{ Prefix: SchemaPrefix("rdftype"), IRI: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", } SchemaJSON = SchemaMapping{ Prefix: SchemaPrefix("jsonschema"), IRI: "https://www.w3.org/2019/wot/json-schema#", } )
well know schemata
var DefaultContext = map[string]interface{}{ SchemaWoT.Prefix.String(): SchemaWoT.IRI, SchemaHypermedia.Prefix.String(): SchemaHypermedia.IRI, SchemaRdfType.Prefix.String(): SchemaRdfType.IRI, SchemaJSON.Prefix.String(): SchemaJSON.IRI, }
DefaultContext defines the default context Modifications to existing prefixes will corrupt parsing process
var (
DefaultJSONDLDOptions = ld.NewJsonLdOptions("")
)
Default json-ld options
Functions ¶
func AppendSchema ¶
func AppendSchema(m SchemaMapping)
AppendSchema appends a schema to the default context
Types ¶
type ActionConstraint ¶
type ActionConstraint struct { Name *string Type *[]string InputConstraint *InputConstraint IsIdempotent *bool IsSafe *bool }
ActionConstraint defines an action constraint
type BooleanNode ¶
type BooleanNode []BooleanValue
BooleanNode defines an array of boolean values
func (BooleanNode) Value ¶
func (b BooleanNode) Value() bool
Value returns the first element inside the boolean node or false if no such element exists
type BooleanValue ¶
type BooleanValue struct {
Value bool `json:"@value"`
}
BooleanValue describes a boolean value
type DataPropertyConstraint ¶
DataPropertyConstraint defines a data property constraint
type ExpandedActionAffordance ¶
type ExpandedActionAffordance struct { Name StringNode `json:"https://www.w3.org/2019/wot/td#name"` Type []string `json:"@type,omitempty"` Form ExpandedFormNode `json:"https://www.w3.org/2019/wot/td#hasForm"` Input ExpandedDataSchemaNode `json:"https://www.w3.org/2019/wot/td#hasInputSchema"` IsIdempotent BooleanNode `json:"https://www.w3.org/2019/wot/td#isIdempotent"` IsSafe BooleanNode `json:"https://www.w3.org/2019/wot/td#isSafe"` }
ExpandedActionAffordance defines an expanded action affordance within a td
func (*ExpandedActionAffordance) Compact ¶
func (e *ExpandedActionAffordance) Compact() (json.RawMessage, error)
Compact compacts an expanded action affordance
func (ExpandedActionAffordance) Fulfills ¶
func (t ExpandedActionAffordance) Fulfills(c ActionConstraint) bool
Fulfills checks if ActionConstraint is fulfilled by given ExpandedActionAffordance
type ExpandedDataProperty ¶
type ExpandedDataProperty struct { Name StringNode `json:"https://www.w3.org/2019/wot/json-schema#propertyName"` Type []string `json:"@type,omitempty"` DataType IDNode `json:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"` }
ExpandedDataProperty is part of a data schema
func (ExpandedDataProperty) Fulfills ¶
func (t ExpandedDataProperty) Fulfills(c DataPropertyConstraint) bool
Fulfills checks if DataPropertyConstraint is fulfilled by given ExpandedDataProperty
type ExpandedDataSchema ¶
type ExpandedDataSchema struct { DataType IDNode `json:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"` Properties []ExpandedDataProperty `json:"https://www.w3.org/2019/wot/json-schema#properties"` }
ExpandedDataSchema can be inside an input param of an action affordance or inside a property
type ExpandedDataSchemaNode ¶
type ExpandedDataSchemaNode []ExpandedDataSchema
ExpandedDataSchemaNode is an array of expanded data schema
func (ExpandedDataSchemaNode) Fulfills ¶
func (t ExpandedDataSchemaNode) Fulfills(c InputConstraint) bool
Fulfills checks if ExpandedInputConstraint matches with given ExpandedDataProperty
func (ExpandedDataSchemaNode) Value ¶
func (s ExpandedDataSchemaNode) Value() ExpandedDataSchema
Value returns the first element inside the schema node or an empty schema if no such element exists
type ExpandedForm ¶
type ExpandedForm struct { ContentType StringNode `json:"https://www.w3.org/2019/wot/hypermedia#forContentType"` Op IDNode `json:"https://www.w3.org/2019/wot/hypermedia#hasOperationType"` Href IDNode `json:"https://www.w3.org/2019/wot/hypermedia#hasTarget"` }
ExpandedForm is part of actions and properties and describes how to resolve an entity
type ExpandedFormNode ¶
type ExpandedFormNode []ExpandedForm
ExpandedFormNode is an array of expanded forms
func (ExpandedFormNode) Value ¶
func (s ExpandedFormNode) Value() ExpandedForm
Value returns the first element inside the form node or an empty form if no such element exists
type ExpandedPropertyAffordance ¶
type ExpandedPropertyAffordance struct { Name StringNode `json:"https://www.w3.org/2019/wot/td#name"` Type []string `json:"@type,omitempty"` DataType IDNode `json:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"` Properties []ExpandedDataProperty `json:"https://www.w3.org/2019/wot/json-schema#properties"` Form ExpandedFormNode `json:"https://www.w3.org/2019/wot/td#hasForm"` IsObservable BooleanNode `json:"https://www.w3.org/2019/wot/td#isObservable"` }
ExpandedPropertyAffordance defines an expanded property affordance within a td
func (*ExpandedPropertyAffordance) Compact ¶
func (e *ExpandedPropertyAffordance) Compact() (json.RawMessage, error)
Compact compacts an expanded property affordance
func (ExpandedPropertyAffordance) Fulfills ¶
func (t ExpandedPropertyAffordance) Fulfills(c PropertyConstraint) bool
Fulfills checks if PropertyConstraint is fulfilled by given ExpandedPropertyAffordance
type ExpandedThingDescription ¶
type ExpandedThingDescription struct { ID string `json:"@id"` Type []string `json:"@type,omitempty"` Name StringNode `json:"https://www.w3.org/2019/wot/td#name"` Actions []ExpandedActionAffordance `json:"https://www.w3.org/2019/wot/td#hasActionAffordance"` Properties []ExpandedPropertyAffordance `json:"https://www.w3.org/2019/wot/td#hasPropertyAffordance"` }
ExpandedThingDescription reflects a thing description in its expanded format Note: currently this lib only supports a small sub set of fields
func FromBytes ¶
func FromBytes(b []byte) (ExpandedThingDescription, error)
FromBytes expands input bytes and converts it to ExpandedThingDescription
func FromResponse ¶
func FromResponse(resp *http.Response) (ExpandedThingDescription, error)
FromResponse tries to extract an expanded wot td from a response object
func (*ExpandedThingDescription) Compact ¶
func (e *ExpandedThingDescription) Compact() (json.RawMessage, error)
Compact compacts the thing description
func (ExpandedThingDescription) Fulfills ¶
func (t ExpandedThingDescription) Fulfills(c ThingConstraint) bool
Fulfills checks if constraint matches with given element A thing description matches if ID, type and name match (if given) and if at least one of the PropertyConstraints and one of the ActionConstraints matches (if given)
func (*ExpandedThingDescription) GetActionAffordances ¶
func (t *ExpandedThingDescription) GetActionAffordances(constraint ActionConstraint) []ExpandedActionAffordance
GetActionAffordances searches for an action affordance with specific criteria
func (*ExpandedThingDescription) GetPropertyAffordances ¶
func (t *ExpandedThingDescription) GetPropertyAffordances(constraint PropertyConstraint) []ExpandedPropertyAffordance
GetPropertyAffordances searches for a property affordance with specific criteria
type ExpandedThingDescriptionSet ¶
type ExpandedThingDescriptionSet map[string]ExpandedThingDescription
ExpandedThingDescriptionSet set of thing descriptions with some convenience functions
func NewExpandedThingDescriptionSet ¶
func NewExpandedThingDescriptionSet(tds ...ExpandedThingDescription) ExpandedThingDescriptionSet
NewExpandedThingDescriptionSet creates a new set
func (*ExpandedThingDescriptionSet) Append ¶
func (s *ExpandedThingDescriptionSet) Append(td ExpandedThingDescription)
Append appends an expanded td to the list
func (*ExpandedThingDescriptionSet) Get ¶
func (s *ExpandedThingDescriptionSet) Get(id string) ExpandedThingDescription
Get retrieves a td by id
func (*ExpandedThingDescriptionSet) GetActionAffordances ¶
func (s *ExpandedThingDescriptionSet) GetActionAffordances(constraint ThingConstraint) []ExpandedActionAffordance
GetActionAffordances searches within a set for all actions affordances where constraints match
func (*ExpandedThingDescriptionSet) GetPropertyAffordances ¶
func (s *ExpandedThingDescriptionSet) GetPropertyAffordances(constraint ThingConstraint) []ExpandedPropertyAffordance
GetPropertyAffordances searches within a set for all property affordances where constraints match
func (*ExpandedThingDescriptionSet) Remove ¶
func (s *ExpandedThingDescriptionSet) Remove(id string)
Remove removes a td from the list
type InputConstraint ¶
type InputConstraint struct { DataType *string DataPropertyConstraint *DataPropertyConstraint }
InputConstraint defines an input constraint
type PropertyConstraint ¶
type PropertyConstraint struct { Name *string Type *[]string DataType *string DataPropertyConstraint *DataPropertyConstraint IsObservable *bool }
PropertyConstraint defines a property constraint
type SchemaMapping ¶
type SchemaMapping struct { Prefix SchemaPrefix IRI string }
SchemaMapping defines a prefix iri mapping
func (SchemaMapping) IRIPrefix ¶
func (s SchemaMapping) IRIPrefix(nodeID string) string
IRIPrefix builds a prefixed node name for referencing elements in a thing description. Eg. SchemaWoT.IRIPrefix(PropertyAffordance) would return "https://...#PropertyAffordance"
type SchemaPrefix ¶
type SchemaPrefix string
SchemaPrefix like wot, schema...
func (SchemaPrefix) String ¶
func (p SchemaPrefix) String() string
type StringNode ¶
type StringNode []StringValue
StringNode defines an array of string values
func (StringNode) Value ¶
func (s StringNode) Value() string
Value returns the first element inside the string node or an empty string if no such element exists
type StringValue ¶
type StringValue struct {
Value string `json:"@value"`
}
StringValue describes a string value
type ThingConstraint ¶
type ThingConstraint struct { ID *string Type *[]string Name *string PropertyConstraint *PropertyConstraint ActionConstraint *ActionConstraint }
ThingConstraint defines a thing constraint