gossamer

package module
v0.0.0-...-8289b80 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

README

gossamer

Gossamer is an implementation of the OGC SensorThings API

GoDoc Build Status Coverage Status

Documentation

Index

Constants

View Source
const (
	MSG_ERR_HANDLING_REQUEST = "An error occured handling request"
	MSG_ERR_INSERTING_ENTITY = "An error occured inserting entity"
	MSG_ERR_DELETING_ENTITY  = "An error occured deleting entity"
)
View Source
const (
	UNIT_VOLTAGE = "Voltage"
	UNIT_CELSIUS = "Celsius"
)

Variables

View Source
var ERR_INVALID_ENTITY = errors.New("Invalid Entity")
View Source
var ERR_QUERYOPTION_BLANK = errors.New("Query option string blank")
View Source
var ERR_QUERYOPTION_INVALID_LENGTH = errors.New("Invalid Query Option. Query Options must have a key and value.")
View Source
var ERR_QUERYOPTION_INVALID_VALUE = errors.New("Invalid Query Option value")
View Source
var GLOB_ENV_HOST = "localhost:8000"

Globals

View Source
var STD_TIME_FORMAT_INSTANT = "2006-01-02T15:04:05-07:00"
View Source
var STD_TIME_FORMAT_PERIOD = "2006-01-02T15:04:05.00Z"

Functions

func GenerateEntityId

func GenerateEntityId() string

func GetAssociatedEntityId

func GetAssociatedEntityId(entity SensorThing, et EntityType) string

func IsEntity

func IsEntity(e string) bool

func IsQueryOption

func IsQueryOption(s string) bool

Checks if a given query option is a valid one

func IsSingularEntity

func IsSingularEntity(e string) bool
func ResolveEntityLink(id string, ent EntityType) string

func ResolveSelfLinkUrl

func ResolveSelfLinkUrl(id string, ent EntityType) string

func SetAssociatedEntityId

func SetAssociatedEntityId(entity SensorThing, et EntityType, id string)

func ThrowHttpBadRequest

func ThrowHttpBadRequest(msg string, w http.ResponseWriter)

func ThrowHttpCreated

func ThrowHttpCreated(msg string, w http.ResponseWriter)

func ThrowHttpInternalServerError

func ThrowHttpInternalServerError(msg string, w http.ResponseWriter)

func ThrowHttpMethodNotAllowed

func ThrowHttpMethodNotAllowed(msg string, w http.ResponseWriter)

func ThrowHttpOk

func ThrowHttpOk(msg string, w http.ResponseWriter)

func ThrowNotAcceptable

func ThrowNotAcceptable(msg string, w http.ResponseWriter)

func ValidateDeleteRequestUrl

func ValidateDeleteRequestUrl(req Request) error

func ValidateGetRequestUrl

func ValidateGetRequestUrl(req Request) error

func ValidateIntegrityConstraints

func ValidateIntegrityConstraints(entity SensorThing) error

func ValidateMandatoryProperties

func ValidateMandatoryProperties(entity SensorThing) error

func ValidatePatchRequestUrl

func ValidatePatchRequestUrl(req Request) error

func ValidatePostRequestUrl

func ValidatePostRequestUrl(req Request) error

TODO: Refactor this into whitelists

func ValidatePutRequestUrl

func ValidatePutRequestUrl(req Request) error

Types

type Client

type Client interface {
	QueryObservations() ClientQuery
	QueryThings() ClientQuery
	QueryObservedProperties() ClientQuery
	QueryLocations() ClientQuery
	QueryDatastreams() ClientQuery
	QuerySensors() ClientQuery
	QueryFeaturesOfInterest() ClientQuery
	QueryHistoricalLocations() ClientQuery

	GetObservation(string) (Observation, error)
	GetThing(string) (Thing, error)
	GetObservedProperty(string) (ObservedProperty, error)
	GetLocation(string) (Location, error)
	GetDatastream(string) (Datastream, error)
	GetSensor(string) (Sensor, error)
	GetFeaturesOfInterest(string) (FeatureOfInterest, error)
	GetHistoricalLocation(string) (HistoricalLocation, error)

	FindObservations() ([]Observation, error)
	FindThings() ([]Thing, error)
	FindObservedProperties() ([]ObservedProperty, error)
	FindLocations() ([]Location, error)
	FindDatastreams() ([]Datastream, error)
	FindSensors() ([]Sensor, error)
	FindFeaturesOfInterest() ([]FeatureOfInterest, error)
	FindHistoricalLocations() ([]HistoricalLocation, error)

	InsertObservation(Observation) error
	InsertThing(Thing) error
	InsertObservedProperty(ObservedProperty) error
	InsertLocation(Location) error
	InsertDatastream(Datastream) error
	InsertSensor(Sensor) error
	InsertFeaturesOfInterest(FeatureOfInterest) error

	DeleteObservation(string) error
	DeleteThing(string) error
	DeleteObservedProperty(string) error
	DeleteLocation(string) error
	DeleteDatastream(string) error
	DeleteSensor(string) error
	DeleteFeaturesOfInterest(string) error

	UpdateObservation(Observation) error
	UpdateThing(Thing) error
	UpdateObservedProperty(ObservedProperty) error
	UpdateLocation(Location) error
	UpdateDatastream(Datastream) error
	UpdateSensor(Sensor) error
	UpdateFeaturesOfInterest(FeatureOfInterest) error

	PatchObservation(Observation) error
	PatchThing(Thing) error
	PatchObservedProperty(ObservedProperty) error
	PatchLocation(Location) error
	PatchDatastream(Datastream) error
	PatchSensor(Sensor) error
	PatchFeaturesOfInterest(FeatureOfInterest) error
}

