View API This section describes basic usage of the View REST API. Browse https://github.com/apache/ambari/blob/trunk/ambari-views/docs/index.md for detailed usage information and examples. Get List of Deployed Views Creating a View Instance: Files View Creating a View Instance: Capacity Scheduler View Get List of Deployed Views 1. Gets the list of all deployed views GET /api/v1/views Once you have a list of views, you can drill-into a view and see the available versions. GET /api/v1/views/files 3. You can go a level deeper and see more information about that specific version for the view, such as the parameters and the archive name, and a list of all instances of the view for that specific view version. GET /api/v1/views/files/versions/0.1.0 Creating a View Instance: Files View The following example shows creating an instance of the Files View, name FILES, version 0.1.0 view called "MyFiles". 1. Create the view instance. POST /api/v1/views/files/versions/0.1.0/instances/myfiles [ "ViewInstanceInfo" : "properties" : "dataworker.defaultfs" : "webhdfs://your.namenode.host:50070" ] 201 - CREATED When creating your view instance, be sure to provide all view instance properties, otherwise you will receive a 500 required with a message explaining the properties that are required. Restart Ambari Server to pick-up the view instance and UI resources.
ambari-server restart 3. Confirm the newly created view instance is available. GET /api/v1/views/files/versions/0.1.0 "http://c6401.ambari.apache.org:8080/api/v1/views/files/versions/0.1.0/", "ViewVersionInfo" : "archive" : "/var/lib/ambari-server/resources/views/work/files0.1.0", "label" : "Files", "masker_class" : null, "parameters" : [ "name" : "dataworker.defaultfs", "description" : "FileSystem URI",, "name" : "dataworker.username", "description" : "The username (defaults to ViewContext username)", "required" : false, ], "view_name" : "FILES", "permissions" : [ ], "instances" : [ "http://c6401.ambari.apache.org:8080/api/v1/views/files/versions/0.1.0/instances/ MyFiles", "ViewInstanceInfo" : "instance_name" : "MyFiles", "view_name" : "FILES" ] 4. Browse to the view instance directly. http://c6401.ambari.apache.org:8080/views/files/0.1.0/myfiles/ or http://c6401.ambari.apache.org:8080/#/main/views/files/0.1.0/myfiles
Creating a View Instance: Capacity Scheduler View The following example shows creating an instance of the Capacity Scheduler View, name CAPACITY-SCHEDULER, version 0.1.0 view called "CS_1", using the label "Capacity Scheduler". 1. Create the view instance. POST /api/v1/views/capacity-scheduler/versions/0.1.0/instances/cs_1 [ "ViewInstanceInfo" : "label" : "Capacity Scheduler", "properties" : "ambari.server.url" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/mycluster", "ambari.server.username" : "admin", "ambari.server.password" : "admin" ] 201 - CREATED When creating your view instance, be sure to provide all view instance properties, otherwise you will receive a 500 required with a message explaining the properties that are required. Restart Ambari Server to pick-up the view instance and UI resources. ambari-server restart 3. Confirm the newly created view instance is available.
GET /api/v1/views/capacity-scheduler/versions/0.1.0 "http://c6401.ambari.apache.org:8080/api/v1/views/capacity-scheduler/versions/0.1.0/", "ViewVersionInfo" : "archive" : "/var/lib/ambari-server/resources/views/work/capacity-scheduler0.1.0", "label" : "Capacity Scheduler", "masker_class" : null, "parameters" : [ "name" : "ambari.server.url", "description" : "Target Ambari Server REST API cluster URL (for example: http://ambari.server:8080/api/v1/clusters/c1)",, "name" : "ambari.server.username", "description" : "Target Ambari administrator username (for example: admin)",, "name" : "ambari.server.password", "description" : "Target Ambari administrator password (for example: admin)", ], "view_name" : "CAPACITY-SCHEDULER", "permissions" : [ ], "instances" : [ "http://c6401.ambari.apache.org:8080/api/v1/views/capacity-scheduler/versions/0.1.0/instances/cs_1", "ViewInstanceInfo" : "instance_name" : "CS_1", "view_name" : "CAPACITY-SCHEDULER" ] 4. Browse to the view instance directly.
http://c6401.ambari.apache.org:8080/views/capacity-scheduler/0.1.0/cs_1/ or http://c6401.ambari.apache.org:8080/#/main/views/capacity-scheduler/0.1.0/cs_1/