1
|
|
|
<?php |
2
|
|
|
// Copyright 1999-2019. Plesk International GmbH. |
3
|
|
|
|
4
|
|
|
namespace PleskX\Api\Operator; |
5
|
|
|
|
6
|
|
|
use PleskX\Api\Struct\Webspace as Struct; |
7
|
|
|
|
8
|
|
|
class Webspace extends \PleskX\Api\Operator |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
public function getPermissionDescriptor() |
12
|
|
|
{ |
13
|
|
|
$response = $this->request('get-permission-descriptor.filter'); |
14
|
|
|
return new Struct\PermissionDescriptor($response); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function getLimitDescriptor() |
18
|
|
|
{ |
19
|
|
|
$response = $this->request('get-limit-descriptor.filter'); |
20
|
|
|
return new Struct\LimitDescriptor($response); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function getPhysicalHostingDescriptor() |
24
|
|
|
{ |
25
|
|
|
$response = $this->request('get-physical-hosting-descriptor.filter'); |
26
|
|
|
return new Struct\PhysicalHostingDescriptor($response); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param array $properties |
31
|
|
|
* @param array|null $hostingProperties |
32
|
|
|
* @param $planName |
33
|
|
|
* @return Struct\Info |
34
|
|
|
*/ |
35
|
|
|
public function create(array $properties, array $hostingProperties = null, $planName = null) |
36
|
|
|
{ |
37
|
|
|
$packet = $this->_client->getPacket(); |
38
|
|
|
$info = $packet->addChild($this->_wrapperTag)->addChild('add'); |
39
|
|
|
|
40
|
|
|
$infoGeneral = $info->addChild('gen_setup'); |
41
|
|
|
foreach ($properties as $name => $value) { |
42
|
|
|
$infoGeneral->addChild($name, $value); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
if ($hostingProperties) { |
46
|
|
|
$infoHosting = $info->addChild('hosting')->addChild('vrt_hst'); |
47
|
|
|
foreach ($hostingProperties as $name => $value) { |
48
|
|
|
$property = $infoHosting->addChild('property'); |
49
|
|
|
$property->addChild('name', $name); |
50
|
|
|
$property->addChild('value', $value); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
if (isset($properties['ip_address'])) { |
54
|
|
|
$infoHosting->addChild("ip_address", $properties['ip_address']); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
if ($planName) { |
59
|
|
|
$info->addChild('plan-name', $planName); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$response = $this->_client->request($packet); |
63
|
|
|
return new Struct\Info($response); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param string $field |
68
|
|
|
* @param integer|string $value |
69
|
|
|
* @return bool |
70
|
|
|
*/ |
71
|
|
|
public function delete($field, $value) |
72
|
|
|
{ |
73
|
|
|
return $this->_delete($field, $value); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $field |
78
|
|
|
* @param integer|string $value |
79
|
|
|
* @return Struct\GeneralInfo |
80
|
|
|
*/ |
81
|
|
|
public function get($field, $value) |
82
|
|
|
{ |
83
|
|
|
$items = $this->_getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value); |
84
|
|
|
return reset($items); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return Struct\GeneralInfo[] |
89
|
|
|
*/ |
90
|
|
|
public function getAll() |
91
|
|
|
{ |
92
|
|
|
return $this->_getItems(Struct\GeneralInfo::class, 'gen_info'); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param string $field |
97
|
|
|
* @param integer|string $value |
98
|
|
|
* @return Struct\DiskUsage |
99
|
|
|
*/ |
100
|
|
|
public function getDiskUsage($field, $value) |
101
|
|
|
{ |
102
|
|
|
$items = $this->_getItems(Struct\DiskUsage::class, 'disk_usage', $field, $value); |
103
|
|
|
return reset($items); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
} |
107
|
|
|
|