Client API

type ClientQuery

type ClientQuery interface {
	GetEntityType() EntityType

	Top(int) ClientQuery

	All() ([]SensorThing, error)
	One(string) (SensorThing, error)
}

type CountOption

type CountOption interface {
	QueryOption
	GetValue() bool
}

func CreateCountOption

func CreateCountOption(s string) (CountOption, error)

type Datastore

type Datastore interface {
	Query(ResourcePath, QueryOptions) (interface{}, error)
	Insert(ResourcePath, SensorThing) error
	Delete(EntityType, string) error
	Update(SensorThing) error
	Patch(SensorThing) error
	Init()
	Shutdown()
}

type Datastream

type Datastream interface {
	SensorThing
}

A Datastream groups a collection of Observations and the Observations in a Datastream measure the same ObservedProperty and are produced by the same Sensor.

type DatastreamEntity

type DatastreamEntity struct {
	SensorThingsEntity      `bson:",inline"`
	NavLinkThing            string                    `json:"Thing@iot.navigationLink,omitempty" bson:"-"`
	NavLinkSensor           string                    `json:"Sensor@iot.navigationLink,omitempty" bson:"-"`
	NavLinkObservedProperty string                    `json:"ObservedProperty@iot.navigationLink,omitempty" bson:"-"`
	NavLinkObservations     string                    `json:"Observations@iot.navigationLink,omitempty" bson:"-"`
	PhenomenonTime          *TimePeriod               `json:"phenomenonTime,omitempty" bson:"phenomenonTime,omitempty"`
	ResultTime              *TimePeriod               `json:"resultTime,omitempty" bson:"resultTime,omitempty"`
	UnitOfMeasurement       interface{}               `json:"unitOfMeasurement,omitempty" bson:"unitOfMeasurement,omitempty"`
	ObservationType         DatastreamObservationType `json:"observationType,omitempty" bson:"observationType,omitempty"`
	Description             string                    `json:"description,omitempty" bson:"description,omitempty"`
	IdThing                 string                    `json:"-" bson:"@iot_things_id"`
	IdObservedProperty      string                    `json:"-" bson:"@iot_observedproperties_id"`
	IdSensor                string                    `json:"-" bson:"@iot_sensors_id"`
	Thing                   *ThingEntity              `json:"Thing,omitempty" bson:"-"`
	ObservedProperty        *ObservedPropertyEntity   `json:"ObservedProperty,omitempty" bson:"-"`
	Sensor                  *SensorEntity             `json:"Sensor,omitempty" bson:"-"`
	Observations            []*ObservationEntity      `json:"Observations,omitempty" bson:"-"`
}

A Datastream groups a collection of Observations and the Observations in a Datastream measure the same ObservedProperty and are produced by the same Sensor.

func NewDatastreamEntity

func NewDatastreamEntity() *DatastreamEntity

func NewDatastreamEntityWithId

func NewDatastreamEntityWithId(id string) *DatastreamEntity

func (DatastreamEntity) GetType

func (e DatastreamEntity) GetType() EntityType

type DatastreamObservationType

type DatastreamObservationType string
const (
	DATASTREAM_OBSTYPE_CATEGORY         DatastreamObservationType = "http://www.opengis.net/def/observationType/ OGC-OM/2.0/OM_CategoryObservation"
	DATASTREAM_OBSTYPE_COUNT            DatastreamObservationType = "http://www.opengis.net/def/observationType/ OGC-OM/2.0/OM_CountObservation"
	DATASTREAM_OBSTYPE_MEASUREMENT      DatastreamObservationType = "http://www.opengis.net/def/observationType/ OGC-OM/2.0/OM_Measurement"
	DATASTREAM_OBSTYPE_OBSERVATION      DatastreamObservationType = "http://www.opengis.net/def/observationType/ OGC-OM/2.0/OM_Observation"
	DATASTREAM_OBSTYPE_TRUTHOBSERVATION DatastreamObservationType = "http://www.opengis.net/def/observationType/ OGC-OM/2.0/OM_TruthObservation"
)

type EntityType

