To add or modify labels applied to a bucket, you make a PUT
request
that is scoped to the desired bucket, and you use the tagging
query string parameter along with a <Tagging>
element in the request body.
Query string parameters
Parameter | Description | Required |
---|---|---|
tagging |
Used when adding or modifying labels applied to a bucket. If used, include the labels in the body of the request. | No |
See signed URL query string parameters for information on the parameters you include when creating and using signed URLs.
Request headers
Request body elements
The following request body elements are applicable only if you use the tagging
query string parameter to set the labels that are applied to the bucket.
Element | Description |
---|---|
Tagging |
The container for TagSet. |
TagSet |
The container for all labels that are applied to the bucket. |
Tag |
A container for an individual label. A label is composed of a
key:value pair. |
Key |
The key for a label. |
Value |
The value for a label. |
Request syntax
The following syntax applies to PUT Bucket requests that use the
tagging
query string parameter.
PUT /?tagging HTTP/1.1 Host: BUCKET_NAME.storage.googleapis.com Date: DATE Content-Length: REQUEST_BODY_LENGTH Authorization: AUTHENTICATION_STRING <?xml version="1.0" encoding="UTF-8"?> <Tagging> <TagSet> <Tag> <Key>LABEL_KEY</Key> <Value>LABEL_VALUE</Value> </Tag> </TagSet> </Tagging>
Response headers
The request can return a variety of response headers depending on the request headers you use.
Response body elements
The response does not include an XML document in the response body.
Example
The following example sets a label configuration that consists of two labels to
a bucket named my-bucket
.
Request
PUT /?tagging HTTP/1.1 Host: my-bucket.storage.googleapis.com Date: Thu, 24 Jan 2016 02:34:56 GMT Content-Length: 196 Authorization: Bearer ya29.AHES6ZRVmB7fkLtd1XTmq6mo0S1wqZZi3-Lh_s-6Uw7p8vtgSwg <?xml version="1.0" encoding="UTF-8"?> <Tagging> <TagSet> <Tag> <Key>environment</Key> <Value>production</Value> </Tag> <Tag> <Key>billing</Key> <Value>marketing-department</Value> </Tag> </TagSet> </Tagging>
Response
HTTP/1.1 200 OK Date: Thu, 24 Jan 2016 02:34:56 GMT Expires: Mon, 01 Jan 1990 00:00:00 GMT Cache-Control: no-cache, no-store, must-revalidate Content-Length: 0 Content-Type: text/html