Documentation
¶
Index ¶
- Constants
- Variables
- func IsValidAttributeName(name string) bool
- func IsValidFieldSyntax(str string) bool
- func IsValidString(str string) bool
- func SanitizeString(str string) string
- type APIResources
- type ActionType
- type Attribute
- func (a *Attribute) GetAsBoolean() (bool, error)
- func (a *Attribute) GetAsDateTime() (time.Time, error)
- func (a *Attribute) GetAsFloat() (float64, error)
- func (a *Attribute) GetAsGeoJSON() (*geojson.Geometry, error)
- func (a *Attribute) GetAsGeoPoint() (*GeoPoint, error)
- func (a *Attribute) GetAsInteger() (int, error)
- func (a *Attribute) GetAsString() (string, error)
- type AttributeType
- type BatchQuery
- type BatchUpdate
- type Entity
- func (e *Entity) GetAttribute(name string) (*Attribute, error)
- func (e *Entity) GetAttributeAsBoolean(attributeName string) (bool, error)
- func (e *Entity) GetAttributeAsDateTime(attributeName string) (time.Time, error)
- func (e *Entity) GetAttributeAsFloat(attributeName string) (float64, error)
- func (e *Entity) GetAttributeAsGeoJSON(attributeName string) (*geojson.Geometry, error)
- func (e *Entity) GetAttributeAsGeoPoint(attributeName string) (*GeoPoint, error)
- func (e *Entity) GetAttributeAsInteger(attributeName string) (int, error)
- func (e *Entity) GetAttributeAsString(attributeName string) (string, error)
- func (e *Entity) GetDateCreated() (time.Time, error)
- func (e *Entity) GetDateExpires() (time.Time, error)
- func (e *Entity) GetDateModified() (time.Time, error)
- func (e *Entity) MarshalJSON() ([]byte, error)
- func (e *Entity) SetAttribute(name string, typ AttributeType, value interface{}) error
- func (e *Entity) SetAttributeAsBoolean(name string, value bool) error
- func (e *Entity) SetAttributeAsDateTime(name string, value time.Time) error
- func (e *Entity) SetAttributeAsFloat(name string, value float64) error
- func (e *Entity) SetAttributeAsGeoJSON(name string, value *geojson.Geometry) error
- func (e *Entity) SetAttributeAsGeoPoint(name string, value *GeoPoint) error
- func (e *Entity) SetAttributeAsInteger(name string, value int) error
- func (e *Entity) SetAttributeAsNumber(name string, value float64) error
- func (e *Entity) SetAttributeAsString(name string, value string) error
- func (e *Entity) SetAttributeAsText(name string, value string) error
- func (e *Entity) SetDateExpires(value time.Time)
- func (e *Entity) UnmarshalJSON(b []byte) error
- type EntityMatcher
- func (entityMatcher *EntityMatcher) ById(id string) *EntityMatcher
- func (entityMatcher *EntityMatcher) ByIdPattern(idPattern string) *EntityMatcher
- func (entityMatcher *EntityMatcher) ByType(typeName string) *EntityMatcher
- func (entityMatcher *EntityMatcher) ByTypePattern(typePattern string) *EntityMatcher
- type GeoPoint
- type GeorelModifier
- type GeospatialRelationship
- type Metadata
- type Notification
- type OrionTime
- type QueryExpression
- type SimpleLocationFormatGeometry
- type SimpleQueryOperator
- type SimpleQueryStatement
- func NewBinarySimpleQueryStatement(attr string, operator SimpleQueryOperator, value string) (SimpleQueryStatement, error)
- func NewBinarySimpleQueryStatementMultipleValues(attr string, operator SimpleQueryOperator, values ...string) (SimpleQueryStatement, error)
- func NewBinarySimpleQueryStatementRange(attr string, operator SimpleQueryOperator, minimum string, maximum string) (SimpleQueryStatement, error)
- type SimplifiedEntityRepresentation
- type Subscription
- type SubscriptionNotification
- type SubscriptionNotificationHttp
- type SubscriptionNotificationHttpCustom
- type SubscriptionStatus
- type SubscriptionSubject
- type SubscriptionSubjectCondition
- type SubscriptionSubjectConditionExpression
- type SubscriptionSubjectEntity
Constants ¶
const ( DateCreatedAttributeName string = "dateCreated" DateModifiedAttributeName string = "dateModified" DateExpiresAttributeName string = "dateExpires" )
const ( InvalidChars string = `<>"'=;()` InvalidFieldChars string = `&?/#` // plus control characters and whitespaces )
Variables ¶
var ReservedAttrNames = [...]string{"id", "type", "geo:distance", "dateCreated", "dateModified"}
Functions ¶
func IsValidAttributeName ¶
IsValidAttributeName checks whether the attribute name is valid or is forbidden. See: https://orioncontextbroker.docs.apiary.io/#introduction/specification/attribute-names-restrictions
func IsValidFieldSyntax ¶
IsValidFieldSyntax checks whether the field syntax is valid or violates restrictions. See: https://orioncontextbroker.docs.apiary.io/#introduction/specification/field-syntax-restrictions
func IsValidString ¶
IsValidString checks whether the string is valid or contains any forbidden character. See: https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/user/forbidden_characters.md
func SanitizeString ¶
SanitizeString removes any forbidden character from a string.
Types ¶
type APIResources ¶
type ActionType ¶
type ActionType string
const ( AppendAction ActionType = "append" AppendStrictAction ActionType = "appendStrict" UpdateAction ActionType = "update" DeleteAction ActionType = "delete" ReplaceAction ActionType = "replace" )
type Attribute ¶
type Attribute struct {
Metadata map[string]*Metadata `json:"metadata,omitempty"`
// contains filtered or unexported fields
}
Attribute is a Context attribute, i.e. a property of a context entity.
func (*Attribute) GetAsBoolean ¶ added in v0.3.3
func (*Attribute) GetAsFloat ¶
func (*Attribute) GetAsGeoJSON ¶ added in v0.5.0
func (*Attribute) GetAsGeoPoint ¶
func (*Attribute) GetAsInteger ¶
func (*Attribute) GetAsString ¶
type AttributeType ¶
type AttributeType string
const ( StringType AttributeType = "String" TextType AttributeType = "Text" NumberType AttributeType = "Number" FloatType AttributeType = "Float" IntegerType AttributeType = "Integer" BooleanType AttributeType = "Boolean" PercentageType AttributeType = "Percentage" DateTimeType AttributeType = "DateTime" GeoPointType AttributeType = "geo:point" GeoLineType AttributeType = "geo:line" GeoPolygonType AttributeType = "geo:polygon" GeoBoxType AttributeType = "geo:box" GeoJSONType AttributeType = "geo:json" )
type BatchQuery ¶ added in v0.4.2
type BatchQuery struct {
Entities []*EntityMatcher `json:"entities,omitempty"`
Attrs []string `json:"attrs,omitempty"`
Expression *QueryExpression `json:"expression,omitempty"`
Metadata []string `json:"metadata,omitempty"`
}
func (*BatchQuery) Match ¶ added in v0.4.2
func (batchQuery *BatchQuery) Match(matchers ...*EntityMatcher) error
type BatchUpdate ¶
type BatchUpdate struct {
ActionType ActionType `json:"actionType"`
Entities []*Entity `json:"entities"`
}
func NewBatchUpdate ¶
func NewBatchUpdate(action ActionType) *BatchUpdate
func (*BatchUpdate) AddEntity ¶
func (u *BatchUpdate) AddEntity(entity *Entity)
type Entity ¶
type Entity struct {
Id string `json:"id"`
Type string `json:"type,omitempty"`
Attributes map[string]*Attribute `json:"-"`
}
Entity is a context entity, i.e. a thing in the NGSI model.
func (*Entity) GetAttributeAsBoolean ¶ added in v0.3.3
func (*Entity) GetAttributeAsDateTime ¶ added in v0.2.3
func (*Entity) GetAttributeAsFloat ¶ added in v0.2.3
func (*Entity) GetAttributeAsGeoJSON ¶ added in v0.5.0
func (*Entity) GetAttributeAsGeoPoint ¶ added in v0.2.3
func (*Entity) GetAttributeAsInteger ¶ added in v0.2.3
func (*Entity) GetAttributeAsString ¶ added in v0.2.3
func (*Entity) GetDateCreated ¶ added in v0.2.4
func (*Entity) GetDateExpires ¶ added in v0.2.4
func (*Entity) GetDateModified ¶ added in v0.2.4
func (*Entity) MarshalJSON ¶
func (*Entity) SetAttribute ¶
func (e *Entity) SetAttribute(name string, typ AttributeType, value interface{}) error
func (*Entity) SetAttributeAsBoolean ¶ added in v0.3.3
func (*Entity) SetAttributeAsDateTime ¶
func (*Entity) SetAttributeAsFloat ¶
func (*Entity) SetAttributeAsGeoJSON ¶ added in v0.5.0
func (*Entity) SetAttributeAsGeoPoint ¶
func (*Entity) SetAttributeAsInteger ¶
func (*Entity) SetAttributeAsNumber ¶ added in v0.4.4
func (*Entity) SetAttributeAsString ¶
func (*Entity) SetAttributeAsText ¶ added in v0.4.3
func (*Entity) SetDateExpires ¶ added in v0.2.4
func (*Entity) UnmarshalJSON ¶
type EntityMatcher ¶ added in v0.4.2
type EntityMatcher struct {
Id string `json:"id,omitempty"`
IdPattern string `json:"idPattern,omitempty"`
Type string `json:"type,omitempty"`
TypePattern string `json:"typePattern,omitempty"`
}
func NewEntityMatcher ¶ added in v0.4.2
func NewEntityMatcher() *EntityMatcher
func (*EntityMatcher) ById ¶ added in v0.4.2
func (entityMatcher *EntityMatcher) ById(id string) *EntityMatcher
func (*EntityMatcher) ByIdPattern ¶ added in v0.4.2
func (entityMatcher *EntityMatcher) ByIdPattern(idPattern string) *EntityMatcher
func (*EntityMatcher) ByType ¶ added in v0.4.2
func (entityMatcher *EntityMatcher) ByType(typeName string) *EntityMatcher
func (*EntityMatcher) ByTypePattern ¶ added in v0.4.2
func (entityMatcher *EntityMatcher) ByTypePattern(typePattern string) *EntityMatcher
type GeorelModifier ¶
type GeorelModifier string
func GeorelModifierMaxDistance ¶
func GeorelModifierMaxDistance(maxDistance float64) GeorelModifier
func GeorelModifierMinDistance ¶
func GeorelModifierMinDistance(minDistance float64) GeorelModifier
type GeospatialRelationship ¶
type GeospatialRelationship string
const ( GeorelNear GeospatialRelationship = "near" GeorelCoveredBy GeospatialRelationship = "coveredBy" GeorelIntersects GeospatialRelationship = "intersects" GeorelEquals GeospatialRelationship = "equals" GeorelDisjoint GeospatialRelationship = "disjoint" )
type Metadata ¶
type Metadata struct {
// contains filtered or unexported fields
}
Metadata is a Context metadata, i.e. an optional part of the attribute.
type Notification ¶ added in v0.2.0
type OrionTime ¶
func (OrionTime) MarshalJSON ¶
type QueryExpression ¶ added in v0.4.2
type QueryExpression struct {
Q string `json:"q,omitempty"`
Mq string `json:"mq,omitempty"`
Georel GeospatialRelationship `json:"georel,omitempty"`
Geometry SimpleLocationFormatGeometry `json:"geometry,omitempty"`
Coords string `json:"coords,omitempty"`
}
type SimpleLocationFormatGeometry ¶
type SimpleLocationFormatGeometry string
const ( SLFPoint SimpleLocationFormatGeometry = "point" SLFLine SimpleLocationFormatGeometry = "line" SLFPolygon SimpleLocationFormatGeometry = "polygon" SLFBox SimpleLocationFormatGeometry = "box" )
type SimpleQueryOperator ¶
type SimpleQueryOperator string
const ( SQEqual SimpleQueryOperator = "==" SQUnequal SimpleQueryOperator = "!=" SQGreaterThan SimpleQueryOperator = ">" SQLessThan SimpleQueryOperator = "<" SQGreaterOrEqualThan SimpleQueryOperator = ">=" SQLessOrEqualThan SimpleQueryOperator = "<=" SQMatchPattern SimpleQueryOperator = "~=" )
type SimpleQueryStatement ¶
type SimpleQueryStatement string
func NewBinarySimpleQueryStatement ¶
func NewBinarySimpleQueryStatement(attr string, operator SimpleQueryOperator, value string) (SimpleQueryStatement, error)
func NewBinarySimpleQueryStatementMultipleValues ¶
func NewBinarySimpleQueryStatementMultipleValues(attr string, operator SimpleQueryOperator, values ...string) (SimpleQueryStatement, error)
func NewBinarySimpleQueryStatementRange ¶
func NewBinarySimpleQueryStatementRange(attr string, operator SimpleQueryOperator, minimum string, maximum string) (SimpleQueryStatement, error)
type SimplifiedEntityRepresentation ¶
type SimplifiedEntityRepresentation string
SimplifiedEntityRepresentation are representation modes to generate simplified representations of entitites. See: https://orioncontextbroker.docs.apiary.io/#introduction/specification/simplified-entity-representation
const ( KeyValuesRepresentation SimplifiedEntityRepresentation = "keyValues" ValuesRepresentation SimplifiedEntityRepresentation = "values" UniqueRepresentation SimplifiedEntityRepresentation = "unique" CountRepresentation SimplifiedEntityRepresentation = "count" )
type Subscription ¶
type Subscription struct {
Id string `json:"id,omitempty"`
Description string `json:"description,omitempty"`
Subject *SubscriptionSubject `json:"subject,omitempty"`
Notification *SubscriptionNotification `json:"notification,omitempty"`
Expires *OrionTime `json:"expires,omitempty"`
Status SubscriptionStatus `json:"status,omitempty"`
Throttling uint `json:"throttling,omitempty"`
}
type SubscriptionNotification ¶
type SubscriptionNotification struct {
Attrs []string `json:"attrs,omitempty"`
ExceptAttrs []string `json:"exceptAttrs,omitempty"`
Http *SubscriptionNotificationHttp `json:"http,omitempty"`
HttpCustom *SubscriptionNotificationHttpCustom `json:"httpCustom,omitempty"`
AttrsFormat string `json:"attrsFormat,omitempty"`
Metadata []string `json:"metadata,omitempty"`
TimesSent uint `json:"timesSent,omitempty"`
LastNotification *time.Time `json:"lastNotification,omitempty"`
LastFailure *time.Time `json:"lastFailure,omitempty"`
LastSuccess *time.Time `json:"lastSuccess,omitempty"`
}
type SubscriptionNotificationHttp ¶
type SubscriptionNotificationHttp struct {
Url string `json:"url"`
}
type SubscriptionStatus ¶
type SubscriptionStatus string
const ( SubscriptionActive SubscriptionStatus = "active" SubscriptionInactive SubscriptionStatus = "inactive" SubscriptionExpired SubscriptionStatus = "expired" SubscriptionFailed SubscriptionStatus = "failed" )
type SubscriptionSubject ¶
type SubscriptionSubject struct {
Entities []*SubscriptionSubjectEntity `json:"entities,omitempty"`
Condition *SubscriptionSubjectCondition `json:"condition,omitempty"`
}
type SubscriptionSubjectCondition ¶
type SubscriptionSubjectCondition struct {
Attrs []string `json:"attrs,omitempty"`
Expression *SubscriptionSubjectConditionExpression `json:"expression,omitempty"`
}
type SubscriptionSubjectConditionExpression ¶
type SubscriptionSubjectConditionExpression = QueryExpression
type SubscriptionSubjectEntity ¶
type SubscriptionSubjectEntity = EntityMatcher