This commit is contained in:
cutemeli
2025-12-22 10:35:30 +00:00
parent 0bfc6c8425
commit 5ce7ca2c5d
38927 changed files with 0 additions and 4594700 deletions

View File

@@ -1,33 +0,0 @@
# Copyright 1999-2025. WebPros International GmbH.
version: '3'
services:
plesk:
image: plesk/plesk:latest
logging:
driver: none
ports:
["8443:8443"]
tmpfs:
- /tmp
- /run
- /run/lock
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup
cgroup: host
tests:
build: .
environment:
REMOTE_URL: https://plesk:8443
REMOTE_PASSWORD: changeme1Q**
command: >
bash -c "cd /opt/api-php-lib
&& composer install
&& ./wait-for-plesk.sh
&& composer lint
&& composer test -- --testdox"
depends_on:
- plesk
links:
- plesk
volumes:
- .:/opt/api-php-lib

View File

@@ -1,4 +0,0 @@
# Copyright 1999-2025. WebPros International GmbH.
phpunit:
arguments: '--stop-on-failure'
timeout: 0

View File

@@ -1,23 +0,0 @@
<?xml version="1.0"?>
<!-- Copyright 1999-2025. WebPros International GmbH. -->
<psalm
errorLevel="3"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<PropertyNotSetInConstructor errorLevel="suppress" />
<UndefinedPropertyFetch errorLevel="suppress" />
</issueHandlers>
</psalm>

View File

@@ -1,70 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
abstract class AbstractStruct
{
/**
* @param string $property
* @param mixed $value
*
* @throws \Exception
*/
public function __set(string $property, $value)
{
throw new \Exception("Try to set an undeclared property '{$property}' to a value: {$value}.");
}
/**
* Initialize list of scalar properties by response.
*
* @param \SimpleXMLElement $apiResponse
* @param array $properties
*
* @throws \Exception
*/
protected function initScalarProperties(\SimpleXMLElement $apiResponse, array $properties) : void
{
foreach ($properties as $property) {
if (\is_array($property)) {
$classPropertyName = \current($property);
$value = $apiResponse->{\key($property)};
} else {
/** @psalm-suppress PossiblyInvalidArgument */
$classPropertyName = $this->underToCamel(\str_replace('-', '_', $property));
$value = $apiResponse->{$property};
}
$reflectionProperty = new \ReflectionProperty($this, $classPropertyName);
$propertyType = $reflectionProperty->getType();
if (\is_null($propertyType)) {
$docBlock = $reflectionProperty->getDocComment();
$propertyType = \preg_replace('/^.+ @var ([a-z]+) .+$/', '\\1', $docBlock);
} else {
/** @psalm-suppress UndefinedMethod */
$propertyType = $propertyType->getName();
}
if ('string' == $propertyType) {
$value = (string) $value;
} elseif ('int' == $propertyType) {
$value = (int) $value;
} elseif ('bool' == $propertyType) {
$value = \in_array((string) $value, ['true', 'on', 'enabled']);
} else {
throw new \Exception("Unknown property type '{$propertyType}'.");
}
$this->{$classPropertyName} = $value;
}
}
/**
* Convert underscore separated words into camel case.
*
* @param string $under
*
* @return string
*/
private function underToCamel(string $under) : string
{
$under = '_' . \str_replace('_', ' ', \strtolower($under));
return \ltrim(\str_replace(' ', '', \ucwords($under)), '_');
}
}

View File

