Update server metadata items¶
Overview¶
Updates metadata items by key for a specified server.
Classification¶
- Update
API Operation Object¶
- metadata
Synchronous / Asynchronous¶
- asynchronous
Request¶
HTTP Request Method¶
- POST
HTTP Request Path¶
{api_endpoint}/v2/{project_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": {
"<key>": "<value>",
<<repeat>>
}
}
Request Parameter¶
name | style | format | description | required/optional | default value | action for invalid parameter | response code for invalid parameter |
---|---|---|---|---|---|---|---|
project_id | URL | UUID(3) | project id | required | - | Terminate | 400, 404 |
server_id | URL | UUID String | instance id | required | - | Terminate | 404 |
token_id | Header | authentication token string | keystone authentication token | required | - | Terminate | 401 |
key | Body | String(1-255 characters),int | key for metadata | optional | - | Terminate | 400, 404, 413 |
value | Body | String(0-255 characters),int | value for metadata | optional | - | Terminate | 404, 413 |
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 code | condition |
---|---|
200 | normal end |
400 | not found metadata entity in body |
- | project is not found |
- | metadata_key is 0 characters |
401 | unauthorized |
403 | not authorized to perform the requested action |
- | number of meta data has reached the quota limit |
404 | specified the instance id that not found |
- | not found a specified project |
- | metadata key size = 0 characters |
- | metadata item size = 0 characters |
409 | specified instance has been locked |
- | instance status is invalid(status isn’t ACTIVE,PAUSED,SUSPENDED,STOPPED) |
- | instance task status is not None. |
413 | metadata key size > 255 characters |
- | metadata item size > 255 characters |
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": {
"<key>": "<value>",
<<repeat>>
}
}
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": {
"<key>": "<value>",
<<repeat>>
}
}
Execution Example¶
HTTP Request¶
POST /v2/e4ee5a9bdf934e35b62c8b995152feee/servers/5ec95878-b74d-40f2-be61-c3c1ae5e5b19/metadata HTTP/1.1
User-Agent: curl/7.35.0
Host: localhost:8774
Content-Type: application/json
Accept: application/json
X-Auth-Token: 870466f60fd3461abbcf1f2f16ffc30f
Content-Length: 46
{ "metadata": { "sample_key": "sample_value"}}
HTTP Response¶
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 44
X-Compute-Request-Id: req-0cea63ec-68dd-424f-ad40-675c7bb21f3b
Date: Fri, 19 Dec 2014 06:59:10 GMT
{"metadata": {"sample_key": "sample_value"}}
Error Execution Example¶
HTTP Request¶
POST /v2/a95f0b8574504834bd6249d91dbd5a9c/servers/fd2caaa0-cdcb-4f43-bd65-2bdbe29e06b1/metadata HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token:cd08bf66ed2044c0ae07458cfeb42e82
Content-type: application/json
Accept: application/json
Content-Length: 49
{"metadata":{"key3":"val3","key1":"val1_update"}}
HTTP Response¶
HTTP/1.1 400 Bad Request
Content-Length: 188
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-ed054b62-3aa1-43cc-8c34-7b3d9da08c6e
Date: Thu, 08 Oct 2015 09:45:09 GMT
{"badRequest": {"message": "Malformed request URL: URL's project_id 'a95f0b8574504834bd6249d91dbd5a9c' doesn't match Context's project_id '895f0b8574504834bd6249d91dbd5a9c'", "code": 400}}