tencent cloud

Feedback

Versioning

Last updated: 2022-05-19 14:40:49

    Overview

    This document provides an overview of APIs and SDK code samples for versioning.

    API Operation Description
    PUT Bucket versioning Setting versioning Sets versioning for a bucket
    GET Bucket versioning Querying versioning Queries the versioning information of a bucket

    Setting versioning

    Feature description

    This API (PUT Bucket versioning) is used to set the versioning configuration for a bucket.

    Method prototype

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

    Sample request

    Enabling versioning

    <?php
    require dirname(__FILE__) . '/../vendor/autoload.php';
    $secretId = "SECRETID"; //Replace it with the actual `SecretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi
    $secretKey = "SECRETKEY"; //Replace it with the actual `SecretKey`, which can be viewed and managed in the CAM console 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->putBucketVersioning(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
          'Status' => 'Enabled'
      )); 
      // Request succeeded
      print_r($result);
    } catch (\Exception $e) {
      // Request failed
      echo "$e\n";
    }
    

    Suspending Versioning

    <?php
    require dirname(__FILE__) . '/../vendor/autoload.php';
    $secretId = "SECRETID"; //Replace it with the actual `SecretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi
    $secretKey = "SECRETKEY"; //Replace it with the actual `SecretKey`, which can be viewed and managed in the CAM console 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->putBucketVersioning(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
          'Status' => 'Suspended'
      )); 
      // Request succeeded
      print_r($result);
    } catch (\Exception $e) {
      // Request failed
      echo "$e\n";
    }
    

    Parameter description

    Parameter Type Description Required
    Bucket String Bucket for which versioning is enabled or suspended in the format of BucketName-APPID Yes
    Status String Versioning status. Valid values: Suspended; Enabled Yes

    Querying versioning

    Feature description

    This API (GET Bucket versioning) is used to query the versioning configuration of a bucket.

    Method prototype

    public Guzzle\Service\Resource\Model getBucketVersioning(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 in the CAM console at https://console.tencentcloud.com/cam/capi
    $secretKey = "SECRETKEY"; //Replace it with the actual `SecretKey`, which can be viewed and managed in the CAM console 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->getBucketVersioning(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\n";
    }
    

    Parameter description

    Parameter Type Description Required
    Bucket String Bucket for which versioning is queried in the format of BucketName-APPID Yes

    Response description

    Parameter Type Description Parent Node
    Status String Versioning status. Valid values: Suspended, Enabled or null None
    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