@@ -1,482 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
use DOMDocument;
use SimpleXMLElement;
/**
* Client for Plesk XML-RPC API.
*/
class Client
{
public const RESPONSE_SHORT = 1;
public const RESPONSE_FULL = 2;
private string $host;
private int $port;
private string $protocol;
protected string $login = '';
private string $password = '';
private string $proxy = '';
private string $secretKey = '';
private string $version = '';
protected array $operatorsCache = [];
/**
* @var callable|null
*/
protected $verifyResponseCallback;
/**
* Create client.
*
* @param string $host
* @param int $port
* @param string $protocol
*/
public function __construct(string $host, int $port = 8443, string $protocol = 'https')
{
$this->host = $host;
$this->port = $port;
$this->protocol = $protocol;
}
/**
* Setup credentials for authentication.
*
* @param string $login
* @param string $password
*/
public function setCredentials(string $login, string $password) : void
{
$this->login = $login;
$this->password = $password;
}
/**
* Define secret key for alternative authentication.
*
* @param string $secretKey
*/
public function setSecretKey(string $secretKey) : void
{
$this->secretKey = $secretKey;
}
/**
* Set proxy server for requests.
*
* @param string $proxy
*/
public function setProxy(string $proxy) : void
{
$this->proxy = $proxy;
}
/**
* Set default version for requests.
*
* @param string $version
*/
public function setVersion(string $version) : void
{
$this->version = $version;
}
/**
* Set custom function to verify response of API call according your own needs.
* Default verifying will be used if it is not specified.
*
* @param callable|null $function
*/
public function setVerifyResponse(?callable $function = null) : void
{
$this->verifyResponseCallback = $function;
}
/**
* Retrieve host used for communication.
*
* @return string
*/
public function getHost() : string
{
return $this->host;
}
/**
* Retrieve port used for communication.
*
* @return int
*/
public function getPort() : int
{
return $this->port;
}
/**
* Retrieve name of the protocol (http or https) used for communication.
*
* @return string
*/
public function getProtocol() : string
{
return $this->protocol;
}
/**
* Retrieve XML template for packet.
*
* @param string|null $version
*
* @return SimpleXMLElement
*/
public function getPacket($version = null) : SimpleXMLElement
{
$protocolVersion = !\is_null($version) ? $version : $this->version;
$content = "<?xml version='1.0' encoding='UTF-8' ?>";
$content .= '<packet' . ('' === $protocolVersion ? '' : " version='{$protocolVersion}'") . '/>';
return new SimpleXMLElement($content);
}
/**
* Perform API request.
*
* @param string|array|SimpleXMLElement $request
* @param int $mode
*
* @return XmlResponse
* @throws \Exception
*/
public function request($request, int $mode = self::RESPONSE_SHORT) : \PleskX\Api\XmlResponse
{
if ($request instanceof SimpleXMLElement) {
$request = $request->asXml();
} else {
$xml = $this->getPacket();
if (\is_array($request)) {
$request = $this->arrayToXml($request, $xml)->asXML();
} elseif (\preg_match('/^[a-z]/', $request)) {
$request = $this->expandRequestShortSyntax($request, $xml);
}
}
if ('sdk' == $this->protocol) {
$xml = $this->performSdkCall((string) $request);
} else {
$xml = $this->performHttpRequest((string) $request);
}
$this->verifyResponseCallback ? \call_user_func($this->verifyResponseCallback, $xml) : $this->verifyResponse($xml);
$result = self::RESPONSE_FULL === $mode ? $xml : ($xml->xpath('//result') ?: [null])[0];
return new \PleskX\Api\XmlResponse($result ? (string) $result->asXML() : '');
}
private function performSdkCall(string $request) : \PleskX\Api\XmlResponse
{
$version = '' == $this->version ? null : $this->version;
$requestXml = new SimpleXMLElement($request);
$innerNodes = $requestXml->children();
$innerXml = $innerNodes && \count($innerNodes) > 0 && $innerNodes[0] ? $innerNodes[0]->asXml() : '';
/** @psalm-suppress UndefinedClass */
$result = \pm_ApiRpc::getService($version)->call($innerXml, $this->login);
return new \PleskX\Api\XmlResponse($result ? (string) $result->asXML() : '');
}
/**
* Perform HTTP request to end-point.
*
* @param string $request
*
* @throws Client\Exception
*
* @return XmlResponse
*/
private function performHttpRequest($request)
{
$curl = \curl_init();
\curl_setopt($curl, \CURLOPT_URL, "{$this->protocol}://{$this->host}:{$this->port}/enterprise/control/agent.php");
\curl_setopt($curl, \CURLOPT_RETURNTRANSFER, \true);
\curl_setopt($curl, \CURLOPT_POST, \true);
\curl_setopt($curl, \CURLOPT_SSL_VERIFYPEER, \false);
\curl_setopt($curl, \CURLOPT_SSL_VERIFYHOST, \false);
\curl_setopt($curl, \CURLOPT_HTTPHEADER, $this->getHeaders());
\curl_setopt($curl, \CURLOPT_POSTFIELDS, $request);
if ('' !== $this->proxy) {
\curl_setopt($curl, \CURLOPT_PROXY, $this->proxy);
}
$result = \curl_exec($curl);
if (\false === $result) {
throw new \PleskX\Api\Client\Exception(\curl_error($curl), \curl_errno($curl));
}
\curl_close($curl);
return new \PleskX\Api\XmlResponse((string) $result);
}
/**
* Perform multiple API requests using single HTTP request.
*
* @param array $requests
* @param int $mode
*
* @throws Client\Exception
*
* @return array
*/
public function multiRequest(array $requests, int $mode = self::RESPONSE_SHORT) : array
{
$requestXml = $this->getPacket();
foreach ($requests as $request) {
if ($request instanceof SimpleXMLElement) {
throw new \PleskX\Api\Client\Exception('SimpleXML type of request is not supported for multi requests.');
} else {
if (\is_array($request)) {
$request = $this->arrayToXml($request, $requestXml)->asXML();
if (!$request) {
throw new \PleskX\Api\Client\Exception('Failed to create an XML string for request');
}
} elseif (\preg_match('/^[a-z]/', $request)) {
$this->expandRequestShortSyntax($request, $requestXml);
}
}
}
if ('sdk' == $this->protocol) {
throw new \PleskX\Api\Client\Exception('Multi requests are not supported via SDK.');
} else {
$xmlString = $requestXml->asXML();
if (!$xmlString) {
throw new \PleskX\Api\Client\Exception('Failed to create an XML string for request');
}
$responseXml = $this->performHttpRequest($xmlString);
}
return $this->splitResponseToArray($responseXml, $mode);
}
private function splitResponseToArray(\PleskX\Api\XmlResponse $responseXml, $mode = self::RESPONSE_SHORT) : array
{
$responses = [];
$nodes = $responseXml->children();
if (!$nodes) {
return [];
}
foreach ($nodes as $childNode) {
$dom = $this->getDomDocument($this->getPacket());
if (!$dom) {
continue;
}
$childDomNode = \dom_import_simplexml($childNode);
if (!\is_null($childDomNode)) {
$childDomNode = $dom->importNode($childDomNode, \true);
$dom->documentElement->appendChild($childDomNode);
}
$response = \simplexml_load_string($dom->saveXML());
if (!$response) {
return [];
}
$responses[] = self::RESPONSE_FULL == $mode ? $response : ($response->xpath('//result') ?: [null])[0];
}
return $responses;
}
private function getDomDocument(SimpleXMLElement $xml) : ?DOMDocument
{
$dom = \dom_import_simplexml($xml);
if (\is_null($dom)) {
return null;
}
return $dom->ownerDocument;
}
/**
* Retrieve list of headers needed for request.
*
* @return array
*/
private function getHeaders()
{
$headers = ['Content-Type: text/xml', 'HTTP_PRETTY_PRINT: TRUE'];
if ($this->secretKey) {
$headers[] = "KEY: {$this->secretKey}";
} else {
$headers[] = "HTTP_AUTH_LOGIN: {$this->login}";
$headers[] = "HTTP_AUTH_PASSWD: {$this->password}";
}
return $headers;
}
/**
* Verify that response does not contain errors.
*
* @param XmlResponse $xml
*
* @throws Exception
*/
private function verifyResponse($xml) : void
{
if ($xml->system && $xml->system->status && 'error' == (string) $xml->system->status) {
throw new \PleskX\Api\Exception((string) $xml->system->errtext, (int) $xml->system->errcode);
}
if ($xml->xpath('//status[text()="error"]') && $xml->xpath('//errcode') && $xml->xpath('//errtext')) {
$errorCode = (int) ($xml->xpath('//errcode') ?: [null])[0];
$errorMessage = (string) ($xml->xpath('//errtext') ?: [null])[0];
throw new \PleskX\Api\Exception($errorMessage, $errorCode);
}
}
/**
* Expand short syntax (some.method.call) into full XML representation.
*
* @param string $request
* @param SimpleXMLElement $xml
*
* @return false|string
*/
private function expandRequestShortSyntax($request, SimpleXMLElement $xml)
{
$parts = \explode('.', $request);
$node = $xml;
$lastParts = \end($parts);
foreach ($parts as $part) {
// phpcs:ignore
@(list($name, $value) = \explode('=', $part));
if ($part !== $lastParts) {
$node = $node->addChild($name);
} else {
$node->{$name} = (string) $value;
}
}
return $xml->asXML();
}
/**
* Convert array to XML representation.
*
* @param array $array
* @param SimpleXMLElement $xml
* @param string $parentEl
*
* @return SimpleXMLElement
*/
private function arrayToXml(array $array, SimpleXMLElement $xml, $parentEl = null)
{
foreach ($array as $key => $value) {
$el = \is_int($key) && $parentEl ? $parentEl : $key;
if (\is_array($value)) {
$this->arrayToXml($value, $this->isAssocArray($value) ? $xml->addChild($el) : $xml, $el);
} elseif (!isset($xml->{$el})) {
$xml->{$el} = (string) $value;
} else {
$xml->{$el}[] = (string) $value;
}
}
return $xml;
}
/**
* @param array $array
*
* @return bool
*/
private function isAssocArray(array $array)
{
return $array && \array_keys($array) !== \range(0, \count($array) - 1);
}
/**
* @param string $name
*
* @return mixed
*/
private function getOperator(string $name)
{
if (!isset($this->operatorsCache[$name])) {
$className = '\\PleskX\\Api\\Operator\\' . $name;
/** @psalm-suppress InvalidStringClass */
$this->operatorsCache[$name] = new $className($this);
}
return $this->operatorsCache[$name];
}
public function server() : \PleskX\Api\Operator\Server
{
return $this->getOperator('Server');
}
public function customer() : \PleskX\Api\Operator\Customer
{
return $this->getOperator('Customer');
}
public function webspace() : \PleskX\Api\Operator\Webspace
{
return $this->getOperator('Webspace');
}
public function subdomain() : \PleskX\Api\Operator\Subdomain
{
return $this->getOperator('Subdomain');
}
public function dns() : \PleskX\Api\Operator\Dns
{
return $this->getOperator('Dns');
}
public function dnsTemplate() : \PleskX\Api\Operator\DnsTemplate
{
return $this->getOperator('DnsTemplate');
}
public function databaseServer() : \PleskX\Api\Operator\DatabaseServer
{
return $this->getOperator('DatabaseServer');
}
public function mail() : \PleskX\Api\Operator\Mail
{
return $this->getOperator('Mail');
}
public function certificate() : \PleskX\Api\Operator\Certificate
{
return $this->getOperator('Certificate');
}
public function siteAlias() : \PleskX\Api\Operator\SiteAlias
{
return $this->getOperator('SiteAlias');
}
public function ip() : \PleskX\Api\Operator\Ip
{
return $this->getOperator('Ip');
}
public function eventLog() : \PleskX\Api\Operator\EventLog
{
return $this->getOperator('EventLog');
}
public function secretKey() : \PleskX\Api\Operator\SecretKey
{
return $this->getOperator('SecretKey');
}
public function ui() : \PleskX\Api\Operator\Ui
{
return $this->getOperator('Ui');
}
public function servicePlan() : \PleskX\Api\Operator\ServicePlan
{
return $this->getOperator('ServicePlan');
}
public function virtualDirectory() : \PleskX\Api\Operator\VirtualDirectory
{
return $this->getOperator('VirtualDirectory');
}
public function database() : \PleskX\Api\Operator\Database
{
return $this->getOperator('Database');
}
public function session() : \PleskX\Api\Operator\Session
{
return $this->getOperator('Session');
}
public function locale() : \PleskX\Api\Operator\Locale
{
return $this->getOperator('Locale');
}
public function logRotation() : \PleskX\Api\Operator\LogRotation
{
return $this->getOperator('LogRotation');
}
public function protectedDirectory() : \PleskX\Api\Operator\ProtectedDirectory
{
return $this->getOperator('ProtectedDirectory');
}
public function reseller() : \PleskX\Api\Operator\Reseller
{
return $this->getOperator('Reseller');
}
public function resellerPlan() : \PleskX\Api\Operator\ResellerPlan
{
return $this->getOperator('ResellerPlan');
}
public function aps() : \PleskX\Api\Operator\Aps
{
return $this->getOperator('Aps');
}
public function servicePlanAddon() : \PleskX\Api\Operator\ServicePlanAddon
{
return $this->getOperator('ServicePlanAddon');
}
public function site() : \PleskX\Api\Operator\Site
{
return $this->getOperator('Site');
}
public function phpHandler() : \PleskX\Api\Operator\PhpHandler
{
return $this->getOperator('PhpHandler');
}
}

View File

@@ -1,11 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Client;
/**
* Transport layer exception.
*/
class Exception extends \Exception
{
}

View File

@@ -1,11 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
/**
* Exceptions for XML-RPC API client.
*/
class Exception extends \Exception
{
}

View File

@@ -1,24 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
/**
* Internal client for Plesk XML-RPC API (via SDK).
*/
class InternalClient extends \PleskX\Api\Client
{
public function __construct()
{
parent::__construct('localhost', 0, 'sdk');
}
/**
* Setup login to execute requests under certain user.
*
* @param string $login
*/
public function setLogin(string $login) : void
{
$this->login = $login;
}
}

View File

