ClusterControl Client SDK
ClusterControl has a HTTPS based RPC API that provides complete access and control of the CMON Controller which is its workflow engine. The ClusterCOntrol CMON API documentation is readily available here.
Using the CMON RPCv2 API directly though requires that clients are passing JSON documents of jobs specs to be executed. Creating these CMON JSON job specs are straightforward however cumbersome given its text based nature where correct syntax and manual validations is needed in order for the jobs to be executed.
A more user (developer) friendly way of using the CMON RPCv2 API is to use the OpenAPI specification to document and generate API client libraries for various system languages. The OpenAPI documentation is machine readable and makes it easy formally describe an API and also use tools such as the openapi-generator to generate client libraries.
You can use your favourite programming language such as Go or Python to create applications which integrates with ClusterControl to manage and monitor your databases.
This project is hosted in Github called clustercontrol-client-sdk.
SDK for various programming languages
ClusterControl API (v2) SDK has bindings for various programming languages.
API binding for Java
API binding for Java is available in the java
subdirectory. It requires Apache Maven to build. Here are the build instructions.
Setting up Apache Maven Here are instructions on how to setup Maven.
- Download the latest maven from here and extract it to your machine.
- Install JDK 8 and set
JAVA_HOME
to the directory where JDK is installed. -
Update
PATH
environment variable to include the Maven and JDKbin
directories. -
Building Java bindings:
We also provide an API Abstraction Layer above the underlying low-level API bindings. This makes it super easy to use the API SDK. See the instructions here.
API binding for Python
API binding for Python is available in the python
subdirectory.
We hope to provide in the very near future an API Abstraction Layer above the underlying low-level API bindings. This makes it super easy to use the API SDK. See the instructions here.
API binding for GoLang
API binding for GoLang is available in the go
subdirectory.
We hope to provide in the very near future an API Abstraction Layer above the underlying low-level API bindings. This makes it super easy to use the API SDK. See the instructions here.
Generating Sources from the API definition
Note
It is not required for you to generate new sources from the API definition. However, if you happend to modify the API definition, then you will have to generate new sources from the definition in order for the sources to reflect changes to the definition.
-
Install Java Runtime 8. Skip these steps if you already have the latest generated language bindings:
- Follow the instructions for Linux.
- Follow the instructions for MacOS.
-
Download and setup the openapi-generator:
$ cd clustercontrol-client-sdk $ mkdir -p $PWD/bin/openapitools $ curl -o $PWD/bin/openapitools/openapi-generator-cli.sh https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh $ chmod +x $PWD/bin/openapitools/openapi-generator-cli.sh $ export PATH=$PATH:$PWD/bin/openapitools
-
Install Apache Maven. Follow the instructions here for your favourite OS:
-
Check if
openapi-generator.sh
is setup properly: -
Generate API language bindings:
# install make with 'apt install make' #make python #make java make go ... [main] INFO o.o.codegen.TemplateManager - writing file /root/clustercontrol-client-sdk/./generated/go/.openapi-generator/FILES ################################################################################ # Thanks for using OpenAPI Generator. # # Please consider donation to help us maintain this project 🙏 # # https://opencollective.com/openapi_generator/donate # ################################################################################
The next step is to write your first applicaton which calls upon these generated client API stubs. Checkout the respective binding subdiirectories for java
, python
and go
.