33.2. Basic Information on API Call

Warning

Almost all parts of this Chapter describes the matters and tasks OUTSIDE of NTT Com’s Support, including how to configure the Customer Client settings. Therefore, you are required to fully understand and confirm the details on these tasks explained here in advance before you will execute these tasks. Additionally, the contents on this page is ONLY the things that NTT Com has already confirmed under the specific environments, regarding the softwares as described below. However, this chapter also describes some OpenSource software matters, so you are noted that NTT Com can NOT fully guarantee any motions nor provide any supports, regarding these matters.

33.2.1. Overviews

Enterprise Cloud 2.0 has provided the OpenStack-Compatible API, by which so you can operate Enterprise Cloud 2.0 from the program as well as automatize the infrastructure configuration.

Following describes an example on how to obtain an authentic Token with a Keystone and how to operate at API by using the newly obtained Token.

Note

Following describes how to execute a basic API call by utilizing [ curl ]. In fact, using an API client provided by the OpenStack community enables more easier API operation. For more information, please refer to Openstack Client .

33.2.2. Obtain an authentic Token via a Keystone.

Keystone is an integrated service of authentication in OpenStack and Enterprise Cloud 2.0 . The basic flow of API utilizing at Enterprise Cloud 2.0 is as described below:

  1. Obtain an authentic Token at API via Keystone.

  2. Execute an API call by using the newly obtained Token as an authentification information.

First, we describe a procedure 1. Obtain an Authentic Token at API via Keystone.

33.2.2.1. Required Information for authentication of a Keystone Token.

The following information are necessary for an API Call.

  • Take a note on the following information, viewing [ Verifying User Information ].

    • Customer Indigenous API Key [ Example: DJ0lAxtptGTV9HZbiPPOe1nj9icP0CGV ]

    • Customer Indigenous API Secret Key ( Example: A990fiJklk12H35K )

  • Keystone API Endpoint [ Example: https://keystone-jp1-ecl.api.ntt.com/v3/auth/tokens ]

    • If you are an Admin User, you will be able to obtain a Token by using any Keystone API Endpoint of any region.

    • For the ordinal users, you need to use Keystone of the Region which an Tenant exists in and the relevant user has an access permission for.

    • Following describes an example that you are the Admin-User as described below:

33.2.2.2. Execute an API call by using a curl command.

As describes below, execute the request by using a curl command. Input the following information to [ (${} ] on your newly obtained API Key and API Secret Key Information and an Endpoint.

  • ${APIkey} : Costomer Indegenous API Key

  • ${APIsecret} : Customer Indegenous API Secret Key

  • ${KeystoneEndPoint} : Keystone API Endpoint

# curl -i \
-H "Content-Type: application/json" \
-d '
{
   "auth": {
       "identity": {
           "methods": [
               "password"
           ],
           "password": {
               "user": {
                   "domain": {
                       "id": "default"
                   },
                   "name": "${APIkey}",
                   "password": "${APIsecret}"
               }
           }
       }
   }
}' ${KeystoneEndPoint}

When you use the above example, the below request are as described below.

# curl -i \
-H "Content-Type: application/json" \
-d '
{
   "auth": {
       "identity": {
           "methods": [
               "password"
           ],
           "password": {
               "user": {
                   "domain": {
                       "id": "default"
                   },
                   "name": "DJ0lAxtptGTV9HZbiPPOe1nj9icP0CGV",
                   "password": "A990fiJklk12H35K"
               }
           }
       }
   }
}' https://keystone-jp1-ecl.api.ntt.com/v3/auth/tokens

When the API request success, the following response will reply as below:

HTTP/1.1 201 Created
Date: Thu, 17 Mar 2016 10:06:32 GMT
Content-Type: application/json
Content-Length: 324
Connection: keep-alive
X-Subject-Token: dc03494823a841338430052e9ee95e07
Vary: X-Auth-Token
X-Distribution: Ubuntu
Set-Cookie: TS0183560f=01059ca7b10af7d1eaff84d7b1231b09a7d50550648db89c3aaae5f866871fd0ce11e0895b; Path=/

The Token means a value, described as X-Subject-Token.

33.2.3. Execute an API call by using your newly obtained Token.

The newly obtained Token has been already setting up about the vaild date. If it is within the vaid date, you can use the newly Token. Here, you do an API call to creat a new Tenant in JP 1 region by using a management function of Enterprise Cloud 2.0 .

[ Input the Token to the part described in ${} ]

  • ${Token} : A New Token just obtained in the previous chapter.

  • ${ContractId} : Contract ID starting from [ econ ]

curl -i -1 \
 -X POST \
 -H "X-Auth-Token: ${Token}" \
 -H "Content-Type: application/json" \
-d \
'{
   "tenant_name": "New Tenant for Tutorial",
   "description": "Support Dummy",
   "region":"jp1",
   "contract_id": "${ContractId}"
}' https://sss-jp1-ecl.api.ntt.com/api/v1.0/tenants

In the case of the above example [ Token: dc03494823a841338430052e9ee95e07, Contract ID: econ1234 ], an API call is as described below:

curl -i -1 \
 -X POST \
 -H "X-Auth-Token: dc03494823a841338430052e9ee95e07" \
 -H "Content-Type: application/json" \
-d \
'{
   "tenant_name": "New-Tenant-for-Tutorial",
   "description": "Support Dummy",
   "region":"jp1",
   "contract_id": "econ1234"
}' https://sss-jp1-ecl.api.ntt.com/api/v1.0/tenants

You can obtain the following response if you successed.

HTTP/1.1 201 Created
Date: Thu, 17 Mar 2016 10:10:49 GMT
Content-Type: application/json
Content-Length: 164
Connection: keep-alive
Set-Cookie: TS0183560f=01059ca7b1631838062ab300142381bf1e810308834a81430a08afafb04eb1e12faca30579; Path=/

{"tenant_id":"4a0103d3d9ef46bbac13446eb949b11f","tenant_name":"New-Tenant-for-Tutorial","description":"Support Dummy","region":"jp1","contract_id":"econ1234"}

You can use an API by following the below flow:

Note

For more information on how to use an API and what an API scope is, please refer to the relevant API references on reaspective services.