|
1
|
|
|
<?php |
|
2
|
|
|
// Copyright 1999-2016. Parallels IP Holdings 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
|
|
|
* @return Struct\Info |
|
32
|
|
|
*/ |
|
33
|
|
|
public function create(array $properties, array $hostingProperties = null) |
|
34
|
|
|
{ |
|
35
|
|
|
$packet = $this->_client->getPacket(); |
|
36
|
|
|
$info = $packet->addChild('webspace')->addChild('add'); |
|
37
|
|
|
|
|
38
|
|
|
$infoGeneral = $info->addChild('gen_setup'); |
|
39
|
|
|
foreach ($properties as $name => $value) { |
|
40
|
|
|
$infoGeneral->addChild($name, $value); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
if ($hostingProperties) { |
|
44
|
|
|
$infoHosting = $info->addChild('hosting')->addChild('vrt_hst'); |
|
45
|
|
|
foreach ($hostingProperties as $name => $value) { |
|
46
|
|
|
$property = $infoHosting->addChild('property'); |
|
47
|
|
|
$property->addChild('name', $name); |
|
48
|
|
|
$property->addChild('value', $value); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
if (isset($properties['ip_address'])) { |
|
52
|
|
|
$infoHosting->addChild("ip_address", $properties['ip_address']); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
$response = $this->_client->request($packet); |
|
57
|
|
|
return new Struct\Info($response); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param string $field |
|
62
|
|
|
* @param integer|string $value |
|
63
|
|
|
* @return bool |
|
64
|
|
|
*/ |
|
65
|
|
|
public function delete($field, $value) |
|
66
|
|
|
{ |
|
67
|
|
|
$packet = $this->_client->getPacket(); |
|
68
|
|
|
$packet->addChild('webspace')->addChild('del')->addChild('filter')->addChild($field, $value); |
|
69
|
|
|
$response = $this->_client->request($packet); |
|
70
|
|
|
return 'ok' === (string)$response->status; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param string $field |
|
75
|
|
|
* @param integer|string $value |
|
76
|
|
|
* @return Struct\GeneralInfo |
|
77
|
|
|
*/ |
|
78
|
|
|
public function get($field, $value) |
|
79
|
|
|
{ |
|
80
|
|
|
$packet = $this->_client->getPacket(); |
|
81
|
|
|
$getTag = $packet->addChild('webspace')->addChild('get'); |
|
82
|
|
|
$getTag->addChild('filter')->addChild($field, $value); |
|
83
|
|
|
$getTag->addChild('dataset')->addChild('gen_info'); |
|
84
|
|
|
$response = $this->_client->request($packet); |
|
85
|
|
|
return new Struct\GeneralInfo($response->data->gen_info); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|