@@ -1,87 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
class Operator
{
protected string $wrapperTag = '';
protected \PleskX\Api\Client $client;
public function __construct(\PleskX\Api\Client $client)
{
$this->client = $client;
if ('' === $this->wrapperTag) {
$classNameParts = \explode('\\', \get_class($this));
$this->wrapperTag = \end($classNameParts);
$this->wrapperTag = \strtolower(\preg_replace('/([a-z])([A-Z])/', '\\1-\\2', $this->wrapperTag));
}
}
/**
* Perform plain API request.
*
* @param string|array $request
* @param int $mode
*
* @return XmlResponse
*/
public function request($request, $mode = \PleskX\Api\Client::RESPONSE_SHORT) : \PleskX\Api\XmlResponse
{
$wrapperTag = $this->wrapperTag;
if (\is_array($request)) {
$request = [$wrapperTag => $request];
} elseif (\preg_match('/^[a-z]/', $request)) {
$request = "{$wrapperTag}.{$request}";
} else {
$request = "<{$wrapperTag}>{$request}</{$wrapperTag}>";
}
return $this->client->request($request, $mode);
}
/**
* @param string $field
* @param int|string $value
* @param string $deleteMethodName
*
* @return bool
*/
protected function deleteBy(string $field, $value, string $deleteMethodName = 'del') : bool
{
$response = $this->request([$deleteMethodName => ['filter' => [$field => $value]]]);
return 'ok' === (string) $response->status;
}
/**
* @param string $structClass
* @param string $infoTag
* @param string|null $field
* @param int|string|null $value
* @param callable|null $filter
*
* @return array
*/
protected function getItems($structClass, $infoTag, $field = null, $value = null, ?callable $filter = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->{$field} = (string) $value;
}
$getTag->addChild('dataset')->addChild($infoTag);
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult || !isset($xmlResult->data) || !isset($xmlResult->data->{$infoTag})) {
continue;
}
if (!\is_null($filter) && !$filter($xmlResult->data->{$infoTag})) {
continue;
}
/** @psalm-suppress InvalidStringClass */
$item = new $structClass($xmlResult->data->{$infoTag});
if (isset($xmlResult->id) && \property_exists($item, 'id')) {
$item->id = (int) $xmlResult->id;
}
$items[] = $item;
}
return $items;
}
}

View File

@@ -1,8 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
class Aps extends \PleskX\Api\Operator
{
}

View File

@@ -1,72 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Certificate as Struct;
class Certificate extends \PleskX\Api\Operator
{
public function generate(array $properties) : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('generate')->addChild('info');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param array $properties
* @param string|Struct\Info $certificate
* @param string|null $privateKey
*/
public function install(array $properties, $certificate, ?string $privateKey = null) : bool
{
return $this->callApi('install', $properties, $certificate, $privateKey);
}
/**
* @param array $properties
* @param Struct\Info $certificate
*/
public function update(array $properties, Struct\Info $certificate) : bool
{
return $this->callApi('update', $properties, $certificate);
}
/**
* @param string $method
* @param array $properties
* @param string|Struct\Info $certificate
* @param string|null $privateKey
*/
private function callApi(string $method, array $properties, $certificate, ?string $privateKey = null) : bool
{
$packet = $this->client->getPacket();
$installTag = $packet->addChild($this->wrapperTag)->addChild($method);
foreach ($properties as $name => $value) {
$installTag->{$name} = $value;
}
$contentTag = $installTag->addChild('content');
if (\is_string($certificate)) {
$contentTag->addChild('csr', $certificate);
$contentTag->addChild('pvt', $privateKey);
} elseif ($certificate instanceof \PleskX\Api\Struct\Certificate\Info) {
foreach ($certificate->getMapping() as $name => $value) {
$contentTag->{$name} = $value;
}
}
$result = $this->client->request($packet);
return 'ok' == (string) $result->status;
}
public function delete(string $name, array $properties) : bool
{
$packet = $this->client->getPacket();
$removeTag = $packet->addChild($this->wrapperTag)->addChild('remove');
$removeTag->addChild('filter')->addChild('name', $name);
foreach ($properties as $name => $value) {
$removeTag->{$name} = $value;
}
$result = $this->client->request($packet);
return 'ok' == (string) $result->status;
}
}

View File

@@ -1,86 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Customer as Struct;
class Customer extends \PleskX\Api\Operator
{
public function create(array $properties) : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add')->addChild('gen_info');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo
*/
public function get(string $field, $value) : Struct\GeneralInfo
{
$items = $this->getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value);
return \reset($items);
}
/**
* @return Struct\GeneralInfo[]
*/
public function getAll() : array
{
return $this->getItems(Struct\GeneralInfo::class, 'gen_info');
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function enable(string $field, $value) : bool
{
return $this->setProperties($field, $value, ['status' => 0]);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function disable(string $field, $value) : bool
{
return $this->setProperties($field, $value, ['status' => 16]);
}
/**
* @param string $field
* @param int|string $value
* @param array $properties
*
* @return bool
*/
public function setProperties(string $field, $value, array $properties) : bool
{
$packet = $this->client->getPacket();
$setTag = $packet->addChild($this->wrapperTag)->addChild('set');
$setTag->addChild('filter')->addChild($field, (string) $value);
$genInfoTag = $setTag->addChild('values')->addChild('gen_info');
foreach ($properties as $property => $propertyValue) {
$genInfoTag->addChild($property, (string) $propertyValue);
}
$response = $this->client->request($packet);
return 'ok' === (string) $response->status;
}
}

View File

@@ -1,129 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Database as Struct;
use PleskX\Api\XmlResponse;
class Database extends \PleskX\Api\Operator
{
public function create(array $properties) : Struct\Info
{
return new Struct\Info($this->process('add-db', $properties));
}
public function createUser(array $properties) : Struct\UserInfo
{
return new Struct\UserInfo($this->process('add-db-user', $properties));
}
private function process(string $command, array $properties) : XmlResponse
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild($command);
foreach ($properties as $name => $value) {
if (\false !== \strpos($value, '&')) {
$info->{$name} = $value;
continue;
}
$info->{$name} = $value;
}
return $this->client->request($packet);
}
public function updateUser(array $properties) : bool
{
$response = $this->process('set-db-user', $properties);
return 'ok' === (string) $response->status;
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value) : Struct\Info
{
$items = $this->getAll($field, $value);
return \reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\UserInfo
*/
public function getUser(string $field, $value) : Struct\UserInfo
{
$items = $this->getAllUsers($field, $value);
return \reset($items);
}
/**
* @param string|null $field
* @param int|string $value
*
* @return Struct\Info[]
*/
public function getAll(?string $field, $value) : array
{
$response = $this->getBy('get-db', $field, $value);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if ($xmlResult) {
$items[] = new Struct\Info($xmlResult);
}
}
return $items;
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\UserInfo[]
*/
public function getAllUsers(string $field, $value) : array
{
$response = $this->getBy('get-db-users', $field, $value);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if ($xmlResult) {
$items[] = new Struct\UserInfo($xmlResult);
}
}
return $items;
}
/**
* @param string $command
* @param string|null $field
* @param int|string $value
*
* @return XmlResponse
*/
private function getBy(string $command, ?string $field, $value) : XmlResponse
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild($command);
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->{$field} = (string) $value;
}
return $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value, 'del-db');
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function deleteUser(string $field, $value) : bool
{
return $this->deleteBy($field, $value, 'del-db-user');
}
}

View File

@@ -1,71 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\DatabaseServer as Struct;
class DatabaseServer extends \PleskX\Api\Operator
{
protected string $wrapperTag = 'db_server';
public function getSupportedTypes() : array
{
$response = $this->request('get-supported-types');
return (array) $response->type;
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value) : Struct\Info
{
$items = $this->getBy($field, $value);
return \reset($items);
}
/**
* @return Struct\Info[]
*/
public function getAll() : array
{
return $this->getBy();
}
public function getDefault(string $type) : Struct\Info
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get-default');
$filterTag = $getTag->addChild('filter');
/** @psalm-suppress UndefinedPropertyAssignment */
$filterTag->type = $type;
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string|null $field
* @param int|string|null $value
*
* @return Struct\Info[]
*/
private function getBy($field = null, $value = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->{$field} = (string) $value;
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
if (!\is_null($xmlResult->data)) {
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
}
return $items;
}
}

View File

@@ -1,112 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Dns as Struct;
class Dns extends \PleskX\Api\Operator
{
public function create(array $properties) : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add_rec');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
return new Struct\Info($this->client->request($packet));
}
/**
* Send multiply records by one request.
*
* @param array $records
*
* @return \SimpleXMLElement[]
*/
public function bulkCreate(array $records) : array
{
$packet = $this->client->getPacket();
foreach ($records as $properties) {
$info = $packet->addChild($this->wrapperTag)->addChild('add_rec');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if ($xmlResult) {
$items[] = $xmlResult;
}
}
return $items;
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value) : Struct\Info
{
$items = $this->getAll($field, $value);
return \reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info[]
*/
public function getAll(string $field, $value) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get_rec');
$filterTag = $getTag->addChild('filter');
$filterTag->addChild($field, (string) $value);
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
if (!\is_null($xmlResult->data)) {
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
}
return $items;
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value, 'del_rec');
}
/**
* Delete multiply records by one request.
*
* @param array $recordIds
*
* @return \SimpleXMLElement[]
*/
public function bulkDelete(array $recordIds) : array
{
$packet = $this->client->getPacket();
foreach ($recordIds as $recordId) {
$packet->addChild($this->wrapperTag)->addChild('del_rec')->addChild('filter')->addChild('id', $recordId);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if ($xmlResult) {
$items[] = $xmlResult;
}
}
return $items;
}
}

View File

@@ -1,80 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Dns as Struct;
class DnsTemplate extends \PleskX\Api\Operator
{
protected string $wrapperTag = 'dns';
/**
* @param array $properties
*
* @return Struct\Info
*/
public function create(array $properties) : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add_rec');
unset($properties['site-id'], $properties['site-alias-id']);
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
return new Struct\Info($this->client->request($packet));
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value) : Struct\Info
{
$items = $this->getAll($field, $value);
return \reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info[]
*/
public function getAll($field = null, $value = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get_rec');
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->{$field} = (string) $value;
}
$getTag->addChild('template');
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
if (!\is_null($xmlResult->data)) {
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
}
return $items;
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
$packet = $this->client->getPacket();
$delTag = $packet->addChild($this->wrapperTag)->addChild('del_rec');
$delTag->addChild('filter')->addChild($field, (string) $value);
$delTag->addChild('template');
$response = $this->client->request($packet);
return 'ok' === (string) $response->status;
}
}

View File

@@ -1,38 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\EventLog as Struct;
class EventLog extends \PleskX\Api\Operator
{
protected string $wrapperTag = 'event_log';
/**
* @return Struct\Event[]
*/
public function get() : array
{
$records = [];
$response = $this->request('get');
foreach ($response->event ?? [] as $eventInfo) {
$records[] = new Struct\Event($eventInfo);
}
return $records;
}
/**
* @return Struct\DetailedEvent[]
*/
public function getDetailedLog() : array
{
$records = [];
$response = $this->request('get_events');
foreach ($response->event ?? [] as $eventInfo) {
$records[] = new Struct\DetailedEvent($eventInfo);
}
return $records;
}
public function getLastId() : int
{
return (int) $this->request('get-last-id')->getValue('id');
}
}

View File

@@ -1,23 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Ip as Struct;
class Ip extends \PleskX\Api\Operator
{
/**
* @return Struct\Info[]
*/
public function get() : array
{
$ips = [];
$packet = $this->client->getPacket();
$packet->addChild($this->wrapperTag)->addChild('get');
$response = $this->client->request($packet);
foreach ($response->addresses->ip_info ?? [] as $ipInfo) {
$ips[] = new Struct\Info($ipInfo);
}
return $ips;
}
}

View File

@@ -1,30 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Locale as Struct;
class Locale extends \PleskX\Api\Operator
{
/**
* @param string|null $id
*
* @return Struct\Info|Struct\Info[]
*/
public function get($id = null)
{
$locales = [];
$packet = $this->client->getPacket();
$filter = $packet->addChild($this->wrapperTag)->addChild('get')->addChild('filter');
if (!\is_null($id)) {
$filter->addChild('id', $id);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
foreach ($response->locale->get->result ?? [] as $localeInfo) {
if (!\is_null($localeInfo->info)) {
$locales[(string) $localeInfo->info->id] = new Struct\Info($localeInfo->info);
}
}
return !\is_null($id) ? \reset($locales) : $locales;
}
}

View File

@@ -1,8 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
class LogRotation extends \PleskX\Api\Operator
{
}

View File

@@ -1,77 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Client;
use PleskX\Api\Operator;
use PleskX\Api\Struct\Mail as Struct;
class Mail extends Operator
{
public function create(string $name, int $siteId, bool $mailbox = \false, string $password = '') : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('create');
$filter = $info->addChild('filter');
$filter->addChild('site-id', (string) $siteId);
$mailname = $filter->addChild('mailname');
$mailname->addChild('name', $name);
if ($mailbox) {
$mailname->addChild('mailbox')->addChild('enabled', 'true');
}
if (!empty($password)) {
/** @psalm-suppress UndefinedPropertyAssignment */
$mailname->addChild('password')->value = $password;
}
$response = $this->client->request($packet);
/** @psalm-suppress PossiblyNullArgument */
return new Struct\Info($response->mailname);
}
/**
* @param string $field
* @param int|string $value
* @param int $siteId
*
* @return bool
*/
public function delete(string $field, $value, int $siteId) : bool
{
$packet = $this->client->getPacket();
$filter = $packet->addChild($this->wrapperTag)->addChild('remove')->addChild('filter');
$filter->addChild('site-id', (string) $siteId);
$filter->{$field} = (string) $value;
$response = $this->client->request($packet);
return 'ok' === (string) $response->status;
}
public function get(string $name, int $siteId) : Struct\GeneralInfo
{
$items = $this->getAll($siteId, $name);
return \reset($items);
}
/**
* @param int $siteId
* @param string|null $name
*
* @return Struct\GeneralInfo[]
*/
public function getAll(int $siteId, $name = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get_info');
$filterTag = $getTag->addChild('filter');
$filterTag->addChild('site-id', (string) $siteId);
if (!\is_null($name)) {
$filterTag->addChild('name', $name);
}
$response = $this->client->request($packet, Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult || !isset($xmlResult->mailname)) {
continue;
}
$item = new Struct\GeneralInfo($xmlResult->mailname);
$items[] = $item;
}
return $items;
}
}

View File

@@ -1,54 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Client;
use PleskX\Api\Operator;
use PleskX\Api\Struct\PhpHandler\Info;
class PhpHandler extends Operator
{
/**
* @param string|null $field
* @param int|string|null $value
*
* @return Info
*/
public function get($field = null, $value = null) : ?Info
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$response = $this->client->request($packet, Client::RESPONSE_FULL);
$xmlResult = ($response->xpath('//result') ?: [null])[0];
return $xmlResult ? new Info($xmlResult) : null;
}
/**
* @param string|null $field
* @param int|string $value
*
* @return Info[]
*/
public function getAll($field = null, $value = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$response = $this->client->request($packet, Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
$item = new Info($xmlResult);
$items[] = $item;
}
return $items;
}
}

View File

@@ -1,102 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Client;
use PleskX\Api\Operator;
use PleskX\Api\Struct\ProtectedDirectory as Struct;
class ProtectedDirectory extends Operator
{
protected string $wrapperTag = 'protected-dir';
public function add(string $name, int $siteId, string $header = '') : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add');
$info->addChild('site-id', (string) $siteId);
$info->addChild('name', $name);
$info->addChild('header', $header);
return new Struct\Info($this->client->request($packet));
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value, 'delete');
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\DataInfo
*/
public function get(string $field, $value) : Struct\DataInfo
{
$items = $this->getAll($field, $value);
return \reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\DataInfo[]
*/
public function getAll(string $field, $value) : array
{
$response = $this->getBy('get', $field, $value);
$items = [];
foreach ((array) $response->xpath('//result/data') as $xmlResult) {
if (!$xmlResult) {
continue;
}
$items[] = new Struct\DataInfo($xmlResult);
}
return $items;
}
/**
* @param Struct\Info $protectedDirectory
* @param string $login
* @param string $password
*
* @return Struct\UserInfo
* @psalm-suppress UndefinedPropertyAssignment
*/
public function addUser($protectedDirectory, $login, $password)
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add-user');
$info->{'pd-id'} = (string) $protectedDirectory->id;
$info->login = $login;
$info->password = $password;
return new Struct\UserInfo($this->client->request($packet));
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function deleteUser($field, $value)
{
return $this->deleteBy($field, $value, 'delete-user');
}
/**
* @param string $command
* @param string $field
* @param int|string $value
*
* @return \PleskX\Api\XmlResponse
*/
private function getBy(string $command, string $field, $value)
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild($command);
$filterTag = $getTag->addChild('filter');
$filterTag->{$field} = (string) $value;
return $this->client->request($packet, Client::RESPONSE_FULL);
}
}

View File

