Table of Contents

Version

From Cloudera Manager version 6.0 i.e. API version 30 onwards, this Java API client has been deprecated.

Use new Swagger based Java API client for Cloudera Manager version 6.0 i.e. API version 30 onwards.

Setting Up

Merge the following to your Maven project’s pom.xml:

<project>
  <repositories>
    <repository>
      <id>cdh.repo</id>
      <url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
      <name>Cloudera Repository</name>
    </repository>
    …
  </repositories>
  <dependencies>
    <dependency>
      <groupId>com.cloudera.api</groupId>
      <artifactId>cloudera-manager-api</artifactId>
      <version>7.2.4</version>  <!-- Or the CM version you have -->
    </dependency>
    …
  </dependencies>
  ...
</project>

You can also directly download the jar (and sources) from the Cloudera repository.

Javadoc

Here is the last javadoc, for API version 19 (CM 5.14.0)

Basic Usage

The fundamental client handle is a RootResourceV43. (Replace the version number with the version that you are working with.) With the root resource, you can traverse the REST namespace.

RootResourceV43 apiRoot = new ClouderaManagerClientBuilder()
    .withHost("cm.cloudera.com")
    .withUsernamePassword("admin", "admin")
    .build()
    .getRootV43();

// Get a list of defined clusters
ApiClusterList clusters = apiRoot.getClustersResource()
    .readClusters(DataView.SUMMARY);

To see a full example of cluster deployment using the Java client, see whirr-cm. Specifically, jump straight to CmServerImpl#configure to see the core of the action.