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

RESTful protocol for for Consumption Models.

The following Foreign Key apply:

cons_models.app_id : Foreign Key to Appliances

READ Consumption Model

GET /api/consmod?app_id={app_id} | index

Fetches the ids and names of all the Consumption Models in the appliance defined using the query parameter app_id.

Consumes: Route, Parameter

Produces: JSON

{
  "success": true,
  "message": "Consumption Models retrieved successfully",
  "size": 1,
  "data": [
    {
      "_id": { "$oid": "4ffd693ee4b06b7b2983ed4a" },
      "name": "Consumption Model 1",
      "description": "I am a Consumption Model ",
      "app_id": "4ff5bca7e4b0082c63d08df9",
        "model": {
        "n": 2,
        "params": {
        "n": 3,
        "values": [
          {
            "p": 100,
            "d": 10,
            "s": 0
          },
          {
            "p": 120,
            "d": 5,
            "s": 0
          }
        ]
      }
    }
  }
  ]
}

READ Consumption Models

GET /api/consmod/{consmod_id} | show

Fetches all the the names, types and ids of the Consumption Models included in the given Appliance.

Consumes: Route

Produces: JSON

UPDATE Consumption Models

PUT /api/consmod/{consmod-id} | update

Updates the properties of the Consumption Model after editing.

Consumes: Route, JSON

Produces: JSON

DELETE Consumption Model

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

Deletes the Consumption Model with the given id.

Consumes: Route

Produces: JSON with delete status

CREATE Consumption Model

POST /api/consmod | create

Consumes: Route, JSON

{ name: "Consumption Model 1", description: "I am a Consumption Model ", app_id : "4ff5bca7e4b0082c63d08df9", model : { n : 222, params : { n : 3, values : [ {p : 100, d : 10, s: 0}, {p : 120, d : 5, s: 0 } ] } }

}

Consumption Model Schema

{
"name": "Consumption Model",
"type": "object",
"description": "The function analysis of an appliance",
"properties": {
    "app_id": {
        "type": "string",
        "description": "The Appliance that this consumption model belongs to",
        "optional": false
    },    
    "name": {
        "type": "string",
        "description": "Name of the consumption model",
        "optional": true
    },
    "type": {
        "type": "string",
        "description": "Type of the consumption model",
        "optional": true
    },
    "description": {
        "type": "string",
        "description": "Description of the consumption model",
        "optional": true
    },
    "model" : {
        "type": "object",
        "description": "Parameters of the consumption model",
        "optional": true,
        "properties" : {
            "n" : {
                "type" : "integer",
                "description" : "Number of iterations"
            },
            "params" : {
                "type" : "array",
                "description" : "",
                "items" : {
                "type" : "object",
                "description" : "",
                "properties" : {
                    "n" : {
                        "type" : "integer",
                        "description" : "Number of iterations"
                    },
                    "values" : {
                        "type" : "array",
                        "description" : "",
                        "items" : {
                            "type" : "object",
                            "description" : "",
                            "properties" : {
                                "p" : {
                                    "type" : "number",
                                    "description" : "power"
                                },
                                "d" : {
                                    "type" : "integer",
                                    "description" : "power"
                                },
                                "s" : {
                                    "type" : "number",
                                    "description" : "power"
                                }                                                                     
                            } 
                        }
                    }
                }
                }
            }
        }
    }
},
"additionalProperties" : false
}