Deleting a container
You use the HTTP DELETE method to delete a container. To delete a container, you need to have a Keystone or local authentication token for the HSwift account in which the container exists.
You can delete a container only while it's empty. If you try to delete a container that contains any objects, HCP returns a 409 (Conflict) status code and does not delete the container.
Request line
Depending on whether the HSwift request uses a Keystone tenant ID or the account name, the request line for a request to delete a container has either of these formats:
- With the Keystone tenant ID:
DELETE /swift/v1/tenant-ID/container-name HTTP/1.1
- With the account name:
DELETE /swift/v1/account-name/container-name HTTP/1.1
Request headers
The table below describes the headers you can use in a request to delete a container.
Name | Type | Description |
X-Auth-Token | String |
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 a response to a successful request to a delete a container.
Name | Type | Description |
Content-length | String (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-Type | String (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 Because HCP returns error information in a response body, the response to any request can include a |
Date | Datetime (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-Trans-Id | Uuid (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 tat can be returned in response to a request to delete a container.
Code | Meaning | Description |
204 | No Content | The container was deleted. |
404 | Not Found | The container you are trying to delete does not exist in this account. |
409 | Conflict | The container you are trying to delete is not empty. |
500 | Internal Server Error |
An internal error occurred. If this error persists, contact your tenant administrator. |
503 | Service 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: Deleting a container
Here's a sample DELETE request that deletes the container named sales-mktg
.
Request with curl command line
curl -i -X DELETE http://api.hcp.example.com/swift/v1/AUTH_6b6884ebb6f441cfbb7e740f6a927c9e/sales-mkgt -H "X-Auth-Token: dc5efec8f546455eac974e7bbfd0dd87"
Request headers
DELETE /swift/v1/AUTH_6b6884ebb6f441cfbb7e740f6a927c9e/sales-mkgt HTTP/1.1 X-Auth-Token: dc5efec8f546455eac974e7bbfd0dd87
Response headers
HTTP/1.1 204 No Content Date: Fri, 31 Oct 2014 14:06:11 GMT Content-Length: 0 X-Trans-Id: tx66248155dbb74b6a85f6d-0053fccdcd Content-Type: application/octet-stream