All examples assume default port usage (5001) and use the example admin account created on the Getting Started page.
Retrieves version, full API url, pdf doc link, and wadl link:
$> curl http://0.0.0.0:5001
or:
$> curl http://0.0.0.0:5001/v2.0/
Retrieves the token and expiration date for a user:
$> curl -d '{"passwordCredentials":{"username": "MyAdmin", "password": "P@ssw0rd"}}' -H "Content-type: application/json" http://localhost:5001/v2.0/tokens
This will return something like:
$> {"auth": {"token": {"expires": "2011-08-10T17:45:22.838440", "id": "0eed0ced-4667-4221-a0b2-24c91f242b0b"}}}
Note
Save the “id” as you’ll be using it in the calls below.
Run:
$> curl -H "X-Auth-Token:999888777666" http://localhost:5001/v2.0/tenants
This will return something like:
$> {"tenants": {"values": [{"enabled": 1, "id": "MyTenant", "description": null}], "links": []}}
Run:
$> curl -H "X-Auth-Token:999888777666" http://localhost:5001/v2.0/users
This will return something like:
$> {"users": {"values": [{"email": null, "enabled": true, "id": "MyAdmin", "tenantId": "MyTenant"}], "links": []}}
Run:
$> curl -H "X-Auth-Token:999888777666" http://localhost:5001/v2.0/tokens/0eed0ced-4667-4221-a0b2-24c91f242b0b
This will return something like:
$> {"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"}}}
Run:
$> curl -X DELETE -H "X-Auth-Token:999888777666" http://localhost:5001/tokens/0eed0ced-4667-4221-a0b2-24c91f242b0b
Run:
$> curl -H "X-Auth-Token:999888777666" -H "Content-type: application/json" -d '{"tenant":{"id":"MyTenant2", "description":"My 2nd Tenant", "enabled":true}}' http://localhost:5001/tenants
This will return something like:
$> {"tenant": {"enabled": true, "id": "MyTenant2", "description": "My 2nd Tenant"}}
Run:
$> curl -H "X-Auth-Token:999888777666" http://localhost:5001/v2.0/tenants/MyTenant2
This will return something like:
$> {"tenant": {"enabled": 1, "id": "MyTenant2", "description": "My 2nd Tenant"}}
Run:
$> curl -X PUT -H "X-Auth-Token:999888777666" -H "Content-type: application/json" -d '{"tenant":{"description":"My NEW 2nd Tenant"}}' http://localhost:5001/v2.0/tenants/MyTenant2
This will return something like:
$> {"tenant": {"enabled": true, "id": "MyTenant2", "description": "My NEW 2nd Tenant"}}
Run:
$> curl -X DELETE -H "X-Auth-Token:999888777666" http://localhost:5001/v2.0/tenants/MyTenant2