Skip to content

Commit

Permalink
Getting disk usage details (#54)
Browse files Browse the repository at this point in the history
Getting disk usage details functionality added
  • Loading branch information
baldhead authored and mrsombre committed Mar 4, 2019
1 parent 0e2fff7 commit 36c6360
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Api/Operator/Webspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
4 changes: 4 additions & 0 deletions src/Api/Struct/Site/GeneralInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class GeneralInfo extends \PleskX\Api\Struct
/** @var string */
public $guid;

/** @var string */
public $status;

/** @var string */
public $description;

Expand All @@ -22,6 +25,7 @@ public function __construct($apiResponse)
$this->_initScalarProperties($apiResponse, [
'name',
'ascii-name',
'status',
'guid',
'description',
]);
Expand Down
58 changes: 58 additions & 0 deletions src/Api/Struct/Webspace/DiskUsage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
// Copyright 1999-2019. Plesk International GmbH.
// Author: Frederic Leclercq

namespace PleskX\Api\Struct\Webspace;

class DiskUsage extends \PleskX\Api\Struct
{
/** @var integer */
public $httpdocs;

/** @var integer */
public $httpsdocs;

/** @var integer */
public $subdomains;

/** @var integer */
public $anonftp;

/** @var integer */
public $logs;

/** @var integer */
public $dbases;

/** @var integer */
public $mailboxes;

/** @var integer */
public $maillists;

/** @var integer */
public $domaindumps;

/** @var integer */
public $configs;

/** @var integer */
public $chroot;

public function __construct($apiResponse)
{
$this->_initScalarProperties($apiResponse, [
'httpdocs',
'httpsdocs',
'subdomains',
'anonftp',
'logs',
'dbases',
'mailboxes',
'maillists',
'domaindumps',
'configs',
'chroot',
]);
}
}
8 changes: 8 additions & 0 deletions tests/WebspaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 36c6360

Please sign in to comment.