Tag Management
Updated at:2025-11-03
Baidu AI Cloud provides Tag Management function, enabling quick categorization and identification management of cloud resources by adding tags to each resource. For details, please refer to Manage Bucket Tag API
Set bucket tags (PutBucketTagging)
| Parameters | Types | Description |
|---|---|---|
| bucketName | String | The requested bucket name |
| tags | List< Object > | Tag object list: Each tag consists of a key and a value, and the tag (key + value) must be unique |
| +tagKey | String | Tag key |
| +tagValue | String | Tag value |
Note: The tag-setting API supports adding and modifying tags. If a new tag shares the same key as an existing tag, it will overwrite the previous one.
The following code sets tags by constructing object parameters:
Java
1// Construct tag configuration
2BucketTag tag = BucketTag.builder()
3 .tagKey("key1")
4 .tagValue("1")
5 .build();
6List<BucketTag> tags = new ArrayList<BucketTag>();
7tags.add(tag);
8 // Request
9this.client.putBucketTagging(bucketName, tags);
The following code sets tags by directly passing a JSON string:
Java
1// Construct tag configuration
2String tag = "{\"tags\":[{\"tagKey\":\"key1\"," +
3 "\"tagValue\":\"1\"}]}";
4
5 // Request
6this.client.putBucketTagging(bucketName, testJson);
Get bucket tags (GetBucketTagging)
| Parameters | Types | Description |
|---|---|---|
| bucketName | String | The requested bucket name |
Code example:
Java
1GetBucketTaggingResponse response = this.client.getBucketTagging(bucketName);
Delete bucket tags (DeleteBucketTagging)
| Parameters | Types | Description |
|---|---|---|
| bucketName | String | The requested bucket name |
Note: The tag deletion API will delete all tags of the corresponding bucket
Code example:
Java
1this.client.deleteBucketTagging(bucketName);
