tencent cloud

Feedback

Bucket Tagging

Last updated: 2024-02-02 17:35:19

    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 specified bucket
    Deleting bucket tags
    Deletes specified bucket tags

    Setting a bucket tag

    Feature description

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

    Sample request

    cos.putBucketTagging({
    Bucket: 'examplebucket-1250000000', /*Required*/
    Region: 'COS_REGION', /* Bucket region. Required */
    Tagging: {
    Tags: [
    {"Key": "k1", "Value": "v1"},
    {"Key": "k2", "Value": "v2"}
    ]
    }
    }, function(err, data) {
    console.log(err || data);
    });

    Parameter description

    Parameter Name
    Description
    Type
    Required
    Bucket
    Bucket for which the bucket tag is configured in the format: BucketName-APPID
    String
    Yes
    Region
    Bucket region. For the enumerated values, see Regions and Access Domain Names
    String
    Yes
    Tagging
    Tag information
    Object
    Yes
    - Tags
    Tag information
    ObjectArray
    Yes
    - - Key
    Tag name
    String
    Yes
    - - Value
    Tag value
    String
    Yes

    Callback function description

    function(err, data) { ... }
    Parameter Name
    Description
    Type
    err
    Object returned when an error (network error or service error) occurs. If the request is successful, this is null. For more information, see Error Codes
    Object
    - statusCode
    HTTP status code returned by the request, such as 200, 403, and 404
    Number
    - headers
    Headers returned by the request
    Object
    data
    Data returned when the request is successful. If the request fails, this is null
    Object
    - statusCode
    HTTP status code returned by the request, such as 200, 403, and 404
    Number
    - headers
    Headers returned by the request
    Object

    Querying a bucket tag

    Feature description

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

    Sample request

    cos.getBucketTagging({
    Bucket: 'examplebucket-1250000000', /*Required*/
    Region: 'COS_REGION', /* Bucket region. Required */
    }, function(err, data) {
    console.log(err || data);
    });

    Sample response

    {
    "Tags": [
    {"Key": "k1", "Value": "v1"},
    {"Key": "k2", "Value": "v2"}
    ],
    "statusCode": 200,
    "headers": {}
    }

    Parameter description

    Parameter Name
    Description
    Type
    Required
    Bucket
    Bucket for which the bucket policy is queried in the format: BucketName-APPID
    String
    Yes
    Region
    Bucket region. For the enumerated values, see Regions and Access Domain Names
    String
    Yes

    Callback function description

    function(err, data) { ... }
    Parameter Name
    Description
    Type
    err
    Object returned when an error (network error or service error) occurs. If the request is successful, this is null. For more information, see Error Codes
    Object
    - statusCode
    HTTP status code returned by the request, such as 200, 403, and 404
    Number
    - headers
    Headers returned by the request
    Object
    data
    Data returned when the request is successful. If the request fails, this is null.
    Object
    - statusCode
    HTTP status code returned by the request, such as 200, 403, and 404
    Number
    - headers
    Headers returned by the request
    Object
    - Tags
    Tag information
    ObjectArray
    - - Key
    Tag name
    String
    - - Value
    Tag value
    String

    Deleting a bucket tag

    Feature description

    This API is used to delete specified bucket tags.

    Sample request

    cos.deleteBucketTagging({
    Bucket: 'examplebucket-1250000000', /*Required*/
    Region: 'COS_REGION', /* Bucket region. Required */
    }, function(err, data) {
    console.log(err || data);
    });

    Parameter description

    Parameter Name
    Description
    Type
    Required
    Bucket
    Bucket for which the bucket tag is deleted in the format: BucketName-APPID
    String
    Yes
    Region
    Bucket region. For the enumerated values, see Regions and Access Domain Names
    String
    Yes

    Callback function description

    function(err, data) { ... }
    Parameter Name
    Description
    Type
    err
    Object returned when an error (network error or service error) occurs. If the request is successful, this is null. For more information, see Error Codes
    Object
    - statusCode
    HTTP status code returned by the request, such as 200, 403, and 404
    Number
    - headers
    Headers returned by the request
    Object
    data
    Data returned when the request is successful. If the request fails, this is null.
    Object
    - statusCode
    HTTP status code returned by the request, such as 200, 403, and 404
    Number
    - headers
    Headers returned by the request
    Object
    
    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