tencent cloud

masukan

Bucket Tagging

Terakhir diperbarui:2024-02-04 14:25:57
    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 Bucket Tags

    Description

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

    Method prototype

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

    Sample request

    <?php
    
    require dirname(__FILE__) . '/../vendor/autoload.php';
    
    $secretId = "SECRETID"; //Replace it with the actual SecretId, which can be viewed and managed at https://console.tencentcloud.com/cam/capi
    $secretKey = "SECRETKEY"; //Replace it with the actual SecretKey, which can be viewed and managed at https://console.tencentcloud.com/cam/capi
    $region = "ap-beijing"; //Replace it with the actual region, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket
    $cosClient = new Qcloud\\Cos\\Client(
    array(
    'region' => $region,
    'schema' => 'https', // Protocol header, which is http by default
    'credentials'=> array(
    'secretId' => $secretId ,
    'secretKey' => $secretKey)));
    
    try {
    $result = $cosClient->putBucketTagging(array(
    'Bucket' => 'examplebucket-1250000000', // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket
    'TagSet' => array(
    array('Key'=>'key1',
    'Value'=>'value1',
    ),
    array('Key'=>'key2',
    'Value'=>'value2',
    ),
    ),
    ));
    // Request succeeded
    print_r($result);
    } catch (\\Exception $e) {
    // Request failed
    echo "$e\\n";
    }

    Parameter description

    Parameter
    Description
    Type
    Bucket
    Bucket for tag setting, in the format of BucketName-APPID. For more information, please see Bucket Naming Conventions.
    String
    Key
    Key of the tag
    String
    Value
    Value of the tag
    String

    Querying Bucket Tags

    Description

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

    Method prototype

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

    Sample request

    <?php
    
    require dirname(__FILE__) . '/../vendor/autoload.php';
    
    $secretId = "SECRETID"; //Replace it with the actual SecretId, which can be viewed and managed at https://console.tencentcloud.com/cam/capi
    $secretKey = "SECRETKEY"; //Replace it with the actual SecretKey, which can be viewed and managed at https://console.tencentcloud.com/cam/capi
    $region = "ap-beijing"; //Replace it with the actual region, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket
    $cosClient = new Qcloud\\Cos\\Client(
    array(
    'region' => $region,
    'schema' => 'https', // Protocol header, which is http by default
    'credentials'=> array(
    'secretId' => $secretId ,
    'secretKey' => $secretKey)));
    
    try {
    $result = $cosClient->getBucketTagging(array(
    'Bucket' => 'examplebucket-1250000000', // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket
    ));
    // Request succeeded
    print_r($result);
    } catch (\\Exception $e) {
    // Request failed
    echo($e);
    }

    Parameter description

    Parameter
    Description
    Type
    Bucket
    Bucket for tag query, in the format of BucketName-APPID. For more information, please see Bucket Naming Conventions.
    String

    Sample response

    GuzzleHttp\\Command\\Result Object
    (
    [TagSet] => Array
    (
    [0] => Array
    (
    [Key] => key1
    [Value] => value1
    )
    
    [1] => Array
    (
    [Key] => key2
    [Value] => value2
    )
    
    )
    [RequestId] => NWRmMWVkMjFfMjJiMjU4NjRfNWQ3X2EwMWVj****
    )

    Response description

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

    Deleting Bucket Tags

    Description

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

    Method prototype

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

    Sample request

    <?php
    
    require dirname(__FILE__) . '/../vendor/autoload.php';
    
    $secretId = "SECRETID"; //Replace it with the actual SecretId, which can be viewed and managed at https://console.tencentcloud.com/cam/capi
    $secretKey = "SECRETKEY"; //Replace it with the actual SecretKey, which can be viewed and managed at https://console.tencentcloud.com/cam/capi
    $region = "ap-beijing"; //Replace it with the actual region, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket
    $cosClient = new Qcloud\\Cos\\Client(
    array(
    'region' => $region,
    'schema' => 'https', // Protocol header, which is http by default
    'credentials'=> array(
    'secretId' => $secretId ,
    'secretKey' => $secretKey)));
    
    try {
    $result = $cosClient->deleteBucketTagging(array(
    'Bucket' => 'examplebucket-1250000000', // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket
    );
    // Request succeeded
    print_r($result);
    } catch (\\Exception $e) {
    // Request failed
    echo($e);
    }

    Parameter description

    Parameter
    Description
    Type
    Bucket
    Bucket for tag deletion, in the format of BucketName-APPID. For more information, please see Bucket Naming Conventions.
    String
    
    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