标签管理
更新时间:2026-09-23
应用场景
支持对 Bucket 绑定标签信息,方便根据标签做 Bucket 的资源管理。
运行以下示例前,请先参考初始化完成 BOS Client 初始化,并将示例中的 bucket_name(及其它占位符)替换为实际值。
设置标签
Python
1bucket_name = 'example-bucket-name'
2tag_conf = {
3 "tags": [
4 {
5 "tagKey": "key1",
6 "tagValue": "value123"
7 },
8 {
9 "tagKey": "ttt2",
10 "tagValue": "6863gerg"
11 }
12 ],
13}
14bos_client.put_bucket_tagging(bucket_name, tag_conf=tag_conf)
参数说明
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket_name |
string | 是 | Bucket 名称。 |
tag_conf |
dict | 是 | 标签配置,包含 tags 列表,每个元素含 tagKey、tagValue。 |
说明: 单个 Bucket 的标签数量为 1-200 个,超出或为空会返回错误。
获取标签
Python
1bucket_name = 'example-bucket-name'
2response = bos_client.get_bucket_tagging(bucket_name)
3print(response.tag)
删除标签
Python
1bucket_name = 'example-bucket-name'
2response = bos_client.delete_bucket_tagging(bucket_name)
评价此篇文章
