Checking a container's metadata

You use the HTTP HEAD method to check a container's metadata. To successfully check a container's metadata, you need read permission for the container.

If the container you specify in the HEAD request does not exist, HCP returns a 404 (Not Found) status code. If you do not have read permission for the container, HCP returns a 403 (Forbidden) status code.

Request line

Depending on whether the HSwift request uses a Keystone tenant ID or the account name, the request line for a request to check a container's metadata has either of these formats:

  • With the Keystone tenant ID:
    HEAD /swift/v1/tenant-ID/container-name HTTP/1.1
  • With the account name:
    HEAD /swift/v1/account-name/container-name HTTP/1.1

Request headers

The table below describes the headers you can use in a request to check a container's metadata.

NameTypeDescription
X-Auth-TokenString

Used to supply the Keystone authentication token or local authentication token.

Replace the Keystone authentication token with the prefix HCP, followed by your Local Authentication token, in the format:

"X-Auth-Token: HCP base64-encoded-username:md5-encoded-password"

For example:

"X-Auth-Token: HCP bGdyZWVu:a3b9c163f6c520407ff34cfdb83ca5c6"

Response headers

The table below describes the response headers returned in response to a successful request to check a container's metadata.

NameTypeDescription
Accept-RangesString (Required)Always bytes. This header shows the type of ranges that an object accepts from a Range request header.
Content-lengthString (Required)

The size, in bytes, of the response body if HCP can determine the size before formulating the response.

If the response does not include a response body, the value of the Content-Length is 0 (zero).

Content-TypeString (Required if the Content-Length is greater than 0)

The Internet media type of the response body if HCP can determine the Internet media type. If HCP cannot determine the Internet media type, the value of this header is application/octet-stream.

Because HCP returns error information in a response body, the response to any request can include a Content-Type header.

DateDatetime (Required)

The date and time at which HCP responded to the request in Greenwich Mean Time (GMT). The date and time are returned in this format:

DDD dd MMM yyyy HH:mm:ss GMT

For example:

Thu, 14 Mat 2013 14:27:05 GMT
X-Container-Bytes-UsedInt (Required)The total amount of bytes of data stored in the container. This number is capped by the X-Container-Meta-Quota-Bytes header.
X-Container-Meta-Quota-BytesStringIf a quota has been set on the amount of bytes that can be stored by this container, this header returns the size, in bytes, of objects that can be stored in the container.
X-Container-Object-CountInt (Required)The total number of objects stored in the container. This number includes all objects in all directories that are in the container. Directories are not included in this number.
X-Container-ReadString

Lists the Read and Browse permissions existing on the container.

This header can either list individual Keystone users with the Read permissions or mark the container as public.

X-Container-WriteString

Lists the Write ACL permissions existing on the container.

This header can either list individual Keystone users with Write permissions or mark the container as public.

X-Trans-IdUuid (Required)HCP returns a universally unique identifier (UUID). This UUID does not map to any entries in the HCP database.

HTTP status codes

The table below describes HTTP status codes that can be returned in response to a request to check a container's metadata.

CodeMeaningDescription
204No ContentNo Response Body.
500Internal Server Error

An internal error occurred.

If this error persists, contact your tenant administrator.

503Service Unavailable

HCP is temporarily unable to handle the request, probably due to system overload, maintenance, or upgrade. Try the request again, gradually increasing the delay between each successive attempt.

If this error persists, contact your tenant administrator.

Example: Checking a container's metadata

Here's a sample HEAD request that checks the metadata of a container named finance.

Request with curl command line

curl -i -X HEAD http://api.hcp.example.com/swift/v1/AUTH_6b6884ebb6f441cfbb7e740f6a927c9e/finance -H "X-Auth-Token: dc5efec8f546455eac974e7bbfd0dd87"

Request headers

HEAD /swift/v1/AUTH_6b6884ebb6f441cfbb7e740f6a927c9e/finance HTTP/1.1
X-Auth-Token: dc5efec8f546455eac974e7bbfd0dd87

Response headers

HTTP/1.1 204 No Content
Date: Fri, 31 Oct 2014 13:07:45 GMT
X-Trans-Id: 3c74e66d-9fb7-407d-9762-391d3e77014f
X-Container-Object-Count: 1
X-Container-Bytes-Used: 0
X-Container-Meta-Quota-Bytes: 10737418240
X-Container-Read:
X-Container-Write: *
Accept-Ranges: bytes
Content-Length: 0