api

package
v0.0.0-...-6cd7eb2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertLocationToFoi

func ConvertLocationToFoi(l *entities.Location) *entities.FeatureOfInterest

ConvertLocationToFoi converts a location to FOI

func CopyLocationToFoi

func CopyLocationToFoi(gdb *models.Database, datastreamID interface{}) (string, error)

CopyLocationToFoi copies the location of the thing to the FeatureOfInterest table. If it already exist, returns only the existing FeatureOfInterest ID

func NewAPI

func NewAPI(database models.Database, config configuration.Config, mqtt models.MQTTClient) models.API

NewAPI Initialise a new SensorThings API

Types

type APIv1

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

APIv1 is the default implementation of SensorThingsApi, API needs a database provider, config, endpoint information to setup te needed services

func (a *APIv1) CreateNextLink(incomingURL string, qo *odata.QueryOptions) string

CreateNextLink creates the link to the next page with results

incomingUrl is the url of the request excluding oData query params

func (*APIv1) DeleteDatastream

func (a *APIv1) DeleteDatastream(id interface{}) error

DeleteDatastream deletes a datastream from the database

func (*APIv1) DeleteFeatureOfInterest

func (a *APIv1) DeleteFeatureOfInterest(id interface{}) error

DeleteFeatureOfInterest deletes a given FeatureOfInterest from the database

func (*APIv1) DeleteHistoricalLocation

func (a *APIv1) DeleteHistoricalLocation(id interface{}) error

DeleteHistoricalLocation deletes a given HistoricalLocation from the database

func (*APIv1) DeleteLocation

func (a *APIv1) DeleteLocation(id interface{}) error

DeleteLocation deletes a given Location from the database

func (*APIv1) DeleteObservation

func (a *APIv1) DeleteObservation(id interface{}) error

DeleteObservation deletes a given Observation from the database

func (*APIv1) DeleteObservedProperty

func (a *APIv1) DeleteObservedProperty(id interface{}) error

DeleteObservedProperty deletes a given ObservedProperty from the database

func (*APIv1) DeleteSensor

func (a *APIv1) DeleteSensor(id interface{}) error

DeleteSensor deletes a sensor from the database by given sensor id

func (*APIv1) DeleteThing

func (a *APIv1) DeleteThing(id interface{}) error

DeleteThing deletes a given Thing from the database

func (*APIv1) GetAcceptedPaths

func (a *APIv1) GetAcceptedPaths() []string

GetAcceptedPaths returns an array of accepted endpoint paths

func (*APIv1) GetBasePathInfo

func (a *APIv1) GetBasePathInfo() *entities.ArrayResponse

GetBasePathInfo when navigating to the base resource path will return a JSON array of the available SensorThings resource endpoints.

func (*APIv1) GetConfig

func (a *APIv1) GetConfig() *configuration.Config

GetConfig return the current configuration.Config set for the api

func (*APIv1) GetDatastream

func (a *APIv1) GetDatastream(id interface{}, qo *odata.QueryOptions, path string) (*entities.Datastream, error)

GetDatastream retrieves a sensor by id and given query

func (*APIv1) GetDatastreamByObservation

func (a *APIv1) GetDatastreamByObservation(observationID interface{}, qo *odata.QueryOptions, path string) (*entities.Datastream, error)

GetDatastreamByObservation returns a datastream linked to the given observation

func (*APIv1) GetDatastreams