type EntityType string
const (
	ENTITY_THING               EntityType = "Thing"
	ENTITY_THINGS              EntityType = "Things"
	ENTITY_OBSERVEDPROPERTY    EntityType = "ObservedProperty"
	ENTITY_OBSERVEDPROPERTIES  EntityType = "ObservedProperties"
	ENTITY_LOCATION            EntityType = "Location"
	ENTITY_LOCATIONS           EntityType = "Locations"
	ENTITY_DATASTREAM          EntityType = "Datastream"
	ENTITY_DATASTREAMS         EntityType = "Datastreams"
	ENTITY_SENSOR              EntityType = "Sensor"
	ENTITY_SENSORS             EntityType = "Sensors"
	ENTITY_OBSERVATION         EntityType = "Observation"
	ENTITY_OBSERVATIONS        EntityType = "Observations"
	ENTITY_FEATURESOFINTEREST  EntityType = "FeaturesOfInterest"
	ENTITY_HISTORICALLOCATION  EntityType = "HistoricalLocation"
	ENTITY_HISTORICALLOCATIONS EntityType = "HistoricalLocations"
	ENTITY_UNKNOWN             EntityType = "UNKNOWN"
)

func DiscoverEntityType

func DiscoverEntityType(e string) EntityType

type ExpandOption

type ExpandOption interface {
	QueryOption
	GetValue() []string
}

The $expand system query option indicates the related entities to be represented inline. The value of the $expand query option must be a comma separated list of navigation property names. Additionally each navigation property can be followed by a forward slash and another navigation property to enable identifying a multi-level relationship.

func CreateExpandOption

func CreateExpandOption(s string) (ExpandOption, error)

Creates an Expand QueryOption given a string value

type FeatureOfInterest

type FeatureOfInterest interface {
	SensorThing

	GetDescription() string
	GetEncodingType() LocationEncodingType
	GetFeature() interface{}
}

An Observation results in a value being assigned to a phenomenon. The phenomenon is a property of a feature, the latter being the FeatureOfInterest of the Observation [OGC and ISO 19156:2001]. In the context of the Internet of Things, many Observations’ FeatureOfInterest can be the Location of the Thing. For example, the FeatureOfInterest of a wifi-connect thermostat can be the Location of the thermostat (i.e., the living room where the thermostat is located in). In the case of remote sensing, the FeatureOfInterest can be the geographical area or volume that is being sensed.

type FeatureOfInterestEntity

type FeatureOfInterestEntity struct {
	SensorThingsEntity  `bson:",inline"`
	NavLinkObservations string               `json:"Observations@iot.navigationLink,omitempty" bson:"-"`
	Description         string               `json:"description,omitempty" bson:"description,omitempty"`
	EncodingType        LocationEncodingType `json:"encodingType,omitempty" bson:"encodingType,omitempty"`
	Feature             interface{}          `json:"feature,omitempty" bson:"feature,omitempty"`
	Observations        []*ObservationEntity `json:"Observations,omitempty" bson:"-"`
}

An Observation results in a value being assigned to a phenomenon. The phenomenon is a property of a feature, the latter being the FeatureOfInterest of the Observation [OGC and ISO 19156:2001]. In the context of the Internet of Things, many Observations’ FeatureOfInterest can be the Location of the Thing. For example, the FeatureOfInterest of a wifi-connect thermostat can be the Location of the thermostat (i.e., the living room where the thermostat is located in). In the case of remote sensing, the FeatureOfInterest can be the geographical area or volume that is being sensed.

func NewFeatureOfInterestEntity

func NewFeatureOfInterestEntity() *FeatureOfInterestEntity

func NewFeatureOfInterestEntityWithId

func NewFeatureOfInterestEntityWithId(id string) *FeatureOfInterestEntity

func (FeatureOfInterestEntity) GetDescription

func (e FeatureOfInterestEntity) GetDescription() string

func (FeatureOfInterestEntity) GetEncodingType

func (e FeatureOfInterestEntity) GetEncodingType() LocationEncodingType

func (FeatureOfInterestEntity) GetFeature

func (e FeatureOfInterestEntity) GetFeature() interface{}

func (FeatureOfInterestEntity) GetType

func (e FeatureOfInterestEntity) GetType() EntityType

type FilterOption

type FilterOption interface {
	QueryOption
}

func CreateFilterOption

func CreateFilterOption(s string) (FilterOption, error)

type GossamerCountOption

type GossamerCountOption struct {
	// contains filtered or unexported fields
}

func (*GossamerCountOption) GetType

func (o *GossamerCountOption) GetType() QueryOptionType

func (*GossamerCountOption) GetValue

func (o *GossamerCountOption) GetValue() bool

type GossamerExpandOption

type GossamerExpandOption struct {
	// contains filtered or unexported fields
}

func (*GossamerExpandOption) GetType

func (*GossamerExpandOption) GetValue

func (o *GossamerExpandOption) GetValue() []string

type GossamerFilterOption

type GossamerFilterOption struct {
}

func (*GossamerFilterOption) GetType

type GossamerOrderByOption

type GossamerOrderByOption struct {
	// contains filtered or unexported fields
}

func (*GossamerOrderByOption) GetSortProperties

func (o *GossamerOrderByOption) GetSortProperties() []string

func (*GossamerOrderByOption) GetType

