Usage examples

How to create a new FlinkRestClient instance

The simplest way to create a new FlinkRestClient instance is using its static factory method:

from flink_rest_client import FlinkRestClient

rest_client = FlinkRestClient.get(host="localhost", port=8082)

To check that the client can connect to Flink Jobmanager’s webserver the overview method can be used, which returns an overview over the Flink cluster.

from flink_rest_client import FlinkRestClient

rest_client = FlinkRestClient.get(host="localhost", port=8082)
result = rest_client.overview()
print(result)

Output:

{
 "taskmanagers": 1,
 "slots-total": 4,
 "slots-available": 4,
 "jobs-running": 0,
 "jobs-finished": 0,
 "jobs-cancelled": 0,
 "jobs-failed": 0,
 "flink-version": "1.12.4",
 "flink-commit": "5364a6b"
}