func (a *APIv1) GetDatastreams(qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetDatastreams retrieves an array of sensors based on the given query

func (*APIv1) GetDatastreamsByObservedProperty

func (a *APIv1) GetDatastreamsByObservedProperty(oID interface{}, qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetDatastreamsByObservedProperty returns all datastreams linked to the given ObservedProperty

func (*APIv1) GetDatastreamsBySensor

func (a *APIv1) GetDatastreamsBySensor(sensorID interface{}, qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetDatastreamsBySensor returns all datastreams linked to the given sensor

func (*APIv1) GetDatastreamsByThing

func (a *APIv1) GetDatastreamsByThing(thingID interface{}, qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetDatastreamsByThing returns all datastreams linked to the given thing

func (*APIv1) GetEndpoints

func (a *APIv1) GetEndpoints() *map[entities.EntityType]models.Endpoint

GetEndpoints returns all configured endpoints for the HTTP server

func (*APIv1) GetFeatureOfInterest

func (a *APIv1) GetFeatureOfInterest(id interface{}, qo *odata.QueryOptions, path string) (*entities.FeatureOfInterest, error)

GetFeatureOfInterest returns a FeatureOfInterest by id

func (*APIv1) GetFeatureOfInterestByObservation

func (a *APIv1) GetFeatureOfInterestByObservation(id interface{}, qo *odata.QueryOptions, path string) (*entities.FeatureOfInterest, error)

GetFeatureOfInterestByObservation retrieves a FeatureOfInterest by given Observation id

func (*APIv1) GetFeatureOfInterests

func (a *APIv1) GetFeatureOfInterests(qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetFeatureOfInterests return FeaturesOfInterest based on the given QueryOptions

func (*APIv1) GetHistoricalLocation

func (a *APIv1) GetHistoricalLocation(id interface{}, qo *odata.QueryOptions, path string) (*entities.HistoricalLocation, error)

GetHistoricalLocation retrieves a single HistoricalLocation by id

func (*APIv1) GetHistoricalLocations

func (a *APIv1) GetHistoricalLocations(qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetHistoricalLocations retrieves all HistoricalLocations

func (*APIv1) GetHistoricalLocationsByLocation

func (a *APIv1) GetHistoricalLocationsByLocation(locationID interface{}, qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetHistoricalLocationsByLocation retrieves all HistoricalLocations linked to a given location

func (*APIv1) GetHistoricalLocationsByThing

func (a *APIv1) GetHistoricalLocationsByThing(thingID interface{}, qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetHistoricalLocationsByThing retrieves all HistoricalLocations linked to a given thing

func (*APIv1) GetLocation

func (a *APIv1) GetLocation(id interface{}, qo *odata.QueryOptions, path string) (*entities.Location, error)

GetLocation retrieves a single location by id

func (*APIv1) GetLocations

func (a *APIv1) GetLocations(qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetLocations retrieves all locations from the database and returns it as and ArrayResponse

func (*APIv1) GetLocationsByHistoricalLocation

func (a *APIv1) GetLocationsByHistoricalLocation(hlID interface{}, qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetLocationsByHistoricalLocation retrieves the latest locations linked to a HistoricalLocation

func (*APIv1) GetLocationsByThing

func (a *APIv1) GetLocationsByThing(thingID interface{}, qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetLocationsByThing retrieves the latest locations linked to a thing

func (*APIv1) GetObservation

func (a *APIv1) GetObservation(id interface{}, qo *odata.QueryOptions, path string) (*entities.Observation, error)

GetObservation returns an observation by id

func (*APIv1) GetObservations

func (a *APIv1) GetObservations(qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetObservations return all observations by given QueryOptions

func (*APIv1) GetObservationsByDatastream

func (a *APIv1) GetObservationsByDatastream(datastreamID interface{}, qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetObservationsByDatastream returns all observations by given Datastream and QueryOptions

func (*APIv1) GetObservationsByFeatureOfInterest

func (a *APIv1) GetObservationsByFeatureOfInterest(foiID interface{}, qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetObservationsByFeatureOfInterest returns all observation by given FeatureOfInterest end QueryOptions

func (*APIv1) GetObservedProperties

func (a *APIv1) GetObservedProperties(qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetObservedProperties todo

func (*APIv1) GetObservedProperty

func (a *APIv1) GetObservedProperty(id interface{}, qo *odata.QueryOptions, path string) (*entities.ObservedProperty, error)

GetObservedProperty todo

func (*APIv1) GetObservedPropertyByDatastream

func (a *APIv1) GetObservedPropertyByDatastream(datastreamID interface{}, qo *odata.QueryOptions, path string) (*entities.ObservedProperty, error)

GetObservedPropertyByDatastream todo

func (*APIv1) GetSensor

func (a *APIv1) GetSensor(id interface{}, qo *odata.QueryOptions, path string) (*entities.Sensor, error)

GetSensor retrieves a sensor by id and given query

func (*APIv1) GetSensorByDatastream

func (a *APIv1) GetSensorByDatastream(id interface{}, qo *odata.QueryOptions, path string) (*entities.Sensor, error)

GetSensorByDatastream retrieves a sensor by given datastream

func (*APIv1) GetSensors

func (a *APIv1) GetSensors(qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetSensors retrieves an array of sensors based on the given query

func (*APIv1) GetThing

func (a *APIv1) GetThing(id interface{}, qo *odata.QueryOptions, path string) (*entities.Thing, error)

GetThing returns a thing entity based on the given id and QueryOptions returns an error when the entity cannot be found

func (*APIv1) GetThingByDatastream

func (a *APIv1) GetThingByDatastream(id interface{}, qo *odata.QueryOptions, path string) (*entities.Thing, error)

GetThingByDatastream returns a thing entity based on the given datastream id and QueryOptions

func (*APIv1) GetThingByHistoricalLocation

func (a *APIv1) GetThingByHistoricalLocation(id interface{}, qo *odata.QueryOptions, path string) (*entities.Thing, error)

GetThingByHistoricalLocation returns a thing entity based on the given HistoricalLocation id and QueryOptions

func (*APIv1) GetThings

func (a *APIv1) GetThings(qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetThings returns an array of thing entities based on the QueryOptions

func (*APIv1) GetThingsByLocation

func (a *APIv1) GetThingsByLocation(id interface{}, qo *odata.QueryOptions, path string) (*entities.ArrayResponse, error)

GetThingsByLocation returns things based on the given location id and QueryOptions

func (*APIv1) GetTopics

func (a *APIv1) GetTopics(prefix string) *[]models.Topic

GetTopics returns all configured topics for the MQTT client

func (*APIv1) GetVersionInfo

func (a *APIv1) GetVersionInfo() *models.VersionInfo

GetVersionInfo retrieves the version info of the current supported SensorThings API Version and running server version

func (*APIv1) LinkLocation

func (a *APIv1) LinkLocation(thingID interface{}, locationID interface{}) error

LinkLocation links a thing with a location in the database

func (*APIv1) MQTTPublish

func (a *APIv1) MQTTPublish(topics []string, msg string, qos byte)

MQTTPublish publishes a message to a set of given topics

func (*APIv1) PatchDatastream

func (a *APIv1) PatchDatastream(id interface{}, datastream *entities.Datastream) (*entities.Datastream, error)

PatchDatastream updates the given datastream in the database

func (*APIv1) PatchFeatureOfInterest

func (a *APIv1) PatchFeatureOfInterest(id interface{}, foi *entities.FeatureOfInterest) (*entities.FeatureOfInterest, error)

PatchFeatureOfInterest updates the given FeatureOfInterest in the database

func (*APIv1) PatchHistoricalLocation

func (a *APIv1) PatchHistoricalLocation(id interface{}, hl *entities.HistoricalLocation) (*entities.HistoricalLocation, error)

PatchHistoricalLocation updates the given HistoricalLocation in the database

func (*APIv1) PatchLocation

func (a *APIv1) PatchLocation(id interface{}, location *entities.Location) (*entities.Location, error)

PatchLocation updates the given location in the database

func (*APIv1) PatchObservation

func (a *APIv1) PatchObservation(id interface{}, observation *entities.Observation) (*entities.Observation, error)

PatchObservation updates the given observation in the database

func (*APIv1) PatchObservedProperty

func (a *APIv1) PatchObservedProperty(id interface{}, op *entities.ObservedProperty) (*entities.ObservedProperty, error)

PatchObservedProperty patches a given ObservedProperty

func (*APIv1) PatchSensor

func (a *APIv1) PatchSensor(id interface{}, sensor *entities.Sensor) (*entities.Sensor, error)

PatchSensor updates a sensor in the database

func (*APIv1) PatchThing

func (a *APIv1) PatchThing(id interface{}, thing *entities.Thing) (*entities.Thing, error)

PatchThing updates the given thing in the database

func (*APIv1) PostCreateObservations

func (a *APIv1) PostCreateObservations(data *entities.CreateObservations) ([]string, []error)

PostCreateObservations checks for correctness of the datastreams and observations and calls PostcreateObservations on the database ToDo: use transactions

func (*APIv1) PostDatastream

func (a *APIv1) PostDatastream(datastream *entities.Datastream) (*entities.Datastream, []error)

PostDatastream adds a new datastream to the database

func (*APIv1) PostDatastreamByThing

func (a *APIv1) PostDatastreamByThing(thingID interface{}, datastream *entities.Datastream) (*entities.Datastream, []error)

PostDatastreamByThing adds a new datastream by given thing ID

func (*APIv1) PostFeatureOfInterest

func (a *APIv1) PostFeatureOfInterest(foi *entities.FeatureOfInterest) (*entities.FeatureOfInterest, []error)

PostFeatureOfInterest adds a FeatureOfInterest to the database

func (*APIv1) PostHistoricalLocation

func (a *APIv1) PostHistoricalLocation(hl *entities.HistoricalLocation) (*entities.HistoricalLocation, []error)

PostHistoricalLocation adds a new HistoricalLocation to the database

func (*APIv1) PostLocation

func (a *APIv1) PostLocation(location *entities.Location) (*entities.Location, []error)

PostLocation tries to add a new location

func (*APIv1) PostLocationByThing

func (a *APIv1) PostLocationByThing(thingID interface{}, location *entities.Location) (*entities.Location, []error)

PostLocationByThing checks if the given location entity is valid and adds it to the database the new location will be linked to a thing if needed

func (*APIv1) PostObservation

func (a *APIv1) PostObservation(observation *entities.Observation) (*entities.Observation, []error)

PostObservation checks for correctness of the observation and calls PostObservation on the database

func (*APIv1) PostObservationByDatastream

func (a *APIv1) PostObservationByDatastream(datastreamID interface{}, observation *entities.Observation) (*entities.Observation, []error)

PostObservationByDatastream creates an Observation with a linked datastream by given datastream id and calls PostObservation on the database

func (*APIv1) PostObservedProperty

func (a *APIv1) PostObservedProperty(op *entities.ObservedProperty) (*entities.ObservedProperty, []error)

PostObservedProperty todo

func (*APIv1) PostSensor

func (a *APIv1) PostSensor(sensor *entities.Sensor) (*entities.Sensor, []error)

PostSensor adds a new sensor to the database

func (*APIv1) PostThing

func (a *APIv1) PostThing(thing *entities.Thing) (*entities.Thing, []error)

PostThing checks if a posted thing entity is valid and adds it to the database a posted thing can also contain Locations and DataStreams

func (*APIv1) PutDatastream

func (a *APIv1) PutDatastream(id interface{}, datastream *entities.Datastream) (*entities.Datastream, []error)

PutDatastream updates the given thing in the database

func (*APIv1) PutFeatureOfInterest

func (a *APIv1) PutFeatureOfInterest(id interface{}, foi *entities.FeatureOfInterest) (*entities.FeatureOfInterest, []error)

PutFeatureOfInterest adds a FeatureOfInterest to the database

func (*APIv1) PutHistoricalLocation

func (a *APIv1) PutHistoricalLocation(id interface{}, hl *entities.HistoricalLocation) (*entities.HistoricalLocation, []error)

PutHistoricalLocation adds a new HistoricalLocation to the database

func (*APIv1) PutLocation

func (a *APIv1) PutLocation(id interface{}, location *entities.Location) (*entities.Location, []error)

PutLocation updates the given thing in the database

func (*APIv1) PutObservation

func (a *APIv1) PutObservation(id interface{}, observation *entities.Observation) (*entities.Observation, []error)

PutObservation updates the given observation in the database

func (*APIv1) PutObservedProperty

func (a *APIv1) PutObservedProperty(id interface{}, op *entities.ObservedProperty) (*entities.ObservedProperty, []error)

PutObservedProperty patches a given ObservedProperty

func (*APIv1) PutSensor

func (a *APIv1) PutSensor(id interface{}, sensor *entities.Sensor) (*entities.Sensor, []error)

PutSensor updates the given thing in the database

func (*APIv1) PutThing

func (a *APIv1) PutThing(id interface{}, thing *entities.Thing) (*entities.Thing, []error)

PutThing updates the given thing in the database

func (a *APIv1) SetLinks(entity entities.Entity, qo *odata.QueryOptions)

SetLinks processes the entities by setting the necessary links before sending back

func (*APIv1) Start

func (a *APIv1) Start()

Start is used to set the initial state of the api such as loading of the foi states

Jump to

Keyboard shortcuts

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