Sign inSign up

cenidetiot/smartsecurity-web-service

By cenidetiot

Updated almost 8 years ago

Data Models' Web Service - SmartSecurity Scenario of project SMARTSDK

Image
1

430

cenidetiot/smartsecurity-web-service repository overview

Smartsecurity Web Service

Clone this repo
  git clone https://github.com/cenidetiot/smartsecurity-web-service.git
 
Install requirements
  npm i
Configurations

  //MYSQL Configurations 
  exports.mysql = {
    host : 'URL', // MySQL Host
    db : 'databasename', //Database name
    user : 'databaseuser', // Database User
    password : '*******' // Database Password
  }
  // Orion Contextbroker configurations
  exports.context = {
    host:'URL', // Orion Host
    v : "v2", // Ngsi Version
    port : 1026 // Orion Port
  }
  
  exports.keyrock = "URL" //KeyRock URL
  exports.crate = 'URL'; // CrateDB Host
  
Run
  npm start 

DataModels APIREST Routes

Public Data Models

Organization
GET /api/organization get all organizations and by attributes
Example : /organization?status=1
POST /api/organization create a new organization
GET /api/organization/idOrganization get an especific organization
PUT /api/organization/idOrganization update an especific organization
DELETE /api/organization/idOrganization update an especific organization

Zones
GET /api/zone get all Zones and by attributes
Example : /zone?status=1&owner=5
POST /api/zone create a new Zone
GET /api/zone/idZone get an especific Zone
PUT /api/zone/idZone update an especific Zone
DELETE /api/zone/idZone update an especific Zone

Subzones
GET /api/subzone get all Subzones and by attributes
POST /api/subzones create a new Subzone
GET /api/subzone/idSubzone get an especific Subzone
PUT /api/subzone/idSubzone update an especific Subzone
DELETE /api/subzone/idSubzone update an especific Subzone

Road
GET /api/road get all Roads and by attributes
POST /api/road create a new Road
GET /api/road/idRoad get an especific Road
PUT /api/road/idRoad update an especific Road
DELETE /api/road/idRoad update an especific Road

RoadSegment
GET /api/roadSegment get all RoadSegments and by attributes
POST /api/roadSegment create a new RoadSegment
GET /api/roadSegment/idRoadSegment get an especific RoadSegment
PUT /api/roadSegment/idRoadSegment update an especific RoadSegment
DELETE /api/roadSegment/idRoadSegment update an especific RoadSegment

OffStreetParking
GET /api/offStreetParking get all OffStreetParkings and by attributes
POST /api/offStreetParking create a new OffStreetParking
GET /api/offStreetParking/idOffStreetParking get an especific OffStreetParking
PUT /api/offStreetParking/idOffStreetParking update an especific OffStreetParking
DELETE /api/offStreetParking/idOffStreetParking update an especific OffStreetParking

Private Data Models

DeviceToken
GET /api/device/token get all DeviceToken and by attributes
POST /api/device/token create a new DeviceToken
GET /api/device/token/refDevice get an especific DeviceToken
PUT /api/device/token/refDevice update an especific DeviceToken
DELETE /api/device/token/refDevice update an especific DeviceToken

User
GET /api/user get all User and by attributes
POST /api/user create a new User
GET /api/user get an especific User
PUT /api/user update an especific User
DELETE /api/user update an especific User
POST /api/user/login obtain the token from keystone and data user

  {
    'phoneNumber': 'phoneNumber',
    'password' : 'password'
  }

Response

  {
    'token': '<token>',
    'user' : {}
  }

Especial Services Routes

Alerts
GET /service/alerts/zone/history/:idZone get the last 10 alerts on the especified zone
GET /service/alerts/zone/current/:idZone get all the alerts generated since midnight on especified zone
GET /service/alerts/subzone/history/:idSubzone get the last 10 alerts on the especified subzone
GET /service/alerts/subzone/current/:idSubzone get all the alerts generated since midnight on especified subzone

Devices
GET /service/device/zone/:idZone get all devices on the especified zone
Especific Params example : /service/device/zone/:idZone?id=Smartphone_1828273&type=Device&owner=Daniel%20Torres GET /service/device/subzone/:idSubzone get all devices on the especified subzone
Especific Params example : /service/device/zone/:idSubzone?id=Smartphone_1828273&type=Device&owner=Daniel%20Torres

Especial Functions
POST /service/zone/point Determine if a point is on a zone

  {
    'point' : [x, y]
    'polygon' [[a,b],[c,d],[e,f],[a,b]]
  }

POST /service/query Determine if a point is on a zone Example

  {
    'id' : "Entity id"
    'type' : "Entity type"
  }

Crate API Routes (Time Services)

GET /crate/locationOwnerDateTime?owner=41&date=2018-02-08&time=12 get an specific owner device in a specific date and time(hour)

Tag summary

Content type

Image

Digest

Size

276.1 MB

Last updated

almost 8 years ago

docker pull cenidetiot/smartsecurity-web-service