2
Copyright 2011 OpenStack, LLC
5
Licensed under the Apache License, Version 2.0 (the "License"); you may
6
not use this file except in compliance with the License. You may obtain
7
a copy of the License at
9
http://www.apache.org/licenses/LICENSE-2.0
11
Unless required by applicable law or agreed to in writing, software
12
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
License for the specific language governing permissions and limitations
17
Curl Admin API examples
20
All examples assume default port usage (5001) and use the example admin account created
21
on the Getting Started page.
25
Retrieves version, full API url, pdf doc link, and wadl link::
27
$> curl http://0.0.0.0:5001
31
$> curl http://0.0.0.0:5001/v2.0/
36
Retrieves the token and expiration date for a user::
38
$> curl -d '{"passwordCredentials":{"username": "MyAdmin", "password": "P@ssw0rd"}}' -H "Content-type: application/json" http://localhost:5001/v2.0/tokens
40
This will return something like::
42
$> {"auth": {"token": {"expires": "2011-08-10T17:45:22.838440", "id": "0eed0ced-4667-4221-a0b2-24c91f242b0b"}}}
46
Save the "id" as you'll be using it in the calls below.
49
Retrieve a list of tenants:
53
$> curl -H "X-Auth-Token:0eed0ced-4667-4221-a0b2-24c91f242b0b" http://localhost:5001/v2.0/tenants
55
This will return something like::
57
$> {"tenants": {"values": [{"enabled": 1, "id": "MyTenant", "description": null}], "links": []}}
59
Retrieve a list of users:
63
$> curl -H "X-Auth-Token:0eed0ced-4667-4221-a0b2-24c91f242b0b" http://localhost:5001/v2.0/users
65
This will return something like::
67
$> {"users": {"values": [{"email": null, "enabled": true, "id": "MyAdmin", "tenantId": "MyTenant"}], "links": []}}
69
Retrieve information about the token:
73
$> curl -H "X-Auth-Token:0eed0ced-4667-4221-a0b2-24c91f242b0b" http://localhost:5001/v2.0/tokens/0eed0ced-4667-4221-a0b2-24c91f242b0b
75
This will return something like::
77
$> {"auth": {"token": {"expires": "2011-08-11T04:26:58.145171", "id": "0eed0ced-4667-4221-a0b2-24c91f242b0b"}, "user": {"username": "MyAdmin", "roleRefs": [{"roleId": "Admin", "id": 1}], "tenantId": "MyTenant"}}}
83
$> curl -X DELETE -H "X-Auth-Token:0eed0ced-4667-4221-a0b2-24c91f242b0b" http://localhost:5001/tokens/0eed0ced-4667-4221-a0b2-24c91f242b0b
89
$> curl -H "X-Auth-Token:6a8c89aa-a342-463e-b955-38bea3f524a1" -H "Content-type: application/json" -d '{"tenant":{"id":"MyTenant2", "description":"My 2nd Tenant", "enabled":true}}' http://localhost:5001/tenants
91
This will return something like::
93
$> {"tenant": {"enabled": true, "id": "MyTenant2", "description": "My 2nd Tenant"}}
99
$> curl -H "X-Auth-Token:6a8c89aa-a342-463e-b955-38bea3f524a1" http://localhost:5001/v2.0/tenants/MyTenant2
101
This will return something like::
103
$> {"tenant": {"enabled": 1, "id": "MyTenant2", "description": "My 2nd Tenant"}}
109
$> curl -X PUT -H "X-Auth-Token:57b83ec2-c20f-4d08-88ff-bce6f6027d07" -H "Content-type: application/json" -d '{"tenant":{"description":"My NEW 2nd Tenant"}}' http://localhost:5001/v2.0/tenants/MyTenant2
111
This will return something like::
113
$> {"tenant": {"enabled": true, "id": "MyTenant2", "description": "My NEW 2nd Tenant"}}
119
$> curl -X DELETE -H "X-Auth-Token:57b83ec2-c20f-4d08-88ff-bce6f6027d07" http://localhost:5001/v2.0/tenants/MyTenant2
b'\\ No newline at end of file'