The latest version of the SAP Cloud Connector (2.11), which has been released today, introduces a REST API which can be used to read and write Cloud Connector configuration.
For more details about the 2.11 release, please head over to Matthieus blogpost. It covers all new features of this release.
In the last two days, I created a little command-line-tool to show some of the functionalities of the new API. It currently provides read-only access to some of the Cloud Connector endpoints and is not meant for production. But the source code is available to inspire you.
To get a brief overview, watch this gif:
The first thing to do after installation is to add your Cloud Connector instance. Therefore, run “config-addinstance”. You can switch between instances (if you have configured more than one) by running “switchinstance”. Any subsequent call will be executed on the selected instance. Selecting an instance will change your prompt so something like this: “Administrator@localhost:8443 >”, so you always know which instance is the current target. Your configuration is saved in a file called scc_cli.json in your home directory.
After adding and selecting your instance, you can run e.g., commondescription to get the HA-role and the description of your Cloud Connector instance. Run help to get a list of all available commands.
I recommend to just install the latest Cloud Connector and the CLI (node and npm required) and play around before you continue reading. Installation guidance is available here. Please don’t use a productive Cloud Connector installation for playing around.
If you’re interested in the implementation, look at the Cloud Connector Configuration REST API documentation and the code on GitHub. Before looking at the code, you should familiarize yourself with the concept of Promises, if you haven’t already, otherwise you’re going to have a bad time trying to understand what’s going on. The most interesting pieces of code (for the ones who want to know more about the Cloud Connector API) are located in the CloudConnectorInstance.js file. Most of the other code is “housekeeping”: loading and saving the configuration, reading and dispatching the commands from stdin, formatting the output, etc.
Did you like my work? If yes, then please give the repository a ★ on GitHub. If it gets a bunch of stars, I’ll consider extending the CLI.