This operation adds tags to a bucket.
After tags are added to a bucket, all charging data records (CDRs) generated by the requests for this bucket will take the same tags. Thus, CDR reports can be categorized for detailed cost analysis. For example, if a running application uploads data to a bucket, you can tag the bucket with the application name. In this manner, the costs on the application can be analyzed using tags on CDRs.
To perform this operation, you must have the PutBucketTagging permission. By default, only the bucket owner can delete the tags of a bucket. The bucket owner can allow other users to perform this operation by setting a bucket policy or granting them the permission.
1 2 3 4 5 6 7 8 9 10 11 12 13 | PUT /?tagging HTTP/1.1
Host: bucketname.obs.region.example.com
Date: date
Authorization: authorization string
Content-MD5: md5
<Tagging>
<TagSet>
<Tag>
<Key>Tag Name</Key>
<Value>Tag Value</Value>
</Tag>
</TagSet>
</Tagging>
|
This request contains no parameter.
Table 1 lists the request header.
In this request, you must configure bucket tags in the request body. The tag configuration is uploaded in XML format. Table 2 describes the configuration elements.
Header |
Description |
Mandatory |
---|---|---|
Tagging |
Element of the tag set and tag Type: element Ancestor: none |
Yes |
TagSet |
Element of the tag set Type: element Ancestor: Tagging |
Yes |
Tag |
Element of the tag information Type: element Ancestor: TagSet |
Yes |
Key |
Tag name Type: string Ancestor: Tag |
Yes |
Value |
Tag value Type: string Ancestor: Tag |
Yes |
1 2 3 4 5 | HTTP/1.1 status_code
x-obs-request-id: request id
x-obs-id-2: id
Content-Length: length
Date: date
|
The response to the request uses common headers. For details, see Table 1.
This response involves no elements.
In addition common error codes, this API also returns other error codes. The following table lists common errors and possible causes. For details, see Table 3.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | PUT /?tagging HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.example.com
Accept: */*
Date: Wed, 27 Jun 2018 13:22:50 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:Pf1ZyGvVYg2BzOjokZ/BAeR1mEQ=
Content-MD5: MnAEvkfQIGnBpchOE2U6Og==
Content-Length: 182
<Tagging xmlns="http://obs.example.com/doc/2015-06-30/">
<TagSet>
<Tag>
<Key>TagName1</Key>
<Value>TageSetVaule1</Value>
</Tag>
</TagSet>
</Tagging>
|
1 2 3 4 5 | HTTP/1.1 204 No Content
Server: OBS
x-obs-request-id: BF26000001643FEBA09B1ED46932CD07
x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCSEZp87iEirC6DggPB5cN49pSvHBWClg
Date: Wed, 27 Jun 2018 13:22:50 GMT
|