tencent cloud

All product documents
Cloud Object Storage
Bucket Tagging
Last updated: 2024-02-02 14:36:36
Bucket Tagging
Last updated: 2024-02-02 14:36:36

Overview

This document provides an overview of APIs and SDK code samples related to bucket tagging.
API
Operation
Description
Setting bucket tags
Sets tags for an existing bucket
Querying bucket tags
Queries the existing tags of a bucket
Deleting bucket tags
Deletes the tags of a bucket

Setting Bucket Tags

Description

This API is used to set tags for an existing bucket.

Sample code

try
{
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.cloud.tencent.com/developer.
string bucket = "examplebucket-1250000000";
PutBucketTaggingRequest request = new PutBucketTaggingRequest(bucket);
string akey = "aTagKey";
string avalue = "aTagValue";
string bkey = "bTagKey";
string bvalue = "bTagValue";

request.AddTag(akey, avalue);
request.AddTag(bkey, bvalue);

// Execute the request
PutBucketTaggingResult result = cosXml.PutBucketTagging(request);

// Request succeeded
Console.WriteLine(result.GetResultInfo());
}
catch (COSXML.CosException.CosClientException clientEx)
{
// Request failed
Console.WriteLine("CosClientException: " + clientEx);
}
catch (COSXML.CosException.CosServerException serverEx)
{
// Request failed
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}
Note:
For more samples, please visit GitHub.

Querying Bucket Tags

Description

This API is used to query the existing tags of a specified bucket.

Sample code

try
{
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.cloud.tencent.com/developer.
string bucket = "examplebucket-1250000000";
GetBucketTaggingRequest request = new GetBucketTaggingRequest(bucket);
// Execute the request
GetBucketTaggingResult result = cosXml.GetBucketTagging(request);

// Request succeeded
Tagging tagging = result.tagging;
Console.WriteLine(tagging);
}
catch (COSXML.CosException.CosClientException clientEx)
{
// Request failed
Console.WriteLine("CosClientException: " + clientEx);
}
catch (COSXML.CosException.CosServerException serverEx)
{
// Request failed
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}
Note:
For more samples, please visit GitHub.

Deleting Bucket Tags

Description

This API is used to delete the existing tags from a bucket.

Sample code

try
{
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.cloud.tencent.com/developer.
string bucket = "examplebucket-1250000000";
DeleteBucketTaggingRequest request = new DeleteBucketTaggingRequest(bucket);
// Execute the request
DeleteBucketTaggingResult result = cosXml.DeleteBucketTagging(request);

// Request succeeded
Console.WriteLine(result.GetResultInfo());
}
catch (COSXML.CosException.CosClientException clientEx)
{
// Request failed
Console.WriteLine("CosClientException: " + clientEx);
}
catch (COSXML.CosException.CosServerException serverEx)
{
// Request failed
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}
Note:
For more samples, please visit GitHub.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon