Bucket tag

Last updated: 2020-03-20 09:43:32

PDF

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 Guzzle\Service\Resource\Model PutBucketTagging(array $args = array());

Request Sample

try {
    $result = $cosClient->putBucketTagging(array(
        'Bucket' => 'examplebucket-1250000000', 
        'TagSet' => array(
            array('Key'=>'key1',
                  'Value'=>'value1',
            ),  
            array('Key'=>'key2',
                  'Value'=>'value2',
            ),  
        ),  
    ));
    print_r($result);
} catch (\Exception $e) {
    echo "$e\n";
}

Parameter description

Parameter name Description Type
Bucket Bucket is tagged in BucketName-APPID format. For more information, please see Naming convention String
Key Tag key String
Value Tag value String

Query Bucket tag

Function description

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

Method prototype

public Guzzle\Service\Resource\Model GetBucketTagging(array $args = array());

Request Sample

try {
    $result = $cosClient->getBucketTagging(array(
        'Bucket' => 'examplebucket-1250000000', 
    ));
    print_r($result);
} catch (\Exception $e) {
    echo($e);
}

Parameter description

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

Return an example of the result

GuzzleHttp\Command\Result Object
(
    [TagSet] => Array
        (
            [0] => Array
                (
                    [Key] => key1
                    [Value] => value1
                )

            [1] => Array
                (
                    [Key] => key2
                    [Value] => value2
                )

        )
    [RequestId] => NWRmMWVkMjFfMjJiMjU4NjRfNWQ3X2EwMWVj****
)

Return result description

Member variable Description Type
Key Tag key String
Value Tag value String

Delete Bucket tag

Function description

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

Method prototype

public Guzzle\Service\Resource\Model DeleteBucketTagging(array $args = array());

Request Sample

try {
    $result = $cosClient->deleteBucketTagging(array(
        'Bucket' => 'examplebucket-1250000000', 
    );
    print_r($result);
} catch (\Exception $e) {
    echo($e);
}

Parameter description

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