doc-exports/docs/obs/s3api/en-us_topic_0125560290.html
Jawei, Li 1a4c1a720a OBS s3api 2.0.38.SP5
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Jawei, Li <lijiawei5@huawei.com>
Co-committed-by: Jawei, Li <lijiawei5@huawei.com>
2022-11-16 14:51:13 +00:00

159 lines
12 KiB
HTML

<a name="EN-US_TOPIC_0125560290"></a><a name="EN-US_TOPIC_0125560290"></a>
<h1 class="topictitle1">PUT Bucket tagging</h1>
<div id="body1494815431748"><p id="EN-US_TOPIC_0125560290__p35542935152635">This implementation of the <strong id="EN-US_TOPIC_0125560290__b16559191920714">PUT</strong> operation uses the <strong id="EN-US_TOPIC_0125560290__b19510256713">tagging</strong> subresource to add a set of tags to an existing bucket.</p>
<p id="EN-US_TOPIC_0125560290__p4503762510355">This operation is used to add tags to a bucket. Then, all 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, data is being uploaded to a bucket when an application is running. The application name can be tagged for this bucket. Use this tag to filter the CDRs generated by this application for analyzing its costs. However, searching for buckets by tag is not supported.</p>
<p id="EN-US_TOPIC_0125560290__p21509766203212">Only users granted the <strong id="EN-US_TOPIC_0125560290__b59370169203212">s3:PutBucketTagging</strong> permission can perform this operation. By default, the permission is granted to the bucket owner only. However, it can be granted to other users by configuring the bucket policy.</p>
<div class="section" id="EN-US_TOPIC_0125560290__section35786508144743"><h4 class="sectiontitle">Request Syntax</h4><pre class="screen" id="EN-US_TOPIC_0125560290__screen13025998144743">PUT /?tagging HTTP/1.1
User-Agent: agent
Host: bucketname.obs.example.com
Accept: */*
Date: date
Authorization: authorization string
Content-MD5:&lt;md5&gt;
Content-Length: length
Expect: expect
&lt;Tagging&gt;
&lt;TagSet&gt;
&lt;Tag&gt;
&lt;Key&gt;Tag Name&lt;/Key&gt;
&lt;Value&gt;Tag Value&lt;/Value&gt;
&lt;/Tag&gt;
&lt;/TagSet&gt;
&lt;/Tagging&gt;</pre>
</div>
<div class="section" id="EN-US_TOPIC_0125560290__section27343126145027"><h4 class="sectiontitle">Request Parameters</h4><p id="EN-US_TOPIC_0125560290__p200694145027">This request contains no parameter.</p>
</div>
<div class="section" id="EN-US_TOPIC_0125560290__section62377043103446"><h4 class="sectiontitle">Request Headers</h4><p id="EN-US_TOPIC_0125560290__p47492047103633">Content-MD5 will be a required header for this operation. This request uses common headers. For details about common request headers, see section <a href="en-us_topic_0125560462.html">Common Request Headers</a>.</p>
</div>
<div class="section" id="EN-US_TOPIC_0125560290__section41685955145027"><h4 class="sectiontitle">Request Elements</h4><p id="EN-US_TOPIC_0125560290__p4388859110387">In this request, you must configure the tags of buckets in the request body. The configurations of tags are uploaded in the XML format. The following table describes the elements to be configured.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0125560290__table55855374145027" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Elements to be configured for bucket tags</caption><thead align="left"><tr id="EN-US_TOPIC_0125560290__row43394869145027"><th align="left" class="cellrowborder" valign="top" width="20.200000000000003%" id="mcps1.3.7.3.2.4.1.1"><p id="EN-US_TOPIC_0125560290__p25323481145027">Element</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="60.61%" id="mcps1.3.7.3.2.4.1.2"><p id="EN-US_TOPIC_0125560290__p37936074145027">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="19.189999999999998%" id="mcps1.3.7.3.2.4.1.3"><p id="EN-US_TOPIC_0125560290__p52923119145027">Mandatory or Not</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0125560290__row58914224145027"><td class="cellrowborder" valign="top" width="20.200000000000003%" headers="mcps1.3.7.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560290__p46789943103837">Tagging</p>
</td>
<td class="cellrowborder" valign="top" width="60.61%" headers="mcps1.3.7.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560290__p31889035103837">Container for the <strong id="EN-US_TOPIC_0125560290__b18565866103837">TagSet</strong> and <strong id="EN-US_TOPIC_0125560290__b32875072103837">Tag</strong> elements</p>
<p id="EN-US_TOPIC_0125560290__p27440198103837">Type: Container</p>
<p id="EN-US_TOPIC_0125560290__p45635198103837">Ancestor: None</p>
</td>
<td class="cellrowborder" valign="top" width="19.189999999999998%" headers="mcps1.3.7.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560290__p5463532103837">Yes</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560290__row30825325103856"><td class="cellrowborder" valign="top" width="20.200000000000003%" headers="mcps1.3.7.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560290__p63172917103947">TagSet</p>
</td>
<td class="cellrowborder" valign="top" width="60.61%" headers="mcps1.3.7.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560290__p16732614103947">Container for a set of tags</p>
<p id="EN-US_TOPIC_0125560290__p16375801103947">Type: Container</p>
<p id="EN-US_TOPIC_0125560290__p13164488103947">Ancestor: Tagging</p>
</td>
<td class="cellrowborder" valign="top" width="19.189999999999998%" headers="mcps1.3.7.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560290__p59690594103947">Yes</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560290__row31612336415"><td class="cellrowborder" valign="top" width="20.200000000000003%" headers="mcps1.3.7.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560290__p1222411393419">Tag</p>
</td>
<td class="cellrowborder" valign="top" width="60.61%" headers="mcps1.3.7.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560290__p162241539134113">Container for tag information</p>
<p id="EN-US_TOPIC_0125560290__p4224103954116">Type: Container. Each bucket supports a maximum of 20 tags.</p>
<p id="EN-US_TOPIC_0125560290__p11224203911415">Ancestor: TagSet</p>
</td>
<td class="cellrowborder" valign="top" width="19.189999999999998%" headers="mcps1.3.7.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560290__p152246392412">Yes</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560290__row14152335144117"><td class="cellrowborder" valign="top" width="20.200000000000003%" headers="mcps1.3.7.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560290__p722417392414">Key</p>
</td>
<td class="cellrowborder" valign="top" width="60.61%" headers="mcps1.3.7.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560290__p13224113914410">Name of the tag</p>
<p id="EN-US_TOPIC_0125560290__p222433944115">Type: String. It can contain a maximum of 36 characters, including A to Z, a to z, 0 to 9, hyphens (-), underscores (_), and Unicode(\u4E00-\u9FFF). In the same bucket, the key of a tag must be unique.</p>
<p id="EN-US_TOPIC_0125560290__p16224153920415">Ancestor: Tag</p>
</td>
<td class="cellrowborder" valign="top" width="19.189999999999998%" headers="mcps1.3.7.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560290__p172244391412">Yes</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560290__row161844376411"><td class="cellrowborder" valign="top" width="20.200000000000003%" headers="mcps1.3.7.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560290__p2022417399410">Value</p>
</td>
<td class="cellrowborder" valign="top" width="60.61%" headers="mcps1.3.7.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560290__p8224123974116">Value of the tag</p>
<p id="EN-US_TOPIC_0125560290__p522412394416">Type: String. It can contain a maximum of 43 characters, including A to Z, a to z, 0 to 9, hyphens (-), underscores (_), periods (.), and Unicode(\u4E00-\u9FFF). Note that periods (.) can be used for this parameter.</p>
<p id="EN-US_TOPIC_0125560290__p622412391419">Ancestor: Tag</p>
</td>
<td class="cellrowborder" valign="top" width="19.189999999999998%" headers="mcps1.3.7.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560290__p0224143920415">Yes</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0125560290__section5866353914519"><h4 class="sectiontitle">Response Syntax</h4><pre class="screen" id="EN-US_TOPIC_0125560290__screen5412621714519">HTTP/1.1 204 No Content
Server: Server Name
x-amz-request-id: request id
x-amz-id-2: id
x-reserved: amazon, aws and amazon web services are trademarks or registered trademarks of Amazon Technologies, Inc
Date: date</pre>
</div>
<div class="section" id="EN-US_TOPIC_0125560290__section1737390614519"><h4 class="sectiontitle">Response Headers</h4><p id="EN-US_TOPIC_0125560290__p3148273104058">This response uses common headers. For details about common response headers, see section <a href="en-us_topic_0125560484.html">Common Response Headers</a>.</p>
</div>
<div class="section" id="EN-US_TOPIC_0125560290__section4911114514519"><h4 class="sectiontitle">Response Elements</h4><p id="EN-US_TOPIC_0125560290__p1857984514519">This response involves no elements.</p>
</div>
<div class="section" id="EN-US_TOPIC_0125560290__section3300087714519"><h4 class="sectiontitle">Error Responses</h4><p id="EN-US_TOPIC_0125560290__p22074950104125">Except for common error responses, special error responses are also returned. The following table lists error responses and possible causes.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0125560290__table3266664814519" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Error responses and possible causes</caption><thead align="left"><tr id="EN-US_TOPIC_0125560290__row4080837914519"><th align="left" class="cellrowborder" valign="top" width="22.45%" id="mcps1.3.11.3.2.4.1.1"><p id="EN-US_TOPIC_0125560290__p1714439414519">Error Code</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="59.18%" id="mcps1.3.11.3.2.4.1.2"><p id="EN-US_TOPIC_0125560290__p4651869814519">Possible Cause</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="18.37%" id="mcps1.3.11.3.2.4.1.3"><p id="EN-US_TOPIC_0125560290__p991821114519">HTTP Status Code</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0125560290__row6517759614519"><td class="cellrowborder" valign="top" width="22.45%" headers="mcps1.3.11.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560290__p24011918104225">InvalidTag</p>
</td>
<td class="cellrowborder" valign="top" width="59.18%" headers="mcps1.3.11.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560290__p65917245104225">An invalid tag is provided when configuring a tag for a bucket.</p>
</td>
<td class="cellrowborder" valign="top" width="18.37%" headers="mcps1.3.11.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560290__p37696661104225">400 Bad Request</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560290__row6582834414519"><td class="cellrowborder" valign="top" width="22.45%" headers="mcps1.3.11.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560290__p33340710104225">MalformedXML</p>
</td>
<td class="cellrowborder" valign="top" width="59.18%" headers="mcps1.3.11.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560290__p16243018104225">The provided XML format is incorrect when configuring a bucket tag.</p>
</td>
<td class="cellrowborder" valign="top" width="18.37%" headers="mcps1.3.11.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560290__p40616082104225">400 Bad Request</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0125560290__section21401127145254"><h4 class="sectiontitle">Sample Request</h4><pre class="screen" id="EN-US_TOPIC_0125560290__screen55769758145254">PUT /?tagging HTTP/1.1
User-Agent: curl/7.19.7 (x86_64-suse-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8j zlib/1.2.7 libidn/1.10
Host: bucketname.obs.example.com
Accept: */*
Date: Tue, 09 May 2017 02:41:20 +0000
Authorization: authorization string
Content-MD5: 5yPl6Bu6q5Z6vBItpJAqAQ==
Content-Length: 544
Expect: 100-continue
&lt;Tagging&gt;
&lt;TagSet&gt;
&lt;Tag&gt;
&lt;Key&gt;TagNameJJ1&lt;/Key&gt;
&lt;Value&gt;tytttasceettt&lt;/Value&gt;
&lt;/Tag&gt;
&lt;/TagSet&gt;
&lt;/Tagging&gt;</pre>
</div>
<div class="section" id="EN-US_TOPIC_0125560290__section32165774145254"><h4 class="sectiontitle">Sample Response</h4><pre class="screen" id="EN-US_TOPIC_0125560290__screen55290886145254">HTTP/1.1 204 No Content
Server: OBS
x-amz-request-id: 0002B7532E0000015BEB146F2846E8E5
x-amz-id-2: a68r9ufCPuQCBUcwv1clom3zy/LsP+Bp+JJccmsmy2ptuwV3g0YMu3FIoTaEWA02
x-reserved: amazon, aws and amazon web services are trademarks or registered trademarks of Amazon Technologies, Inc
Date: Tue, 09 May 2017 02:40:37 GMT</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0125560493.html">Operations on Buckets</a></div>
</div>
</div>