Bucket tag

Last updated: 2020-03-20 09:30:06

PDF

Note

This document provides an overview of API on Bucket tags and sample SDK code.

API Operation name pedagogical operation
PUT Bucket tagging Set Bucket tag Set the label for the existing Bucket
GET Bucket tagging Query Bucket tag Query the existing Bucket tags under the specified Bucket
DELETE Bucket tagging Delete Bucket tag Delete the specified Bucket tag

Set Bucket tag

Function description

PUT Bucket tagging is used to label the existing Bucket.

Method prototype

public void setBucketTaggingConfiguration(SetBucketTaggingConfigurationRequest setBucketTaggingConfigurationRequest);
public void setBucketTaggingConfiguration(String bucketName, BucketTaggingConfiguration bucketTaggingConfiguration);

Request Sample

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 description

Parameter name Description Type
SetBucketLoggingConfigurationRequest Bucket tag setting request SetBucketLoggingConfigurationRequest

Request member description:

Request member Setting method Description Type
BucketName Constructor or set method Bucket is tagged in BucketName-APPID format. For more information, please see Naming convention String
TaggingConfiguration Constructor or set method Bucket's label configuration BucketTaggingConfiguration

BucketLoggingConfiguration member description:

Parameter name Description Type
TagSets Bucket's tag configuration collection List

TagSet member description:

Parameter name Description Type
Tags The Key and Value, length of the label is no more than 128 bytes. Key and Value support English letters, numbers, spaces, plus sign, minus sign, underscore, equal sign, period, colon and slash. Map < String, String >

Return result description

  • Success: no return value.
  • Failure: if an error occurs (such as Identity verification failure), an exception CosClientException or CosServiceException is thrown. For more information, please see Exception Handling .

Query Bucket tag

Function description

GET Bucket tagging is used to query the existing Bucket tags under the specified Bucket.

Method prototype

public BucketTaggingConfiguration getBucketTaggingConfiguration(String bucketName);

Request Sample

String bucketName = "examplebucket-1250000000";
BucketTaggingConfiguration bucketTaggingConfiguration = cosclient.getBucketTaggingConfiguration(bucketName);

Parameter description

Parameter name Description Type
BucketName Query the tag Bucket in BucketName-APPID format. For more information, please see Naming convention String

Return result description

  • Success: return BucketTaggingConfiguration, containing Bucket's tag setting information.
  • Failure: if an error occurs (such as Identity verification failure), an exception CosClientException or CosServiceException is thrown. For more information, please see Exception Handling .

Delete Bucket tag

Function description

DELETE Bucket tagging is used to delete the existing Bucket tag under the specified Bucket.

Method prototype

public void deleteBucketTaggingConfiguration(String bucketName);

Request Sample

String bucketName = "examplebucket-1250000000";
BucketTaggingConfiguration bucketTaggingConfiguration = cosclient.deleteBucketTaggingConfiguration(bucketName);

Parameter description

Parameter name Description Type
BucketName Bucket with the deleted tag is in BucketName-APPID format. For more information, please see Naming convention String

Return result description

  • Success: no return value.
  • Failure: if an error occurs (such as Identity verification failure), an exception CosClientException or CosServiceException is thrown. For more information, please see Exception Handling .