@@ -1,69 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Reseller as Struct;
class Reseller extends \PleskX\Api\Operator
{
public function create(array $properties) : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add')->addChild('gen-info');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo
*/
public function get(string $field, $value) : Struct\GeneralInfo
{
$items = $this->getAll($field, $value);
return \reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo[]
*/
public function getAll($field = null, $value = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$datasetTag = $getTag->addChild('dataset');
$datasetTag->addChild('gen-info');
$datasetTag->addChild('permissions');
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult || !$xmlResult->data) {
continue;
}
$item = new Struct\GeneralInfo($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
return $items;
}
}

View File

@@ -1,8 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
class ResellerPlan extends \PleskX\Api\Operator
{
}

View File

@@ -1,62 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\SecretKey as Struct;
class SecretKey extends \PleskX\Api\Operator
{
protected string $wrapperTag = 'secret_key';
public function create(string $ipAddress = '', string $description = '') : string
{
$packet = $this->client->getPacket();
$createTag = $packet->addChild($this->wrapperTag)->addChild('create');
if ('' !== $ipAddress) {
$createTag->addChild('ip_address', $ipAddress);
}
if ('' !== $description) {
$createTag->addChild('description', $description);
}
$response = $this->client->request($packet);
return (string) $response->key;
}
public function delete(string $keyId) : bool
{
return $this->deleteBy('key', $keyId, 'delete');
}
public function get(string $keyId) : Struct\Info
{
$items = $this->getBy($keyId);
return \reset($items);
}
/**
* @return Struct\Info[]
*/
public function getAll() : array
{
return $this->getBy();
}
/**
* @param string|null $keyId
*
* @return Struct\Info[]
*/
public function getBy($keyId = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get_info');
$filterTag = $getTag->addChild('filter');
if (!\is_null($keyId)) {
$filterTag->addChild('key', $keyId);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result/key_info') as $keyInfo) {
if (!$keyInfo) {
continue;
}
$items[] = new Struct\Info($keyInfo);
}
return $items;
}
}

View File

@@ -1,110 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Server as Struct;
use PleskX\Api\XmlResponse;
class Server extends \PleskX\Api\Operator
{
public function getProtos() : array
{
$packet = $this->client->getPacket();
$packet->addChild($this->wrapperTag)->addChild('get_protos');
$response = $this->client->request($packet);
/** @psalm-suppress PossiblyNullPropertyFetch */
return (array) $response->protos->proto;
}
public function getGeneralInfo() : Struct\GeneralInfo
{
return new Struct\GeneralInfo($this->getInfo('gen_info'));
}
public function getPreferences() : Struct\Preferences
{
return new Struct\Preferences($this->getInfo('prefs'));
}
public function getAdmin() : Struct\Admin
{
return new Struct\Admin($this->getInfo('admin'));
}
public function getKeyInfo() : array
{
$keyInfo = [];
$keyInfoXml = $this->getInfo('key');
foreach ($keyInfoXml->property ?? [] as $property) {
$keyInfo[(string) $property->name] = (string) $property->value;
}
return $keyInfo;
}
public function getComponents() : array
{
$components = [];
$componentsXml = $this->getInfo('components');
foreach ($componentsXml->component ?? [] as $component) {
$components[(string) $component->name] = (string) $component->version;
}
return $components;
}
public function getServiceStates() : array
{
$states = [];
$statesXml = $this->getInfo('services_state');
foreach ($statesXml->srv ?? [] as $service) {
$states[(string) $service->id] = ['id' => (string) $service->id, 'title' => (string) $service->title, 'state' => (string) $service->state];
}
return $states;
}
public function getSessionPreferences() : Struct\SessionPreferences
{
return new Struct\SessionPreferences($this->getInfo('session_setup'));
}
public function getShells() : array
{
$shells = [];
$shellsXml = $this->getInfo('shells');
foreach ($shellsXml->shell ?? [] as $shell) {
$shells[(string) $shell->name] = (string) $shell->path;
}
return $shells;
}
public function getNetworkInterfaces() : array
{
$interfacesXml = $this->getInfo('interfaces');
return (array) $interfacesXml->interface;
}
public function getStatistics() : Struct\Statistics
{
return new Struct\Statistics($this->getInfo('stat'));
}
public function getSiteIsolationConfig() : array
{
$config = [];
$configXml = $this->getInfo('site-isolation-config');
foreach ($configXml->property ?? [] as $property) {
$config[(string) $property->name] = (string) $property->value;
}
return $config;
}
public function getUpdatesInfo() : Struct\UpdatesInfo
{
return new Struct\UpdatesInfo($this->getInfo('updates'));
}
public function createSession(string $login, string $clientIp) : string
{
$packet = $this->client->getPacket();
$sessionNode = $packet->addChild($this->wrapperTag)->addChild('create_session');
$sessionNode->addChild('login', $login);
$dataNode = $sessionNode->addChild('data');
$dataNode->addChild('user_ip', \base64_encode($clientIp));
$dataNode->addChild('source_server');
$response = $this->client->request($packet);
return (string) $response->id;
}
private function getInfo(string $operation) : XmlResponse
{
$packet = $this->client->getPacket();
$packet->addChild($this->wrapperTag)->addChild('get')->addChild($operation);
$response = $this->client->request($packet);
return $response->{$operation};
}
}

View File

@@ -1,66 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\ServicePlan as Struct;
class ServicePlan extends \PleskX\Api\Operator
{
public function create(array $properties) : Struct\Info
{
$response = $this->request(['add' => $properties]);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value) : Struct\Info
{
$items = $this->getBy($field, $value);
return \reset($items);
}
/**
* @return Struct\Info[]
*/
public function getAll() : array
{
return $this->getBy();
}
/**
* @param string|null $field
* @param int|string|null $value
*
* @return Struct\Info[]
*/
private function getBy($field = null, $value = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
$items[] = new Struct\Info($xmlResult);
}
return $items;
}
}

View File

@@ -1,66 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\ServicePlanAddon as Struct;
class ServicePlanAddon extends \PleskX\Api\Operator
{
public function create(array $properties) : Struct\Info
{
$response = $this->request(['add' => $properties]);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value) : Struct\Info
{
$items = $this->getBy($field, $value);
return \reset($items);
}
/**
* @return Struct\Info[]
*/
public function getAll() : array
{
return $this->getBy();
}
/**
* @param string|null $field
* @param int|string|null $value
*
* @return Struct\Info[]
*/
private function getBy($field = null, $value = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
$items[] = new Struct\Info($xmlResult);
}
return $items;
}
}

View File

@@ -1,37 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Session as Struct;
class Session extends \PleskX\Api\Operator
{
public function create(string $username, string $userIp) : string
{
$packet = $this->client->getPacket();
$creator = $packet->addChild('server')->addChild('create_session');
$creator->addChild('login', $username);
$loginData = $creator->addChild('data');
$loginData->addChild('user_ip', \base64_encode($userIp));
$loginData->addChild('source_server', '');
$response = $this->client->request($packet);
return (string) $response->id;
}
/**
* @return Struct\Info[]
*/
public function get() : array
{
$sessions = [];
$response = $this->request('get');
foreach ($response->session ?? [] as $sessionInfo) {
$sessions[(string) $sessionInfo->id] = new Struct\Info($sessionInfo);
}
return $sessions;
}
public function terminate(string $sessionId) : bool
{
$response = $this->request("terminate.session-id={$sessionId}");
return 'ok' === (string) $response->status;
}
}

View File

@@ -1,76 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Site as Struct;
class Site extends \PleskX\Api\Operator
{
public const PROPERTIES_HOSTING = 'hosting';
public function create(array $properties) : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add');
$infoGeneral = $info->addChild('gen_setup');
foreach ($properties as $name => $value) {
if (!\is_scalar($value)) {
continue;
}
$infoGeneral->{$name} = (string) $value;
}
// set hosting properties
if (isset($properties[static::PROPERTIES_HOSTING]) && \is_array($properties[static::PROPERTIES_HOSTING])) {
$hostingNode = $info->addChild('hosting')->addChild('vrt_hst');
foreach ($properties[static::PROPERTIES_HOSTING] as $name => $value) {
$propertyNode = $hostingNode->addChild('property');
/** @psalm-suppress UndefinedPropertyAssignment */
$propertyNode->name = $name;
/** @psalm-suppress UndefinedPropertyAssignment */
$propertyNode->value = $value;
}
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return ?Struct\GeneralInfo
*/
public function get(string $field, $value) : ?Struct\GeneralInfo
{
$items = $this->getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value);
return \reset($items) ?: null;
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\HostingInfo|null
*/
public function getHosting(string $field, $value) : ?Struct\HostingInfo
{
$items = $this->getItems(Struct\HostingInfo::class, 'hosting', $field, $value, function (\SimpleXMLElement $node) {
return isset($node->vrt_hst);
});
return empty($items) ? null : \reset($items);
}
/**
* @return Struct\GeneralInfo[]
*/
public function getAll() : array
{
return $this->getItems(Struct\GeneralInfo::class, 'gen_info');
}
}

View File

@@ -1,72 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\SiteAlias as Struct;
class SiteAlias extends \PleskX\Api\Operator
{
public function create(array $properties, array $preferences = []) : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('create');
if (\count($preferences) > 0) {
$prefs = $info->addChild('pref');
foreach ($preferences as $key => $value) {
$prefs->addChild($key, \is_bool($value) ? $value ? '1' : '0' : $value);
}
}
$info->addChild('site-id', $properties['site-id']);
$info->addChild('name', $properties['name']);
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value, 'delete');
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo
*/
public function get(string $field, $value) : Struct\GeneralInfo
{
$items = $this->getAll($field, $value);
return \reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo[]
*/
public function getAll($field = null, $value = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->{$field} = (string) $value;
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
if (!\is_null($xmlResult->info)) {
$item = new Struct\GeneralInfo($xmlResult->info);
$items[] = $item;
}
}
return $items;
}
}

View File

