Get Bucket Labels

To return a bucket's labels you make a GET request that is scoped to the desired bucket, and you use the tagging query string parameter. The bucket's labels are returned in an XML document in the response body.

Query string parameters

Parameter Description Required
tagging You can use this to return the labels associated with a bucket, each of which is given as a key:value pair. No

Request headers

See common request headers.

Request body elements

This request does not include an XML document in the request body.

Request syntax

The following syntax applies to GET Bucket requests that use the tagging query string parameter.

GET /?tagging HTTP/1.1
Host: <bucket>.storage.googleapis.com
Date: <date>
Content-Length: <request body length>
Authorization: <authentication string>

Response headers

The request can return a variety of response headers depending on the request headers you use.

Response body elements

The following response body elements are applicable only if you use the tagging query string parameter to get 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.

Example

The following example retrieves the labels for a bucket named my-bucket. In this example, the bucket has two labels applied to it.

Request

GET /?tagging HTTP/1.1
Host: my-bucket.storage.googleapis.com
Date: Thu, 24 Jan 2016 02:34:56 GMT
Content-Length: 0
Authorization: Bearer ya29.AHES6ZRVmB7fkLtd1XTmq6mo0S1wqZZi3-Lh_s-6Uw7p8vtgSwg

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: 196
Content-Type: text/html

<?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>

Send feedback about...

Cloud Storage Documentation