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,8 +0,0 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "TECH "

View File

@@ -1,13 +0,0 @@
name: test
on: [push]
jobs:
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: docker compose run tests
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

View File

@@ -1,5 +0,0 @@
/.env
/vendor/
/phpunit.xml
/.phpunit.result.cache
/coverage.xml

View File

@@ -1,9 +0,0 @@
FROM php:8.2-cli
RUN apt-get update \
&& apt-get install -y unzip \
&& docker-php-ext-install pcntl \
&& pecl install xdebug \
&& echo "zend_extension=xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

View File

@@ -1,13 +0,0 @@
Copyright 1999-2025. WebPros International GmbH.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -1,67 +0,0 @@
## PHP library for Plesk XML-RPC API
[![Test Status](https://github.com/plesk/api-php-lib/actions/workflows/test.yml/badge.svg)](https://github.com/plesk/api-php-lib/actions/workflows/test.yml)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/plesk/api-php-lib/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/plesk/api-php-lib/?branch=master)
[![codecov](https://codecov.io/gh/plesk/api-php-lib/branch/master/graph/badge.svg?token=5Kwbddpdeb)](https://codecov.io/gh/plesk/api-php-lib)
PHP object-oriented library for Plesk XML-RPC API.
## Install Via Composer
[Composer](https://getcomposer.org/) is a preferable way to install the library:
`composer require plesk/api-php-lib`
## Usage Examples
Here is an example on how to use the library and create a customer with desired properties:
```php
$client = new \PleskX\Api\Client($host);
$client->setCredentials($login, $password);
$client->customer()->create([
'cname' => 'Plesk',
'pname' => 'John Smith',
'login' => 'john',
'passwd' => 'secret',
'email' => 'john@smith.com',
]);
```
It is possible to use a secret key instead of password for authentication.
```php
$client = new \PleskX\Api\Client($host);
$client->setSecretKey($secretKey)
```
In case of Plesk extension creation one can use an internal mechanism to access XML-RPC API. It does not require to pass authentication because the extension works in the context of Plesk.
```php
$client = new \PleskX\Api\InternalClient();
$protocols = $client->server()->getProtos();
```
For additional examples see tests/ directory.
## How to Run Unit Tests
One the possible ways to become familiar with the library is to check the unit tests.
To run the unit tests use the following command:
`REMOTE_HOST=your-plesk-host.dom REMOTE_PASSWORD=password composer test`
To use custom port one can provide a URL (e.g. for Docker container):
`REMOTE_URL=https://your-plesk-host.dom:port REMOTE_PASSWORD=password composer test`
One more way to run tests is to use Docker:
`docker-compose run tests`
## Continuous Testing
During active development it could be more convenient to run tests in continuous manner. Here is the way how to achieve it:
`REMOTE_URL=https://your-plesk-host.dom:port REMOTE_PASSWORD=password composer test:watch`

View File

@@ -1,58 +0,0 @@
{
"name": "plesk/api-php-lib",
"type": "library",
"description": "PHP object-oriented library for Plesk XML-RPC API",
"license": "Apache-2.0",
"authors": [
{
"name": "Alexei Yuzhakov",
"email": "sibprogrammer@gmail.com"
},
{
"name": "WebPros International GmbH.",
"email": "plesk-dev-leads@plesk.com"
}
],
"require": {
"php": "^7.4 || ^8.0",
"ext-curl": "*",
"ext-xml": "*",
"ext-simplexml": "*",
"ext-dom": "*"
},
"require-dev": {
"phpunit/phpunit": "^9",
"spatie/phpunit-watcher": "^1.22",
"vimeo/psalm": "^4.10 || ^5.0",
"squizlabs/php_codesniffer": "^3.6"
},
"config": {
"process-timeout": 0,
"platform": {
"php": "7.4.27"
}
},
"scripts": {
"test": "phpunit",
"test:watch": "phpunit-watcher watch",
"lint": [
"psalm",
"phpcs"
]
},
"autoload": {
"psr-4": {
"PleskX\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"PleskXTest\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
}

File diff suppressed because it is too large Load Diff

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,28 +0,0 @@
<?xml version="1.0"?>
<!-- Copyright 1999-2025. WebPros International GmbH. -->
<ruleset name="PHP library for Plesk XML-RPC API">
<file>src</file>
<file>tests</file>
<rule ref="Generic">
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
<exclude name="Generic.Files.EndFileNoNewline"/>
<exclude name="Generic.Files.LowercasedFilename.NotFound"/>
<exclude name="Generic.PHP.RequireStrictTypes"/>
<exclude name="Generic.PHP.ClosingPHPTag"/>
<exclude name="Generic.PHP.UpperCaseConstant"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="Generic.Classes.OpeningBraceSameLine"/>
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
<exclude name="Generic.Formatting.MultipleStatementAlignment"/>
<exclude name="Generic.Formatting.NoSpaceAfterCast"/>
<exclude name="Generic.Formatting.SpaceBeforeCast"/>
<exclude name="Generic.Formatting.SpaceAfterNot"/>
<exclude name="Generic.Commenting.DocComment"/>
<exclude name="Generic.ControlStructures.DisallowYodaConditions"/>
</rule>
<rule ref="PSR1"/>
<rule ref="PSR2"/>
<rule ref="PSR12">
<exclude name="PSR12.Files.FileHeader"/>
</rule>
</ruleset>

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" encoding="UTF-8"?>
<!-- Copyright 1999-2025. WebPros International GmbH. -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" verbose="true" colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<clover outputFile="coverage.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="E2E">
<directory>./tests</directory>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="-1"/>
<env name="REMOTE_URL" value=""/>
<env name="REMOTE_PASSWORD" value=""/>
</php>
<logging/>
</phpunit>

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,76 +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,577 +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): 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 XmlResponse($result ? (string) $result->asXML() : '');
}
private function performSdkCall(string $request): 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 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 Client\Exception(curl_error($curl), curl_errno($curl));
}
curl_close($curl);
return new 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 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 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 Client\Exception('Multi requests are not supported via SDK.');
} else {
$xmlString = $requestXml->asXML();
if (!$xmlString) {
throw new Client\Exception('Failed to create an XML string for request');
}
$responseXml = $this->performHttpRequest($xmlString);
}
return $this->splitResponseToArray($responseXml, $mode);
}
private function splitResponseToArray(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 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 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(): Operator\Server
{
return $this->getOperator('Server');
}
public function customer(): Operator\Customer
{
return $this->getOperator('Customer');
}
public function webspace(): Operator\Webspace
{
return $this->getOperator('Webspace');
}
public function subdomain(): Operator\Subdomain
{
return $this->getOperator('Subdomain');
}
public function dns(): Operator\Dns
{
return $this->getOperator('Dns');
}
public function dnsTemplate(): Operator\DnsTemplate
{
return $this->getOperator('DnsTemplate');
}
public function databaseServer(): Operator\DatabaseServer
{
return $this->getOperator('DatabaseServer');
}
public function mail(): Operator\Mail
{
return $this->getOperator('Mail');
}
public function certificate(): Operator\Certificate
{
return $this->getOperator('Certificate');
}
public function siteAlias(): Operator\SiteAlias
{
return $this->getOperator('SiteAlias');
}
public function ip(): Operator\Ip
{
return $this->getOperator('Ip');
}
public function eventLog(): Operator\EventLog
{
return $this->getOperator('EventLog');
}
public function secretKey(): Operator\SecretKey
{
return $this->getOperator('SecretKey');
}
public function ui(): Operator\Ui
{
return $this->getOperator('Ui');
}
public function servicePlan(): Operator\ServicePlan
{
return $this->getOperator('ServicePlan');
}
public function virtualDirectory(): Operator\VirtualDirectory
{
return $this->getOperator('VirtualDirectory');
}
public function database(): Operator\Database
{
return $this->getOperator('Database');
}
public function session(): Operator\Session
{
return $this->getOperator('Session');
}
public function locale(): Operator\Locale
{
return $this->getOperator('Locale');
}
public function logRotation(): Operator\LogRotation
{
return $this->getOperator('LogRotation');
}
public function protectedDirectory(): Operator\ProtectedDirectory
{
return $this->getOperator('ProtectedDirectory');
}
public function reseller(): Operator\Reseller
{
return $this->getOperator('Reseller');
}
public function resellerPlan(): Operator\ResellerPlan
{
return $this->getOperator('ResellerPlan');
}
public function aps(): Operator\Aps
{
return $this->getOperator('Aps');
}
public function servicePlanAddon(): Operator\ServicePlanAddon
{
return $this->getOperator('ServicePlanAddon');
}
public function site(): Operator\Site
{
return $this->getOperator('Site');
}
public function phpHandler(): 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,25 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
/**
* Internal client for Plesk XML-RPC API (via SDK).
*/
class InternalClient extends 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,106 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
class Operator
{
protected string $wrapperTag = '';
protected Client $client;
public function __construct(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 = Client::RESPONSE_SHORT): 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,87 +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,99 +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,149 +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,85 +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,132 +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,93 +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,46 +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,26 +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,35 +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,91 +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,62 +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,118 +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,83 +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,77 +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,143 +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,77 +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,77 +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,47 +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,94 +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,85 +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,88 +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,45 +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,199 +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,38 +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,48 +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,20 +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,28 +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,22 +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,24 +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,30 +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,30 +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,24 +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,24 +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,22 +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,22 +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,20 +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,36 +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,20 +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,18 +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,18 +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,29 +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,20 +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,24 +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,22 +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,22 +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,22 +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,18 +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,49 +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 Statistics\Objects($apiResponse->objects);
$this->version = new Statistics\Version($apiResponse->version);
$this->other = new Statistics\Other($apiResponse->other);
$this->loadAverage = new Statistics\LoadAverage($apiResponse->load_avg);
$this->memory = new Statistics\Memory($apiResponse->mem);
$this->swap = new Statistics\Swap($apiResponse->swap);
$this->diskSpace = [];
foreach ($apiResponse->diskspace ?? [] as $disk) {
$this->diskSpace[(string) $disk->device->name] = new Statistics\DiskSpace($disk->device);
}
}
}

View File

@@ -1,22 +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,20 +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,28 +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,38 +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,22 +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,22 +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,28 +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,20 +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,24 +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,24 +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,28 +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,40 +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,25 +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,20 +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,22 +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,20 +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,27 +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,35 +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,38 +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,45 +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,22 +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,22 +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,20 +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,20 +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 LimitInfo($propertyInfo);
}
}
}

View File

@@ -1,22 +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,22 +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 Limit($limit);
}
}
}

View File

@@ -1,20 +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 PermissionInfo($propertyInfo);
}
}
}

View File

@@ -1,22 +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,20 +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;
}
}
}

Some files were not shown because too many files have changed in this diff Show More