ngsi

package
v0.0.0-...-357839d Latest Latest
Warning

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

Go to latest
Published: May 27, 2021 License: MIT Imports: 16 Imported by: 3

Documentation

Index

Constants

View Source
const (
	//GeoSpatialRelationNearPoint describes a relation as a max or min distance from a Point
	GeoSpatialRelationNearPoint = "near"
	//GeoSpatialRelationWithinRect describes a relation as an overlapping polygon
	GeoSpatialRelationWithinRect = "within"

	//QueryDefaultPaginationLimit defines the limit that should be used for GET operations
	//when the client does not supply a value
	QueryDefaultPaginationLimit = uint64(1000)
)

Variables

This section is empty.

Functions

func NewCreateEntityHandler

func NewCreateEntityHandler(ctxReg ContextRegistry) http.HandlerFunc

NewCreateEntityHandler handles incoming POST requests for NGSI entities

func NewQueryEntitiesHandler

func NewQueryEntitiesHandler(ctxReg ContextRegistry) http.HandlerFunc

NewQueryEntitiesHandler handles GET requests for NGSI entitites

func NewRegisterContextSourceHandler

func NewRegisterContextSourceHandler(ctxReg ContextRegistry) http.HandlerFunc

NewRegisterContextSourceHandler handles POST requests for csource registrations

func NewRetrieveEntityHandler

func NewRetrieveEntityHandler(ctxReg ContextRegistry) http.HandlerFunc

NewRetrieveEntityHandler retrieves entity by ID.

func NewUpdateEntityAttributesHandler

func NewUpdateEntityAttributesHandler(ctxReg ContextRegistry) http.HandlerFunc

NewUpdateEntityAttributesHandler handles PATCH requests for NGSI entitity attributes

Types

type ContextRegistry

type ContextRegistry interface {
	GetContextSourcesForQuery(query Query) []ContextSource
	GetContextSourcesForEntity(entityID string) []ContextSource
	GetContextSourcesForEntityType(entityType string) []ContextSource

	Register(source ContextSource)
}

ContextRegistry is where Context Sources register the information that they can provide

func NewContextRegistry

func NewContextRegistry() ContextRegistry

NewContextRegistry initializes and returns a new default context registry without any registered context sources

type ContextSource

type ContextSource interface {
	ProvidesAttribute(attributeName string) bool
	ProvidesEntitiesWithMatchingID(entityID string) bool
	ProvidesType(typeName string) bool

	CreateEntity(typeName, entityID string, request Request) error
	GetEntities(query Query, callback QueryEntitiesCallback) error
	RetrieveEntity(entityID string, request Request) (Entity, error)
	UpdateEntityAttributes(entityID string, request Request) error
}

ContextSource provides query and subscription support for a set of entities

func NewRemoteContextSource

func NewRemoteContextSource(registration CsourceRegistration) (ContextSource, error)

NewRemoteContextSource creates an instance of a ContextSource by wrapping a CsourceRegistration

type CsourceRegistration

type CsourceRegistration interface {
	Endpoint() string
	ProvidesAttribute(attributeName string) bool
	ProvidesEntitiesWithMatchingID(entityID string) bool
	ProvidesType(typeName string) bool
}

CsourceRegistration is a wrapper for information about a registered context source

func NewCsourceRegistration

func NewCsourceRegistration(entityTypeName string, attributeNames []string, endpoint string, idpattern *string) (CsourceRegistration, error)

NewCsourceRegistration creates and returns a concrete implementation of the CsourceRegistration interface

func NewCsourceRegistrationFromJSON

func NewCsourceRegistrationFromJSON(jsonBytes []byte) (CsourceRegistration, error)

NewCsourceRegistrationFromJSON unpacks a byte buffer into a CsourceRegistration and validates its contents

type Entity

type Entity interface {
}

Entity is an informational representative of something that is supposed to exist in the real world, physically or conceptually

type GeoQuery

type GeoQuery struct {
	Geometry    string    `json:"geometry"`
	Coordinates []float64 `json:"coordinates"`
	GeoRel      string    `json:"georel"`
	GeoProperty *string   `json:"geoproperty,omitempty"`
	// contains filtered or unexported fields
}

GeoQuery contains information about a geo-query that may be used for subscriptions or when querying entitites

func (*GeoQuery) Distance

func (gq *GeoQuery) Distance() (uint32, bool)

Distance returns the required distance in meters from a near Point and a boolean flag indicating if it is inclusive or exclusive

func (*GeoQuery) Point

func (gq *GeoQuery) Point() (float64, float64, error)

Point extracts the position in the enclosed geometry

func (*GeoQuery) Rectangle

func (gq *GeoQuery) Rectangle() (float64, float64, float64, float64, error)

Rectangle extracts the two positions (opposing corners) within the enclosed geometry

type Query

type Query interface {
	HasDeviceReference() bool
	Device() string

	PaginationLimit() uint64
	PaginationOffset() uint64

	IsGeoQuery() bool
	Geo() *GeoQuery

	EntityAttributes() []string
	EntityTypes() []string

	Request() *http.Request
}

Query is an interface to be used when passing queries to context registries and sources

type QueryEntitiesCallback

type QueryEntitiesCallback func(entity Entity) error

QueryEntitiesCallback is used when queried context sources should pass back any entities matching the query that has been passed in

type Request

type Request interface {
	BodyReader() io.Reader
	DecodeBodyInto(v interface{}) error
	Request() *http.Request
}

Request is an interface to be used when passing header and body information for NGSI-LD API requests

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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