API Usage Tutorial

Cloudera Navigator Concepts

The API terminology is similar to that used in the web UI:

Entity

Abstract data structure that describes structural features of any entity.

An entity can be uniquely identified by its identity.

Relation

Describes relationship among entities.

A relationship itself is an entity and like any other entity can have properties, comments associated with it.

API Usage Examples

Explore Around

Let's select two file entities starting at offset 10. $ curl -u <username>:<password> 'http://www.example.org:7187/api/v1/entities?query=type:file&limit=2&offset=10' [ { "identity" : "83f4cdcc37c379144fef22e3dbdf7c8c", "atime" : 0, "name" : "ROOT", "mtime" : 1374585120000, "permissions" : 493, "path" : "/", "group" : "supergroup", "type" : "DIRECTORY", "resId" : "858e5548b4cd3457432eb491ee74729d", "size" : 0, "sourceType" : "HDFS" }, { "identity" : "6144fabee63641275c5577697f16266a", "atime" : 0, "name" : "hbase", "mtime" : 1374584820000, "permissions" : 493, "path" : "/hbase", "group" : "hbase", "type" : "DIRECTORY", "resId" : "858e5548b4cd3457432eb491ee74729d", "size" : 0, "sourceType" : "HDFS" } ]

Let's select a specific entity: $ curl -u <username>:<password> 'http://www.example.org:7187/api/v1/entities/f53ae3547a90b7519b44041db1898972' { "identity" : "f53ae3547a90b7519b44041db1898972", "atime" : 1374584820000, "name" : "www.example.org%2C22101%2C1374584823722.1374584829311", "mtime" : 1374584820000, "permissions" : 420, "path" : "/hbase/.logs/www.example.org,22101,1374584823722/www.example.org%2C22101%2C1374584823722.1374584829311", "group" : "hbase", "type" : "FILE", "resId" : "858e5548b4cd3457432eb491ee74729d", "size" : 0, "sourceType" : "HDFS" }

Let's update an entity to add a new name. $ curl -u <username>:<password> -X PUT -H "Content-Type: application/json" -d '{"name":"ab","description":"dfsdfr","tags":["tag1"],"properties":{"property1":"value1"}}' http://www.example.org:7187/api/v1/entities/e5f94cd59a8ca6df96247ce88b6c9c28 { "atime" : 0, "mtime" : 1374584820000, "type" : "DIRECTORY", "resId" : "858e5548b4cd3457432eb491ee74729d", "size" : 0, "identity" : "e5f94cd59a8ca6df96247ce88b6c9c28", "description" : "dfsdfr", "originalName" : ".tmp", "name" : "ab", "permissions" : 493, "path" : "/hbase/.tmp", "group" : "hbase", "sourceType" : "HDFS", "tags" : [ "tag1" ], "properties" : { "property1" : "value1" } }