There is few things more useful than a set of examples when starting to work with a new API. Here is some I ' ve started collecting up for my work:
The first of three articles:more. Policy
Get a token. This user have the role ' admin ' in a project, which means they can execute admin operations.
Save the following in a file named Token-request.json
{ "Auth": { "Identity": { "Methods": [ "Password" ], "Password": { "User": { "Domain": { "name":"Default" }, "name":"Admin", "Password":"Freeipa4all" } } }, "Scope": { "Project": { "Domain": { "name":"Default" }, "name":"Demo" } } }}
and execute it with
" Content-type:application/json " http:///Localhost:35357/v3/auth/tokens | awk '/x-subject-token/{print $} '
To list domains
Curl-si-h"x-auth-token: $TOKEN""Content-type:application/json " http://localhost:35357/v3/domains
Create a domain
Curl -H"x-auth-token: $TOKEN""Content-type:application/json " ' {"domain": {"description": "--optional--", "Enabled": True, "name": "Dom1"}} ' http://localhost:35357/v3/domains
To list users
Curl-si-h"x-auth-token: $TOKEN""content-type:application/json" http://localhost:35357/v3/users
To create a users, create file named Create_user.json file like this:
{ "User": { "default_project_id":"d0f445c3379b48f38a2ab0f17314bbf9", "Description":"Description", "domain_id":"default", "Email":"[email protected]", "enabled":true, "name":"Ayoung", "Password":"Changeme" } }
Execute it like this
Curl-si-h"x-auth-token: $TOKEN""content-type:application/json" http://localhost:35357/v3/users-d @create_user. JSON
The response should look like this, with different auto-generated IDs.
{"User": {"Description":"Description","links": {" Self":"Http://192.168.0.2:5000/v3/users/8221b007376a40ce8459c05f90077f16"},"enabled":true,"Email":"[email protected]","default_project_id":"d0f445c3379b48f38a2ab0f17314bbf9","ID":"8221b007376a40ce8459c05f90077f16","domain_id":"default","name":"Ayoung"}}
Note: The above case, the new user_id is 8221B007376A40CE8459C05F90077F16. Use this to get the user directly:
$ curl-h"X-auth-token: $TOKEN"-H"Content-type:application/json"http//Localhost:35357/v3/users/8221b007376a40ce8459c05f90077f16{"User": {"name":"Ayoung","links": {" Self":"Http://192.168.0.2:5000/v3/users/8221b007376a40ce8459c05f90077f16"},"enabled":true,"Email":"[email protected]","default_project_id":"d0f445c3379b48f38a2ab0f17314bbf9","ID":"8221b007376a40ce8459c05f90077f16","domain_id":"default","Description":"Description"}}
To the additional operations, see the V3 Identity API.
from:http://adam.younglogic.com/2013/09/keystone-v3-api-examples/
Keystone V3 API Examples