@@ -1,76 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Subdomain as Struct;
class Subdomain extends \PleskX\Api\Operator
{
public function create(array $properties) : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add');
foreach ($properties as $name => $value) {
if (\is_array($value)) {
foreach ($value as $propertyName => $propertyValue) {
$property = $info->addChild($name);
/** @psalm-suppress UndefinedPropertyAssignment */
$property->name = $propertyName;
/** @psalm-suppress UndefinedPropertyAssignment */
$property->value = $propertyValue;
}
continue;
}
$info->{$name} = $value;
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value) : Struct\Info
{
$items = $this->getAll($field, $value);
return \reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info[]
*/
public function getAll($field = null, $value = null) : array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!\is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult || empty($xmlResult->data)) {
continue;
}
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
return $items;
}
}

View File

@@ -1,36 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Ui as Struct;
class Ui extends \PleskX\Api\Operator
{
public function getNavigation() : array
{
$response = $this->request('get-navigation');
/** @psalm-suppress ImplicitToStringCast, PossiblyNullArgument */
return \unserialize(\base64_decode($response->navigation));
}
public function createCustomButton(string $owner, array $properties) : int
{
$packet = $this->client->getPacket();
$buttonNode = $packet->addChild($this->wrapperTag)->addChild('create-custombutton');
$buttonNode->addChild('owner')->addChild($owner);
$propertiesNode = $buttonNode->addChild('properties');
foreach ($properties as $name => $value) {
$propertiesNode->{$name} = $value;
}
$response = $this->client->request($packet);
return (int) $response->id;
}
public function getCustomButton(int $id) : Struct\CustomButton
{
$response = $this->request("get-custombutton.filter.custombutton-id={$id}");
return new Struct\CustomButton($response);
}
public function deleteCustomButton(int $id) : bool
{
return $this->deleteBy('custombutton-id', $id, 'delete-custombutton');
}
}

View File

@@ -1,9 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
class VirtualDirectory extends \PleskX\Api\Operator
{
protected string $wrapperTag = 'virtdir';
}

View File

@@ -1,169 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Operator;
use PleskX\Api\Struct\Webspace as Struct;
class Webspace extends Operator
{
public function getPermissionDescriptor() : Struct\PermissionDescriptor
{
$response = $this->request('get-permission-descriptor.filter');
return new Struct\PermissionDescriptor($response);
}
public function getLimitDescriptor() : Struct\LimitDescriptor
{
$response = $this->request('get-limit-descriptor.filter');
return new Struct\LimitDescriptor($response);
}
public function getPhysicalHostingDescriptor() : Struct\PhysicalHostingDescriptor
{
$response = $this->request('get-physical-hosting-descriptor.filter');
return new Struct\PhysicalHostingDescriptor($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\PhpSettings
*/
public function getPhpSettings(string $field, $value) : Struct\PhpSettings
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$getTag->addChild('filter')->addChild($field, (string) $value);
$getTag->addChild('dataset')->addChild('php-settings');
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
return new Struct\PhpSettings($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Limits
*/
public function getLimits(string $field, $value) : Struct\Limits
{
$items = $this->getItems(Struct\Limits::class, 'limits', $field, $value);
return \reset($items);
}
/**
* @param array $properties
* @param array|null $hostingProperties
* @param string $planName
*
* @return Struct\Info
*/
public function create(array $properties, ?array $hostingProperties = null, string $planName = '') : Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add');
$infoGeneral = $info->addChild('gen_setup');
foreach ($properties as $name => $value) {
if (\is_array($value)) {
continue;
} else {
$infoGeneral->addChild($name, (string) $value);
}
}
if ($hostingProperties) {
$infoHosting = $info->addChild('hosting')->addChild('vrt_hst');
foreach ($hostingProperties as $name => $value) {
$property = $infoHosting->addChild('property');
/** @psalm-suppress UndefinedPropertyAssignment */
$property->name = $name;
/** @psalm-suppress UndefinedPropertyAssignment */
$property->value = $value;
}
if (isset($properties['ip_address'])) {
foreach ((array) $properties['ip_address'] as $ipAddress) {
$infoHosting->addChild('ip_address', $ipAddress);
}
}
}
if ('' !== $planName) {
$info->addChild('plan-name', $planName);
}
$response = $this->client->request($packet);
return new Struct\Info($response, $properties['name'] ?? '');
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value) : bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo
*/
public function get(string $field, $value) : Struct\GeneralInfo
{
$items = $this->getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value);
return \reset($items);
}
/**
* @return Struct\GeneralInfo[]
*/
public function getAll() : array
{
return $this->getItems(Struct\GeneralInfo::class, 'gen_info');
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\DiskUsage
*/
public function getDiskUsage(string $field, $value) : Struct\DiskUsage
{
$items = $this->getItems(Struct\DiskUsage::class, 'disk_usage', $field, $value);
return \reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function enable(string $field, $value) : bool
{
return $this->setProperties($field, $value, ['status' => 0]);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function disable(string $field, $value) : bool
{
return $this->setProperties($field, $value, ['status' => 16]);
}
/**
* @param string $field
* @param int|string $value
* @param array $properties
*
* @return bool
*/
public function setProperties(string $field, $value, array $properties) : bool
{
$packet = $this->client->getPacket();
$setTag = $packet->addChild($this->wrapperTag)->addChild('set');
$setTag->addChild('filter')->addChild($field, (string) $value);
$genInfoTag = $setTag->addChild('values')->addChild('gen_setup');
foreach ($properties as $property => $propertyValue) {
$genInfoTag->addChild($property, (string) $propertyValue);
}
$response = $this->client->request($packet);
return 'ok' === (string) $response->status;
}
}

View File

@@ -1,27 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Certificate;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public ?string $request = null;
public ?string $privateKey = null;
public ?string $publicKey = null;
public ?string $publicKeyCA = null;
public function __construct($input)
{
if ($input instanceof \SimpleXMLElement) {
$this->initScalarProperties($input, [['csr' => 'request'], ['pvt' => 'privateKey']]);
} else {
foreach ($input as $name => $value) {
$this->{$name} = $value;
}
}
}
public function getMapping() : array
{
return \array_filter(['csr' => $this->request, 'pvt' => $this->privateKey, 'cert' => $this->publicKey, 'ca' => $this->publicKeyCA]);
}
}

View File

@@ -1,30 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Customer;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public int $id;
public string $company;
public string $personalName;
public string $login;
public string $guid;
public string $email;
public string $phone;
public string $fax;
public string $address;
public string $postalCode;
public string $city;
public string $state;
public string $country;
public string $description;
public string $externalId;
public bool $enabled;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [['cname' => 'company'], ['pname' => 'personalName'], 'login', 'guid', 'email', 'phone', 'fax', 'address', ['pcode' => 'postalCode'], 'city', 'state', 'country', 'external-id', 'description']);
$this->enabled = '0' === (string) $apiResponse->status;
}
}

View File

@@ -1,15 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Customer;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $guid;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'guid']);
}
}

View File

@@ -1,19 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Database;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $name;
public string $type;
public int $webspaceId;
public int $dbServerId;
public int $defaultUserId;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'name', 'type', 'webspace-id', 'db-server-id', 'default-user-id']);
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Database;
use PleskX\Api\AbstractStruct;
class UserInfo extends AbstractStruct
{
public int $id;
public string $login;
public int $dbId;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'login', 'db-id']);
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\DatabaseServer;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $host;
public int $port;
public string $type;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'host', 'port', 'type']);
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Dns;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public int $siteId;
public int $siteAliasId;
public string $type;
public string $host;
public string $value;
public string $opt;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'site-id', 'site-alias-id', 'type', 'host', 'value', 'opt']);
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\EventLog;
use PleskX\Api\AbstractStruct;
class DetailedEvent extends AbstractStruct
{
public int $id;
public string $type;
public int $time;
public string $class;
public string $objectId;
public string $user;
public string $host;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'type', 'time', 'class', ['obj_id' => 'objectId'], 'user', 'host']);
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\EventLog;
use PleskX\Api\AbstractStruct;
class Event extends AbstractStruct
{
public string $type;
public int $time;
public string $class;
public string $id;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['type', 'time', 'class', 'id']);
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Ip;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $ipAddress;
public string $netmask;
public string $type;
public string $interface;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['ip_address', 'netmask', 'type', 'interface']);
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Locale;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $id;
public string $language;
public string $country;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', ['lang' => 'language'], 'country']);
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Mail;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public int $id;
public string $name;
public string $description;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'name', 'description']);
}
}

View File

@@ -1,15 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Mail;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $name;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'name']);
}
}

View File

@@ -1,23 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\PhpHandler;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $id;
public string $displayName;
public string $fullVersion;
public string $version;
public string $type;
public string $path;
public string $clipath;
public string $phpini;
public string $custom;
public string $handlerStatus;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'display-name', 'full-version', 'version', 'type', 'path', 'clipath', 'phpini', 'custom', 'handler-status']);
}
}

View File

@@ -1,15 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\ProtectedDirectory;
use PleskX\Api\AbstractStruct;
class DataInfo extends AbstractStruct
{
public string $name;
public string $header;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['name', 'header']);
}
}

View File

@@ -1,14 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\ProtectedDirectory;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id']);
}
}

View File

@@ -1,14 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\ProtectedDirectory;
use PleskX\Api\AbstractStruct;
class UserInfo extends AbstractStruct
{
public int $id;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id']);
}
}

