• Native OpenStack API

noa
  1. Help Center
  2. Native OpenStack API
  3. API Reference
  4. Nova
  5. Metadata
  6. Set Metadata Item

Set Metadata Item

Function Description

This interface is used to configure the metadata of an ECS key.

Interface Format

Method

URI

Description

PUT

/v2/{tenant_id}/servers/{server_id}/metadata/{key}

/v2.1/{tenant_id}/servers/{server_id}/metadata/{key}

Configures the metadata of a specified key.

Restrictions

The ECS must be in the active, stopped, paused, or suspended state. That is, the value of the ECS-EXT-STS:vm_state attribute of the ECS must be active, stopped, paused, or suspended.

Expanded Interface

N/A

Request Parameter

Request Parameter

Parameter

Type

Mandatory

Description

meta

Dict

Yes

Specifies the user-defined metadata key-value pair.

Data structure description of the meta field

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the key name.

The value contains a maximum of 255 Unicode characters and cannot be empty. It can contain letters in upper or lower cases, digits, hyphens (-), underscores (_), colons (:), and decimal points (.).

value

Yes

String

Specifies the key value.

The value can contain a maximum of 255 Unicode characters.

Response Parameter

Parameter

Type

Mandatory

Description

meta

Dict

Yes

Specifies the user-defined metadata key-value pair.

Request Example

PUT /v2/9c53a566cb3443ab910cf0daebca90c4/servers/998af54b-5762-4041-abc1-f98a2c27b3a2/metadata/key1
PUT /v2.1/9c53a566cb3443ab910cf0daebca90c4/servers/998af54b-5762-4041-abc1-f98a2c27b3a2/metadata/key1
{
"meta": {
            "key1": "value1"
     }
}

Response Example

{
"meta": {
            "key1": "value1"
     }
}

Returned Values

For details, see section General Request Returned Values.

Error Code

Table 1 Task error code

Error Code

Description

404

Server does not exist.

This error occurs if the ECS does not exist.