diff --git a/src/HPCloud/Storage/ObjectStorage.php b/src/HPCloud/Storage/ObjectStorage.php index 7b0550e..ef0291c 100644 --- a/src/HPCloud/Storage/ObjectStorage.php +++ b/src/HPCloud/Storage/ObjectStorage.php @@ -338,6 +338,33 @@ class ObjectStorage { } } + /** + * Retrieve account info. + * + * This returns information about: + * + * - The total bytes used by this Object Storage instance (`bytes`). + * - The number of containers (`count`). + * + * @return array + * An associative array of account info. Typical keys are: + * - bytes + * - count + * @throws \HPCloud\Transport\AuthorizationException + * if the user credentials are invalid or have expired. + */ + public function accountInfo() { + $url = $this->url(); + $data = $this->req($url, 'HEAD', FALSE); + + $results = array( + 'bytes' => $data->header('X-Account-Bytes-Used', 0), + 'count' => $data->header('X-Account-Container-Count', 0), + ); + + return $results; + } + /** * Do a GET on Swift. * diff --git a/test/Tests/ObjectStorageTest.php b/test/Tests/ObjectStorageTest.php index c70ad7a..b0babf8 100644 --- a/test/Tests/ObjectStorageTest.php +++ b/test/Tests/ObjectStorageTest.php @@ -61,7 +61,18 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase { } /** - * Test the process of fetching a list of containers. + * @depends testCreateContainer + */ + public function testAccountInfo () { + $store = $this->auth(); + + $info = $store->accountInfo(); + + $this->assertTrue($info['count'] > 0); + $this->assertTrue($info['bytes'] > 0); + } + + /** * @depends testCreateContainer */ public function testContainers() {