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