Jump to: navigation, search

Difference between revisions of "Horizon/RESTAPI"

(GET requests =)
(added new postman collection links)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  
 
== Horizon REST API ==
 
== Horizon REST API ==
Horizon has a REST API that allows client side code to make API through the Horizon server without DJANGO server side rendering. This is to support the angular work being done in Horizon. It takes care of issues like cross origin resource scripting as well as leveraging authentication and authorization libraries already in existence.
+
Starting in Kilo, Horizon has a REST API that allows client side code to make API through the Horizon server without DJANGO server side rendering. This is to support the angular work being done in Horizon. It takes care of issues like cross origin resource scripting as well as leveraging authentication and authorization libraries already in existence.
  
'''THE API ARE FOR THE EXCLUSIVE USE OF HORIZON DEVELOPMENT AND ARE NOT SUPPORTED FOR EXTERNAL USE AT THIS TIME'''
+
=== THESE APIs ARE FOR THE EXCLUSIVE USE OF HORIZON DEVELOPMENT AND ARE NOT INTENDED FOR EXTERNAL USE AT THIS TIME ===
 +
They are very early in development and intended to support in tree development.  Until further notice, there will be no deprecation period if they need to change.
 +
 
 +
=== Status ===
 +
 
 +
==== Liberty ====
 +
