Configuring ECS Metadata

Function

This API is used to configure ECS metadata.

When you call this API, all the metadata of this ECS will be deleted, and the ECS uses the value configured in the request.

Constraints

An ECS must be in active, stopped, paused, or suspended state, which is specified by OS-EXT-STS:vm_state.

URI

PUT /v2.1/{project_id}/servers/{server_id}/metadata

Table 1 describes the parameters in the URI.

Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

For details about how to obtain the ID, see Obtaining a Project ID.

server_id

Yes

Specifies the ECS ID.

Request

Table 2 describes the request parameters.

Table 2 Request

Parameter

Type

Mandatory

Description

metadata

Object

Yes

Specifies the user-defined metadata key-value pair.

For a metadata key:

A key contains a maximum of 255 Unicode characters and cannot be empty. A key can contain uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), hyphens (-), underscores (_), colons (:), and periods (.).

For a metadata value:

A value contains a maximum of 255 Unicode characters.

Response

Table 3 describes the response parameters.

Table 3 Response parameters

Parameter

Type

Description

metadata

Object

Specifies the user-defined metadata key-value pair.

Example Request

Configure the metadata of a specified ECS.

PUT https://{endpoint}/v2.1/{project_id}/servers/{server_id}/metadata

{
    "metadata": {
            "key1": "value1",
            "key2": "value2"
    }
}

Example Response

{
    "metadata": {
            "key1": "value1",
            "key2": "value2"
    }
}

Returned Values

See Returned Values for General Requests.