func (*GossamerOrderByOption) GetValue

func (o *GossamerOrderByOption) GetValue() []OrderByOptionValue

type GossamerOrderByOptionValue

type GossamerOrderByOptionValue struct {
	// contains filtered or unexported fields
}

func (GossamerOrderByOptionValue) GetSortProperty

func (o GossamerOrderByOptionValue) GetSortProperty() string

type GossamerQueryOption

type GossamerQueryOption struct {
	// contains filtered or unexported fields
}

func (*GossamerQueryOption) CountSet

func (o *GossamerQueryOption) CountSet() bool

func (*GossamerQueryOption) ExpandSet

func (o *GossamerQueryOption) ExpandSet() bool

func (*GossamerQueryOption) FilterSet

func (o *GossamerQueryOption) FilterSet() bool

func (*GossamerQueryOption) GetCountOption

func (o *GossamerQueryOption) GetCountOption() CountOption

func (*GossamerQueryOption) GetExpandOption

func (o *GossamerQueryOption) GetExpandOption() ExpandOption

func (*GossamerQueryOption) GetFilterOption

func (o *GossamerQueryOption) GetFilterOption() FilterOption

func (*GossamerQueryOption) GetOrderByOption

func (o *GossamerQueryOption) GetOrderByOption() OrderByOption

func (*GossamerQueryOption) GetSelectOption

func (o *GossamerQueryOption) GetSelectOption() SelectOption

func (*GossamerQueryOption) GetSkipOption

func (o *GossamerQueryOption) GetSkipOption() SkipOption

func (*GossamerQueryOption) GetTopOption

func (o *GossamerQueryOption) GetTopOption() TopOption

func (*GossamerQueryOption) OrderBySet

func (o *GossamerQueryOption) OrderBySet() bool

func (*GossamerQueryOption) SelectSet

func (o *GossamerQueryOption) SelectSet() bool

func (*GossamerQueryOption) Set

func (o *GossamerQueryOption) Set(optType QueryOptionType, value QueryOption)

func (*GossamerQueryOption) SkipSet

func (o *GossamerQueryOption) SkipSet() bool

func (*GossamerQueryOption) TopSet

func (o *GossamerQueryOption) TopSet() bool

type GossamerRequest

type GossamerRequest struct {
	// contains filtered or unexported fields
}

func (GossamerRequest) GetProtocol

func (r GossamerRequest) GetProtocol() ProtocolType

func (GossamerRequest) GetQueryOptions

func (r GossamerRequest) GetQueryOptions() QueryOptions

func (GossamerRequest) GetResourcePath

func (r GossamerRequest) GetResourcePath() ResourcePath

type GossamerSelectOption

type GossamerSelectOption struct {
	// contains filtered or unexported fields
}

func (*GossamerSelectOption) GetType

func (*GossamerSelectOption) GetValue

func (o *GossamerSelectOption) GetValue() []string

type GossamerSkipOption

type GossamerSkipOption struct {
	// contains filtered or unexported fields
}

func (*GossamerSkipOption) GetType

func (o *GossamerSkipOption) GetType() QueryOptionType

func (*GossamerSkipOption) GetValue

func (o *GossamerSkipOption) GetValue() int

type GossamerTopOption

type GossamerTopOption struct {
	// contains filtered or unexported fields
}

func (*GossamerTopOption) GetType

func (o *GossamerTopOption) GetType() QueryOptionType

func (*GossamerTopOption) GetValue

func (o *GossamerTopOption) GetValue() int

type GossamerUnitOfMeasurement

type GossamerUnitOfMeasurement struct {
	// contains filtered or unexported fields
}

func (*GossamerUnitOfMeasurement) GetDefinition

func (u *GossamerUnitOfMeasurement) GetDefinition() string

func (*GossamerUnitOfMeasurement) GetName

func (u *GossamerUnitOfMeasurement) GetName() string

func (*GossamerUnitOfMeasurement) GetSymbol

func (u *GossamerUnitOfMeasurement) GetSymbol() string

type HistoricalLocation

type HistoricalLocation interface {
	SensorThing

	// The time when the Thing is known at the Location.
	GetTime() *TimeInstant
}

A Thing’s HistoricalLocation entity set provides the current (i.e., last known) and previous locations of the Thing with their time.

type HistoricalLocationEntity

type HistoricalLocationEntity struct {
	SensorThingsEntity         `bson:",inline"`
	NavLinkHistoricalLocations string            `json:"HistoricalLocations@iot.navigationLink,omitempty"`
	NavLinkThing               string            `json:"Thing@iot.navigationLink,omitempty"`
	Time                       *TimeInstant      `json:"time" bson:"time,omitempty"`
	IdThing                    string            `json:"-" bson:"@iot_things_id"`
	IdLocations                []string          `json:"-" bson:"@iot_locations_id"`
	Thing                      *ThingEntity      `json:"Thing,omitempty" bson:"-"`
	Locations                  []*LocationEntity `json:"Locations,omitempty" bson:"-"`
}

