node-red / node-red.github.io

Node-RED Site
http://nodered.org
Other
99 stars 151 forks source link

Add API Documentation for `/flows/state` endpoint #303

Closed shantanoo-desai closed 1 year ago

shantanoo-desai commented 1 year ago

Description

Document the HTTP API endpoint for the Flow State Management feature available from v3.0.x.

The following endpoints SHOULD be documented:

GET /flows/state

Request:

an HTTP GET request on /flows/state (with authentication mechanism requires authorization tokens) the current state of the Flow should be available.

Response: Either {"state":"start"} or {"state":"stop"}

POST /flows/state

Request:

an HTTP POST request on /flow/state (with authentication mechanism requires authorization tokens) along with URL-encoded value of state parameter should start or stop the flow.

the value of state parameter is either start or stop and SHOULD be url-encoded

Response: Depending on the trigger the returned value is now the current state of the flow either {"state":"start"} or {"state":"stop"}

Example with curl

 curl -XPOST \
 -H 'Authorization: Bearer  <TOKEN>' \
--data-urlencode 'state=start' \
http://localhost:1880/flows/state 

Starts a stopped flow with the response as

{"state":"start"}

(and vice versa with state=stop)

 curl -XGET \
 -H 'Authorization: Bearer  <TOKEN>' \
http://localhost:1880/flows/state

returns the current state value

Effort

A PR for the documentation will follow as soon as possible