This document provides an overview of APIs and SDK code samples related to bucket tagging.
API | Operation | Description |
---|---|---|
PUT Bucket tagging | Setting bucket tags | Sets tags for an existing bucket |
GET Bucket tagging | Querying bucket tags | Queries the existing tags of a bucket |
DELETE Bucket tagging | Deleting bucket tags | Deletes the tags of a bucket |
For the parameters and method description of all the APIs in the SDK, see API Documentation.
This API is used to set tags for an existing bucket.
try
{
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.intl.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.
This API is used to query the existing tags of a specified bucket.
try
{
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.intl.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.
This API is used to delete the existing tags from a bucket.
try
{
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.intl.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.
Apakah halaman ini membantu?