Skip to content

API Documentation

Joesan edited this page Jul 12, 2020 · 20 revisions

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.

On Heroku

The base url for all API Endpoint's is located at:

https://cryptic-taiga-18841.herokuapp.com/plantsim

On your Local Machine

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!

PowerPlant Operations API

The API's listed below can be used to steer a PowerPlant!

To Dispatch a OnOffType PowerPlant:

URL: /powerplant/1/dispatch

Payload:

{
  "powerPlantId" : 1,
  "command" : "turnOn",
  "value" : true,
  "powerPlantType" : "OnOffType"
}

To ReturnToNormal a OnOffType PowerPlant:

URL: /powerplant/1/dispatch

Payload:

{
  "powerPlantId" : 1,
  "command" : "turnOn",
  "value" : false,
  "powerPlantType" : "OnOffType"
}

[OR]

To ReturnToNormal a OnOffType PowerPlant:

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!

To Dispatch a RampUpType PowerPlant:

URL: /powerplant/2/dispatch

Payload:

{
 "powerPlantId" : 2,
 "command" : "dispatch",
 "value" : 800.0,
 "powerPlantType" : "RampUpType"
}

To ReturnToNormal a RampUpType PowerPlant:

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!

PowerPlant Management API's

The API's below could be used to do CRUD operations for a PowerPlant

To fetch the PowerPlant details

URL: /powerplant/2/details

To Add a new PowerPlant

URL:

To Update an existing PowerPlant

URL:

To Search for PowerPlant's

URL:

To fetch the PowerPlant telemetry

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!

Streaming API's

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

To fetch all Events and Alerts for all PowerPlant's

URL: ws://localhost:9000/plantsim/powerplant/events

To fetch all Events and Alerts for a specific PowerPlant

URL: ws://localhost:9000/plantsim/powerplant/events?id=2

To fetch TelemetrySignals for a specific PowerPlant

URL: ws://localhost:9000/plantsim/powerplant/signals?id=1

Special API's - Use it at your own risk!

We have a very special EndPoint that demonstrates the Resiliency of our WebSocket Event Streams

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/