Create or replace server metadata items

Overview

Creates or replaces metadata items 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

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

{
    "metadata": {
        "<metadata_key>": "<metadata_value>",
        <<repeat>>
    }
}

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 Body String(1-255 characters) key for metadata Server Metadata optional
metadata_value Body String(1-255 characters) value for metadata Server Metadata optional

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

{
    "metadata": {
        "<metadata_key>": "<metadata_value>",
        <<repeat>>
    }
}

Response Parameter

Response Parameters
item format description  
metadata_key Body String(1-255 characters) key for metadata Server Metadata
metadata_value Body 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

Request Header

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

Request Body

{
    "metadata": {
        "foo": "bar"
    }
}

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

{
    "metadata": {
        "foo": "bar"
    }
}

Execution Example 1

HTTP Request

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

{"metadata": {"HA_Enabled": "false"}}

HTTP Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 30
X-Compute-Request-Id: req-77b24cd6-aa46-40c3-811b-245d888f1530
Date: Thu, 15 Oct 2015 04:41:54 GMT

{"metadata": {"HA_Enabled": "false"}}

Execution Example 2

HTTP Request

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

{"metadata": {}}

HTTP Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 30
X-Compute-Request-Id: req-77b24cd6-aa46-40c3-811b-245d888f1530
Date: Thu, 15 Oct 2015 04:41:54 GMT

{"metadata": {}}

Error Execution Example

HTTP Request

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

{"metadata": {"key3": "val3"}}

HTTP Response

HTTP/1.1 400 Bad Request
Content-Length: 187
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-9858ba7e-14fc-40ff-b252-6d24e2e8ba72
Date: Thu, 15 Oct 2015 04:42:14 GMT

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