List keypairs

Overview

Lists keypairs that are associated with the account.

Classification

  • List

API Operation Object

  • os-keypairs

Synchronous / Asynchronous

  • -

Request

HTTP Request Method

  • GET

HTTP Request Path

{api_endpoint}/v2/{tenant_id}/os-keypairs

HTTP Request Header

Format

Accept-Encoding: gzip, deflate, compress (optional)
Accept: application/json
X-Auth-Token: <token_id>
Content-Type: application/json

HTTP Request Body

Format

  • none

Request Parameter

Request Parameters
name style format description required/optional
tenant_id URI String The ID for the tenant or account in a multi-tenancy cloud. required

Response

HTTP Response Header

Format

HTTP/1.1 <response_code> <message>       (ex. 200 OK)
  • <response_code>: see "HTTP Responses" section

  • <message>: message based on the response code

    • skip auto insert field such as "X-Compute-Request-Id" and "Content-Length", "Date"

Response Code

Response Codes
response code condition
200 normal end
400 badRequest
401 unauthorized
403 forbidden
404 itemNotFound
405 badMethod
413 overLimit
503 serviceUnavailable

HTTP Response Body

Format

{
    "keypairs": [
        {
            "keypair": {
                "fingerprint": "<fingerprint>",
                "name": "<name>",
                "public_key": "<public_key>"
            }
        }
    ]
}

Response Parameter

Response Parameters
item format description
fingerprint String fingerprint
name String The name to associate with the keypair.
public_key String The public ssh key to import. If not provided, a key is generated.

Sample API Request and Response

Sample API Request

Request URI

https://example.com/v2/{tenant_id}/os-keypairs

Request Header

Accept-Encoding: gzip, deflate, compress (optional)
Accept: application/json
X-Auth-Token: ajk3adjiown02
Content-Type: application/json

Request Body

  • none

Sample API Response

Response Header

HTTP/1.1 200 OK
  • <response_code>: see "HTTP Responses" section

  • <message>: message based on the response code

    • skip auto insert field such as "X-Compute-Request-Id" and "Content-Length", "Date"

Response Body

{
    "keypairs": [
        {
            "keypair": {
                "fingerprint": "15:b0:f8:b3:f9:48:63:71:cf:7b:5b:38:6d:44:2d:4a",
                "name": "keypair-601a2305-4f25-41ed-89c6-2a966fc8027a",
                "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC+Eo/RZRngaGTkFs7I62ZjsIlO79KklKbMXi8F+KITD4bVQHHn+kV+4gRgkgCRbdoDqoGfpaDFs877DYX9n4z6FrAIZ4PES8TNKhatifpn9NdQYWA+IkU8CuvlEKGuFpKRi/k7JLos/gHi2hy7QUwgtRvcefvD/vgQZOVw/mGR9Q== Generated-by-Nova\n"
            }
        }
    ]
}

Execution Example

HTTP Request

GET /v2/895f0b8574504834bd6249d91dbd5a9c/os-keypairs HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token:aa8d8ee4622c4e10ace2a5a16b58caf2
Content-type: application/json
Accept: application/json

HTTP Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 399
X-Compute-Request-Id: req-1e091d5f-9089-4338-bea7-38aa7ef083f8
Date: Thu, 08 Oct 2015 00:53:03 GMT

{"keypairs": [{"keypair": {"public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDx8nkQv/zgGgB4rMYmIf+6A4l6Rr+o/6lHBQdW5aYd44bd8JttDCE/F/pNRr0lRE+PiqSPO8nDPHw0010JeMH9gYgnnFlyY3/OcJ02RhIPyyxYpv9FhY+2YiUkpwFOcLImyrxEsYXpD/0d3ac30bNH6Sw9JD9UZHYcpSxsIbECHw== Generated-by-Nova", "name": "keypair-dab428fe-6186-4a14-b3de-92131f76cd39", "fingerprint": "1e:2c:9b:56:79:4b:45:77:f9:ca:7a:98:2c:b0:d5:3c"}}]}

Error Execution Example

HTTP Request

GET /v2/e4ee5a9bdf934e35b62c8b995152feee/os-keypairs HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: eb46ce9e8a204cbabacc51282ac691ad
Accept: application/json

HTTP Response

HTTP/1.1 400 Bad Request
Content-Length: 188
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-afb6fa49-c26b-4eed-81ca-5be3b19b59cc
Date: Wed, 07 Oct 2015 06:15:05 GMT

{"badRequest": {"message": "Malformed request URL: URL's project_id 'e4ee5a9bdf934e35b62c8b995152feee' doesn't match Context's project_id 'f66f8e846a65484a9a6740077e72e3dd'", "code": 400}}