From 36c63608f3bf789253ed0d124f332375c6fa5fc2 Mon Sep 17 00:00:00 2001 From: Fred Date: Mon, 4 Mar 2019 06:48:53 +0100 Subject: [PATCH] Getting disk usage details (#54) Getting disk usage details functionality added --- src/Api/Operator/Webspace.php | 11 +++++ src/Api/Struct/Site/GeneralInfo.php | 4 ++ src/Api/Struct/Webspace/DiskUsage.php | 58 +++++++++++++++++++++++++++ tests/WebspaceTest.php | 8 ++++ 4 files changed, 81 insertions(+) create mode 100644 src/Api/Struct/Webspace/DiskUsage.php diff --git a/src/Api/Operator/Webspace.php b/src/Api/Operator/Webspace.php index f8ef7850..3c7909d2 100644 --- a/src/Api/Operator/Webspace.php +++ b/src/Api/Operator/Webspace.php @@ -91,4 +91,15 @@ public function getAll() return $this->_getItems(Struct\GeneralInfo::class, 'gen_info'); } + /** + * @param string $field + * @param integer|string $value + * @return Struct\DiskUsage + */ + public function getDiskUsage($field, $value) + { + $items = $this->_getItems(Struct\DiskUsage::class, 'disk_usage', $field, $value); + return reset($items); + } + } diff --git a/src/Api/Struct/Site/GeneralInfo.php b/src/Api/Struct/Site/GeneralInfo.php index 4da96d0e..11e22aba 100644 --- a/src/Api/Struct/Site/GeneralInfo.php +++ b/src/Api/Struct/Site/GeneralInfo.php @@ -14,6 +14,9 @@ class GeneralInfo extends \PleskX\Api\Struct /** @var string */ public $guid; + /** @var string */ + public $status; + /** @var string */ public $description; @@ -22,6 +25,7 @@ public function __construct($apiResponse) $this->_initScalarProperties($apiResponse, [ 'name', 'ascii-name', + 'status', 'guid', 'description', ]); diff --git a/src/Api/Struct/Webspace/DiskUsage.php b/src/Api/Struct/Webspace/DiskUsage.php new file mode 100644 index 00000000..bf43db21 --- /dev/null +++ b/src/Api/Struct/Webspace/DiskUsage.php @@ -0,0 +1,58 @@ +_initScalarProperties($apiResponse, [ + 'httpdocs', + 'httpsdocs', + 'subdomains', + 'anonftp', + 'logs', + 'dbases', + 'mailboxes', + 'maillists', + 'domaindumps', + 'configs', + 'chroot', + ]); + } +} diff --git a/tests/WebspaceTest.php b/tests/WebspaceTest.php index 3546c804..3cdc9e72 100644 --- a/tests/WebspaceTest.php +++ b/tests/WebspaceTest.php @@ -18,6 +18,14 @@ public function testGetLimitDescriptor() $this->assertNotEmpty($descriptor->limits); } + public function testGetDiskUsage() + { + $webspace = static::_createWebspace(); + $diskusage = static::$_client->webspace()->getDiskUsage('id', $webspace->id); + + $this->assertObjectHasAttribute('httpdocs', $diskusage); + } + public function testGetPhysicalHostingDescriptor() { $descriptor = static::$_client->webspace()->getPhysicalHostingDescriptor();