Server sideː [https://github.com/openstack/horizon/tree/master/openstack_dashboard/api/rest]
 +
Client sideː [https://github.com/openstack/horizon/tree/master/openstack_dashboard/static/openstack-service-api]
 +
 
 +
==== Kilo ====
 +
Summit Talkː [https://www.openstack.org/summit/vancouver-2015/summit-videos/presentation/beyond-the-horizon-innovating-and-customizing-horizon-using-angularjs]
 +
Server sideː [https://github.com/openstack/horizon/tree/master/openstack_dashboard/api/rest]
 +
Client sideː [https://github.com/openstack/horizon/tree/stable/kilo/horizon/static/horizon/js/angular/services]
  
 
=== Testing ===
 
=== Testing ===
  
To Test the Horizon REST APIs using POSTMAN (Chrome Plugin)ː
+
To Test the Horizon REST APIs using POSTMAN (Chrome Plugin), login normally going to the exact API address (or localhost) that you'll use from POSTMAN. Once you've logged in your browser will have an access cookie that it'll pass on with all its requests.
  
# Login normally going to the exact API address (or localhost) that you'll use from POSTMAN
+
You will also want to install the POSTMAN interceptor and log into horizon from your browser.
  
 
==== GET requests ====
 
==== GET requests ====
Input the URL. For exampleː http://127.0.0.1:8005/api/glance/images
+
Input the URL.  
 +
 
 +
For exampleː http://127.0.0.1:8005/api/glance/images
 +
 
 
Set the following header:
 
Set the following header:
 
{| class="wikitable"
 
{| class="wikitable"
Line 20: Line 35:
 
| X-Requested-With || XMLHttpRequest
 
| X-Requested-With || XMLHttpRequest
 
|}
 
|}
 +
 +
The GET requests should include a csrftoken cookie (eg. csrftoken=onXnBfMqIxuFGr437P91Uuxdl09t2ykQ). You should copy this off if you need to perform any POST requests.
  
 
==== POST requests ====
 
==== POST requests ====
Input the URL. For exampleː http://127.0.0.1:8005/api/nova/keypairs/
+
Input the URL.  
 +
 
 +
For exampleː http://127.0.0.1:8005/api/nova/keypairs/
  
 
Set the following headers
 
Set the following headers
Line 33: Line 52:
 
| Content-Type || application/json
 
| Content-Type || application/json
 
|-
 
|-
| X-CSRFToken || a current token
+
| X-CSRFToken || the value of the csrftoken cookie you've seen in any GET request to the same address. You can obtain the token from the cookie sent via your REQUEST headers of the above GET call.
 
|}
 
|}
  
Line 43: Line 62:
 
   "name":"foo"  
 
   "name":"foo"  
 
  }
 
  }
 +
 +
==== Postman Collections ====
 +
 +
Some POSTMAN Collections to help with testing can be found below.  The date that they worked is listed and collection follows.
 +
 +
===== 2016-04-18 =====
 +
  Cinder Horizonː https://www.getpostman.com/collections/342a35ae1063767049ed
 +
  Glance Directː https://www.getpostman.com/collections/2ec9be630bc6b860e31d
 +
  Glance Horizonː https://www.getpostman.com/collections/0fb61d16402b0b2bb640
 +
  Keystone Directː https://www.getpostman.com/collections/a8364572e67c0f067c2e
 +
  Keystone Horizonː https://www.getpostman.com/collections/3fe2767e50acf34893fc
 +
  Network Abstraction Horizonː https://www.getpostman.com/collections/165869c840477c8b22a7
 +
  Neutron Directː https://www.getpostman.com/collections/96ced18cd6483318ccf1
 +
  Neutron Horizonː https://www.getpostman.com/collections/f372f0480ada8fdb61ed
 +
  Nova Directː https://www.getpostman.com/collections/127fc0afe0dacd4806d5
 +
  Nova Horizonː https://www.getpostman.com/collections/b5d0ed70a0c7b5f82d03
 +
  Horizon Policyː https://www.getpostman.com/collections/dd65a2cc201169bcab91
 +
  Searchlight Directː https://www.getpostman.com/collections/4165d893505350d5761a
 +
  Searchlight Horizonː https://www.getpostman.com/collections/2c1fa8a695303122ad7a
 +
 +
Work with the following Postman environment at the bottom of this page.
 +
 +
===== 2015-04-06 =====
 +
  Keystone: https://www.getpostman.com/collections/311080eb87c7bca1b7b1
 +
  Neutron: https://www.getpostman.com/collections/401a40ae526887e378ef
 +
  Network: https://www.getpostman.com/collections/be29e7af5243d09d8b99
 +
  Nova Direct: https://www.getpostman.com/collections/0b6e8b0eb23687bfeec0
 +
  Nova Horizon: https://www.getpostman.com/collections/1c24ae62ea46c8a56791
 +
  Policy: https://www.getpostman.com/collections/acf134dde5c77ad81a1b
 +
  Cinder: https://www.getpostman.com/collections/6c7391cd25603c2218fe
 +
  Config: https://www.getpostman.com/collections/b64d279e663de38897c8
 +
  Glance: https://www.getpostman.com/collections/2dd5e5e2e849bf3880fc
 +
 +
===== POSTMAN ENVIRONMENT =====
 +
 +
<code>
 +
{
 +
"name": "OpenStack @ 192.168.200.200",
 +
"values": [
 +
{
 +
"key": "IP",
 +
"value": "127.0.0.1",
 +
"type": "text",
 +
"name": "IP",
 +
"enabled": true
 +
},
 +
{
 +
"key": "HORIZON_PORT",
 +
"value": "8005",
 +
"type": "text",
 +
"name": "HORIZON_PORT",
 +
"enabled": true
 +
},
 +
{
 +
"key": "TOKEN",
 +
"value": "REPLACE̞ME",
 +
"type": "text",
 +
"name": "TOKEN",
 +
"enabled": true
 +
},
 +
{
 +
"key": "KEYSTONE_PORT",
 +
"value": "5000",
 +
"type": "text",
 +
"name": "KEYSTONE_PORT",
 +
"enabled": true
 +
},
 +
{
 +
"key": "OS_TENANT_NAME",
 +
"value": "demo",
 +
"type": "text",
 +
"name": "OS_TENANT_NAME",
 +
"enabled": true
 +
},
 +
{
 +
"key": "OS_TENANT_ID",
 +
"value": "REPLACE̠ME",
 +
"type": "text",
 +
"name": "OS_TENANT_ID",
 +
"enabled": true
 +
},
 +
{
 +
"key": "OS_USERNAME",
 +
"value": "admin",
 +
"type": "text",
 +
"name": "OS_USERNAME",
 +
"enabled": true
 +
},
 +
{
 +
"key": "OS_PASSWORD",
 +
"value": "REPLACE̙ME",
 +
"type": "text",
 +
"name": "OS_PASSWORD",
 +
"enabled": true
 +
},
 +
{
 +
"key": "NOVA_V2_PORT",
 +
"value": "8774",
 +
"type": "text",
 +
"name": "NOVA_V2_PORT",
 +
"enabled": true
 +
},
 +
{
 +
"key": "SEARCHLIGHT_V1_PORT",
 +
"value": "9393",
 +
"type": "text",
 +
"name": "SEARCHLIGHT_V1_PORT",
 +
"enabled": true
 +
},
 +
{
 +
"key": "OS_DOMAIN_NAME",
 +
"value": "admin",
 +
"type": "text",
 +
"name": "OS_DOMAIN_NAME",
 +
"enabled": true
 +
},
 +
{
 +
"key": "OS_DOMAIN_ID",
 +
"value": null,
 +
"type": "text",
 +
"name": "OS_DOMAIN_ID",
 +
"enabled": true
 +
},
 +
{
 +
"key": "GLANCE_V2_PORT",
 +
"value": "9292",
 +
"type": "text",
 +
"name": "GLANCE_V2_PORT",
 +
"enabled": true
 +
},
 +
{
 +
"key": "HORIZON_LOCAL_IP",
 +
"value": "127.0.0.1",
 +
"type": "text",
 +
"name": "HORIZON_LOCAL_IP",
 +
"enabled": true
 +
},
 +
{
 +
"key": "SEARCHLIGHT_LOCAL_IP",
 +
"value": "127.0.0.1",
 +
"type": "text",
 +
"enabled": true
 +
}
 +
],
 +
"team": null,
 +
"timestamp": 1461035969136,
 +
"synced": false,
 +
"syncedFilename": "",
 +
"isDeleted": false
 +
}
 +
</code>

Latest revision as of 03:37, 19 April 2016

Horizon REST API

Starting in Kilo, Horizon has a REST API that allows client side code to make API through the Horizon server without DJANGO server side rendering. This is to support the angular work being done in Horizon. It takes care of issues like cross origin resource scripting as well as leveraging authentication and authorization libraries already in existence.

THESE APIs ARE FOR THE EXCLUSIVE USE OF HORIZON DEVELOPMENT AND ARE NOT INTENDED FOR EXTERNAL USE AT THIS TIME

They are very early in development and intended to support in tree development. Until further notice, there will be no deprecation period if they need to change.

Status

Liberty

Server sideː [1]
Client sideː [2]

Kilo

Summit Talkː [3]
Server sideː [4]
Client sideː [5]

Testing

To Test the Horizon REST APIs using POSTMAN (Chrome Plugin), login normally going to the exact API address (or localhost) that you'll use from POSTMAN. Once you've logged in your browser will have an access cookie that it'll pass on with all its requests.

You will also want to install the POSTMAN interceptor and log into horizon from your browser.

GET requests

Input the URL.

For exampleː http://127.0.0.1:8005/api/glance/images

Set the following header:

Header Value
X-Requested-With XMLHttpRequest

The GET requests should include a csrftoken cookie (eg. csrftoken=onXnBfMqIxuFGr437P91Uuxdl09t2ykQ). You should copy this off if you need to perform any POST requests.

POST requests

Input the URL.

For exampleː http://127.0.0.1:8005/api/nova/keypairs/

Set the following headers

Header Value
X-Requested-With XMLHttpRequest
Content-Type application/json
X-CSRFToken the value of the csrftoken cookie you've seen in any GET request to the same address. You can obtain the token from the cookie sent via your REQUEST headers of the above GET call.

Set the raw content as JSON formatted.

Exampleː

{
 "name":"foo" 
}

Postman Collections

Some POSTMAN Collections to help with testing can be found below. The date that they worked is listed and collection follows.

2016-04-18
 Cinder Horizonː https://www.getpostman.com/collections/342a35ae1063767049ed
 Glance Directː https://www.getpostman.com/collections/2ec9be630bc6b860e31d
 Glance Horizonː https://www.getpostman.com/collections/0fb61d16402b0b2bb640
 Keystone Directː https://www.getpostman.com/collections/a8364572e67c0f067c2e
 Keystone Horizonː https://www.getpostman.com/collections/3fe2767e50acf34893fc
 Network Abstraction Horizonː https://www.getpostman.com/collections/165869c840477c8b22a7
 Neutron Directː https://www.getpostman.com/collections/96ced18cd6483318ccf1
 Neutron Horizonː https://www.getpostman.com/collections/f372f0480ada8fdb61ed
 Nova Directː https://www.getpostman.com/collections/127fc0afe0dacd4806d5
 Nova Horizonː https://www.getpostman.com/collections/b5d0ed70a0c7b5f82d03
 Horizon Policyː https://www.getpostman.com/collections/dd65a2cc201169bcab91
 Searchlight Directː https://www.getpostman.com/collections/4165d893505350d5761a
 Searchlight Horizonː https://www.getpostman.com/collections/2c1fa8a695303122ad7a

Work with the following Postman environment at the bottom of this page.

2015-04-06
 Keystone: https://www.getpostman.com/collections/311080eb87c7bca1b7b1
 Neutron: https://www.getpostman.com/collections/401a40ae526887e378ef
 Network: https://www.getpostman.com/collections/be29e7af5243d09d8b99
 Nova Direct: https://www.getpostman.com/collections/0b6e8b0eb23687bfeec0
 Nova Horizon: https://www.getpostman.com/collections/1c24ae62ea46c8a56791
 Policy: https://www.getpostman.com/collections/acf134dde5c77ad81a1b
 Cinder: https://www.getpostman.com/collections/6c7391cd25603c2218fe
 Config: https://www.getpostman.com/collections/b64d279e663de38897c8
 Glance: https://www.getpostman.com/collections/2dd5e5e2e849bf3880fc
POSTMAN ENVIRONMENT

{ "name": "OpenStack @ 192.168.200.200", "values": [ { "key": "IP", "value": "127.0.0.1", "type": "text", "name": "IP", "enabled": true }, { "key": "HORIZON_PORT", "value": "8005", "type": "text", "name": "HORIZON_PORT", "enabled": true }, { "key": "TOKEN", "value": "REPLACE̞ME", "type": "text", "name": "TOKEN", "enabled": true }, { "key": "KEYSTONE_PORT", "value": "5000", "type": "text", "name": "KEYSTONE_PORT", "enabled": true }, { "key": "OS_TENANT_NAME", "value": "demo", "type": "text", "name": "OS_TENANT_NAME", "enabled": true }, { "key": "OS_TENANT_ID", "value": "REPLACE̠ME", "type": "text", "name": "OS_TENANT_ID", "enabled": true }, { "key": "OS_USERNAME", "value": "admin", "type": "text", "name": "OS_USERNAME", "enabled": true }, { "key": "OS_PASSWORD", "value": "REPLACE̙ME", "type": "text", "name": "OS_PASSWORD", "enabled": true }, { "key": "NOVA_V2_PORT", "value": "8774", "type": "text", "name": "NOVA_V2_PORT", "enabled": true }, { "key": "SEARCHLIGHT_V1_PORT", "value": "9393", "type": "text", "name": "SEARCHLIGHT_V1_PORT", "enabled": true }, { "key": "OS_DOMAIN_NAME", "value": "admin", "type": "text", "name": "OS_DOMAIN_NAME", "enabled": true }, { "key": "OS_DOMAIN_ID", "value": null, "type": "text", "name": "OS_DOMAIN_ID", "enabled": true }, { "key": "GLANCE_V2_PORT", "value": "9292", "type": "text", "name": "GLANCE_V2_PORT", "enabled": true }, { "key": "HORIZON_LOCAL_IP", "value": "127.0.0.1", "type": "text", "name": "HORIZON_LOCAL_IP", "enabled": true }, { "key": "SEARCHLIGHT_LOCAL_IP", "value": "127.0.0.1", "type": "text", "enabled": true } ], "team": null, "timestamp": 1461035969136, "synced": false, "syncedFilename": "", "isDeleted": false }