Skip to content
kyrcha edited this page Jun 27, 2012 · 37 revisions

This page specifies the RESTful protocol between the client and server applications of the CASSANDRA platform.

The conventions for writing the protocol will be:

[RESTful route] | [action]

To better present the protocol we have separated it by the entities involved as seen below:

Projects

Scenarios

Installations

Activities

Activity Models

Appliances

Simulation Parameters

Activity Model

Each Activity has ActivityModels. For example we could have weekday cooking and weekend cooking.

READ

/{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod | index

Fetches all the ActivityModels inside the given Activity.

Consumes: Route

Produces: JSON

{
  activityModels : [
    {id: 1, name="Cooking-Weekend"},
    {id: 2, name="Cooking-Weekday"}
  ]
}

--

/{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod/{actmod-id} | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod/{actmod-id} | show

Fetches the properties of an ActivityModel and other included entities (names and ids) i.e. Distribution.

Consumes: Route

Produces: JSON

{
  id: 1,
  name: "Cooking-Weekday",
  appliances: [ ... ],
  dayType: working,
  isShiftable: true,
  startTime: {
    distributionType: Gaussian,
    distributionParameters: ...,
    distributionValue: ....,
  }
  duration: {
    distributionType: Gaussian,
    distributionParameters: ...,
    distributionValue: ....,
  }
}

--

/{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod/new | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod/new | new

Prepares for editing a new ActivityModel. Can be though as of loading an empty ActivityModel (empty form).

Consumes: Route

Produces: default values decided? JSON : nothing;

--

/{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod/{actmod-id}/edit | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod/{actmod-id}/edit | edit

Fetches the properties of the ActivityModel for editing.

Consumes: Route

Produces: JSON: like the one in show action

CREATE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod | POST /{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod | create

Creates a new ActivityModel for the given Activity, based on the properties filled up by the user.

Consumes: Route, JSON: like the one in show action

Produces: Create status

UPDATE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod/{actmod-id} | PUT /{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod/{actmod-id} | update

Updates the properties of the ActivityModel after editing.

Consumes: Route, JSON: like the one in show action

Produces: Update status

DELETE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod | DELETE /{usrnm}/prj/{prj-id}/scn/{scn-id}/agnt/{agnt-id}/act/{act-id}/actmod/{actmod-id} | delete

Deletes the existing ActivityModel.

Consumes: Route

Produces: Delete status


Appliance

READ

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/app | index

Fetches all the Appliances inside the scenario.

Consumes: Route

Produces: JSON

{
   appliances: [
     {id: 1, name: "Fridge"},
     {id: 2, name: "Oven"},
     {id: 3, name: "TV"}
   ] 
}

--

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id} | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id} | show

Fetches the properties of an appliance and other included entities (names and ids) i.e. ConsumptionModel. Using this route the user can edit directly an appliance presented in the installation(s) without browsing specifically for it through the Installations path.

Consumes: Route

Produces: JSON

{
  id: 1,
  name: "Fridge",
  energyClass: "Class A",
  standByConsumption: 4,
  isControllable: false,
  isShiftable: false,
  consumptionModel : {
    steps: ...,
  }
}

--

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app/new | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/new | new

Prepares for editing a new Appliance. Can be though as of loading an empty Appliance (empty form).

Consumes: Route

Produces: if default values decided? JSON : nothing;

--

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/edit | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/edit | edit

Fetches the properties of the Appliance for editing.

Consumes: Route

Produces: JSON: same as in action show

CREATE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app | POST /{usrnm}/prj/{prj-id}/scn/{scn-id}/app | create

Creates a new consumption model for the given Appliance, based on the properties filled up by the user when creating a new ConsumptionModel. Alternatively, one can create a new appliance by making a drag-n-drop action from the library and passing the {lib-id} and {app-id} ids as parameters i.e.:

POST /{usrnm}/prj/{prj-id}/scn/{scn-id}/app?lib-id=1&app-id=4

Consumes: Route, JSON: same as in action show, params

Produces: Create status

UPDATE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id} | PUT /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id} | update

Updates the properties of the Appliance after editing.

Consumes: Route, JSON: same as in action show

Produces: Update status

DELETE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app | DELETE /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id} | delete

Deletes the existing Appliance. The Appliance is deleted from all the Installations referencing it as well.

Consumes: Route

Produces: Delete status


ConsumptionModel

There is no id in the RESTful routes for the ConsumptionModel since there is a 1 to 1 relationship between the ConsumptionModel and the Appliance. The JSON data include just a vector of number defining the consumption model.

READ

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod | show

Fetches the properties of the ConsumptionModel for visualization purposes.

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod/new | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod/new | new

Prepares for editing a new ConsumptionModel. Can be though as of loading an empty ConsumptionModel (empty form).

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod/edit | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod/edit | edit

Fetches the properties of the ConsumptionModel for editing.

All read ops:

Consumes: Route

Produces: JSON

CREATE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod | POST /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod | create

Creates a new consumption model for the given Appliance, based on the properties filled up by the user when creating a new ConsumptionModel.

Consumes: Route, JSON

Produces: Create status

UPDATE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod | PUT /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod | update

Updates the properties of the ConsumptionModel after editing.

Consumes: Route, JSON

Produces: Update status

DELETE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod | DELETE /{usrnm}/prj/{prj-id}/scn/{scn-id}/app/{app-id}/cnsmod | delete

Deletes the existing ConsumptionModel.

Consumes: Route

Produces: Delete status

Simulation

READ

Entity containing the simulation parameters of the scenario i.e. Calendar, location information, number of runs etc. Each scenario can have many Simulations.

/{usrnm}/prj/{prj-id}/scn/{scn-id}/sim | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/sim | index

Fetches all the Simulations inside the scenario.

Consumes: Route

Produces: JSON

{
  simulations: [
    {id=1, name: "Summer simulation"},
    {id=2, name: "Winter simulation"}
  ]
}

--

/{usrnm}/prj/{prj-id}/scn/{scn-id}/sim/{sim-id} | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/sim/{sim-id} | show

Fetches the properties (simulation parameters) of a Simulation.

Consumes: Route

Produces: JSON

{
  id=1,
  name="Summer simulation",
  calendar: {
    dayOfMonth: ...,
    dayOfWeek: ...,
    month: ...,
    year: ...
  },
  locationInfo: {
    lat: ...,
    lng: ...
  },
  numberOfRuns: {
     n = 10
  }
}

--

/{usrnm}/prj/{prj-id}/scn/{scn-id}/sim/new | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/sim/new | new

Prepares for editing a new Simulation. Can be though as of loading an empty Simulation (empty form).

Consumes: Route

Produces: JSON

--

/{usrnm}/prj/{prj-id}/scn/{scn-id}/sim/{sim-id}/edit | GET /{usrnm}/prj/{prj-id}/scn/{scn-id}/sim/{sim-id}/edit | edit

Fetches the properties of the Simulation for editing.

Consumes: Route

Produces: JSON

CREATE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/sim | POST /{usrnm}/prj/{prj-id}/scn/{scn-id}/sim | create

Creates a new _Simulation for the given Scenario, based on the properties filled up by the user when creating a new Simulation.

Consumes: Route, JSON

Produces: Create status

UPDATE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/sim/{sim-id} | PUT /{usrnm}/prj/{prj-id}/scn/{scn-id}/sim/{sim-id} | update

Updates the properties of the Simulation after editing.

Consumes: Route, JSON

Produces: Update status

DELETE

/{usrnm}/prj/{prj-id}/scn/{scn-id}/sim | DELETE /{usrnm}/prj/{prj-id}/scn/{scn-id}/sim/{sim-id} | delete

Deletes the existing Simulation.

Consumes: Route

Produces: Delete status


Runs

A run is created when a user decides to execute a scenario given some simulation parameters.

READ

/{usrnm}/prj/{prj-id}/runs | GET /{usrnm}/prj/{prj-id}/runs | index

Displays a list with all the runs (queued, completed, running) under the given project.

Consumes: Route

Produces: JSON

{
  runs: [
    {id=1, status=completed, percentage=100},
    {id=2, status=running, percentage=45},
    {id=3, status=queued, percentage=0}
  ]
}

--

/{usrnm}/prj/{prj-id}/runs/{run-id} | GET /{usrnm}/prj/{prj-id}/runs/{run-id} | show

Displays the status and/or the results of the given run.

Consumes: Route

Produces: JSON

{
  id:1,
  status=completed, 
  percentage=100
  results {
    ...
  },
  statistics {
    ...
  },
  summary {
    ...
  }
}

CREATE

/{usrnm}/prj/{prj-id}/sims | POST /{usrnm}/prj/{prj-id}/sims | create

Creates a new run by posting the entire scenario.

Consumes: Route, JSON

Produces: Create status

DELETE

/{usrnm}/prj/{prj-id}/sims | DELETE /{usrnm}/prj/{prj-id}/sims/{sim-id} | delete

Deletes the run along with the results.

Consumes: Route

Produces: Delete status

UPDATE

/{usrnm}/prj/{prj-id}/sims/{sim-id} | PUT /{usrnm}/prj/{prj-id}/sims/{sim-id}/{pause|resume} | update status

Based on what is passed in the http request the run can be paused or resumed.

Consumes: Route

Produces: Update status


Library

We assume for now that the libraries are read-only (R ops). There is no functionality in the protocol (yet) to make CUD operations. Also Demographics and CSNs to be added in the library.

READ

/libs | GET /libs | index

Returns a list of libs along with their ids.

--

/libs/{lib-id} | GET /libs/{lib-id} | index

For the given {lib-id} a list of contained entities is returned along with their name, type and id. These entities are structured in a tree according to their type. For now four top level types will be available: Installation, Appliance, Activity and DemandSideManagement.

--

/libs/{lib-id}/inst | GET /libs/{lib-id}/inst | index

Returns a list of Installations available in the library.

--

/libs/{lib-id}/app | GET /libs/{lib-id}/app | index

Returns a list of Appliances available in the library.

--

/libs/{lib-id}/act | GET /libs/{lib-id}/act | index

Returns a list of Activities available in the library.

--

/libs/{lib-id}/dsm | GET /libs/{lib-id}/dsm | index

Returns a list of DemandSideManagement schemes available in the library.

--

/libs/{lib-id}/inst/{inst-id} | GET /libs/{lib-id}/inst/{inst-id} | show

Displays the properties of the Installation with that {inst-id}.

--

/libs/{lib-id}/inst/{inst-id}/app | GET /libs/{lib-id}/inst/{inst-id}/app | index

Displays the Appliances of the Installation with that {inst-id}.

--

/libs/{lib-id}/inst/{inst-id}/app/{app-id} | GET /libs/{lib-id}/inst/{inst-id}/app/{app-id} | show

Displays the properties of the {app-id} Appliance of the Installation with that {inst-id}.

--

/libs/{lib-id}/inst/{inst-id}/app/{app-id}/consmod | GET /libs/{lib-id}/inst/{inst-id}/app/{app-id}/consmod | show

Displays the ConsumptionModel of the {app-id} Appliance of the Installation with that {inst-id}.

--

/libs/{lib-id}/app/{app-id} | GET /libs/{lib-id}/app/{app-id} | show

Displays the properties of the Appliance with that {app-id}.

--

/libs/{lib-id}/app/{app-id}/consmod | GET /libs/{lib-id}/app/{app-id}/consmod | show

Displays the ConsumptionModel of the given Appliance.


TODO

Users

Users should be able to login (MD5 hash and https as minimum security requirements) and after successfully entering their credentials, they should be redirected to /api/prj, where a list of their projects should be displayed.

Demographics

Under development.

Consumer Social Networks

Under development.

Clone this wiki locally