tencent cloud

Feedback

Bucket Tagging

Last updated: 2024-02-02 16:24:05

    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 a Bucket Tag

    API description

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

    Method prototype

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

    Sample request

    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
    Description
    Type
    setBucketTaggingConfigurationRequest
    Request to set the bucket tag
    SetBucketTaggingConfigurationRequest
    Request member description:
    Request Member
    Set Method
    Description
    Type
    bucketName
    Constructor or set method
    Bucket that the tag is set for, formatted as BucketName-APPID. For more information, please see Naming Conventions.
    String
    taggingConfiguration
    Constructor or set method
    Tagging configuration of the bucket
    BucketTaggingConfiguration
    Description of the BucketLoggingConfiguration member:
    Parameter
    Description
    Type
    tagSets
    Collection of tags for the bucket
    List<TagSet>
    Description of the TagSet member:
    Parameter
    Description
    Type
    tags
    The tag’s key and value, which cannot exceed 128 bytes and can contain letters, digits, spaces, plus signs (+), minus signs (−), underscores (_), equal signs (=), dots (.), colons (:), and slashes (/).
    Map<String, String>

    Response description

    Success: No value is returned.
    Failure: An error (such as authentication failure) occurs, throwing the "CosClientException" or "CosServiceException" exception. For more information, please see Troubleshooting.

    Querying Bucket Tags

    API description

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

    Method prototype

    public BucketTaggingConfiguration getBucketTaggingConfiguration(String bucketName);

    Sample request

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

    Parameter description

    Parameter
    Description
    Type
    bucketName
    Bucket to query the tags from, formatted as BucketName-APPID. For more information, please see Naming Conventions.
    String

    Response description

    Success: returns BucketTaggingConfiguration, including the bucket’s tagging configuration.
    Failure: An error (such as authentication failure) occurs, throwing the "CosClientException" or "CosServiceException" exception. For more information, please see Troubleshooting.

    Deleting Bucket Tags

    API description

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

    Method prototype

    public void deleteBucketTaggingConfiguration(String bucketName);

    Sample request

    String bucketName = "examplebucket-1250000000";
    cosClient.deleteBucketTaggingConfiguration(bucketName);

    Parameter description

    Parameter
    Description
    Type
    bucketName
    Bucket to delete the tags from, formatted as BucketName-APPID. For more information, please see Naming Conventions.
    String

    Response description

    Success: No value is returned.
    Failure: An error (such as authentication failure) occurs, throwing the "CosClientException" or "CosServiceException" exception. For more information, please see Troubleshooting.
    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