Making API calls with cdpcurl

To use cdpcurl to make API calls, first form the correct URI using the API reference documentation, and then construct the request.

To form the required URI, start by determining the hostname based on the service being called:

  • iam: iamapi.us-west-1.altus.cloudera.com
  • All other services: api.us-west-1.cdp.cloudera.com
Then form the URI. The correct URI is an HTTPS URL at the chosen host, with a path indicated for your desired endpoint in the API documentation. For example, the URI for a listEnvironments call would look something like this:
https://api.us-west-1.cdp.cloudera.com/api/v1/environments2/listEnvironments

Most CDP API calls are POST requests, so be sure to use the [-X REQUEST] and [-d DATA] arguments in the command. These are briefly documented in the awscurl documentation, but [-X REQUEST] specifies the type of request (most often POST in CDP) and [-d DATA] specifies the request content (in the POST example below, an empty JSON request). If the -d option value begins with "@", then the remainder of the value is the path to a file containing the content; otherwise, the value is the content itself.

You can then run the request. For example:
$ cdpcurl --profile sandbox -X POST -d '{}' https://api.us-west-1.cdp.cloudera.com/api/v1/environments2/listEnvironments

For a complete list of cdpcurl options, run cdpcurl --help.