-
-
Notifications
You must be signed in to change notification settings - Fork 7
API Documentation
There are two possibilities to call and execute the API's. You could either use the deployed version on Heroku or run and use the application locally.
The base url for all API Endpoint's is located at:
https://cryptic-taiga-18841.herokuapp.com/plantsim
When you run your application locally, this will be your default base URL:
http://localhost:9000/plantsim
Before you browse through the API's below, the application also exposed JVM metrics as an end-point:
http://localhost:9000/plantsim/app/metrics
Every API Endpoint below is relative to the base URL!
The API's listed below can be used to steer a PowerPlant!
URL:
/powerplant/1/dispatch
Payload:
{
"powerPlantId" : 1,
"command" : "turnOn",
"value" : true,
"powerPlantType" : "OnOffType"
}
URL:
/powerplant/1/dispatch
Payload:
{
"powerPlantId" : 1,
"command" : "turnOn",
"value" : false,
"powerPlantType" : "OnOffType"
}
[OR]
URL:
/powerplant/1/release
Payload:
{
"powerPlantId" : 1
}
You might wonder why I need a Payload, but hang tight - I would like to have the option to ReturnToNormal at a specific power value! Hence the need for this Payload at the moment!
URL:
/powerplant/2/dispatch
Payload:
{
"powerPlantId" : 2,
"command" : "dispatch",
"value" : 800.0,
"powerPlantType" : "RampUpType"
}
URL:
/powerplant/1/release
Payload:
{
"powerPlantId" : 1
}
You might wonder why I need a Payload, but hang tight - I would like to have the option to ReturnToNormal at a specific power value! Hence the need for this Payload at the moment!
The API's below could be used to do CRUD operations for a PowerPlant
URL: /powerplant/2/details
URL:
URL:
URL:
URL: /powerplant/2/telemetry
There are also API endpoints to tap into some events that happen in the application. These API endpoints are implemented as WebSocket endpoints:
+NOTE: Please refer [here](https://chrome.google.com/webstore/detail/simple-websocket-+client/pfdhoblngboilpfeibdedpjgfnlcodoo?hl=en) to set up a WebSocket client locally on your Chrome browser so +that you can test these Endpoints!
We have several streaming API's that you can tap into. They are as below!
Note: For the Heroku version of the API, use the following as the base url:
wss://cryptic-taiga-18841.herokuapp.com/plantsim
URL:
ws://localhost:9000/plantsim/powerplant/events
URL:
ws://localhost:9000/plantsim/powerplant/events?id=2
URL:
ws://localhost:9000/plantsim/powerplant/signals?id=1
URL:
/powerplant/1/killEventStream
This EndPoint works only for OnOffType PowerPlant's because, I have implemented the Kill mechanism only for these PowerPlant types. This is anyway just for demonstration purposes. Even if you keep calling this EndPoint when your application is up and running, you will not notice any damaging effects. The Events WebSocket stream will just continue to push events to the WebSocket clients that have already connected to it! Isn't this cool?
For more information, have a look here: https://www.reactivemanifesto.org/