• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Python SDK)
  4. Bucket-Related APIs
  5. PUT Bucket tagging

PUT Bucket tagging

API Description

You can use this API to set bucket tags.

Method Definition

ObsClient.setBucketTagging(bucketName, tagInfo)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

tagInfo

TagInfo

Mandatory

Bucket tag set

Returned Result

Type

Description

GetResult

SDK common result object

Sample Code

try:
    from com.obs.models.tag import TagInfo 
     
    tagInfo = TagInfo() 
    tagInfo.addTag('tag1', 'value1').addTag('tag2', 'value2') 
     
    resp = obsClient.setBucketTagging('bucketname', tagInfo) 
      
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())