Added accountInfo method to ObjectStorage.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user