View File

@@ -1,23 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Reseller;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public int $id;
public string $personalName;
public string $login;
public array $permissions;
public function __construct(\SimpleXMLElement $apiResponse)
{
if (!\is_null($apiResponse->{'gen-info'})) {
$this->initScalarProperties($apiResponse->{'gen-info'}, [['pname' => 'personalName'], 'login']);
}
$this->permissions = [];
foreach ($apiResponse->permissions->permission ?? [] as $permissionInfo) {
$this->permissions[(string) $permissionInfo->name] = (string) $permissionInfo->value;
}
}
}

View File

@@ -1,15 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Reseller;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $guid;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'guid']);
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\SecretKey;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $key;
public string $ipAddress;
public string $description;
public string $login;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['key', 'ip_address', 'description', 'login']);
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class Admin extends AbstractStruct
{
public string $companyName;
public string $name;
public string $email;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [['admin_cname' => 'companyName'], ['admin_pname' => 'name'], ['admin_email' => 'email']]);
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public string $serverName;
public string $serverGuid;
public string $mode;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['server_name', 'server_guid', 'mode']);
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class Preferences extends AbstractStruct
{
public int $statTtl;
public int $trafficAccounting;
public int $restartApacheInterval;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['stat_ttl', 'traffic_accounting', 'restart_apache_interval']);
}
}

View File

@@ -1,14 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class SessionPreferences extends AbstractStruct
{
public int $loginTimeout;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['login_timeout']);
}
}

View File

@@ -1,40 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class Statistics extends AbstractStruct
{
/** @var Statistics\Objects */
public $objects;
/** @var Statistics\Version */
public $version;
/** @var Statistics\Other */
public $other;
/** @var Statistics\LoadAverage */
public $loadAverage;
/** @var Statistics\Memory */
public $memory;
/** @var Statistics\Swap */
public $swap;
/** @var Statistics\DiskSpace[] */
public $diskSpace;
/**
* @param \SimpleXMLElement $apiResponse
* @psalm-suppress PossiblyNullArgument
*/
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->objects = new \PleskX\Api\Struct\Server\Statistics\Objects($apiResponse->objects);
$this->version = new \PleskX\Api\Struct\Server\Statistics\Version($apiResponse->version);
$this->other = new \PleskX\Api\Struct\Server\Statistics\Other($apiResponse->other);
$this->loadAverage = new \PleskX\Api\Struct\Server\Statistics\LoadAverage($apiResponse->load_avg);
$this->memory = new \PleskX\Api\Struct\Server\Statistics\Memory($apiResponse->mem);
$this->swap = new \PleskX\Api\Struct\Server\Statistics\Swap($apiResponse->swap);
$this->diskSpace = [];
foreach ($apiResponse->diskspace ?? [] as $disk) {
$this->diskSpace[(string) $disk->device->name] = new \PleskX\Api\Struct\Server\Statistics\DiskSpace($disk->device);
}
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class DiskSpace extends AbstractStruct
{
public int $total;
public int $used;
public int $free;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['total', 'used', 'free']);
}
}

View File

@@ -1,18 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class LoadAverage extends AbstractStruct
{
public float $load1min;
public float $load5min;
public float $load15min;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->load1min = (float) $apiResponse->l1 / 100.0;
$this->load5min = (float) $apiResponse->l5 / 100.0;
$this->load15min = (float) $apiResponse->l15 / 100.0;
}
}

View File

@@ -1,19 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class Memory extends AbstractStruct
{
public int $total;
public int $used;
public int $free;
public int $shared;
public int $buffer;
public int $cached;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['total', 'used', 'free', 'shared', 'buffer', 'cached']);
}
}

View File

@@ -1,24 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class Objects extends AbstractStruct
{
public int $clients;
public int $domains;
public int $databases;
public int $activeDomains;
public int $mailBoxes;
public int $mailRedirects;
public int $mailGroups;
public int $mailResponders;
public int $databaseUsers;
public int $problemClients;
public int $problemDomains;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['clients', 'domains', 'databases', ['active_domains' => 'activeDomains'], ['mail_boxes' => 'mailBoxes'], ['mail_redirects' => 'mailRedirects'], ['mail_groups' => 'mailGroups'], ['mail_responders' => 'mailResponders'], ['database_users' => 'databaseUsers'], ['problem_clients' => 'problemClients'], ['problem_domains' => 'problemDomains']]);
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class Other extends AbstractStruct
{
public string $cpu;
public int $uptime;
public bool $insideVz;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['cpu', 'uptime', ['inside_vz' => 'insideVz']]);
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class Swap extends AbstractStruct
{
public int $total;
public int $used;
public int $free;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['total', 'used', 'free']);
}
}

View File

@@ -1,19 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class Version extends AbstractStruct
{
public string $internalName;
public string $version;
public string $build;
public string $osName;
public string $osVersion;
public string $osRelease;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [['plesk_name' => 'internalName'], ['plesk_version' => 'version'], ['plesk_build' => 'build'], ['plesk_os' => 'osName'], ['plesk_os_version' => 'osVersion'], ['os_release' => 'osRelease']]);
}
}

View File

@@ -1,15 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class UpdatesInfo extends AbstractStruct
{
public string $lastInstalledUpdate;
public bool $installUpdatesAutomatically;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['last_installed_update', 'install_updates_automatically']);
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\ServicePlan;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $name;
public string $guid;
public string $externalId;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'name', 'guid', 'external-id']);
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\ServicePlanAddon;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $name;
public string $guid;
public string $externalId;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'name', 'guid', 'external-id']);
}
}

View File

@@ -1,19 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Session;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $id;
public string $type;
public string $ipAddress;
public string $login;
public string $loginTime;
public string $idle;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'type', 'ip-address', 'login', 'login-time', 'idle']);
}
}

View File

@@ -1,27 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Site;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public int $id;
public string $creationDate;
public string $name;
public string $asciiName;
public string $guid;
public string $status;
public int $realSize;
public array $ipAddresses = [];
public string $description;
public string $webspaceGuid;
public int $webspaceId;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [['cr_date' => 'creationDate'], 'name', 'ascii-name', 'status', 'real_size', 'guid', 'description', 'webspace-guid', 'webspace-id']);
foreach ($apiResponse->dns_ip_address ?? [] as $ip) {
$this->ipAddresses[] = (string) $ip;
}
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Site;
use PleskX\Api\AbstractStruct;
class HostingInfo extends AbstractStruct
{
public array $properties = [];
public string $ipAddress;
public function __construct(\SimpleXMLElement $apiResponse)
{
foreach ($apiResponse->vrt_hst->property ?? [] as $property) {
$this->properties[(string) $property->name] = (string) $property->value;
}
if (!\is_null($apiResponse->vrt_hst)) {
$this->initScalarProperties($apiResponse->vrt_hst, ['ip_address']);
}
}
}

View File

@@ -1,15 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Site;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $guid;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'guid']);
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\SiteAlias;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public string $name;
public string $asciiName;
public string $status;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['name', 'ascii-name', 'status']);
}
}

View File

@@ -1,15 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\SiteAlias;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $status;
public int $id;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id', 'status']);
}
}

View File

@@ -1,21 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Subdomain;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $parent;
public string $name;
public array $properties;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->properties = [];
$this->initScalarProperties($apiResponse, ['id', 'parent', 'name']);
foreach ($apiResponse->property ?? [] as $propertyInfo) {
$this->properties[(string) $propertyInfo->name] = (string) $propertyInfo->value;
}
}
}

View File

@@ -1,24 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Ui;
use PleskX\Api\AbstractStruct;
class CustomButton extends AbstractStruct
{
public int $id;
public int $sortKey;
public bool $public;
public bool $internal;
public bool $noFrame;
public string $place;
public string $url;
public string $text;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id']);
if (!\is_null($apiResponse->properties)) {
$this->initScalarProperties($apiResponse->properties, ['sort_key', 'public', 'internal', ['noframe' => 'noFrame'], 'place', 'url', 'text']);
}
}
}

View File

@@ -1,24 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class DiskUsage extends AbstractStruct
{
public int $httpdocs;
public int $httpsdocs;
public int $subdomains;
public int $anonftp;
public int $logs;
public int $dbases;
public int $mailboxes;
public int $maillists;
public int $domaindumps;
public int $configs;
public int $chroot;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['httpdocs', 'httpsdocs', 'subdomains', 'anonftp', 'logs', 'dbases', 'mailboxes', 'maillists', 'domaindumps', 'configs', 'chroot']);
}
}

View File

@@ -1,30 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public int $id;
public string $creationDate;
public string $name;
public string $asciiName;
public string $status;
public int $realSize;
public int $ownerId;
public array $ipAddresses = [];
public string $guid;
public string $vendorGuid;
public string $description;
public string $adminDescription;
public bool $enabled;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [['cr_date' => 'creationDate'], 'name', 'ascii-name', 'status', 'real_size', 'owner-id', 'guid', 'vendor-guid', 'description', 'admin-description']);
foreach ($apiResponse->dns_ip_address ?? [] as $ip) {
$this->ipAddresses[] = (string) $ip;
}
$this->enabled = '0' === (string) $apiResponse->status;
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class HostingPropertyInfo extends AbstractStruct
{
public string $name;
public string $type;
public string $label;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['name', 'type', 'label']);
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $guid;
public string $name;
public function __construct(\SimpleXMLElement $apiResponse, string $name = '')
{
$this->initScalarProperties($apiResponse, ['id', 'guid']);
$this->name = $name;
}
}

