tencent cloud

masukan

Bucket Tagging

Terakhir diperbarui:2021-08-31 17:34:19

    Overview

    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

    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&dxlt;TagSet&dxgt;

    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&dxlt;String, String&dxgt;

    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.
    Hubungi Kami

    Hubungi tim penjualan atau penasihat bisnis kami untuk membantu bisnis Anda.

    Dukungan Teknis

    Buka tiket jika Anda mencari bantuan lebih lanjut. Tiket kami tersedia 7x24.

    Dukungan Telepon 7x24