Skip to content

Consumer social networks

Konstantinos N. Vavliakis edited this page Aug 6, 2013 · 8 revisions

RESTful protocol for Consumer social networks.

A CSN graph can be created for a Run, so it can only be applied on existing Runs. CSN Graphs cannot be updated, only created or deleted.

CREATE CSN Graph

POST /api/csn | create

Creates a new Graph based on the graph creation parameters. Schema: Graph.schema

example:

curl -k -i --data @graph.json --header Content-type:application/json https://localhost:8443/cassandra/api/csn

Produces: Route, JSON

{
        "prj_id" : "51b4be46712e87092cbe7f27",
        "run_id" : "f",
        "graphType" : "MinReactivePowerPerHour",
        "minWeight" : 1.1,
        "noedges" : false
}

Produces: JSON

{
  "success": true,
  "message": "Graph created successfully",
  "data": {
    "prj_id": "51b4be46712e87092cbe7f27",
    "run_id": "f",
    "graphType": "MinReactivePowerPerHour",
    "minWeight": 1.1,
    "noedges": false,
    "_id": "5200db3ae4b0e3c03fd40d59",
    "NumberOfNodes": 3,
    "NumberOfEdges": 3
  }
}

READ CSN Graphs

GET /api/csn |  index

example:

curl -k -i --header Content-type:application/json https://localhost:8443/cassandra/api/csn?run_id=f

Retrieves the CSN graphs for a Run

Consumes: Route, Parameter

Produces: JSON

 {
  "success": true,
  "message": "CSN graphs retrieved successfully",
  "size": 2,
  "data": [
    {
      "_id": "51e3e174e4b00332065e92d6",
      "graphType": "MaxConsumptionP",
      "minWeight": 100.0,
      "noedges": "false"
    },
    {
      "_id": "51e42dbae4b0826b7fc71a0d",
      "graphType": "PersonType",
      "minWeight": 100.0,
      "noedges": "false"
    }
  ]
}

DELETE Graph

curl -k -i -X DELETE 'https://localhost:8443/cassandra/api/csn?graph_id=516d0a0e4b0d67558c1625e'

Deletes the existing Graph along with its nodes and edges.

Consumes: Route

Produces: Delete status

Graph Schema

{
    "name": "Graph",
    "type": "object",
    "description": "Setting to create a graph",
    "properties": {
        "prj_id" : {
            "type": "string",
            "optional": true
        },
        "run_id" : {
            "type": "string",
            "optional": false
        },
        "img_path"  : {
            "type": "string",
            "optional": true
        },
        "graphType": {
            "type": "string",
            "description": "The Scenario this Installation belongs to",
            "enum": [
                "InstallationType",
                "PersonType",
                "TransformerID",
                "TopologicalDistance",
                "Location",
                "SocialDistance",
                
                "TotalEnergyConsumption",
                "MaxHourlyEnergyConsumption",
                "MinHourlyEnergyConsumption",
                
                "AverageActivePowerPerHour",
                "AverageReactivePowerPerHour",
                
                "MaxActivePowerPerHour",
                "MaxReactivePowerPerHour",
                
                "MinActivePowerPerHour",
                "MinReactivePowerPerHour"
            ],
            "optional": false
        },
        "minWeight": {
            "type": "number",
            "description": "Min weight threshold",
            "optional": false
        },        
        "noedges": {
            "type": "boolean",
            "description": "If true then don't create edges",
            "optional": true
        }
    },
    "additionalProperties" : true
}