A Thing’s HistoricalLocation entity set provides the current (i.e., last known) and previous locations of the Thing with their time.

func NewHistoricalLocationEntity

func NewHistoricalLocationEntity() *HistoricalLocationEntity

func NewHistoricalLocationEntityWithId

func NewHistoricalLocationEntityWithId(id string) *HistoricalLocationEntity

func (HistoricalLocationEntity) GetTime

func (HistoricalLocationEntity) GetType

type Location

type Location interface {
	SensorThing
	GetDescription() string
	GetEncodingType() LocationEncodingType
}

The Location entity locates the Thing or the Things it associated with. A Thing’s Location entity is defined as the last known location of the Thing. A Thing’s Location may be identical to the Thing’s Observations’ FeatureOfInterest. In the context of the IoT, the principle location of interest is usually associated with the location of the Thing, especially for in-situ sensing applications. For example, the location of interest of a wifi-connected thermostat should be the building or the room in which the smart thermostat is located. And the FeatureOfInterest of the Observations made by the thermostat (e.g., room temperature readings) should also be the building or the room. In this case, the content of the smart thermostat’s location should be the same as the content of the temperature readings’ feature of interest.

type LocationEncodingType

type LocationEncodingType string
const (
	LOCATION_ENCTYPE_GEOJSON LocationEncodingType = "application/vnd.geo+json"
)

type LocationEntity

type LocationEntity struct {
	SensorThingsEntity         `bson:",inline"`
	NavLinkHistoricalLocations string                      `json:"HistoricalLocations@iot.navigationLink,omitempty" bson:"-"`
	NavLinkThings              string                      `json:"Things@iot.navigationLink,omitempty" bson:"-"`
	Description                string                      `json:"description,omitempty" bson:"description,omitempty"`
	EncodingType               LocationEncodingType        `json:"encodingType,omitempty" bson:"encodingType,omitempty"`
	Location                   interface{}                 `json:"location,omitempty" bson:"location,omitempty"`
	Things                     []*ThingEntity              `json:"Things,omitempty" bson:"-"`
	HistoricalLocations        []*HistoricalLocationEntity `json:"HistoricalLocations,omitempty" bson:"-"`
}

The Location entity locates the Thing or the Things it associated with. A Thing’s Location entity is defined as the last known location of the Thing. A Thing’s Location may be identical to the Thing’s Observations’ FeatureOfInterest. In the context of the IoT, the principle location of interest is usually associated with the location of the Thing, especially for in-situ sensing applications. For example, the location of interest of a wifi-connected thermostat should be the building or the room in which the smart thermostat is located. And the FeatureOfInterest of the Observations made by the thermostat (e.g., room temperature readings) should also be the building or the room. In this case, the content of the smart thermostat’s location should be the same as the content of the temperature readings’ feature of interest.

func NewLocationEntity

func NewLocationEntity() *LocationEntity

func NewLocationEntityWithId

func NewLocationEntityWithId(id string) *LocationEntity

func (LocationEntity) GetDescription

func (e LocationEntity) GetDescription() string

func (LocationEntity) GetEncodingType

func (e LocationEntity) GetEncodingType() LocationEncodingType

func (LocationEntity) GetType

func (e LocationEntity) GetType() EntityType

type Observation

type Observation interface {
	SensorThing

	// The time instant or period of when the Observation happens.
	GetPhenomenonTime() *TimePeriod

	// The time of the Observation's result was generated.
	GetResultTime() *TimeInstant

	// The estimated value of an ObservedProperty from the Observation.
	GetResult() interface{}

	// Describes the quality of the result.
	GetResultQuality() interface{}

	// The time period during which the result may be used.
	GetValidTime() *TimePeriod

	// Key-value pairs showing the environmental conditions during measurement.
	GetParameters() map[string]interface{}
}

An Observation is act of measuring or otherwise determining the value of a property

type ObservationEntity

type ObservationEntity struct {
	SensorThingsEntity       `bson:",inline"`
	NavLinkFeatureOfInterest string                   `json:"FeatureOfInterest@iot.navigationLink,omitempty" bson:"-"`
	NavLinkDatastream        string                   `json:"Datastream@iot.navigationLink,omitempty" bson:"-"`
	PhenomenonTime           *TimePeriod              `json:"phenomenonTime,omitempty" bson:"phenomenonTime,omitempty"`
	Result                   interface{}              `json:"result,omitempty" bson:"result,omitempty"`
	ResultTime               *TimeInstant             `json:"resultTime,omitempty" bson:"resultTime,omitempty"`
	ResultQuality            interface{}              `json:"resultQuality,omitempty" bson:"resultQuality,omitempty"`
	ValidTime                *TimePeriod              `json:"validTime,omitempty" bson:"validTime,omitempty"`
	Parameters               map[string]interface{}   `json:"parameters,omitempty" bson:"parameters,omitempty"`
	IdDatastream             string                   `json:"-" bson:"@iot_datastreams_id"`
	IdFeatureOfInterest      string                   `json:"-" bson:"@iot_featureofinterests_id"`
	Datastream               *DatastreamEntity        `json:"Datastream,omitempty" bson:"-"`
	FeatureOfInterest        *FeatureOfInterestEntity `json:"FeatureOfInterest,omitempty" bson:"-"`
}

