Help Center> Object Storage Service> SDK Reference> Python> Bucket-Related APIs> Obtaining the Versioning Status of a Bucket

Obtaining the Versioning Status of a Bucket

API Description

You can use this API to obtain the versioning status of a bucket.

Method Definition

ObsClient.getBucketVersioning(bucketName)

Request Parameters

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

Returned Results

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

str

Versioning status of the bucket

Sample Code

try:
    resp = obsClient.getBucketVersioning('bucketname') 
      
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('status:', resp.body) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())