This document provides an overview of APIs and SDK code samples related to bucket tagging.
API | Operation Name | Operation Description |
---|---|---|
PUT Bucket tagging | Setting a bucket tag | Sets a tag for an existing bucket |
GET Bucket tagging | Querying bucket tags | Queries the existing tags of a specified bucket |
DELETE Bucket tagging | Deleting a bucket tag | Deletes a specified bucket tag |
This API (PUT Bucket tagging) is used to set a tag for an existing bucket.
public void setBucketTaggingConfiguration(SetBucketTaggingConfigurationRequest setBucketTaggingConfigurationRequest);
public void setBucketTaggingConfiguration(String bucketName, BucketTaggingConfiguration bucketTaggingConfiguration);
String bucketName = "examplebucket-1250000000";
List<TagSet> tagSetList = new LinkedList<TagSet>();
TagSet tagSet = new TagSet();
tagSet.setTag("age", "18");
tagSet.setTag("name", "xiaoming");
tagSetList.add(tagSet);
BucketTaggingConfiguration bucketTaggingConfiguration = new BucketTaggingConfiguration();
bucketTaggingConfiguration.setTagSets(tagSetList);
SetBucketTaggingConfigurationRequest setBucketTaggingConfigurationRequest =
new SetBucketTaggingConfigurationRequest(bucketName, bucketTaggingConfiguration);
cosclient.setBucketTaggingConfiguration(setBucketTaggingConfigurationRequest);
Parameter Name | Description | Type |
---|---|---|
setBucketLoggingConfigurationRequest | Request to set bucket tag | SetBucketLoggingConfigurationRequest |
Request
member description:
Request Member | Setting Method | Description | Type |
---|---|---|---|
bucketName | Constructor or set method | Bucket for which to set a tag in the format of BucketName-APPID . For more information, please see Naming Convention |
String |
taggingConfiguration | Constructor or set method | Bucket tag configuration | BucketTaggingConfiguration |
BucketLoggingConfiguration
member description:
Parameter Name | Description | Type |
---|---|---|
tagSets | Bucket tag configuration set | List |
TagSet
member description:
Parameter Name | Description | Type |
---|---|---|
tags | Tag key and value, which can contain letters, digits, spaces, plus signs, minus signs, underscores, equal signs, dots, colons, and slashes with a maximum length of 128 bytes | Map<String, String> |
CosClientException
or CosServiceException
exception was thrown. For more information, please see Troubleshooting.This API (GET Bucket tagging) is used to query the existing tags of a specified bucket.
public BucketTaggingConfiguration getBucketTaggingConfiguration(String bucketName);
String bucketName = "examplebucket-1250000000";
BucketTaggingConfiguration bucketTaggingConfiguration = cosclient.getBucketTaggingConfiguration(bucketName);
Parameter Name | Description | Type |
---|---|---|
bucketName | Bucket for which to query a tag in the format of BucketName-APPID . For more information, please see Naming Convention |
String |
BucketTaggingConfiguration
is returned, which contains the tag configuration information of the bucket.CosClientException
or CosServiceException
exception was thrown. For more information, please see Troubleshooting.This API (DELETE Bucket tagging) is used to delete an existing tag of a specified bucket.
public void deleteBucketTaggingConfiguration(String bucketName);
String bucketName = "examplebucket-1250000000";
BucketTaggingConfiguration bucketTaggingConfiguration = cosclient.deleteBucketTaggingConfiguration(bucketName);
Parameter Name | Description | Type |
---|---|---|
bucketName | Bucket for which to delete a tag in the format of BucketName-APPID . For more information, please see Naming Convention |
String |
CosClientException
or CosServiceException
exception was thrown. For more information, please see Troubleshooting.
Was this page helpful?