An Observation is act of measuring or otherwise determining the value of a property

func CloneObservationEntity

func CloneObservationEntity(o Observation) *ObservationEntity

func NewObservationEntity

func NewObservationEntity() *ObservationEntity

func NewObservationEntityWithId

func NewObservationEntityWithId(id string) *ObservationEntity

func (ObservationEntity) GetParameters

func (e ObservationEntity) GetParameters() map[string]interface{}

func (ObservationEntity) GetPhenomenonTime

func (e ObservationEntity) GetPhenomenonTime() *TimePeriod

func (ObservationEntity) GetResult

func (e ObservationEntity) GetResult() interface{}

func (ObservationEntity) GetResultQuality

func (e ObservationEntity) GetResultQuality() interface{}

func (ObservationEntity) GetResultTime

func (e ObservationEntity) GetResultTime() *TimeInstant

func (ObservationEntity) GetType

func (e ObservationEntity) GetType() EntityType

func (ObservationEntity) GetValidTime

func (e ObservationEntity) GetValidTime() *TimePeriod

type ObservationType

type ObservationType string

type ObservedProperty

type ObservedProperty interface {
	SensorThing

	GetName() string
	GetDefinition() string
	GetDescription() string
}

An ObservedProperty specifies the phenomenon of an Observation.

type ObservedPropertyEntity

type ObservedPropertyEntity struct {
	SensorThingsEntity `bson:",inline"`
	NavLinkDatastreams string        `json:"Datastreams@iot.navigationLink,omitempty" bson:"-"`
	Description        string        `json:"description,omitempty" bson:"description,omitempty"`
	Name               string        `json:"name,omitempty" bson:"name,omitempty"`
	Definition         string        `json:"definition,omitempty" bson:"definition,omitempty"`
	Datastreams        []*Datastream `json:"Datastreams,omitempty" bson:"-"`
}

An ObservedProperty specifies the phenomenon of an Observation.

func NewObservedPropertyEntity

func NewObservedPropertyEntity() *ObservedPropertyEntity

func NewObservedPropertyEntityWithId

func NewObservedPropertyEntityWithId(id string) *ObservedPropertyEntity

func (ObservedPropertyEntity) GetDefinition

func (e ObservedPropertyEntity) GetDefinition() string

func (ObservedPropertyEntity) GetDescription

func (e ObservedPropertyEntity) GetDescription() string

func (ObservedPropertyEntity) GetName

func (e ObservedPropertyEntity) GetName() string

func (ObservedPropertyEntity) GetType

func (e ObservedPropertyEntity) GetType() EntityType

type OrderByOption

type OrderByOption interface {
	QueryOption
	GetValue() []OrderByOptionValue
	GetSortProperties() []string
}

The $orderby system query option specifies the order in which items are returned from the service.

func CreateOrderByOption

func CreateOrderByOption(s string) (OrderByOption, error)

type OrderByOptionValue

type OrderByOptionValue interface {
	GetSortProperty() string
}

asc, desc

type ProtocolType

type ProtocolType int
const (
	HTTP ProtocolType = 0
	COAP ProtocolType = 1
)

type QueryOption

type QueryOption interface {
	GetType() QueryOptionType
}

Query Option

func CreateQueryOption

func CreateQueryOption(o QueryOptionType, s string) (QueryOption, error)

type QueryOptionType

type QueryOptionType string
const (
	QUERYOPT_EXPAND  QueryOptionType = "$expand"
	QUERYOPT_SELECT  QueryOptionType = "$select"
	QUERYOPT_ORDERBY QueryOptionType = "$orderby"
	QUERYOPT_TOP     QueryOptionType = "$top"
	QUERYOPT_SKIP    QueryOptionType = "$skip"
	QUERYOPT_COUNT   QueryOptionType = "$count"
	QUERYOPT_FILTER  QueryOptionType = "$filter"
	QUERYOPT_UNKNOWN QueryOptionType = "UNKNOWN"
)

func DiscoverQueryOptionType

func DiscoverQueryOptionType(s string) QueryOptionType

Returns the QueryOptionType for a given query option string

type QueryOptions

type QueryOptions interface {
	ExpandSet() bool
	SelectSet() bool
	OrderBySet() bool
	TopSet() bool
	SkipSet() bool
	CountSet() bool
	FilterSet() bool

	GetExpandOption() ExpandOption
	GetSelectOption() SelectOption
	GetOrderByOption() OrderByOption
	GetTopOption() TopOption
	GetSkipOption() SkipOption
	GetCountOption() CountOption
	GetFilterOption() FilterOption
}

Determines a list of Query Options that has been set for a request

func CreateQueryOptions

func CreateQueryOptions(q string) (QueryOptions, error)

type Request

type Request interface {
	GetProtocol() ProtocolType
	GetQueryOptions() QueryOptions
	GetResourcePath() ResourcePath
}

