Create or update server metadata item

Overview

Sets a metadata item by key for a specified server.

Classification

  • Create

API Operation Object

  • metadata

Synchronous / Asynchronous

  • -

Request

HTTP Request Method

  • PUT

HTTP Request Path

{api_endpoint}/v2/{tenant_id}/servers/{server_id}/metadata/{metadata_key}

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

{
    "meta": {
        "<metadata_key>": "<metadata_value>"
    }
}

Request Parameter

Request Parameters
name style format description required/optional
tenant_id URI UUID The tenant ID in a multi-tenancy cloud. required
server_id URI UUID The UUID for the server. required
metadata_key URI, Body String(1-255 characters) key for metadata Server Metadata required
metadata_value Body String(1-255 characters) value for metadata Server Metadata 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 computeFault
- badRequest
- NetworkNotFound
401 unauthorized
403 forbidden
404 itemNotFound
405 badMethod
409 buildInProgress
413 overLimit
415 badMediaType
500 computeFault
503 serviceUnavailable

HTTP Response Body

Format

{
    "meta": {
        "<metadata_key>": "<metadata_value>"
    }
}

Response Parameter

Response Parameters
item format description
metadata_key String(1-255 characters) key for metadata Server Metadata
metadata_value String(1-255 characters) value for metadata Server Metadata

Sample API Request and Response

Sample API Request

Request URI

https://example.com/v2/{tenant_id}/servers/{server_id}/metadata/{metadata_key}

Request Header

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

Request Body

{
    "meta": {
        "foo": "Bar Value"
    }
}

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

{
    "meta": {
        "foo": "Bar Value"
    }
}

Execution Example 1. Update metadata key2

HTTP Request

PUT /v2/cb8aa2a2c7244af5aab1fa7881ba7f4c/servers/df82dc3f-98e0-4f68-8b75-db8aee7905ab/metadata/key2 HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: 3ca7387517904f04a92d0fd5349890f1
Content-type: application/json
Accept: application/json
Content-Length: 29

{"meta": {"key2": "val2_up"}}

HTTP Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 29
X-Compute-Request-Id: req-ab43af96-10e6-4d8a-9b3d-a62d12d5a21c
Date: Thu, 15 Oct 2015 07:04:52 GMT

{"meta": {"key2": "val2_up"}}

Execution Example 2. Update metadata HA_Enabled

HTTP Request

PUT /v2/cb8aa2a2c7244af5aab1fa7881ba7f4c/servers/df82dc3f-98e0-4f68-8b75-db8aee7905ab/metadata/HA_Enabled HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: 3ca7387517904f04a92d0fd5349890f1
Content-type: application/json
Accept: application/json
Content-Length: 29

{"meta": {"HA_Enabled": "false"}}

HTTP Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 29
X-Compute-Request-Id: req-ab43af96-10e6-4d8a-9b3d-a62d12d5a21c
Date: Thu, 15 Oct 2015 07:04:52 GMT

{"metadata": {"HA_Enabled": "false", "vmha": "false"}}

Error Execution Example

HTTP Request

PUT /v2/cb8aa2a2c7244af5aab1fa7881ba7f4c/servers/df82dc3f-98e0-4f68-8b75-db8aee7905ab/metadata/key2 HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: 3ca7387517904f04a92d0fd5349890f1
Content-type: application/json
Accept: application/json
Content-Length: 30

{"metadata": {"key2": "val2"}}

HTTP Response

HTTP/1.1 400 Bad Request
Content-Length: 66
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-57de538d-8316-4eb4-a802-7650f958cea9
Date: Thu, 15 Oct 2015 07:04:59 GMT

{"badRequest": {"message": "Malformed request body", "code": 400}}