View File

@@ -1,15 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class Limit extends AbstractStruct
{
public string $name;
public string $value;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['name', 'value']);
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class LimitDescriptor extends AbstractStruct
{
public array $limits;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->limits = [];
foreach ($apiResponse->descriptor->property ?? [] as $propertyInfo) {
$this->limits[(string) $propertyInfo->name] = new \PleskX\Api\Struct\Webspace\LimitInfo($propertyInfo);
}
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class LimitInfo extends AbstractStruct
{
public string $name;
public string $type;
public string $label;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['name', 'type', 'label']);
}
}

View File

@@ -1,19 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class Limits extends AbstractStruct
{
public string $overuse;
public array $limits;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['overuse']);
$this->limits = [];
foreach ($apiResponse->limit ?? [] as $limit) {
$this->limits[(string) $limit->name] = new \PleskX\Api\Struct\Webspace\Limit($limit);
}
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class PermissionDescriptor extends AbstractStruct
{
public array $permissions;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->permissions = [];
foreach ($apiResponse->descriptor->property ?? [] as $propertyInfo) {
$this->permissions[(string) $propertyInfo->name] = new \PleskX\Api\Struct\Webspace\PermissionInfo($propertyInfo);
}
}
}

View File

@@ -1,16 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class PermissionInfo extends AbstractStruct
{
public string $name;
public string $type;
public string $label;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['name', 'type', 'label']);
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class PhpSettings extends AbstractStruct
{
public array $properties;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->properties = [];
foreach ($apiResponse->webspace->get->result->data->{'php-settings'}->setting ?? [] as $setting) {
$this->properties[(string) $setting->name] = (string) $setting->value;
}
}
}

View File

@@ -1,17 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class PhysicalHostingDescriptor extends AbstractStruct
{
public array $properties;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->properties = [];
foreach ($apiResponse->descriptor->property ?? [] as $propertyInfo) {
$this->properties[(string) $propertyInfo->name] = new \PleskX\Api\Struct\Webspace\HostingPropertyInfo($propertyInfo);
}
}
}

View File

@@ -1,26 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
/**
* XML wrapper for responses.
*/
class XmlResponse extends \SimpleXMLElement
{
/**
* Retrieve value by node name.
*
* @param string $node
*
* @return string
*/
public function getValue(string $node) : string
{
$result = $this->xpath('//' . $node);
if (\is_array($result) && isset($result[0])) {
return (string) $result[0];
}
return '';
}
}

View File

@@ -1,16 +0,0 @@
#!/bin/bash
### Copyright 1999-2025. WebPros International GmbH.
COUNTER=1
while : ; do
curl -ksL https://plesk:8443/ | grep "<title>Plesk" > /dev/null
[ $? -eq 0 ] && break
echo "($COUNTER) Waiting for the Plesk initialization..."
sleep 5
COUNTER=$((COUNTER + 1))
if [ $COUNTER -eq 60 ]; then
echo "Too long, interrupting..."
break
fi
done

View File

@@ -1,3 +0,0 @@
Simple upgrader
This library provides simple implementation db migrations.

View File

@@ -1,8 +0,0 @@
<?php
// Copyright 1999-2017. Parallels IP Holdings GmbH. All Rights Reserved.
namespace PleskExt\Upgrader;
class Exception extends \Exception
{
}

View File

@@ -1,56 +0,0 @@
<?php
// Copyright 1999-2022. Parallels IP Holdings GmbH. All Rights Reserved.
namespace PleskExt\Upgrader;
class Migration
{
/**
* @var string[] list of SQL queries to upgrade database
*/
private $_queries = [];
/**
* @var string
*/
private $_version;
/**
* @var string
*/
private $_name;
public function __construct($migrationFileFullPath)
{
$migration = \file_get_contents($migrationFileFullPath);
$migration = \preg_replace('/^--.*$/m', '', $migration);
$this->_queries = \array_filter(\array_map('trim', \explode(';', \str_replace(["\n", "\r"], '', $migration))));
$migrationFileName = \basename($migrationFileFullPath);
$firstDashPosition = \strpos($migrationFileName, '_');
$this->_version = \substr($migrationFileName, 0, $firstDashPosition);
$nameWithoutVersion = \substr(\basename($migrationFileName, '.sql'), $firstDashPosition + 1);
$this->_name = static::fromCamelCase(\preg_replace('/_+/', ' ', $nameWithoutVersion));
}
/**
* Converts camelCase string to have spaces between each.
* @param $camelCaseString
* @param string $glue
*
* @return string
*/
public static function fromCamelCase($camelCaseString, $glue = ' ')
{
return \join($glue, \preg_split('/(?<=[a-z])(?=[A-Z])/x', $camelCaseString));
}
public function run(\Zend_Db_Adapter_Abstract $dbAdapter)
{
try {
$dbAdapter->beginTransaction();
foreach ($this->_queries as $query) {
$dbAdapter->query($query);
}
$dbAdapter->commit();
(new \PleskExt\Upgrader\Versions(['db' => $dbAdapter]))->setDbVersion($this->_version);
} catch (\Zend_Db_Exception $e) {
$dbAdapter->rollBack();
throw new \PleskExt\Upgrader\Exception($e->getMessage());
}
}
}

View File

@@ -1,58 +0,0 @@
<?php
// Copyright 1999-2017. Parallels IP Holdings GmbH. All Rights Reserved.
namespace PleskExt\Upgrader;
class MigrationManager
{
/** @var null|\Zend_Db_Adapter_Abstract */
private $_dbAdapter = null;
private $_migrationsDir = null;
public function __construct(\Zend_Db_Adapter_Abstract $dbAdapter, $migrationsDir = null)
{
$this->_dbAdapter = $dbAdapter;
$this->_migrationsDir = $migrationsDir ?: __DIR__ . \DIRECTORY_SEPARATOR;
}
public function initSchema()
{
$initSchema = \file_get_contents($this->_migrationsDir . \DIRECTORY_SEPARATOR . 'init_schema.sql');
$initSchema = \preg_replace('/^--.*$/m', '', $initSchema);
$queries = \array_map('trim', \explode(';', \str_replace(["\n", "\r"], '', $initSchema)));
foreach ($queries as $query) {
if (empty($query)) {
continue;
}
$this->_dbAdapter->query($query);
}
}
public function applyMigrations()
{
foreach ($this->loadMigrations($this->_getCurrentDbVersion()) as $migrationFile) {
$migration = new \PleskExt\Upgrader\Migration($migrationFile);
$migration->run($this->_dbAdapter);
}
}
public function loadMigrations($currentDbVersion)
{
$migrationsToApply = [];
$migrations = \glob($this->_migrationsDir . "//*.sql");
foreach ($migrations as $migrationFile) {
if (\false !== \strpos($migrationFile, 'init_schema.sql')) {
continue;
}
if ($this->getDbVersionByMigration(\basename($migrationFile)) <= $currentDbVersion) {
continue;
}
$migrationsToApply[] = $migrationFile;
}
return $migrationsToApply;
}
public function getDbVersionByMigration($migration)
{
return \substr($migration, 0, \strpos($migration, '_'));
}
private function _getCurrentDbVersion()
{
return (new \PleskExt\Upgrader\Versions(['db' => $this->_dbAdapter]))->getDbVersion();
}
}

View File

@@ -1,6 +0,0 @@
-- Copyright 1999-2017. Parallels IP Holdings GmbH. All Rights Reserved.
CREATE TABLE IF NOT EXISTS `version` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`dbVersion` TEXT NOT NULL
);
INSERT INTO `version` (`dbVersion`) VALUES ('200000000000');

View File

@@ -1,6 +0,0 @@
-- Copyright 1999-2017. Parallels IP Holdings GmbH. All Rights Reserved.
CREATE TABLE IF NOT EXISTS `version` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`dbVersion` TEXT NOT NULL
);
INSERT INTO `version` (`dbVersion`) VALUES ('201605071200');

View File

@@ -1,30 +0,0 @@
<?php
// Copyright 1999-2017. Parallels IP Holdings GmbH. All Rights Reserved.
namespace PleskExt\Upgrader;
/**
* Broker for versions table.
*/
class Versions extends \Zend_Db_Table_Abstract
{
protected $_name = 'version';
public function getDbVersion()
{
if (!$this->exists()) {
return '0';
}
return $this->fetchAll()->current()->dbVersion;
}
public function setDbVersion($version)
{
/** @var \Zend_Db_Table_Row_Abstract $row */
$row = $this->fetchAll()->current();
$row->dbVersion = $version;
$row->save();
}
public function exists()
{
return !empty($this->getAdapter()->describeTable('version'));
}
}