Skip to content
kyrcha edited this page Jul 23, 2012 · 8 revisions

RESTful protocol for Installations.

The following Foreign Key apply:

installations.scenario_id : Foreign Key to Scenarios

installations.belongsToInstallation : Foreign Key to Installations

READ Installations

GET /api/inst?scn_id={scn_id}&filter={filter}&sort={sort}&limit={limit}&skip={skip} |  index

Added to installations (for now) example:

curl 'http://localhost:8080/cassandra/api/inst?scn_id=4ff5bca7e4b0082c63d08df3&limt=20&filter=\{x:234.232\}&sort=\{y:-1\}'

Valid query parameters: @QueryParam("scn_id") String scn_id,

@QueryParam("filter") String filter,

@QueryParam("sort") String sort,

@QueryParam("limit") int limit,

@QueryParam("skip") int skip

sort parameter should be a JSON object, e.g. &sort={y:1} for ascending order and &sort={y:-1} for descending order More info on: http://www.mongodb.org/display/DOCS/Sorting+and+Natural+Order

filter should be a JSON object, e.g. &filter={x:234.232}

Retrieves the installations in the scenario (names, ids).

Consumes: Route, Parameter

Produces: JSON

{ "success": true, "message": "Installations retrieved successfully", "size": 2, "data": [ { "_id": { "$oid": "4ff5bca7e4b0082c63d08df6" }, "name": "Installation 1", "type": "Installation Type", "description": "Installation description", "scenario_id": "4ff5bca7e4b0082c63d08df3" }, { "_id": { "$oid": "4ff5bca7e4b0082c63d08df7" }, "name": "Installation 2", "description": "Installation description 2", "scenario_id": "4ff5bca7e4b0082c63d08df3", "belongsToInstallation": "4ff5bca7e4b0082c63d08df6" } ] }

READ Installation

GET /api/inst/{inst_id} | show

Fetches the properties of the Installation and other included entities (names, ids) such as Appliances that are included in the Installation.

Consumes: Route

Produces: JSON

CREATE Installation

POST /api/inst | create

Creates a new Installation based on the things added in the form.

Consumes: Route, JSON

 {
    name: "Installation 1",
    type : "Installation Type",
    description : "Installation description",
    scenario_id: "4ff5bca7e4b0082c63d08df3",
    belongsToInstallation : "4ff5bca7e4b0082c63d08df6"
    location : "Description of location",
    x : 234.232,
    y : 12.12
 }

Produces: JSON

{
  "success": true,
  "message": "Installation created successfully",
  "objectCreated": {
    name: "Installation 1",
    type : "Installation Type",
    description : "Installation description",
    scenario_id: "4ff5bca7e4b0082c63d08df3",
    belongsToInstallation : "4ff5bca7e4b0082c63d08df6"
    location : "Description of location",
    x : 234.232,
    y : 12.12,
    "_id": {
      "$oid": "4ff5c327e4b0082c63d08e01"
    }
  }
}

UPDATE Installation

PUT /api/inst/{inst_id} | update

Updates the properties of the Installation after editing.

Consumes: Route, JSON

Produces: JSON

Send back the full JSON defining the Installation with the updated fields.

DELETE Installation

DELETE /api/inst/{inst-id} | delete

Deletes the existing Installation. The Appliances are not deleted if they are referenced in other Installations.

Consumes: Route

Produces: Delete status

Installation Schema

{
    "name": "Installation",
    "type": "object",
    "description": "A consumer/producer of energy",
    "properties": {
        "scenario_id": {
            "type": "string",
            "description": "The Scenario this Installation belongs to",
            "optional": false
        },
        "name": {
            "type": "string",
            "description": "Name of the installation",
            "optional": true
        },
        "type": {
            "type": "string",
            "description": "Type of the installation",
            "optional": true
        },                
        "description": {
            "type": "string",
            "description": "Description of the installation",
            "optional": true
        },
        "belongsToInstallation": {
            "type": "string",
            "description": "The ObjectId of the Installation this installation belongs to",
            "optional": true
        },
        "location": {
            "type": "string",
            "description": "The location of the Installation",
            "optional": true
        },
        "x": {
            "type": "number",
            "description": "The X coordinates of the Installation",
            "optional": true
        },
        "y": {
            "type": "number",
            "description": "The Y coordinates of the Installation",
            "optional": true
        }
    },
    "additionalProperties" : false
}