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 array $properties |
30
|
|
|
* @param array|null $hostingProperties |
31
|
|
|
* @param $planName |
32
|
|
|
* @return Struct\Info |
33
|
|
|
*/ |
34
|
|
|
public function create(array $properties, array $hostingProperties = null, $planName = null) |
35
|
|
|
{ |
36
|
|
|
$packet = $this->_client->getPacket(); |
37
|
|
|
$info = $packet->addChild($this->_wrapperTag)->addChild('add'); |
38
|
|
|
|
39
|
|
|
$infoGeneral = $info->addChild('gen_setup'); |
40
|
|
|
foreach ($properties as $name => $value) { |
41
|
|
|
$infoGeneral->addChild($name, $value); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
if ($hostingProperties) { |
45
|
|
|
$infoHosting = $info->addChild('hosting')->addChild('vrt_hst'); |
46
|
|
|
foreach ($hostingProperties as $name => $value) { |
47
|
|
|
$property = $infoHosting->addChild('property'); |
48
|
|
|
$property->addChild('name', $name); |
49
|
|
|
$property->addChild('value', $value); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
if (isset($properties['ip_address'])) { |
53
|
|
|
$infoHosting->addChild("ip_address", $properties['ip_address']); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
if ($planName) { |
58
|
|
|
$info->addChild('plan-name', $planName); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$response = $this->_client->request($packet); |
62
|
|
|
return new Struct\Info($response); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param string $field |
67
|
|
|
* @param integer|string $value |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
|
|
public function delete($field, $value) |
71
|
|
|
{ |
72
|
|
|
return $this->_delete($field, $value); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param string $field |
77
|
|
|
* @param integer|string $value |
78
|
|
|
* @return Struct\GeneralInfo |
79
|
|
|
*/ |
80
|
|
|
public function get($field, $value) |
81
|
|
|
{ |
82
|
|
|
$items = $this->_getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value); |
83
|
|
|
return reset($items); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return Struct\GeneralInfo[] |
88
|
|
|
*/ |
89
|
|
|
public function getAll() |
90
|
|
|
{ |
91
|
|
|
return $this->_getItems(Struct\GeneralInfo::class, 'gen_info'); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $field |
96
|
|
|
* @param integer|string $value |
97
|
|
|
* @return Struct\DiskUsage |
98
|
|
|
*/ |
99
|
|
|
public function getDiskUsage($field, $value) |
100
|
|
|
{ |
101
|
|
|
$items = $this->_getItems(Struct\DiskUsage::class, 'disk_usage', $field, $value); |
102
|
|
|
return reset($items); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
} |
106
|
|
|
|