func CreateIncomingRequest

func CreateIncomingRequest(url *url.URL, t ProtocolType) (Request, error)

type ResourcePath

type ResourcePath interface {
	All() []ResourcePathItem
	Current() ResourcePathItem
	Next() ResourcePathItem
	Prev() ResourcePathItem
	First() ResourcePathItem
	Last() ResourcePathItem

	// Get the containing resource for the target resource
	// e.g. returns
	Containing() ResourcePathItem

	IsLast() bool
	IsFirst() bool
	HasNext() bool

	CurrentIndex() int
	Size() int
	Add(ResourcePathItem)
	At(int) ResourcePathItem
}

type ResourcePathItem

type ResourcePathItem interface {
	GetEntity() EntityType
	GetId() string
	GetQueryOptions() QueryOptions
}

type ResourceUrlType

type ResourceUrlType struct {
	Name string `json:"name"`
	Url  string `json:"url"`
}

type RootResourceResponse

type RootResourceResponse struct {
	// contains filtered or unexported fields
}

type SelectOption

type SelectOption interface {
	QueryOption
	GetValue() []string
}

The $select system query option requests that the service to return only the properties explicitly requested by the client. The value of a $select query option is a comma-separated list of selection clauses. Each selection clause may be a property name (including navigation property names). The service returns the specified content, if available, along with any available expanded navigation properties.

func CreateSelectOption

func CreateSelectOption(s string) (SelectOption, error)

type Sensor

type Sensor interface {
	SensorThing

	GetDescription() string
	GetEncodingType() SensorEncodingType
	GetMetadata() interface{}
}

A Sensor is an instrument that observes a property or phenomenon with the goal of producing an estimate of the value of the property.

type SensorEncodingType

type SensorEncodingType string
const (
	SENSOR_ENCTYPE_PDF      SensorEncodingType = "application/pdf"
	SENSOR_ENCTYPE_SENSORML SensorEncodingType = "http://www.opengis.net/doc/IS/SensorML/2.0"
)

type SensorEntity

type SensorEntity struct {
	SensorThingsEntity `bson:",inline"`
	NavLinkDatastreams string             `json:"Datastreams@iot.navigationLink,omitempty" bson:"-"`
	Description        string             `json:"description,omitempty" bson:"description,omitempty"`
	EncodingType       SensorEncodingType `json:"encodingType,omitempty" bson:"encodingType,omitempty"`
	Metadata           interface{}        `json:"metadata,omitempty" bson:"metadata,omitempty"`
	Datastreams        []*Datastream      `json:"Datastreams,omitempty" bson:"-"`
}

A Sensor is an instrument that observes a property or phenomenon with the goal of producing an estimate of the value of the property.

func CloneSensorEntity

func CloneSensorEntity(o Sensor) *SensorEntity

func NewSensorEntity

func NewSensorEntity() *SensorEntity

func NewSensorEntityWithId

func NewSensorEntityWithId(id string) *SensorEntity

func (SensorEntity) GetDescription

func (e SensorEntity) GetDescription() string

func (SensorEntity) GetEncodingType

func (e SensorEntity) GetEncodingType() SensorEncodingType

func (SensorEntity) GetMetadata

func (e SensorEntity) GetMetadata() interface{}

func (SensorEntity) GetType

func (e SensorEntity) GetType() EntityType

type SensorThing

type SensorThing interface {
	GetId() string
	GetSelfLink() string
	GetType() EntityType
}

Entities

func DecodeJsonToEntityStruct

func DecodeJsonToEntityStruct(decoder *json.Decoder, et EntityType) (SensorThing, error)

type SensorThingsEntity

type SensorThingsEntity struct {
	Id       string `json:"@iot.id,omitempty" bson:"@iot_id"`
	SelfLink string `json:"@iot.selfLink,omitempty" bson:"-"`
}

Base SensorThings Entity

func (SensorThingsEntity) GetId

func (e SensorThingsEntity) GetId() string

SensorThings property: @iot.id

func (e SensorThingsEntity) GetSelfLink() string

SensorThings property: selfLink

type SensorThingsResourcePath

type SensorThingsResourcePath struct {
	// contains filtered or unexported fields
}

func (*SensorThingsResourcePath) Add

func (*SensorThingsResourcePath) All

func (*SensorThingsResourcePath) At

func (*SensorThingsResourcePath) Containing

func (*SensorThingsResourcePath) Current

func (*SensorThingsResourcePath) CurrentIndex

func (r *SensorThingsResourcePath) CurrentIndex() int

func (*SensorThingsResourcePath) First

func (*SensorThingsResourcePath) HasNext

func (r *SensorThingsResourcePath) HasNext() bool

func (*SensorThingsResourcePath) IsFirst

func (r *SensorThingsResourcePath) IsFirst() bool

func (*SensorThingsResourcePath) IsLast

func (r *SensorThingsResourcePath) IsLast() bool

func (*SensorThingsResourcePath) Last

func (*SensorThingsResourcePath) Next

