Table of Contents

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>5.4.0</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 latest javadoc, for API version 10 (CM 5.4.0).

Basic Usage

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

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

// 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.