Adding Tags to a Bucket
API Description
You can use this API to add tags to a bucket. Tags are used to identify and classify OBS buckets. Each bucket can have up to 10 tags. The key and value of a tag can be in Unicode.
For more information, see Tags.
Method Definition
ObsClient.setBucketTagging(bucketName, tagInfo)
Request Parameters
| Field | Type | Optional or Mandatory | Description |
|---|---|---|---|
| bucketName | str | Mandatory | Bucket name |
| tagInfo | Mandatory | Bucket tag settings |
Returned Results
| Type | Description |
|---|---|
| SDK common result object |
Sample Code
try:
from obs 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()) Last Article: Obtaining the Event Notification Settings of a Bucket
Next Article: Obtaining the Tag Settings of a Bucket
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.