func (*SensorThingsResourcePath) Prev

func (*SensorThingsResourcePath) Size

func (r *SensorThingsResourcePath) Size() int

type SensorThingsResourcePathItem

type SensorThingsResourcePathItem struct {
	// contains filtered or unexported fields
}

func (*SensorThingsResourcePathItem) GetEntity

func (*SensorThingsResourcePathItem) GetId

func (*SensorThingsResourcePathItem) GetQueryOptions

func (n *SensorThingsResourcePathItem) GetQueryOptions() QueryOptions

type Server

type Server interface {
	Stop()
	Start()
	UseStore(Datastore)
}

type SkipOption

type SkipOption interface {
	QueryOption
	GetValue() int
}

func CreateSkipOption

func CreateSkipOption(s string) (SkipOption, error)

type Thing

type Thing interface {
	SensorThing

	// This is a short description of the corresponding Thing entity.
	GetDescription() string

	// An Object containing user-annotated properties as key-value pairs.
	GetProperties() map[string]string
}

The OGC SensorThings API follows the ITU-T definition, i.e., with regard to the Internet of Things, a thing is an object of the physical world (physical things) or the information world (virtual things) that is capable of being identified and integrated into communication networks [ITU-T Y.2060].

type ThingEntity

type ThingEntity struct {
	SensorThingsEntity         `bson:",inline"`
	NavLinkLocations           string                      `json:"Locations@iot.navigationLink,omitempty" bson:"-"`
	NavLinkDatastreams         string                      `json:"Datastreams@iot.navigationLink,omitempty" bson:"-"`
	NavLinkHistoricalLocations string                      `json:"HistoricalLocations@iot.navigationLink,omitempty" bson:"-"`
	Description                string                      `json:"description,omitempty" bson:"description,omitempty"`
	Properties                 map[string]string           `json:"properties,omitempty" bson:"properties,omitempty"`
	IdLocations                []string                    `json:"-" bson:"@iot_locations_id"`
	Locations                  []*LocationEntity           `json:",omitempty" bson:"-"`
	HistoricalLocations        []*HistoricalLocationEntity `json:",omitempty" bson:"-"`
	Datastreams                []*DatastreamEntity         `json:",omitempty" bson:"-"`
}

The OGC SensorThings API follows the ITU-T definition, i.e., with regard to the Internet of Things, a thing is an object of the physical world (physical things) or the information world (virtual things) that is capable of being identified and integrated into communication networks [ITU-T Y.2060].

func NewThingEntity

func NewThingEntity() *ThingEntity

func NewThingEntityWithId

func NewThingEntityWithId(id string) *ThingEntity

func (ThingEntity) GetDescription

func (e ThingEntity) GetDescription() string

func (ThingEntity) GetProperties

func (e ThingEntity) GetProperties() map[string]string

func (ThingEntity) GetType

func (e ThingEntity) GetType() EntityType

type TimeInstant

type TimeInstant time.Time

func NewTimeInstant

func NewTimeInstant(t time.Time) *TimeInstant

func (TimeInstant) GetBSON

func (t TimeInstant) GetBSON() (interface{}, error)

func (TimeInstant) IsZero

func (t TimeInstant) IsZero() bool

func (TimeInstant) MarshalJSON

func (t TimeInstant) MarshalJSON() ([]byte, error)

func (*TimeInstant) SetBSON

func (t *TimeInstant) SetBSON(raw bson.Raw) error

func (*TimeInstant) UnmarshalJSON

func (t *TimeInstant) UnmarshalJSON(data []byte) error

type TimePeriod

type TimePeriod struct {
	FromTime time.Time
	ToTime   time.Time
}

func NewDefaultTimePeriod

func NewDefaultTimePeriod() *TimePeriod

func NewTimePeriod

func NewTimePeriod(from time.Time, to time.Time) *TimePeriod

func (*TimePeriod) From

func (t *TimePeriod) From() time.Time

func (TimePeriod) GetBSON

func (t TimePeriod) GetBSON() (interface{}, error)

func (TimePeriod) IsZero

func (t TimePeriod) IsZero() bool

func (TimePeriod) MarshalJSON

func (t TimePeriod) MarshalJSON() ([]byte, error)

func (*TimePeriod) SetBSON

func (t *TimePeriod) SetBSON(raw bson.Raw) error

func (*TimePeriod) To

func (t *TimePeriod) To() time.Time

func (*TimePeriod) UnmarshalJSON

func (t *TimePeriod) UnmarshalJSON(data []byte) error

type TopOption

type TopOption interface {
	QueryOption
	GetValue() int
}

func CreateTopOption

func CreateTopOption(s string) (TopOption, error)

type UnitOfMeasurement

type UnitOfMeasurement interface {
	GetName() string
	GetSymbol() string
	GetDefinition() string
}

func NewUnitOfMeasurementBySymbol

func NewUnitOfMeasurementBySymbol(symbol string) UnitOfMeasurement

type ValueList

type ValueList struct {
	Count int         `json:"count,omitempty"`
	Value interface{} `json:"value"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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