Help Center/ Elastic Volume Service/ API Reference/ API/ Tag Management/ Batch Deleting Tags from a Specified EVS Disk
Updated on 2025-11-25 GMT+08:00

Batch Deleting Tags from a Specified EVS Disk

Function

This API is used to batch delete tags from a specified EVS disk.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, no identity policy-based permission required for calling this API.

URI

POST /v2/{project_id}/cloudvolumes/{volume_id}/tags/action

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

The project ID. For details, see Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

volume_id

Yes

String

Definition

The disk ID.

You can call the Querying Details About All EVS Disks API to obtain the disk ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

The user token.

You can obtain it by calling the IAM API for obtaining a user token. The token is the value of X-Subject-Token in the response header.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

action

Yes

String

Definition

The operation identifier.

Constraints

N/A

Range

The options are as follows:

  • delete: deleting tags

Default Value

N/A

tags

Yes

Array of DeleteTagsOption objects

Definition

The tag list.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 4 DeleteTagsOption

Parameter

Mandatory

Type

Description

key

Yes

String

Definition

The tag key.

Constraints

Tag keys of a resource must be unique.

A tag key can contain a maximum of 36 characters.

Range

Character set: A-Z, a-z, 0-9, hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF)

Default Value

N/A

Response Parameters

Status code: 204

No Content

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error

Error object

Definition

The error code returned if an error occurs. For details about the error code, see Error Codes.

Range

N/A

Table 6 Error

Parameter

Type

Description

code

String

Definition

The error code returned if an error occurs.

Range

For details about the error code, see Error Codes.

message

String

Definition

The error message returned if an error occurs.

Range

N/A

Example Requests

Deleting two tags of an EVS disk (The key of one tag is key1, and the key of the other tag is key2.)

POST https://{endpoint}/v2/{project_id}/cloudvolumes/{volume_id}/tags/action

{
  "action" : "delete",
  "tags" : [ {
    "key" : "key1"
  }, {
    "key" : "key2"
  } ]
}

Example Responses

Status code: 400

Bad Request

{
  "error" : {
    "message" : "XXXX",
    "code" : "XXX"
  }
}

SDK Sample Code

The SDK sample code is as follows.

Java

Deleting two tags of an EVS disk (The key of one tag is key1, and the key of the other tag is key2.)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.evs.v2.region.EvsRegion;
import com.huaweicloud.sdk.evs.v2.*;
import com.huaweicloud.sdk.evs.v2.model.*;

import java.util.List;
import java.util.ArrayList;

public class BatchDeleteVolumeTagsSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        EvsClient client = EvsClient.newBuilder()
                .withCredential(auth)
                .withRegion(EvsRegion.valueOf("<YOUR REGION>"))
                .build();
        BatchDeleteVolumeTagsRequest request = new BatchDeleteVolumeTagsRequest();
        request.withVolumeId("{volume_id}");
        BatchDeleteVolumeTagsRequestBody body = new BatchDeleteVolumeTagsRequestBody();
        List<DeleteTagsOption> listbodyTags = new ArrayList<>();
        listbodyTags.add(
            new DeleteTagsOption()
                .withKey("key1")
        );
        listbodyTags.add(
            new DeleteTagsOption()
                .withKey("key2")
        );
        body.withTags(listbodyTags);
        body.withAction(BatchDeleteVolumeTagsRequestBody.ActionEnum.fromValue("delete"));
        request.withBody(body);
        try {
            BatchDeleteVolumeTagsResponse response = client.batchDeleteVolumeTags(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

Deleting two tags of an EVS disk (The key of one tag is key1, and the key of the other tag is key2.)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkevs.v2.region.evs_region import EvsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkevs.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = EvsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(EvsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = BatchDeleteVolumeTagsRequest()
        request.volume_id = "{volume_id}"
        listTagsbody = [
            DeleteTagsOption(
                key="key1"
            ),
            DeleteTagsOption(
                key="key2"
            )
        ]
        request.body = BatchDeleteVolumeTagsRequestBody(
            tags=listTagsbody,
            action="delete"
        )
        response = client.batch_delete_volume_tags(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

Deleting two tags of an EVS disk (The key of one tag is key1, and the key of the other tag is key2.)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    evs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := evs.NewEvsClient(
        evs.EvsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.BatchDeleteVolumeTagsRequest{}
	request.VolumeId = "{volume_id}"
	var listTagsbody = []model.DeleteTagsOption{
        {
            Key: "key1",
        },
        {
            Key: "key2",
        },
    }
	request.Body = &model.BatchDeleteVolumeTagsRequestBody{
		Tags: listTagsbody,
		Action: model.GetBatchDeleteVolumeTagsRequestBodyActionEnum().DELETE,
	}
	response, err := client.BatchDeleteVolumeTags(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

More

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

204

No Content

400

Bad Request

Error Codes

See Error Codes.