Cloudera Manager RESTful API Java Client
========================================
The project provides all the source you need to build a Java client for the [Cloudera Manager]((http://www.cloudera.com/products-services/tools/) RESTful API.
The Cloudera Manager RESTful API is implemented with [Apache CXF](http://cxf.apache.org/)
using [JAX-RS](http://en.wikipedia.org/wiki/Java_API_for_RESTful_Web_Services) and JAX-B.
The Java models and interfaces provided here serve as a contract between the Cloudera
Manager service and Java client. Cloudera uses this same source internally in the
server implementation. We're providing this source to make it easier for partners and
the open-source community to easily integrate with Cloudera Manager.
The RESTful API follows standard [Create-Read-Update-Delete (CRUD)](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete) semantics.
Each *resource* in the API is capable of creating, reading, updating or deleting a particular entity in the system. A *resource* can
have subresources e.g. the cluster resource has a service resource.
To create the root resource for the API, use the client builder:
```java
ApiRootResource root = new ClouderaManagerClientBuilder()
.withHost("myhost.foo.com")
.withUsernamePassword("admin", "admin")
.build();
```
The `ApiRootResource` has subresources for each of the API versions that it supports. For example...
```java
RootResourceV1 v1 = root.getRootV1();
RootResourceV2 v2 = root.getRootV2();
```
To list the names of all clusters under management, simply use the cluster resource as follows:
```java
ClustersResourceV2 clustersResource = v2.getClustersResource();
ApiClusterList clusters = clustersResource.readClusters(DataView.FULL);
for (ApiCluster cluster: clusters) {
System.out.println(cluster.getName());
}
```
We can use the same pattern to print all clusters, services and roles in a nice hierarchy using
the clusters, services and roles resources. For example,
```java
ClustersResourceV2 clustersResource = v2.getClustersResource();
for (ApiCluster cluster : clustersResource.readClusters(DataView.FULL)) {
System.out.println(cluster.getName());
ServicesResourceV2 servicesResource = clustersResource.getServicesResource(cluster.getName());
for (ApiService service : servicesResource.readServices(DataView.FULL)) {
System.out.println("\t" + service.getName());
RolesResourceV2 rolesResource = servicesResource.getRolesResource(service.getName());
for (ApiRole role : rolesResource.readRoles()) {
System.out.println("\t\t" + role.getName());
}
}
}
```
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
















收起资源包目录





































































































共 751 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论

- acehand2020-07-22这个是要怎么用?有点没搞明白
- u0109918352020-01-19代码还行,官网应该也有
- ah7443495382019-04-15没有前端吗!gongchengshiv2019-04-25前段指的是什么,页面展示?这个实例是java代码调用cm各种接口的例子

gongchengshiv
- 粉丝: 20
- 资源: 18
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
