Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting disk usage details #54

Merged
merged 4 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Api/Operator/Webspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright 1999-2019. Plesk International GmbH.

namespace PleskX\Api\Operator;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove white-space change

use PleskX\Api\Struct\Webspace as Struct;

class Webspace extends \PleskX\Api\Operator
Expand Down Expand Up @@ -34,7 +35,7 @@ public function getPhysicalHostingDescriptor()
public function create(array $properties, array $hostingProperties = null, $planName = null)
{
$packet = $this->_client->getPacket();
$info = $packet->addChild($this->_wrapperTag)->addChild('add');
$info = $packet->addChild($this->_wrapperTag)->addChild('add');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove white-space change


$infoGeneral = $info->addChild('gen_setup');
foreach ($properties as $name => $value) {
Expand Down Expand Up @@ -91,4 +92,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);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove white-space change

}
66 changes: 66 additions & 0 deletions src/Api/Struct/Webspace/DiskUsage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
// Copyright 1999-2019. Plesk International GmbH.
// Author: Frederic Leclercq

namespace PleskX\Api\Struct\Webspace;

class DiskUsage extends \PleskX\Api\Struct
{
/** @var string */
public $name;

baldhead marked this conversation as resolved.
Show resolved Hide resolved
/** @var string */
public $guid;

/** @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, [
'name',
'guid',
'httpdocs',
'httpsdocs',
'subdomains',
'anonftp',
'logs',
'dbases',
'mailboxes',
'maillists',
'domaindumps',
'configs',
'chroot',
]);
}
}
7 changes: 7 additions & 0 deletions tests/WebspaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public function testGetLimitDescriptor()
$this->assertNotEmpty($descriptor->limits);
}

public function testGetDiskUsage()
mrsombre marked this conversation as resolved.
Show resolved Hide resolved
{
$diskusage = static::$_client->webspace()->getDiskUsage();
baldhead marked this conversation as resolved.
Show resolved Hide resolved
$this->assertNotEmpty($diskusage->name);
$this->assertNotEmpty($diskusage->guid);
}

public function testGetPhysicalHostingDescriptor()
{
$descriptor = static::$_client->webspace()->getPhysicalHostingDescriptor();
Expand Down