~ziad-sawalha/keystone/trunk

« back to all changes in this revision

Viewing changes to doc/source/adminAPI_curl_examples.rst

  • Committer: Gerrit Code Review
  • Author(s): Jenkins
  • Date: 2011-08-11 19:13:58 UTC
  • mfrom: (251.1.2)
  • Revision ID: git-v1:1cd3878e74d220d366a6a3e47e43257ce38b6b72
Merge "Adding curl documentation and additional installation doc. Also updated man documentation for keystone-manage"

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
..
 
2
      Copyright 2011 OpenStack, LLC
 
3
      All Rights Reserved.
 
4
 
 
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
 
8
 
 
9
          http://www.apache.org/licenses/LICENSE-2.0
 
10
 
 
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
 
15
      under the License.
 
16
 
 
17
Curl Admin API examples
 
18
=====
 
19
 
 
20
All examples assume default port usage (5001) and use the example admin account created
 
21
on the Getting Started page.
 
22
 
 
23
Initial GET 
 
24
#############
 
25
Retrieves version, full API url, pdf doc link, and wadl link::
 
26
 
 
27
$> curl http://0.0.0.0:5001
 
28
 
 
29
or::
 
30
 
 
31
$> curl http://0.0.0.0:5001/v2.0/
 
32
 
 
33
 
 
34
Retrieve token:
 
35
#####
 
36
Retrieves the token and expiration date for a user::
 
37
 
 
38
        $> curl -d '{"passwordCredentials":{"username": "MyAdmin", "password": "P@ssw0rd"}}' -H "Content-type: application/json" http://localhost:5001/v2.0/tokens
 
39
 
 
40
This will return something like::
 
41
 
 
42
        $> {"auth": {"token": {"expires": "2011-08-10T17:45:22.838440", "id": "0eed0ced-4667-4221-a0b2-24c91f242b0b"}}}
 
43
        
 
44
.. note::
 
45
 
 
46
        Save the "id" as you'll be using it in the calls below.
 
47
 
 
48
 
 
49
Retrieve a list of tenants:
 
50
#####
 
51
        Run:: 
 
52
        
 
53
        $> curl -H "X-Auth-Token:0eed0ced-4667-4221-a0b2-24c91f242b0b" http://localhost:5001/v2.0/tenants
 
54
 
 
55
This will return something like::
 
56
 
 
57
        $> {"tenants": {"values": [{"enabled": 1, "id": "MyTenant", "description": null}], "links": []}}
 
58
        
 
59
Retrieve a list of users:
 
60
#####
 
61
        Run::
 
62
        
 
63
        $> curl -H "X-Auth-Token:0eed0ced-4667-4221-a0b2-24c91f242b0b" http://localhost:5001/v2.0/users
 
64
        
 
65
This will return something like::
 
66
 
 
67
    $> {"users": {"values": [{"email": null, "enabled": true, "id": "MyAdmin", "tenantId": "MyTenant"}], "links": []}}
 
68
        
 
69
Retrieve information about the token:
 
70
#####
 
71
        Run::
 
72
        
 
73
        $> curl -H "X-Auth-Token:0eed0ced-4667-4221-a0b2-24c91f242b0b" http://localhost:5001/v2.0/tokens/0eed0ced-4667-4221-a0b2-24c91f242b0b
 
74
                
 
75
This will return something like::
 
76
 
 
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"}}}    
 
78
 
 
79
Revoking a token:
 
80
#####   
 
81
        Run::
 
82
        
 
83
        $> curl -X DELETE -H "X-Auth-Token:0eed0ced-4667-4221-a0b2-24c91f242b0b" http://localhost:5001/tokens/0eed0ced-4667-4221-a0b2-24c91f242b0b
 
84
        
 
85
Creating a tenant:
 
86
#####
 
87
        Run::
 
88
        
 
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
 
90
        
 
91
This will return something like::
 
92
        
 
93
        $> {"tenant": {"enabled": true, "id": "MyTenant2", "description": "My 2nd Tenant"}}
 
94
        
 
95
Verifying the tenant:
 
96
#####
 
97
        Run::
 
98
        
 
99
        $> curl -H "X-Auth-Token:6a8c89aa-a342-463e-b955-38bea3f524a1" http://localhost:5001/v2.0/tenants/MyTenant2
 
100
        
 
101
This will return something like::
 
102
        
 
103
        $> {"tenant": {"enabled": 1, "id": "MyTenant2", "description": "My 2nd Tenant"}}
 
104
        
 
105
Updating the tenant:
 
106
#####
 
107
        Run::
 
108
        
 
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
 
110
        
 
111
This will return something like::
 
112
 
 
113
        $> {"tenant": {"enabled": true, "id": "MyTenant2", "description": "My NEW 2nd Tenant"}}         
 
114
 
 
115
Deleting the tenant:
 
116
#####
 
117
        Run::
 
118
        
 
119
        $> curl -X DELETE -H "X-Auth-Token:57b83ec2-c20f-4d08-88ff-bce6f6027d07" http://localhost:5001/v2.0/tenants/MyTenant2
 
120
        
 
121
 
 
122
    
 
123
    
 
 
b'\\ No newline at end of file'