Keystone V3 API Examples

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.