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>6.2.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 last javadoc, for API version 19 (CM 5.14.0)

Basic Usage

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

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

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