From 6ac405abbae4b5e457bfd83b9c6e10c010a13208 Mon Sep 17 00:00:00 2001 From: Emanuele Menon Date: Tue, 14 Nov 2017 09:56:22 +0100 Subject: [PATCH 01/40] Added Certificate install command --- .gitignore | 1 + src/PleskX/Api/Operator/Certificate.php | 27 +++++++++++++++++++ .../Api/Struct/Certificate/InstallInfo.php | 17 ++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 src/PleskX/Api/Struct/Certificate/InstallInfo.php diff --git a/.gitignore b/.gitignore index 17c52938..ce35af7d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /php/tests/node_modules /vendor /phpunit.xml +.idea diff --git a/src/PleskX/Api/Operator/Certificate.php b/src/PleskX/Api/Operator/Certificate.php index 1284662e..2db85624 100644 --- a/src/PleskX/Api/Operator/Certificate.php +++ b/src/PleskX/Api/Operator/Certificate.php @@ -24,4 +24,31 @@ public function generate($properties) return new Struct\Info($response); } + + /** + * @param $properties + * @return Struct\InstallInfo + */ + public function install($properties) + { + $packet = $this->_client->getPacket(); + $install = $packet->addChild($this->_wrapperTag)->addChild('install'); + + foreach ($properties as $name => $value) { + if ($name == 'content') { + $content = $install->addChild('content'); + + foreach ($value as $contentKey => $contentValue) { + $content->addChild($contentKey, $contentValue); + } + + continue; + } + + $install->addChild($name, $value); + } + + $response = $this->_client->request($packet); + return new Struct\InstallInfo($response); + } } diff --git a/src/PleskX/Api/Struct/Certificate/InstallInfo.php b/src/PleskX/Api/Struct/Certificate/InstallInfo.php new file mode 100644 index 00000000..b2102a96 --- /dev/null +++ b/src/PleskX/Api/Struct/Certificate/InstallInfo.php @@ -0,0 +1,17 @@ +_initScalarProperties($apiResponse, [ + 'status', + ]); + } +} \ No newline at end of file From 1d29f7a270fe6b0856958d7052cddb3ee96a78f7 Mon Sep 17 00:00:00 2001 From: Emanuele Menon Date: Tue, 14 Nov 2017 10:11:58 +0100 Subject: [PATCH 02/40] Updated package name --- composer.json | 6 +++++- package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c651082e..e9976f80 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,15 @@ { - "name": "plesk/api-php-lib", + "name": "ShellrentSrl/api-php-lib", "description": "PHP object-oriented library for Plesk XML-RPC API", "license": "Apache-2.0", "authors": [ { "name": "Alexei Yuzhakov", "email": "sibprogrammer@gmail.com" + }, + { + "name": "Emanuele Menon", + "email": "emnlmn@gmail.com" } ], "minimum-stability": "dev", diff --git a/package.json b/package.json index 09527116..a9da5275 100644 --- a/package.json +++ b/package.json @@ -6,4 +6,4 @@ "grunt-contrib-watch": "~0.6.1", "grunt-phpunit": "~0.3.5" } -} +} \ No newline at end of file From fc3c89c712596820fae43f4a771ca439a8f15bdc Mon Sep 17 00:00:00 2001 From: Emanuele Menon Date: Tue, 14 Nov 2017 10:28:19 +0100 Subject: [PATCH 03/40] updated readme --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a45784e0..ea0c2980 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,16 @@ PHP object-oriented library for Plesk XML-RPC API. [Composer](https://getcomposer.org/) is a preferable way to install the library: -`composer require plesk/api-php-lib:@dev` +``` +"repositories": [ + { + "type": "vcs", + "url": "https://github.com/emnlmn/plesk-php-api" + } +], +``` + +`composer require ShellrentSrl/api-php-lib:@dev` ## Usage Examples From c8ecd484f35d2585ef80978986b5d6ea49102bd4 Mon Sep 17 00:00:00 2001 From: Emanuele Menon Date: Tue, 14 Nov 2017 10:31:39 +0100 Subject: [PATCH 04/40] Changed ssh over http git repository link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea0c2980..e2343a73 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ PHP object-oriented library for Plesk XML-RPC API. "repositories": [ { "type": "vcs", - "url": "https://github.com/emnlmn/plesk-php-api" + "url": "git@github.com:ShellrentSrl/api-php-lib.git" } ], ``` From 7bf3e56df8c384204cb351b8a7c7d3e7200f3f54 Mon Sep 17 00:00:00 2001 From: Emanuele Menon Date: Mon, 27 Nov 2017 10:28:46 +0100 Subject: [PATCH 05/40] Fixed bug in client --- src/PleskX/Api/Client.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/PleskX/Api/Client.php b/src/PleskX/Api/Client.php index 1f161fd3..5ba9a9cc 100644 --- a/src/PleskX/Api/Client.php +++ b/src/PleskX/Api/Client.php @@ -327,8 +327,12 @@ protected function _expandRequestShortSyntax($request, SimpleXMLElement $xml) $node = $xml; foreach ($parts as $part) { - @list($name, $value) = explode('=', $part); - $node = $node->addChild($name, $value); + if ( strpos( $part, '=') !== false ) { + $node = $node->addChild($part); + } else { + list($name, $value) = explode('=', $part); + $node = $node->addChild($name, $value); + } } return $xml->asXML(); From 54835f60d4c8736aaebf4b4e73da7d2af3ea2bf1 Mon Sep 17 00:00:00 2001 From: Emanuele Menon Date: Mon, 27 Nov 2017 10:30:43 +0100 Subject: [PATCH 06/40] Fix bugfix --- src/PleskX/Api/Client.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PleskX/Api/Client.php b/src/PleskX/Api/Client.php index 5ba9a9cc..ef703066 100644 --- a/src/PleskX/Api/Client.php +++ b/src/PleskX/Api/Client.php @@ -328,10 +328,10 @@ protected function _expandRequestShortSyntax($request, SimpleXMLElement $xml) foreach ($parts as $part) { if ( strpos( $part, '=') !== false ) { - $node = $node->addChild($part); - } else { list($name, $value) = explode('=', $part); $node = $node->addChild($name, $value); + } else { + $node = $node->addChild($part); } } From 201cd1af02fae833c9385fadb36794e2261b1e3f Mon Sep 17 00:00:00 2001 From: Emanuele Menon Date: Mon, 27 Nov 2017 11:59:40 +0100 Subject: [PATCH 07/40] added set status in webspace --- src/PleskX/Api/Operator/Webspace.php | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/PleskX/Api/Operator/Webspace.php b/src/PleskX/Api/Operator/Webspace.php index e7766e53..e96e452c 100644 --- a/src/PleskX/Api/Operator/Webspace.php +++ b/src/PleskX/Api/Operator/Webspace.php @@ -62,6 +62,37 @@ public function create(array $properties, array $hostingProperties = null, $plan return new Struct\Info($response); } + /** + * Imposta lo stato di sospensione al webhosting + * @param array $filters + * @param int $status + * @return bool + */ + public function setStatus( array $filters, $status ) { + $packet = $this->_client->getPacket(); + $setterTag = $packet->addChild( $this->_wrapperTag )->addChild( 'set' ); + if ( !empty( $filters ) ) { + $filterTag = $setterTag->addChild( 'filter' ); + foreach ( $filters as $key => $value ) { + $filterTag->addChild( $key, $value ); + } + } + $valuesTag = $setterTag->addChild( 'values' ); + $valuesTag->addChild( 'gen_setup' )->addChild( 'status', $status ); + $response = $this->_client->request( $packet ); + + return 'ok' === (string)$response->status; + } + + /** + * @param string $field + * @param integer|string $value + * @return bool + */ + public function delete( $field, $value ) { + return $this->_delete( $field, $value ); + } + /** * @param string $field * @param integer|string $value From b8861b688d9c104ee233c5f8455250450c3fb28f Mon Sep 17 00:00:00 2001 From: Emanuele Menon Date: Mon, 27 Nov 2017 12:02:09 +0100 Subject: [PATCH 08/40] Removed duplicated function --- src/PleskX/Api/Operator/Webspace.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/PleskX/Api/Operator/Webspace.php b/src/PleskX/Api/Operator/Webspace.php index e96e452c..abfdb72d 100644 --- a/src/PleskX/Api/Operator/Webspace.php +++ b/src/PleskX/Api/Operator/Webspace.php @@ -93,16 +93,6 @@ public function delete( $field, $value ) { return $this->_delete( $field, $value ); } - /** - * @param string $field - * @param integer|string $value - * @return bool - */ - public function delete($field, $value) - { - return $this->_delete($field, $value); - } - /** * @param string $field * @param integer|string $value From 018a5d77e8387789e60f31c31d55ca653664f8c0 Mon Sep 17 00:00:00 2001 From: armando Date: Mon, 8 Jan 2018 14:36:18 +0100 Subject: [PATCH 09/40] creato metodo per ottenere l'id di un webspace --- .gitignore | 1 + src/PleskX/Api/Operator.php | 28 ++++++++++++++++++++++++++++ src/PleskX/Api/Operator/Webspace.php | 18 +++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ce35af7d..7b66d6a7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /vendor /phpunit.xml .idea +/nbproject diff --git a/src/PleskX/Api/Operator.php b/src/PleskX/Api/Operator.php index c4880e8b..40a31bbb 100755 --- a/src/PleskX/Api/Operator.php +++ b/src/PleskX/Api/Operator.php @@ -90,4 +90,32 @@ protected function _getItems($structClass, $infoTag, $field = null, $value = nul return $items; } + + /** + * @param string|null $field + * @param integer|string|null $value + * @return string[] + */ + protected function _getId( $field = null, $value = null ) + { + $packet = $this->_client->getPacket(); + $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); + + $filterTag = $getTag->addChild('filter'); + if (!is_null($field)) { + $filterTag->addChild($field, $value); + } + + $getTag->addChild('dataset')->addChild($infoTag); + + $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); + + $ids = []; + foreach ($response->xpath('//result') as $xmlResult) { + $ids[] = (string) $xmlResult->id; + } + + return $ids; + + } } diff --git a/src/PleskX/Api/Operator/Webspace.php b/src/PleskX/Api/Operator/Webspace.php index abfdb72d..da6ce53c 100644 --- a/src/PleskX/Api/Operator/Webspace.php +++ b/src/PleskX/Api/Operator/Webspace.php @@ -103,7 +103,23 @@ public function get($field, $value) $items = $this->_getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value); return reset($items); } - + + + /** + * @param string $name + * @return string + */ + public function getIdByName( $name ) { + $result = $this->_getId( 'name', $name ); + + if( isset( $result[0] ) ) { + return $result[0]; + } + + return null; + } + + /** * @return Struct\GeneralInfo[] */ From 7ed129e2aa7de0c8af5ef4549e65be2d117e7d04 Mon Sep 17 00:00:00 2001 From: armando Date: Mon, 8 Jan 2018 15:05:45 +0100 Subject: [PATCH 10/40] fix refuso --- src/PleskX/Api/Operator.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PleskX/Api/Operator.php b/src/PleskX/Api/Operator.php index 40a31bbb..50da1641 100755 --- a/src/PleskX/Api/Operator.php +++ b/src/PleskX/Api/Operator.php @@ -105,9 +105,9 @@ protected function _getId( $field = null, $value = null ) if (!is_null($field)) { $filterTag->addChild($field, $value); } - - $getTag->addChild('dataset')->addChild($infoTag); - + + $getTag->addChild('dataset'); + $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); $ids = []; From 70ef8b4b3344d74ed38b09ebf62cdbdab3f5b87d Mon Sep 17 00:00:00 2001 From: armando Date: Tue, 11 Sep 2018 12:37:52 +0200 Subject: [PATCH 11/40] aggiunta chiamata per l'aggiornamento della password ftp --- src/PleskX/Api/Operator/FtpUser.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/PleskX/Api/Operator/FtpUser.php b/src/PleskX/Api/Operator/FtpUser.php index 9dcb4ec9..7584e6d5 100644 --- a/src/PleskX/Api/Operator/FtpUser.php +++ b/src/PleskX/Api/Operator/FtpUser.php @@ -1,9 +1,29 @@ _client->getPacket(); + $set = $packet->addChild( $this->_wrapperTag )->addChild( 'set' ); + + $filter = $set->addChild( 'filter' ); + $filter->addChild( 'name', $ftpUser ); + + $values = $set->addChild( 'values' ); + $values->addChild( 'password', $newPassword ); + + $response = $this->_client->request($packet); + + return new Struct( $response ); + } } From e96f4537840c3ae71a86caf1c157a2774ca1d2c1 Mon Sep 17 00:00:00 2001 From: armando Date: Tue, 11 Sep 2018 12:46:12 +0200 Subject: [PATCH 12/40] aggiunta classe info per la password ftp --- src/PleskX/Api/Struct/FtpUser/Info.php | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/PleskX/Api/Struct/FtpUser/Info.php diff --git a/src/PleskX/Api/Struct/FtpUser/Info.php b/src/PleskX/Api/Struct/FtpUser/Info.php new file mode 100644 index 00000000..28791764 --- /dev/null +++ b/src/PleskX/Api/Struct/FtpUser/Info.php @@ -0,0 +1,34 @@ +_initScalarProperties($apiResponse, [ + 'status', + 'filter-id', + 'id', + ]); + } +} \ No newline at end of file From dd2b46178b28abec8d1210d6d9c8cb84a021b99f Mon Sep 17 00:00:00 2001 From: armando Date: Tue, 11 Sep 2018 17:20:57 +0200 Subject: [PATCH 13/40] aggiunto chiamata di get per gli utenti ftp --- src/PleskX/Api/Operator/FtpUser.php | 41 ++++++++++++++++++++++++-- src/PleskX/Api/Struct/FtpUser/Info.php | 29 +++++++++++------- 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/src/PleskX/Api/Operator/FtpUser.php b/src/PleskX/Api/Operator/FtpUser.php index 7584e6d5..b58ec83a 100644 --- a/src/PleskX/Api/Operator/FtpUser.php +++ b/src/PleskX/Api/Operator/FtpUser.php @@ -2,11 +2,31 @@ namespace PleskX\Api\Operator; -use PleskX\Api\Struct\FtpUser\Info as Struct; +use PleskX\Api\Struct\FtpUser\Info; class FtpUser extends \PleskX\Api\Operator { + /** + * @param $command + * @param $field + * @param $value + * @return \PleskX\Api\XmlResponse + */ + private function _get($command, $field, $value) { + $packet = $this->_client->getPacket(); + $getTag = $packet->addChild($this->_wrapperTag)->addChild($command); + + $filterTag = $getTag->addChild('filter'); + if (!is_null($field)) { + $filterTag->addChild($field, $value); + } + + $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); + return $response; + } + + /** * @param string $ftpUser * @param string $newPassword @@ -21,9 +41,24 @@ public function updateFtpPassword( $ftpUser, $newPassword ) { $values = $set->addChild( 'values' ); $values->addChild( 'password', $newPassword ); - + $response = $this->_client->request($packet); - return new Struct( $response ); + return new Info( $response ); } + + + /** + * @param string $field + * @param integer|string $value + * @return Struct\Info[] + */ + public function getAll($field = null, $value = null) { + $response = $this->_get('get', $field, $value); + $items = []; + foreach ($response->xpath('//result') as $xmlResult) { + $items[] = new Struct\Info($xmlResult); + } + return $items; + } } diff --git a/src/PleskX/Api/Struct/FtpUser/Info.php b/src/PleskX/Api/Struct/FtpUser/Info.php index 28791764..3dcec2f4 100644 --- a/src/PleskX/Api/Struct/FtpUser/Info.php +++ b/src/PleskX/Api/Struct/FtpUser/Info.php @@ -6,29 +6,38 @@ class Info extends \PleskX\Api\Struct { /** - * Stato della richiesta - * @var string + * @var int */ - public $status; + public $id; /** - * Nome utenza ftp - * @var string + * @var int */ - public $filterId; + public $name; /** - * Identificatore univoco dell'account ftp * @var int */ - public $id; + public $home; + + /** + * @var int + */ + public $quota; + /** + * @var int + */ + public $webspaceId; + public function __construct( $apiResponse ) { $this->_initScalarProperties($apiResponse, [ - 'status', - 'filter-id', 'id', + 'name', + 'home', + 'quota', + 'webspace_id', ]); } } \ No newline at end of file From a229a1a6bac19385b2476c80beb17fad7e0c2b8b Mon Sep 17 00:00:00 2001 From: armando Date: Tue, 11 Sep 2018 17:33:44 +0200 Subject: [PATCH 14/40] aggiunte chiamate per gestire i webuser --- src/PleskX/Api/Operator/WebUser.php | 9 ---- src/PleskX/Api/Operator/Webuser.php | 62 ++++++++++++++++++++++++++ src/PleskX/Api/Struct/Webuser/Info.php | 24 ++++++++++ 3 files changed, 86 insertions(+), 9 deletions(-) delete mode 100644 src/PleskX/Api/Operator/WebUser.php create mode 100644 src/PleskX/Api/Operator/Webuser.php create mode 100644 src/PleskX/Api/Struct/Webuser/Info.php diff --git a/src/PleskX/Api/Operator/WebUser.php b/src/PleskX/Api/Operator/WebUser.php deleted file mode 100644 index 82637e94..00000000 --- a/src/PleskX/Api/Operator/WebUser.php +++ /dev/null @@ -1,9 +0,0 @@ -_client->getPacket(); + $getTag = $packet->addChild($this->_wrapperTag)->addChild($command); + + $filterTag = $getTag->addChild('filter'); + if (!is_null($field)) { + $filterTag->addChild($field, $value); + } + + $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); + return $response; + } + + + /** + * @param string $user + * @param string $newPassword + * @return \PleskX\Api\Struct\FtpUser\Info + */ + public function updatePassword( $user, $newPassword ) { + $packet = $this->_client->getPacket(); + $set = $packet->addChild( $this->_wrapperTag )->addChild( 'set' ); + + $filter = $set->addChild( 'filter' ); + $filter->addChild( 'login', $user ); + + $values = $set->addChild( 'values' ); + $values->addChild( 'password', $newPassword ); + + $this->_client->request($packet); + } + + + /** + * @param string $field + * @param integer|string $value + * @return Struct\Info[] + */ + public function getAll($field = null, $value = null) { + $response = $this->_get('get', $field, $value); + $items = []; + foreach ($response->xpath('//result') as $xmlResult) { + $items[] = new Struct\Info($xmlResult); + } + return $items; + } +} diff --git a/src/PleskX/Api/Struct/Webuser/Info.php b/src/PleskX/Api/Struct/Webuser/Info.php new file mode 100644 index 00000000..09b6004b --- /dev/null +++ b/src/PleskX/Api/Struct/Webuser/Info.php @@ -0,0 +1,24 @@ +_initScalarProperties($apiResponse, [ + 'id', + 'login', + ]); + } +} \ No newline at end of file From 08c0131535f184f90a1536348d3257ed374cb461 Mon Sep 17 00:00:00 2001 From: armando Date: Tue, 11 Sep 2018 17:43:52 +0200 Subject: [PATCH 15/40] fix utilizzo classe info nei clienti degli account ftp --- src/PleskX/Api/Operator/FtpUser.php | 2 +- src/PleskX/Api/Operator/Webuser.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PleskX/Api/Operator/FtpUser.php b/src/PleskX/Api/Operator/FtpUser.php index b58ec83a..36ebd8ba 100644 --- a/src/PleskX/Api/Operator/FtpUser.php +++ b/src/PleskX/Api/Operator/FtpUser.php @@ -57,7 +57,7 @@ public function getAll($field = null, $value = null) { $response = $this->_get('get', $field, $value); $items = []; foreach ($response->xpath('//result') as $xmlResult) { - $items[] = new Struct\Info($xmlResult); + $items[] = new Info($xmlResult); } return $items; } diff --git a/src/PleskX/Api/Operator/Webuser.php b/src/PleskX/Api/Operator/Webuser.php index e6bec7de..14baea4a 100644 --- a/src/PleskX/Api/Operator/Webuser.php +++ b/src/PleskX/Api/Operator/Webuser.php @@ -55,7 +55,7 @@ public function getAll($field = null, $value = null) { $response = $this->_get('get', $field, $value); $items = []; foreach ($response->xpath('//result') as $xmlResult) { - $items[] = new Struct\Info($xmlResult); + $items[] = new Info($xmlResult); } return $items; } From 7b8b4e333f512f2ef2e73b0653042e922d8f796a Mon Sep 17 00:00:00 2001 From: armando Date: Wed, 12 Sep 2018 09:16:38 +0200 Subject: [PATCH 16/40] fix ftpuser e deprecato webuser --- src/PleskX/Api/Operator/FtpUser.php | 5 +-- src/PleskX/Api/Operator/Webuser.php | 57 ++------------------------ src/PleskX/Api/Struct/FtpUser/Info.php | 22 ++-------- src/PleskX/Api/Struct/Webuser/Info.php | 24 ----------- 4 files changed, 8 insertions(+), 100 deletions(-) delete mode 100644 src/PleskX/Api/Struct/Webuser/Info.php diff --git a/src/PleskX/Api/Operator/FtpUser.php b/src/PleskX/Api/Operator/FtpUser.php index 36ebd8ba..fbf7809d 100644 --- a/src/PleskX/Api/Operator/FtpUser.php +++ b/src/PleskX/Api/Operator/FtpUser.php @@ -30,7 +30,6 @@ private function _get($command, $field, $value) { /** * @param string $ftpUser * @param string $newPassword - * @return \PleskX\Api\Struct\FtpUser\Info */ public function updateFtpPassword( $ftpUser, $newPassword ) { $packet = $this->_client->getPacket(); @@ -42,9 +41,7 @@ public function updateFtpPassword( $ftpUser, $newPassword ) { $values = $set->addChild( 'values' ); $values->addChild( 'password', $newPassword ); - $response = $this->_client->request($packet); - - return new Info( $response ); + $this->_client->request($packet); } diff --git a/src/PleskX/Api/Operator/Webuser.php b/src/PleskX/Api/Operator/Webuser.php index 14baea4a..9581e01c 100644 --- a/src/PleskX/Api/Operator/Webuser.php +++ b/src/PleskX/Api/Operator/Webuser.php @@ -4,59 +4,8 @@ use PleskX\Api\Struct\Webuser\Info; - +/** + * @deprecated utilizzare webspace + */ class Webuser extends \PleskX\Api\Operator { - - /** - * @param $command - * @param $field - * @param $value - * @return \PleskX\Api\XmlResponse - */ - private function _get($command, $field, $value) { - $packet = $this->_client->getPacket(); - $getTag = $packet->addChild($this->_wrapperTag)->addChild($command); - - $filterTag = $getTag->addChild('filter'); - if (!is_null($field)) { - $filterTag->addChild($field, $value); - } - - $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); - return $response; - } - - - /** - * @param string $user - * @param string $newPassword - * @return \PleskX\Api\Struct\FtpUser\Info - */ - public function updatePassword( $user, $newPassword ) { - $packet = $this->_client->getPacket(); - $set = $packet->addChild( $this->_wrapperTag )->addChild( 'set' ); - - $filter = $set->addChild( 'filter' ); - $filter->addChild( 'login', $user ); - - $values = $set->addChild( 'values' ); - $values->addChild( 'password', $newPassword ); - - $this->_client->request($packet); - } - - - /** - * @param string $field - * @param integer|string $value - * @return Struct\Info[] - */ - public function getAll($field = null, $value = null) { - $response = $this->_get('get', $field, $value); - $items = []; - foreach ($response->xpath('//result') as $xmlResult) { - $items[] = new Info($xmlResult); - } - return $items; - } } diff --git a/src/PleskX/Api/Struct/FtpUser/Info.php b/src/PleskX/Api/Struct/FtpUser/Info.php index 3dcec2f4..4fa0c70c 100644 --- a/src/PleskX/Api/Struct/FtpUser/Info.php +++ b/src/PleskX/Api/Struct/FtpUser/Info.php @@ -5,29 +5,16 @@ class Info extends \PleskX\Api\Struct { - /** - * @var int - */ + /** @var integer */ public $id; - /** - * @var int - */ + /** @var string */ public $name; - /** - * @var int - */ + /** @var string */ public $home; - /** - * @var int - */ - public $quota; - - /** - * @var int - */ + /** @var integer */ public $webspaceId; @@ -36,7 +23,6 @@ public function __construct( $apiResponse ) { 'id', 'name', 'home', - 'quota', 'webspace_id', ]); } diff --git a/src/PleskX/Api/Struct/Webuser/Info.php b/src/PleskX/Api/Struct/Webuser/Info.php deleted file mode 100644 index 09b6004b..00000000 --- a/src/PleskX/Api/Struct/Webuser/Info.php +++ /dev/null @@ -1,24 +0,0 @@ -_initScalarProperties($apiResponse, [ - 'id', - 'login', - ]); - } -} \ No newline at end of file From 8d9ef82436278f45dd1ef20eb283aa0a4cab5c1e Mon Sep 17 00:00:00 2001 From: armando Date: Wed, 12 Sep 2018 09:38:14 +0200 Subject: [PATCH 17/40] implementato metodo per il cambio password ftp --- src/PleskX/Api/Operator/Webspace.php | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/PleskX/Api/Operator/Webspace.php b/src/PleskX/Api/Operator/Webspace.php index da6ce53c..fc54e364 100644 --- a/src/PleskX/Api/Operator/Webspace.php +++ b/src/PleskX/Api/Operator/Webspace.php @@ -83,6 +83,35 @@ public function setStatus( array $filters, $status ) { return 'ok' === (string)$response->status; } + + + /** + * @param array $filters + * @param string $newPassword + * @return bool + */ + public function updateFtpPassword( array $filters, $newPassword ) { + $packet = $this->_client->getPacket(); + $setterTag = $packet->addChild( $this->_wrapperTag )->addChild( 'set' ); + if ( !empty( $filters ) ) { + $filterTag = $setterTag->addChild( 'filter' ); + foreach ( $filters as $key => $value ) { + $filterTag->addChild( $key, $value ); + } + } + + $valuesTag = $setterTag->addChild( 'values' ); + $infoHosting = $valuesTag->addChild('hosting')->addChild('vrt_hst'); + $property = $infoHosting->addChild('property'); + + $property->addChild('name', 'ftp_password'); + $property->addChild('value', $newPassword); + + $response = $this->_client->request( $packet ); + + return 'ok' === (string)$response->status; + } + /** * @param string $field From ba82634ede1656050d9ea5a9fbca899502c7ecd0 Mon Sep 17 00:00:00 2001 From: Simion Mogildea Date: Mon, 7 Jan 2019 16:45:56 +0100 Subject: [PATCH 18/40] =?UTF-8?q?Implementata=20la=20possibilit=C3=A0=20di?= =?UTF-8?q?=20combio=20piano=20di=20un=20hosting=20plesk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PleskX/Api/Operator/Webspace.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/PleskX/Api/Operator/Webspace.php b/src/PleskX/Api/Operator/Webspace.php index fc54e364..e3bb8f23 100644 --- a/src/PleskX/Api/Operator/Webspace.php +++ b/src/PleskX/Api/Operator/Webspace.php @@ -149,6 +149,26 @@ public function getIdByName( $name ) { } + /** + * Esegue il cambio piano di un hosting + * @param int $webspaceId + * @param string $subscriptionGuid + * @return XmlResponse + */ + public function switchSubscription( $webspaceId, $subscriptionGuid ) { + $packet = $this->_client->getPacket(); + + $switchSubscriptionTag = $packet->addChild( $this->_wrapperTag )->addChild( 'switch-subscription' ); + + $switchSubscriptionTag->addChild( 'filter' )->addChild( 'id', $webspaceId ); + $switchSubscriptionTag->addChild( 'plan-guid', $subscriptionGuid ); + + $response = $this->_client->request( $packet ); + + return $response; + } + + /** * @return Struct\GeneralInfo[] */ @@ -156,5 +176,5 @@ public function getAll() { return $this->_getItems(Struct\GeneralInfo::class, 'gen_info'); } - + } From 5419666798dfbf15912810bbb353da1b4865551b Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Tue, 26 Mar 2019 09:46:33 +0100 Subject: [PATCH 19/40] Aggiunta chiamate di gestione licenze --- src/PleskX/Api/Operator/Server.php | 61 +++++++++++++++++ .../Api/Struct/Server/License/keyInfo.php | 32 +++++++++ .../LicenseAdditional/keyAdditionalInfo.php | 67 +++++++++++++++++++ .../Struct/Server/LicenseAdditionalInfo.php | 60 +++++++++++++++++ src/PleskX/Api/Struct/Server/LicenseInfo.php | 38 +++++++++++ .../Api/Struct/Server/LicenseInstall.php | 48 +++++++++++++ .../Api/Struct/Server/LicensePropertyInfo.php | 33 +++++++++ 7 files changed, 339 insertions(+) create mode 100644 src/PleskX/Api/Struct/Server/License/keyInfo.php create mode 100644 src/PleskX/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php create mode 100644 src/PleskX/Api/Struct/Server/LicenseAdditionalInfo.php create mode 100644 src/PleskX/Api/Struct/Server/LicenseInfo.php create mode 100644 src/PleskX/Api/Struct/Server/LicenseInstall.php create mode 100644 src/PleskX/Api/Struct/Server/LicensePropertyInfo.php diff --git a/src/PleskX/Api/Operator/Server.php b/src/PleskX/Api/Operator/Server.php index ee560bca..ce8fa95d 100644 --- a/src/PleskX/Api/Operator/Server.php +++ b/src/PleskX/Api/Operator/Server.php @@ -2,7 +2,10 @@ // Copyright 1999-2016. Parallels IP Holdings GmbH. namespace PleskX\Api\Operator; + use PleskX\Api\Struct\Server as Struct; +use PleskX\Api\Exception; + class Server extends \PleskX\Api\Operator { @@ -168,4 +171,62 @@ private function _getInfo($operation) return $response->$operation; } + + /** + * Restituisce i dati della licenza eventualmente installata sul server + * @return Struct\LicenseInfo + */ + public function getLicenseInfo() { + $packet = $this->_client->getPacket(); + $packet->addChild( $this->_wrapperTag )->addChild( 'get' )->addChild( 'key' ); + + $response = $this->_client->request( $packet ); + + return new Struct\LicenseInfo( $response ); + } + + + /** + * Restituisce i dati della licenze aggiuntive eventualmente installate sul server + * @return Struct\LicenseAdditionalInfo + */ + public function getAdditionalLicensesInfo() { + $packet = $this->_client->getPacket(); + $packet->addChild( $this->_wrapperTag )->addChild( 'get_additional_key' ); + + $response = $this->_client->request( $packet ); + + if( !is_null( $response->error_code ) or !empty( $response->error_message ) ) { + throw new Exception( $response->error_message, $response->error_code ); + } + + return new Struct\LicenseAdditionalInfo( $response ); + } + + + /** + * Installa una licenza principale o aggiuntiva + * @param string $activationCode + * @param bool $isAdditionalLicense + * @return Struct\LicenseInstall + */ + public function installLicense( $activationCode, $isAdditionalLicense = false ) { + $packet = $this->_client->getPacket(); + $server = $packet->addChild( $this->_wrapperTag ); + $licInstall = $server->addChild( 'lic_install' ); + + $licInstall->addChild( 'activation-code', $activationCode ); + + if( $isAdditionalLicense ) { + $licInstall->addChild( 'additional_key' ); + } + + $response = new Struct\LicenseInstall( $this->_client->request( $packet ) ); + + if( !is_null( $response->error_code ) or !empty( $response->error_message ) ) { + throw new Exception( $response->error_message, $response->error_code ); + } + + return $response; + } } diff --git a/src/PleskX/Api/Struct/Server/License/keyInfo.php b/src/PleskX/Api/Struct/Server/License/keyInfo.php new file mode 100644 index 00000000..f403b094 --- /dev/null +++ b/src/PleskX/Api/Struct/Server/License/keyInfo.php @@ -0,0 +1,32 @@ +properties = []; + + if( isset( $apiResponse->property ) ) { + foreach( $apiResponse->property as $property ) { + $this->properties[] = new LicensePropertyInfo( $property ); + } + } + } +} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php b/src/PleskX/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php new file mode 100644 index 00000000..41f812a3 --- /dev/null +++ b/src/PleskX/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php @@ -0,0 +1,67 @@ +_initScalarProperties( $apiResponse, [ + ['number' => 'key_number'], + ['name' => 'full_name'], + ['active' => 'active'], + ]); + + $this->date_expiry = ''; + if( isset( $apiResponse->lim_date ) ) { + $this->date_expiry = $apiResponse->lim_date; + } + + $this->properties = []; + + if( isset( $apiResponse->property ) ) { + foreach( $apiResponse->property as $property ) { + $this->properties[] = new LicensePropertyInfo( $property ); + } + } + } +} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Server/LicenseAdditionalInfo.php b/src/PleskX/Api/Struct/Server/LicenseAdditionalInfo.php new file mode 100644 index 00000000..461558fa --- /dev/null +++ b/src/PleskX/Api/Struct/Server/LicenseAdditionalInfo.php @@ -0,0 +1,60 @@ + + */ + public function __construct( $apiResponse ) { + $this->_initScalarProperties( $apiResponse, [ + 'status', + ]); + + if( isset( $apiResponse->errcode ) ) { + $this->error_code = $apiResponse->errcode; + } + + $this->error_message = ''; + if( isset( $apiResponse->errtext ) ) { + $this->error_code = $apiResponse->errtext; + } + + if( isset( $apiResponse->key_info ) ) { + $this->key = new keyAdditionalInfo( $apiResponse->key_info ); + } + } +} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Server/LicenseInfo.php b/src/PleskX/Api/Struct/Server/LicenseInfo.php new file mode 100644 index 00000000..39da0ff6 --- /dev/null +++ b/src/PleskX/Api/Struct/Server/LicenseInfo.php @@ -0,0 +1,38 @@ + + */ + public function __construct( $apiResponse ) { + $this->_initScalarProperties( $apiResponse, [ + 'status', + ]); + + if( isset( $apiResponse->key ) ) { + $this->key = new keyInfo( $apiResponse->key ); + } + } +} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Server/LicenseInstall.php b/src/PleskX/Api/Struct/Server/LicenseInstall.php new file mode 100644 index 00000000..f1a6d095 --- /dev/null +++ b/src/PleskX/Api/Struct/Server/LicenseInstall.php @@ -0,0 +1,48 @@ +_initScalarProperties( $apiResponse, [ + [ 'status' => 'status'], + ]); + + if( isset( $apiResponse->errcode ) ) { + $this->error_code = $apiResponse->errcode; + } + + $this->error_message = ''; + if( isset( $apiResponse->errtext ) ) { + $this->error_code = $apiResponse->errtext; + } + } +} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Server/LicensePropertyInfo.php b/src/PleskX/Api/Struct/Server/LicensePropertyInfo.php new file mode 100644 index 00000000..114b1708 --- /dev/null +++ b/src/PleskX/Api/Struct/Server/LicensePropertyInfo.php @@ -0,0 +1,33 @@ +_initScalarProperties( $apiResponse, [ + 'name', + 'value', + ]); + } +} \ No newline at end of file From c9871255ba9f2631ba6677eca8bf5d5e0908d5a4 Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Wed, 27 Mar 2019 18:33:21 +0100 Subject: [PATCH 20/40] Correzioni a chiamate di installazione e richiesta informazioni licenza --- src/PleskX/Api/Operator/Server.php | 4 +-- .../Api/Struct/Server/License/keyInfo.php | 5 +--- .../LicenseAdditional/keyAdditionalInfo.php | 25 ++++--------------- .../Struct/Server/LicenseAdditionalInfo.php | 21 +++------------- src/PleskX/Api/Struct/Server/LicenseInfo.php | 10 ++------ .../Api/Struct/Server/LicenseInstall.php | 16 +++--------- .../Api/Struct/Server/LicensePropertyInfo.php | 10 ++------ 7 files changed, 19 insertions(+), 72 deletions(-) diff --git a/src/PleskX/Api/Operator/Server.php b/src/PleskX/Api/Operator/Server.php index ce8fa95d..ee4c6e2e 100644 --- a/src/PleskX/Api/Operator/Server.php +++ b/src/PleskX/Api/Operator/Server.php @@ -194,13 +194,13 @@ public function getAdditionalLicensesInfo() { $packet = $this->_client->getPacket(); $packet->addChild( $this->_wrapperTag )->addChild( 'get_additional_key' ); - $response = $this->_client->request( $packet ); + $response = new Struct\LicenseAdditionalInfo( $this->_client->request( $packet ) ); if( !is_null( $response->error_code ) or !empty( $response->error_message ) ) { throw new Exception( $response->error_message, $response->error_code ); } - return new Struct\LicenseAdditionalInfo( $response ); + return $response; } diff --git a/src/PleskX/Api/Struct/Server/License/keyInfo.php b/src/PleskX/Api/Struct/Server/License/keyInfo.php index f403b094..944ff1f8 100644 --- a/src/PleskX/Api/Struct/Server/License/keyInfo.php +++ b/src/PleskX/Api/Struct/Server/License/keyInfo.php @@ -10,10 +10,7 @@ */ class keyInfo extends \PleskX\Api\Struct { - /** - * Collezione di proprietà della licenza - * @var \PleskX\Api\Struct\Server\LicensePropertyInfo[] - */ + /** @var \PleskX\Api\Struct\Server\LicensePropertyInfo[] Collezione di proprietà della licenza */ public $properties; diff --git a/src/PleskX/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php b/src/PleskX/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php index 41f812a3..7adf3eda 100644 --- a/src/PleskX/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php +++ b/src/PleskX/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php @@ -10,34 +10,19 @@ */ class keyAdditionalInfo extends \PleskX\Api\Struct { - /** - * Numero completo della licenza - * @var string - */ + /** @var string Numero completo della licenza */ public $key_number; - /** - * Nome completo della licenza - * @var string - */ + /** @var string Nome completo della licenza */ public $full_name; - /** - * Indica se la licenza è installata e funzionante. False se scaduta - * @var bool - */ + /** @var bool Indica se la licenza è installata e funzionante. False se scaduta */ public $active; - /** - * Data di scadenza licenza in formato YYYYMMDD - * @var string - */ + /** @var string Data di scadenza licenza in formato YYYYMMDD */ public $date_expiry; - /** - * Collezione di proprietà della licenza - * @var \PleskX\Api\Struct\Server\LicensePropertyInfo[] - */ + /** @var \PleskX\Api\Struct\Server\LicensePropertyInfo[] Collezione di proprietà della licenza */ public $properties; diff --git a/src/PleskX/Api/Struct/Server/LicenseAdditionalInfo.php b/src/PleskX/Api/Struct/Server/LicenseAdditionalInfo.php index 461558fa..280fd86e 100644 --- a/src/PleskX/Api/Struct/Server/LicenseAdditionalInfo.php +++ b/src/PleskX/Api/Struct/Server/LicenseAdditionalInfo.php @@ -10,29 +10,16 @@ */ class LicenseAdditionalInfo extends \PleskX\Api\Struct { - /** - * Stato della licenza - * @var string - */ + /** @var string Stato della licenza */ public $status; - /** - * Codice di errore in caso di fallimento della richiesta - * NULL se la richiesta è andata a buon fine - * @var int - */ + /** @var int Codice di errore in caso di fallimento della richiesta (NULL se la richiesta è andata a buon fine) */ public $error_code; - /** - * Messaggio di errore in caso di fallimento della richiesta - * @var string - */ + /** @var string Messaggio di errore in caso di fallimento della richiesta */ public $error_message; - /** - * Licenza aggiuntiva - * @var \PleskX\Api\Struct\Server\License\keyAdditionalInfo - */ + /** @var \PleskX\Api\Struct\Server\License\keyAdditionalInfo Licenza aggiuntiva */ public $key; diff --git a/src/PleskX/Api/Struct/Server/LicenseInfo.php b/src/PleskX/Api/Struct/Server/LicenseInfo.php index 39da0ff6..e4576186 100644 --- a/src/PleskX/Api/Struct/Server/LicenseInfo.php +++ b/src/PleskX/Api/Struct/Server/LicenseInfo.php @@ -10,16 +10,10 @@ */ class LicenseInfo extends \PleskX\Api\Struct { - /** - * Stato della licenza - * @var string - */ + /** @var string Stato della licenza */ public $status; - /** - * Licenza - * @var \PleskX\Api\Struct\Server\License\keyInfo - */ + /** @var \PleskX\Api\Struct\Server\License\keyInfo Licenza */ public $key; diff --git a/src/PleskX/Api/Struct/Server/LicenseInstall.php b/src/PleskX/Api/Struct/Server/LicenseInstall.php index f1a6d095..0c13a778 100644 --- a/src/PleskX/Api/Struct/Server/LicenseInstall.php +++ b/src/PleskX/Api/Struct/Server/LicenseInstall.php @@ -8,23 +8,13 @@ */ class LicenseInstall extends \PleskX\Api\Struct { - /** - * Stato della licenza - * @var string - */ + /** @var string Stato della licenza */ public $status; - /** - * Codice di errore in caso di fallimento nell'installazione. - * NULL se la richiesta è andata a buon fine - * @var int - */ + /** @var int Codice di errore in caso di fallimento nell'installazione (NULL se la richiesta è andata a buon fine) */ public $error_code; - /** - * Messaggio di errore in caso di fallimento nell'installazione - * @var string - */ + /** @var string Messaggio di errore in caso di fallimento nell'installazione */ public $error_message; diff --git a/src/PleskX/Api/Struct/Server/LicensePropertyInfo.php b/src/PleskX/Api/Struct/Server/LicensePropertyInfo.php index 114b1708..c17b4d6d 100644 --- a/src/PleskX/Api/Struct/Server/LicensePropertyInfo.php +++ b/src/PleskX/Api/Struct/Server/LicensePropertyInfo.php @@ -8,16 +8,10 @@ */ class LicensePropertyInfo extends \PleskX\Api\Struct { - /** - * Nome della proprietà - * @var string - */ + /** @var string Nome della proprietà */ public $name; - /** - * Valore della proprietà - * @var string - */ + /** @var string Valore della proprietà */ public $value; From db65ed901bc908a2874406cd4461675ff1ace16e Mon Sep 17 00:00:00 2001 From: Shellrent Srl <33652386+shellrent@users.noreply.github.com> Date: Fri, 8 Nov 2019 15:49:55 +0100 Subject: [PATCH 21/40] Correction on composer.json repo namespace name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e9976f80..e1942e9f 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "ShellrentSrl/api-php-lib", + "name": "shellrentsrl/api-php-lib", "description": "PHP object-oriented library for Plesk XML-RPC API", "license": "Apache-2.0", "authors": [ From a370a749e1bd8f2d7713729e7f65fcd8b1080164 Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Wed, 15 Jan 2020 17:05:51 +0100 Subject: [PATCH 22/40] Aggiunta chiamate di rimozione certificato da un hosting --- src/PleskX/Api/Operator/Certificate.php | 57 ++++++++++++++++++- .../Api/Struct/Certificate/PoolInfo.php | 17 ++++++ .../Api/Struct/Certificate/RemoveInfo.php | 17 ++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/PleskX/Api/Struct/Certificate/PoolInfo.php create mode 100644 src/PleskX/Api/Struct/Certificate/RemoveInfo.php diff --git a/src/PleskX/Api/Operator/Certificate.php b/src/PleskX/Api/Operator/Certificate.php index 2db85624..0c332bc3 100644 --- a/src/PleskX/Api/Operator/Certificate.php +++ b/src/PleskX/Api/Operator/Certificate.php @@ -24,6 +24,32 @@ public function generate($properties) return new Struct\Info($response); } + + /** + * Ottiene tutti i certificati installati sul server per un determinato nome a dominio. + * @param string $field + * @param integer|string $value + * @return Struct\Info[] + */ + public function getAll($field, $value ) + { + $packet = $this->_client->getPacket(); + $getTag = $packet->addChild($this->_wrapperTag)->addChild('get-pool'); + + $filterTag = $getTag->addChild('filter'); + $filterTag->addChild($field, $value); + + $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); + + $items = []; + foreach ($response->xpath('//result/certificates') as $xmlResult) { + $item = new Struct\PoolInfo($xmlResult->certificate); + $items[] = $item; + } + + return $items; + } + /** * @param $properties @@ -51,4 +77,33 @@ public function install($properties) $response = $this->_client->request($packet); return new Struct\InstallInfo($response); } -} + + + /** + * @param $properties + * @return Struct\RemoveInfo + */ + public function remove($properties) + { + $packet = $this->_client->getPacket(); + $removeNode = $packet->addChild($this->_wrapperTag)->addChild('remove'); + + foreach ($properties as $key => $value) { + if( $key == 'filter' ) { + $filterNode = $removeNode->addChild('filter'); + + foreach( $value as $contentKey => $contentValue ) { + $filterNode->addChild( $contentKey, $contentValue ); + } + + continue; + } + + $removeNode->addChild($key, $value); + } + + $response = $this->_client->request($packet); + + return new Struct\RemoveInfo( $response ); + } +} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Certificate/PoolInfo.php b/src/PleskX/Api/Struct/Certificate/PoolInfo.php new file mode 100644 index 00000000..d500c3b8 --- /dev/null +++ b/src/PleskX/Api/Struct/Certificate/PoolInfo.php @@ -0,0 +1,17 @@ +_initScalarProperties($apiResponse, [ + ['name' => 'name'], + ]); + } +} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Certificate/RemoveInfo.php b/src/PleskX/Api/Struct/Certificate/RemoveInfo.php new file mode 100644 index 00000000..cfedfc54 --- /dev/null +++ b/src/PleskX/Api/Struct/Certificate/RemoveInfo.php @@ -0,0 +1,17 @@ +_initScalarProperties($apiResponse, [ + 'status', + ]); + } +} \ No newline at end of file From 4b7a160194e5f2dac3a8948203d0a60220e3787c Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Wed, 11 Mar 2020 18:27:37 +0100 Subject: [PATCH 23/40] Aggiunta chiamate di info sui domini di un server --- src/PleskX/Api/Operator/ServicePlan.php | 1 + src/PleskX/Api/Operator/Webspace.php | 80 +++++++++++++++++-- .../Struct/Webspace/CompleteGeneralInfo.php | 67 ++++++++++++++++ .../Api/Struct/Webspace/HostingSetting.php | 18 +++++ src/PleskX/Api/Struct/Webspace/Limit.php | 18 +++++ 5 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php create mode 100644 src/PleskX/Api/Struct/Webspace/HostingSetting.php create mode 100644 src/PleskX/Api/Struct/Webspace/Limit.php diff --git a/src/PleskX/Api/Operator/ServicePlan.php b/src/PleskX/Api/Operator/ServicePlan.php index 13f082f1..e6809292 100644 --- a/src/PleskX/Api/Operator/ServicePlan.php +++ b/src/PleskX/Api/Operator/ServicePlan.php @@ -9,6 +9,7 @@ class ServicePlan extends \PleskX\Api\Operator { /** + * Restituisce i dettagli di un servizio a listino * @param string $field * @param integer|string $value * @return Struct\Info diff --git a/src/PleskX/Api/Operator/Webspace.php b/src/PleskX/Api/Operator/Webspace.php index e3bb8f23..3fd1226f 100644 --- a/src/PleskX/Api/Operator/Webspace.php +++ b/src/PleskX/Api/Operator/Webspace.php @@ -12,7 +12,14 @@ public function getPermissionDescriptor() $response = $this->request('get-permission-descriptor.filter'); return new Struct\PermissionDescriptor($response); } - + + + /** + * Restituisce i dettagli dei parametri che indicano i limiti di un server + * Ad esempio per il parametro che indica il numero di cpu verranno restituite + * informazioni come il codice del parametro, il data type, i permessi di scrittura, ... + * @return \PleskX\Api\Struct\Webspace\LimitDescriptor + */ public function getLimitDescriptor() { $response = $this->request('get-limit-descriptor.filter'); @@ -134,7 +141,56 @@ public function get($field, $value) } + /** + * Restituisce i limiti massimi per una subscription + * @param int $guid L'identificativo universale della subscription + * @return Struct\Limit + */ + public function getLimits( $guid ) + { + $items = $this->_getItems(Struct\Limit::class, 'limits', 'guid', $guid ); + return $items; + } + + + /** + * Restituisce le impostazioni di tipo hosting per una subscription + * @param int $guid L'identificativo universale della subscription + * @return Struct\HostingSetting + */ + public function getHostingSettings( $guid ) + { + $items = $this->_getItems(Struct\HostingSetting::class, 'hosting', 'guid', $guid ); + return $items; + } + + + /** + * Restituisce l'identificativo univoco del servizio a listino associato ad una subscription + * @param int $guid L'identificativo universale della subscription + * @return string + */ + public function getPlanGuid( $guid ) + { + $packet = $this->_client->getPacket(); + $getterTag = $packet->addChild( $this->_wrapperTag )->addChild( 'get' ); + + $filterTag = $getterTag->addChild( 'filter' ); + $filterTag->addChild( 'guid', $guid ); + + $getterTag->addChild( 'dataset' )->addChild( 'subscriptions' ); + + $response = $this->_client->request( $packet ); + + $guidPropertyName = 'plan-guid'; + $planGuidNode = $response->data->subscriptions->subscription->plan->$guidPropertyName; + + return trim( reset( $planGuidNode ) ); + } + + /** + * Restituisce l'ID della subscription (diverso dal GUID) * @param string $name * @return string */ @@ -151,17 +207,17 @@ public function getIdByName( $name ) { /** * Esegue il cambio piano di un hosting - * @param int $webspaceId - * @param string $subscriptionGuid + * @param int $webspaceId Id della Subscription + * @param string $planGuid * @return XmlResponse */ - public function switchSubscription( $webspaceId, $subscriptionGuid ) { + public function switchSubscription( $webspaceId, $planGuid ) { $packet = $this->_client->getPacket(); $switchSubscriptionTag = $packet->addChild( $this->_wrapperTag )->addChild( 'switch-subscription' ); $switchSubscriptionTag->addChild( 'filter' )->addChild( 'id', $webspaceId ); - $switchSubscriptionTag->addChild( 'plan-guid', $subscriptionGuid ); + $switchSubscriptionTag->addChild( 'plan-guid', $planGuid ); $response = $this->_client->request( $packet ); @@ -170,6 +226,8 @@ public function switchSubscription( $webspaceId, $subscriptionGuid ) { /** + * Restituisce tutte le subscriptions (servizi attivati) presenti sul server. + * Tali subscription potrebbero anche essere in uno stato non attivo * @return Struct\GeneralInfo[] */ public function getAll() @@ -177,4 +235,14 @@ public function getAll() return $this->_getItems(Struct\GeneralInfo::class, 'gen_info'); } -} + + /** + * Restituisce tutte le subscriptions (servizi attivati) presenti sul server. + * Tali subscription potrebbero anche essere in uno stato non attivo + * @return Struct\CompleteGeneralInfo[] + */ + public function getCompleteList() + { + return $this->_getItems( Struct\CompleteGeneralInfo::class, 'gen_info' ); + } +} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php b/src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php new file mode 100644 index 00000000..f728bc4e --- /dev/null +++ b/src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php @@ -0,0 +1,67 @@ +Guid = $apiResponse->guid; + $this->Name = $apiResponse->name; + $this->CreationDate = $apiResponse->cr_date; + + $asciiPropertyName = 'ascii-name'; + $this->AsciiName = $apiResponse->$asciiPropertyName; + + $this->Status = (string) $apiResponse->status; + $this->RealSize = (string) $apiResponse->real_size; + } +} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Webspace/HostingSetting.php b/src/PleskX/Api/Struct/Webspace/HostingSetting.php new file mode 100644 index 00000000..cc05835d --- /dev/null +++ b/src/PleskX/Api/Struct/Webspace/HostingSetting.php @@ -0,0 +1,18 @@ +properties = []; + + foreach ($apiResponse->vrt_hst->property as $propertyInfo) { + $this->properties[(string)$propertyInfo->name] = $propertyInfo->value; + } + } +} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Webspace/Limit.php b/src/PleskX/Api/Struct/Webspace/Limit.php new file mode 100644 index 00000000..c75ea56f --- /dev/null +++ b/src/PleskX/Api/Struct/Webspace/Limit.php @@ -0,0 +1,18 @@ +properties = []; + + foreach ($apiResponse->limit as $propertyInfo) { + $this->properties[(string)$propertyInfo->name] = $propertyInfo->value; + } + } +} \ No newline at end of file From be5712394a7332e1a89e425b0bda9e2a4796e5fc Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Fri, 13 Mar 2020 12:26:31 +0100 Subject: [PATCH 24/40] Correzione nome classe per le impostazione hosting --- src/PleskX/Api/Struct/Webspace/HostingSetting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PleskX/Api/Struct/Webspace/HostingSetting.php b/src/PleskX/Api/Struct/Webspace/HostingSetting.php index cc05835d..0ebc7ca9 100644 --- a/src/PleskX/Api/Struct/Webspace/HostingSetting.php +++ b/src/PleskX/Api/Struct/Webspace/HostingSetting.php @@ -2,7 +2,7 @@ namespace PleskX\Api\Struct\Webspace; -class Limit extends \PleskX\Api\Struct +class HostingSetting extends \PleskX\Api\Struct { /** @var array */ public $properties; From 696e51bf595cf715946c176401466353709936e1 Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Fri, 13 Mar 2020 14:50:38 +0100 Subject: [PATCH 25/40] Correzioni alle chiamate di recupero dati di un dominio --- src/PleskX/Api/Operator/Webspace.php | 4 ++-- src/PleskX/Api/Struct/Webspace/HostingSetting.php | 2 +- src/PleskX/Api/Struct/Webspace/Limit.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PleskX/Api/Operator/Webspace.php b/src/PleskX/Api/Operator/Webspace.php index 3fd1226f..48605734 100644 --- a/src/PleskX/Api/Operator/Webspace.php +++ b/src/PleskX/Api/Operator/Webspace.php @@ -149,7 +149,7 @@ public function get($field, $value) public function getLimits( $guid ) { $items = $this->_getItems(Struct\Limit::class, 'limits', 'guid', $guid ); - return $items; + return reset($items); } @@ -161,7 +161,7 @@ public function getLimits( $guid ) public function getHostingSettings( $guid ) { $items = $this->_getItems(Struct\HostingSetting::class, 'hosting', 'guid', $guid ); - return $items; + return reset($items); } diff --git a/src/PleskX/Api/Struct/Webspace/HostingSetting.php b/src/PleskX/Api/Struct/Webspace/HostingSetting.php index 0ebc7ca9..70fd5f4a 100644 --- a/src/PleskX/Api/Struct/Webspace/HostingSetting.php +++ b/src/PleskX/Api/Struct/Webspace/HostingSetting.php @@ -12,7 +12,7 @@ public function __construct($apiResponse) $this->properties = []; foreach ($apiResponse->vrt_hst->property as $propertyInfo) { - $this->properties[(string)$propertyInfo->name] = $propertyInfo->value; + $this->properties[reset( $propertyInfo->name)] = reset( $propertyInfo->value ); } } } \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Webspace/Limit.php b/src/PleskX/Api/Struct/Webspace/Limit.php index c75ea56f..df07676e 100644 --- a/src/PleskX/Api/Struct/Webspace/Limit.php +++ b/src/PleskX/Api/Struct/Webspace/Limit.php @@ -12,7 +12,7 @@ public function __construct($apiResponse) $this->properties = []; foreach ($apiResponse->limit as $propertyInfo) { - $this->properties[(string)$propertyInfo->name] = $propertyInfo->value; + $this->properties[reset( $propertyInfo->name)] = reset( $propertyInfo->value ); } } } \ No newline at end of file From 5f516540d6faf008cd3e6c11b75968549af3930d Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Fri, 13 Mar 2020 15:57:15 +0100 Subject: [PATCH 26/40] Modifiche agli struct per l'analisi dei dati scaricati da fornitore --- src/PleskX/Api/Operator/Webspace.php | 7 +++-- .../Struct/Webspace/CompleteGeneralInfo.php | 27 ++++++++++++++----- .../Api/Struct/Webspace/HostingSetting.php | 6 ++++- src/PleskX/Api/Struct/Webspace/Limit.php | 4 +++ 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/PleskX/Api/Operator/Webspace.php b/src/PleskX/Api/Operator/Webspace.php index 48605734..aaec52d3 100644 --- a/src/PleskX/Api/Operator/Webspace.php +++ b/src/PleskX/Api/Operator/Webspace.php @@ -183,9 +183,12 @@ public function getPlanGuid( $guid ) $response = $this->_client->request( $packet ); $guidPropertyName = 'plan-guid'; - $planGuidNode = $response->data->subscriptions->subscription->plan->$guidPropertyName; - return trim( reset( $planGuidNode ) ); + if( !isset( $response->data->subscriptions->subscription->plan->$guidPropertyName ) ) { + return null; + } + + return trim( reset( $response->data->subscriptions->subscription->plan->$guidPropertyName ) ); } diff --git a/src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php b/src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php index f728bc4e..f3dd3807 100644 --- a/src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php +++ b/src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php @@ -54,14 +54,29 @@ class CompleteGeneralInfo extends \PleskX\Api\Struct */ public function __construct( $apiResponse ) { - $this->Guid = $apiResponse->guid; - $this->Name = $apiResponse->name; - $this->CreationDate = $apiResponse->cr_date; + if( isset( $apiResponse->guid ) ) { + $this->Guid = $apiResponse->guid; + } + + if( isset( $apiResponse->name ) ) { + $this->Name = $apiResponse->name; + } + + if( isset( $apiResponse->cr_date ) ) { + $this->CreationDate = $apiResponse->cr_date; + } $asciiPropertyName = 'ascii-name'; - $this->AsciiName = $apiResponse->$asciiPropertyName; + if( isset( $apiResponse->$asciiPropertyName ) ) { + $this->AsciiName = $apiResponse->$asciiPropertyName; + } + + if( isset( $apiResponse->status ) ) { + $this->Status = (string) $apiResponse->status; + } - $this->Status = (string) $apiResponse->status; - $this->RealSize = (string) $apiResponse->real_size; + if( isset( $apiResponse->real_size ) ) { + $this->RealSize = (string) $apiResponse->real_size; + } } } \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Webspace/HostingSetting.php b/src/PleskX/Api/Struct/Webspace/HostingSetting.php index 70fd5f4a..40944e7f 100644 --- a/src/PleskX/Api/Struct/Webspace/HostingSetting.php +++ b/src/PleskX/Api/Struct/Webspace/HostingSetting.php @@ -10,7 +10,11 @@ class HostingSetting extends \PleskX\Api\Struct public function __construct($apiResponse) { $this->properties = []; - + + if( !isset( $apiResponse->vrt_hst->property ) ) { + return; + } + foreach ($apiResponse->vrt_hst->property as $propertyInfo) { $this->properties[reset( $propertyInfo->name)] = reset( $propertyInfo->value ); } diff --git a/src/PleskX/Api/Struct/Webspace/Limit.php b/src/PleskX/Api/Struct/Webspace/Limit.php index df07676e..5d474517 100644 --- a/src/PleskX/Api/Struct/Webspace/Limit.php +++ b/src/PleskX/Api/Struct/Webspace/Limit.php @@ -11,6 +11,10 @@ public function __construct($apiResponse) { $this->properties = []; + if( !isset( $apiResponse->vrt_hst->property ) ) { + return; + } + foreach ($apiResponse->limit as $propertyInfo) { $this->properties[reset( $propertyInfo->name)] = reset( $propertyInfo->value ); } From be4bae05508e92c6037386ca216bdd5b70cc5d75 Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Fri, 13 Mar 2020 16:16:33 +0100 Subject: [PATCH 27/40] Fix allo struct dei limiti di un hosting plesk --- src/PleskX/Api/Struct/Webspace/Limit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PleskX/Api/Struct/Webspace/Limit.php b/src/PleskX/Api/Struct/Webspace/Limit.php index 5d474517..cda9efee 100644 --- a/src/PleskX/Api/Struct/Webspace/Limit.php +++ b/src/PleskX/Api/Struct/Webspace/Limit.php @@ -11,7 +11,7 @@ public function __construct($apiResponse) { $this->properties = []; - if( !isset( $apiResponse->vrt_hst->property ) ) { + if( !isset( $apiResponse->limit ) ) { return; } From d8d5cd81b46d89aabdf14e04e4e108173cbc76c4 Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Mon, 30 Mar 2020 18:16:27 +0200 Subject: [PATCH 28/40] Aggiunto supporto ottenimento info GET php-handler --- src/PleskX/Api/Client.php | 8 +++++++ src/PleskX/Api/Operator/PhpHandler.php | 33 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) mode change 100644 => 100755 src/PleskX/Api/Client.php create mode 100755 src/PleskX/Api/Operator/PhpHandler.php diff --git a/src/PleskX/Api/Client.php b/src/PleskX/Api/Client.php old mode 100644 new mode 100755 index ef703066..875c4dff --- a/src/PleskX/Api/Client.php +++ b/src/PleskX/Api/Client.php @@ -396,6 +396,14 @@ public function webspace() return $this->_getOperator('Webspace'); } + /** + * @return Operator\PhpHandler + */ + public function phpHandler() + { + return $this->_getOperator('PhpHandler'); + } + /** * @return Operator\Subdomain */ diff --git a/src/PleskX/Api/Operator/PhpHandler.php b/src/PleskX/Api/Operator/PhpHandler.php new file mode 100755 index 00000000..daf2c836 --- /dev/null +++ b/src/PleskX/Api/Operator/PhpHandler.php @@ -0,0 +1,33 @@ +_client->getPacket(); + $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); + + $filterTag = $getTag->addChild('filter'); + $filterTag->addChild('id', $handlerId); + $response = $this->_client->request( $packet ); + + $item = []; + + $item['id'] = $response->getValue( '//id' ); + $item['display-name'] = $response->getValue( '//display-name' ); + $item['full-version'] = $response->getValue( '//full-version' ); + $item['version'] = $response->getValue( '//version' ); + $item['type'] = $response->getValue( '//type' ); + + return $item; + } +} \ No newline at end of file From 70e33c72368c7e07f754ece613f7d3a60ac0272f Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Tue, 31 Mar 2020 15:54:03 +0200 Subject: [PATCH 29/40] Site is now able to retreive domains info with Webspace --- src/PleskX/Api/Operator/Site.php | 8 ++ .../Api/Struct/Site/CompleteGeneralInfo.php | 82 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100755 src/PleskX/Api/Struct/Site/CompleteGeneralInfo.php diff --git a/src/PleskX/Api/Operator/Site.php b/src/PleskX/Api/Operator/Site.php index 106110b6..9f22d208 100755 --- a/src/PleskX/Api/Operator/Site.php +++ b/src/PleskX/Api/Operator/Site.php @@ -81,4 +81,12 @@ public function getAll() return $this->_getItems(Struct\GeneralInfo::class, 'gen_info'); } + /** + * @return Struct\CompleteGeneralInfo[] + */ + public function getAllWebspaceInfos() + { + return $this->_getItems(Struct\CompleteGeneralInfo::class, 'gen_info'); + } + } diff --git a/src/PleskX/Api/Struct/Site/CompleteGeneralInfo.php b/src/PleskX/Api/Struct/Site/CompleteGeneralInfo.php new file mode 100755 index 00000000..7afa2fd2 --- /dev/null +++ b/src/PleskX/Api/Struct/Site/CompleteGeneralInfo.php @@ -0,0 +1,82 @@ +guid ) ) { + $this->Guid = $apiResponse->guid; + } + + if( isset( $apiResponse->name ) ) { + $this->Name = $apiResponse->name; + } + + if( isset( $apiResponse->cr_date ) ) { + $this->CreationDate = $apiResponse->cr_date; + } + + $asciiPropertyName = 'ascii-name'; + if( isset( $apiResponse->$asciiPropertyName ) ) { + $this->AsciiName = $apiResponse->$asciiPropertyName; + } + + if( isset( $apiResponse->status ) ) { + $this->Status = (string) $apiResponse->status; + } + + if( isset( $apiResponse->real_size ) ) { + $this->RealSize = (string) $apiResponse->real_size; + } + } +} \ No newline at end of file From ef47f01a31481d937d9e414a545c9f0797dafb63 Mon Sep 17 00:00:00 2001 From: SVDIGITAL Date: Fri, 19 Jun 2020 11:59:06 +0200 Subject: [PATCH 30/40] Update README - new repository name, organization renaming --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e2343a73..58f77b7f 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,12 @@ PHP object-oriented library for Plesk XML-RPC API. "repositories": [ { "type": "vcs", - "url": "git@github.com:ShellrentSrl/api-php-lib.git" + "url": "git@github.com:shellrent/plesk-api-php-lib.git" } ], ``` -`composer require ShellrentSrl/api-php-lib:@dev` +`composer require shellrent/plesk-api-php-lib:@dev` ## Usage Examples From 2589150fadafc2ffc8463547ebeada9cb4526e98 Mon Sep 17 00:00:00 2001 From: SVDIGITAL Date: Fri, 19 Jun 2020 12:00:33 +0200 Subject: [PATCH 31/40] Update composer.json - new repository name, organization renaming --- composer.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/composer.json b/composer.json index e1942e9f..19957894 100644 --- a/composer.json +++ b/composer.json @@ -1,15 +1,11 @@ { - "name": "shellrentsrl/api-php-lib", + "name": "shellrent/plesk-api-php-lib", "description": "PHP object-oriented library for Plesk XML-RPC API", "license": "Apache-2.0", "authors": [ { "name": "Alexei Yuzhakov", "email": "sibprogrammer@gmail.com" - }, - { - "name": "Emanuele Menon", - "email": "emnlmn@gmail.com" } ], "minimum-stability": "dev", From 1aa233ac280ecd0c4d309f9126f0ba5bf2207394 Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Fri, 19 Jun 2020 14:50:17 +0200 Subject: [PATCH 32/40] Update README --- README.md | 75 +++++++++---------------------------------------------- 1 file changed, 12 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 3503966a..eaa886c1 100755 --- a/README.md +++ b/README.md @@ -5,71 +5,20 @@ PHP object-oriented library for Plesk XML-RPC API. -## Install Via Composer +See: [plesk/api-php-lib](https://github.com/plesk/api-php-lib) -[Composer](https://getcomposer.org/) is a preferable way to install the library: +# Added by Shellrent -``` -"repositories": [ - { - "type": "vcs", - "url": "git@github.com:shellrent/plesk-api-php-lib.git" - } -], -``` +See Pull Requests: -`composer require shellrent/plesk-api-php-lib:@dev` +- https://github.com/shellrent/plesk-api-php-lib/pull/1/files +- https://github.com/shellrent/plesk-api-php-lib/pull/2/files +- https://github.com/shellrent/plesk-api-php-lib/pull/3/files +- https://github.com/shellrent/plesk-api-php-lib/pull/4/files -## Usage Examples +Methods in Operators and new Struct for: -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` +- Managing SSL Certificates (installing, removing...) +- Changing Service Plans and Subscriptions +- Managing Licenses +- Information about Domains, Subscriptions, Limits From a15c78f58c21697dfc19bfe25af896f781e3ed93 Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Mon, 29 Jun 2020 14:54:41 +0200 Subject: [PATCH 33/40] Correzione typo su Client --- src/Api/Client.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Api/Client.php b/src/Api/Client.php index 9f21e676..0e7a1c9e 100755 --- a/src/Api/Client.php +++ b/src/Api/Client.php @@ -581,12 +581,4 @@ public function site() { return $this->_getOperator('Site'); } - - /** - * @return Operator\PhpHandler - */ - public function phpHandler() - { - return $this->_getOperator('PhpHandler'); - } } From a42676847f1cf3f0941eb3627c4e513d75845971 Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Wed, 15 Jul 2020 14:59:40 +0200 Subject: [PATCH 34/40] =?UTF-8?q?Correzione=20classi=20non=20pi=C3=B9=20ut?= =?UTF-8?q?ilizzate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/{PleskX => }/Api/Operator/FtpUser.php | 0 src/Api/Operator/PhpHandler.php | 24 ++++++++++++++ src/{PleskX => }/Api/Operator/Webuser.php | 0 .../Api/Struct/Certificate/InstallInfo.php | 0 .../Api/Struct/Certificate/PoolInfo.php | 0 .../Api/Struct/Certificate/RemoveInfo.php | 0 src/{PleskX => }/Api/Struct/FtpUser/Info.php | 0 .../Api/Struct/Server/License/keyInfo.php | 0 .../LicenseAdditional/keyAdditionalInfo.php | 0 .../Struct/Server/LicenseAdditionalInfo.php | 0 .../Api/Struct/Server/LicenseInfo.php | 0 .../Api/Struct/Server/LicenseInstall.php | 0 .../Api/Struct/Server/LicensePropertyInfo.php | 0 .../Api/Struct/Site/CompleteGeneralInfo.php | 0 .../Struct/Webspace/CompleteGeneralInfo.php | 0 .../Api/Struct/Webspace/HostingSetting.php | 0 src/Api/Struct/Webspace/Limit.php | 23 ++++++------- src/PleskX/Api/Operator/PhpHandler.php | 33 ------------------- src/PleskX/Api/Struct/Webspace/Limit.php | 22 ------------- 19 files changed, 36 insertions(+), 66 deletions(-) rename src/{PleskX => }/Api/Operator/FtpUser.php (100%) mode change 100644 => 100755 mode change 100644 => 100755 src/Api/Operator/PhpHandler.php rename src/{PleskX => }/Api/Operator/Webuser.php (100%) mode change 100644 => 100755 rename src/{PleskX => }/Api/Struct/Certificate/InstallInfo.php (100%) mode change 100644 => 100755 rename src/{PleskX => }/Api/Struct/Certificate/PoolInfo.php (100%) mode change 100644 => 100755 rename src/{PleskX => }/Api/Struct/Certificate/RemoveInfo.php (100%) mode change 100644 => 100755 rename src/{PleskX => }/Api/Struct/FtpUser/Info.php (100%) rename src/{PleskX => }/Api/Struct/Server/License/keyInfo.php (100%) rename src/{PleskX => }/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php (100%) rename src/{PleskX => }/Api/Struct/Server/LicenseAdditionalInfo.php (100%) mode change 100644 => 100755 rename src/{PleskX => }/Api/Struct/Server/LicenseInfo.php (100%) mode change 100644 => 100755 rename src/{PleskX => }/Api/Struct/Server/LicenseInstall.php (100%) mode change 100644 => 100755 rename src/{PleskX => }/Api/Struct/Server/LicensePropertyInfo.php (100%) mode change 100644 => 100755 rename src/{PleskX => }/Api/Struct/Site/CompleteGeneralInfo.php (100%) rename src/{PleskX => }/Api/Struct/Webspace/CompleteGeneralInfo.php (100%) mode change 100644 => 100755 rename src/{PleskX => }/Api/Struct/Webspace/HostingSetting.php (100%) mode change 100644 => 100755 mode change 100644 => 100755 src/Api/Struct/Webspace/Limit.php delete mode 100755 src/PleskX/Api/Operator/PhpHandler.php delete mode 100644 src/PleskX/Api/Struct/Webspace/Limit.php diff --git a/src/PleskX/Api/Operator/FtpUser.php b/src/Api/Operator/FtpUser.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Operator/FtpUser.php rename to src/Api/Operator/FtpUser.php diff --git a/src/Api/Operator/PhpHandler.php b/src/Api/Operator/PhpHandler.php old mode 100644 new mode 100755 index 802c7366..d4846052 --- a/src/Api/Operator/PhpHandler.php +++ b/src/Api/Operator/PhpHandler.php @@ -56,4 +56,28 @@ public function getAll($field = null, $value = null) return $items; } + + /** + * Restituisce tutte le subscriptions (servizi attivati) presenti sul server. + * Tali subscription potrebbero anche essere in uno stato non attivo + * @return Struct\GeneralInfo[] + */ + public function getHandler( $handlerId ) { + $packet = $this->_client->getPacket(); + $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); + + $filterTag = $getTag->addChild('filter'); + $filterTag->addChild('id', $handlerId); + $response = $this->_client->request( $packet ); + + $item = []; + + $item['id'] = $response->getValue( '//id' ); + $item['display-name'] = $response->getValue( '//display-name' ); + $item['full-version'] = $response->getValue( '//full-version' ); + $item['version'] = $response->getValue( '//version' ); + $item['type'] = $response->getValue( '//type' ); + + return $item; + } } diff --git a/src/PleskX/Api/Operator/Webuser.php b/src/Api/Operator/Webuser.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Operator/Webuser.php rename to src/Api/Operator/Webuser.php diff --git a/src/PleskX/Api/Struct/Certificate/InstallInfo.php b/src/Api/Struct/Certificate/InstallInfo.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Struct/Certificate/InstallInfo.php rename to src/Api/Struct/Certificate/InstallInfo.php diff --git a/src/PleskX/Api/Struct/Certificate/PoolInfo.php b/src/Api/Struct/Certificate/PoolInfo.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Struct/Certificate/PoolInfo.php rename to src/Api/Struct/Certificate/PoolInfo.php diff --git a/src/PleskX/Api/Struct/Certificate/RemoveInfo.php b/src/Api/Struct/Certificate/RemoveInfo.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Struct/Certificate/RemoveInfo.php rename to src/Api/Struct/Certificate/RemoveInfo.php diff --git a/src/PleskX/Api/Struct/FtpUser/Info.php b/src/Api/Struct/FtpUser/Info.php similarity index 100% rename from src/PleskX/Api/Struct/FtpUser/Info.php rename to src/Api/Struct/FtpUser/Info.php diff --git a/src/PleskX/Api/Struct/Server/License/keyInfo.php b/src/Api/Struct/Server/License/keyInfo.php similarity index 100% rename from src/PleskX/Api/Struct/Server/License/keyInfo.php rename to src/Api/Struct/Server/License/keyInfo.php diff --git a/src/PleskX/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php b/src/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php similarity index 100% rename from src/PleskX/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php rename to src/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php diff --git a/src/PleskX/Api/Struct/Server/LicenseAdditionalInfo.php b/src/Api/Struct/Server/LicenseAdditionalInfo.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Struct/Server/LicenseAdditionalInfo.php rename to src/Api/Struct/Server/LicenseAdditionalInfo.php diff --git a/src/PleskX/Api/Struct/Server/LicenseInfo.php b/src/Api/Struct/Server/LicenseInfo.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Struct/Server/LicenseInfo.php rename to src/Api/Struct/Server/LicenseInfo.php diff --git a/src/PleskX/Api/Struct/Server/LicenseInstall.php b/src/Api/Struct/Server/LicenseInstall.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Struct/Server/LicenseInstall.php rename to src/Api/Struct/Server/LicenseInstall.php diff --git a/src/PleskX/Api/Struct/Server/LicensePropertyInfo.php b/src/Api/Struct/Server/LicensePropertyInfo.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Struct/Server/LicensePropertyInfo.php rename to src/Api/Struct/Server/LicensePropertyInfo.php diff --git a/src/PleskX/Api/Struct/Site/CompleteGeneralInfo.php b/src/Api/Struct/Site/CompleteGeneralInfo.php similarity index 100% rename from src/PleskX/Api/Struct/Site/CompleteGeneralInfo.php rename to src/Api/Struct/Site/CompleteGeneralInfo.php diff --git a/src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php b/src/Api/Struct/Webspace/CompleteGeneralInfo.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php rename to src/Api/Struct/Webspace/CompleteGeneralInfo.php diff --git a/src/PleskX/Api/Struct/Webspace/HostingSetting.php b/src/Api/Struct/Webspace/HostingSetting.php old mode 100644 new mode 100755 similarity index 100% rename from src/PleskX/Api/Struct/Webspace/HostingSetting.php rename to src/Api/Struct/Webspace/HostingSetting.php diff --git a/src/Api/Struct/Webspace/Limit.php b/src/Api/Struct/Webspace/Limit.php old mode 100644 new mode 100755 index 5cc064ab..cda9efee --- a/src/Api/Struct/Webspace/Limit.php +++ b/src/Api/Struct/Webspace/Limit.php @@ -1,21 +1,22 @@ _initScalarProperties($apiResponse, [ - 'name', - 'value', - ]); + $this->properties = []; + + if( !isset( $apiResponse->limit ) ) { + return; + } + + foreach ($apiResponse->limit as $propertyInfo) { + $this->properties[reset( $propertyInfo->name)] = reset( $propertyInfo->value ); + } } -} +} \ No newline at end of file diff --git a/src/PleskX/Api/Operator/PhpHandler.php b/src/PleskX/Api/Operator/PhpHandler.php deleted file mode 100755 index daf2c836..00000000 --- a/src/PleskX/Api/Operator/PhpHandler.php +++ /dev/null @@ -1,33 +0,0 @@ -_client->getPacket(); - $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); - - $filterTag = $getTag->addChild('filter'); - $filterTag->addChild('id', $handlerId); - $response = $this->_client->request( $packet ); - - $item = []; - - $item['id'] = $response->getValue( '//id' ); - $item['display-name'] = $response->getValue( '//display-name' ); - $item['full-version'] = $response->getValue( '//full-version' ); - $item['version'] = $response->getValue( '//version' ); - $item['type'] = $response->getValue( '//type' ); - - return $item; - } -} \ No newline at end of file diff --git a/src/PleskX/Api/Struct/Webspace/Limit.php b/src/PleskX/Api/Struct/Webspace/Limit.php deleted file mode 100644 index cda9efee..00000000 --- a/src/PleskX/Api/Struct/Webspace/Limit.php +++ /dev/null @@ -1,22 +0,0 @@ -properties = []; - - if( !isset( $apiResponse->limit ) ) { - return; - } - - foreach ($apiResponse->limit as $propertyInfo) { - $this->properties[reset( $propertyInfo->name)] = reset( $propertyInfo->value ); - } - } -} \ No newline at end of file From a71a8d39285cc079b7737c6f13e8428f8eb21d3e Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Mon, 8 Feb 2021 09:33:24 +0100 Subject: [PATCH 35/40] Aggiunta chiamate di gestione certificato in uso --- src/Api/Operator/Webspace.php | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/Api/Operator/Webspace.php b/src/Api/Operator/Webspace.php index e692fa47..bfb9449a 100755 --- a/src/Api/Operator/Webspace.php +++ b/src/Api/Operator/Webspace.php @@ -305,4 +305,64 @@ public function getDiskUsage($field, $value) return reset($items); } + + + /** + * @param array $filters + * @param string $newPassword + * @return bool + */ + public function setCurrentCertificate( $filters, $certificateName ) { + $packet = $this->_client->getPacket(); + $setterTag = $packet->addChild( $this->_wrapperTag )->addChild( 'set' ); + if ( !empty( $filters ) ) { + $filterTag = $setterTag->addChild( 'filter' ); + foreach ( $filters as $key => $value ) { + $filterTag->addChild( $key, $value ); + } + } + + $valuesTag = $setterTag->addChild( 'values' ); + $infoHosting = $valuesTag->addChild('hosting')->addChild('vrt_hst'); + $property = $infoHosting->addChild('property'); + + $property->addChild('name', 'certificate_name'); + $property->addChild('value', $certificateName); + + $response = $this->_client->request( $packet ); + + return 'ok' === (string)$response->status; + } + + + /** + * Restituisce l'identificativo univoco del servizio a listino associato ad una subscription + * @param int $guid L'identificativo universale della subscription + * @return string|null + */ + public function getCurrentCertificate( $filters ) { + $packet = $this->_client->getPacket(); + $getterTag = $packet->addChild( $this->_wrapperTag )->addChild( 'get' ); + + if ( !empty( $filters ) ) { + $filterTag = $getterTag->addChild( 'filter' ); + + foreach( $filters as $key => $value ) { + $filterTag->addChild( $key, $value ); + } + } + + $getterTag->addChild( 'dataset' )->addChild( 'hosting' ); + + $response = $this->_client->request( $packet ); + $responseProperties = $response->data->hosting->vrt_hst->property; + + foreach( $responseProperties as $property ) { + if( $property->name == 'certificate_name' ) { + return trim( reset( $property->value ) ); + } + } + + return null; + } } From 48f77a065f6827c743c9d6164855a0fefe701343 Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Mon, 8 Feb 2021 13:10:34 +0100 Subject: [PATCH 36/40] Correzione commenit --- src/Api/Operator/Webspace.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Api/Operator/Webspace.php b/src/Api/Operator/Webspace.php index bfb9449a..884423d7 100755 --- a/src/Api/Operator/Webspace.php +++ b/src/Api/Operator/Webspace.php @@ -309,7 +309,7 @@ public function getDiskUsage($field, $value) /** * @param array $filters - * @param string $newPassword + * @param string|null $certificateName * @return bool */ public function setCurrentCertificate( $filters, $certificateName ) { @@ -336,8 +336,7 @@ public function setCurrentCertificate( $filters, $certificateName ) { /** - * Restituisce l'identificativo univoco del servizio a listino associato ad una subscription - * @param int $guid L'identificativo universale della subscription + * @param array $filters * @return string|null */ public function getCurrentCertificate( $filters ) { From 95879ab2126dcc62f0efee9e4818ccbc03fe2942 Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Mon, 8 Feb 2021 18:19:24 +0100 Subject: [PATCH 37/40] Aggiunta chiamata di controllo stato webspace --- src/Api/Operator/Webspace.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Api/Operator/Webspace.php b/src/Api/Operator/Webspace.php index 884423d7..2cbceb99 100755 --- a/src/Api/Operator/Webspace.php +++ b/src/Api/Operator/Webspace.php @@ -293,6 +293,22 @@ public function getCompleteList() } + /** + * @return string + */ + public function getSubscriptionStatus() + { + $items = $this->_getItems( Struct\CompleteGeneralInfo::class, 'gen_info' ); + $item = reset($items ); + + if( !isset( $item->Status ) or is_null( $item->Status ) or $item->Status === '' ) { + return null; + } + + return $item->Status; + } + + /** * @param string $field * @param int|string $value From 860e0875e51be94fd56fa55d00e841f9bf5338c2 Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Tue, 9 Feb 2021 09:41:00 +0100 Subject: [PATCH 38/40] Aggiunta chiamata che restituisce lo stato del webspace --- src/Api/Operator/Webspace.php | 42 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/Api/Operator/Webspace.php b/src/Api/Operator/Webspace.php index 2cbceb99..59f9a4fc 100755 --- a/src/Api/Operator/Webspace.php +++ b/src/Api/Operator/Webspace.php @@ -118,6 +118,32 @@ public function create(array $properties, array $hostingProperties = null, $plan return new Struct\Info($response); } + + + /** + * @param $webspaceId + * + * @return string|null + */ + public function getStatus( $webspaceId ) + { + $packet = $this->_client->getPacket(); + $getterTag = $packet->addChild( $this->_wrapperTag )->addChild( 'get' ); + + $filterTag = $getterTag->addChild( 'filter' ); + $filterTag->addChild( 'id', $webspaceId ); + + $getterTag->addChild( 'dataset' )->addChild( 'gen_info' ); + + $response = $this->_client->request( $packet ); + + if( !isset( $response->data->gen_info->status ) ) { + return null; + } + + return trim( reset( $response->data->gen_info->status ) ); + } + /** * Imposta lo stato di sospensione al webhosting @@ -293,22 +319,6 @@ public function getCompleteList() } - /** - * @return string - */ - public function getSubscriptionStatus() - { - $items = $this->_getItems( Struct\CompleteGeneralInfo::class, 'gen_info' ); - $item = reset($items ); - - if( !isset( $item->Status ) or is_null( $item->Status ) or $item->Status === '' ) { - return null; - } - - return $item->Status; - } - - /** * @param string $field * @param int|string $value From bb97190871ad6362b2221410e95bf804d7b98e37 Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Tue, 6 Jun 2023 10:08:55 +0200 Subject: [PATCH 39/40] Fix namespaces for AbstractStruct --- .gitignore | 4 +++- src/Api/Operator.php | 6 +++--- src/Api/Operator/Certificate.php | 18 +++++++++--------- src/Api/Operator/FtpUser.php | 12 ++++++------ src/Api/Operator/PhpHandler.php | 6 +++--- src/Api/Operator/Server.php | 18 +++++++++--------- src/Api/Operator/Site.php | 2 +- src/Api/Struct/Certificate/InstallInfo.php | 6 ++++-- src/Api/Struct/Certificate/PoolInfo.php | 6 ++++-- src/Api/Struct/Certificate/RemoveInfo.php | 6 ++++-- src/Api/Struct/FtpUser/Info.php | 6 ++++-- src/Api/Struct/Server/License/keyInfo.php | 3 ++- .../LicenseAdditional/keyAdditionalInfo.php | 5 +++-- .../Struct/Server/LicenseAdditionalInfo.php | 7 ++++--- src/Api/Struct/Server/LicenseInfo.php | 5 +++-- src/Api/Struct/Server/LicenseInstall.php | 6 ++++-- src/Api/Struct/Server/LicensePropertyInfo.php | 6 ++++-- src/Api/Struct/Site/CompleteGeneralInfo.php | 4 +++- .../Struct/Webspace/CompleteGeneralInfo.php | 4 +++- src/Api/Struct/Webspace/HostingSetting.php | 4 +++- 20 files changed, 79 insertions(+), 55 deletions(-) diff --git a/.gitignore b/.gitignore index e7710589..4408ef08 100755 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ .idea /nbproject/ /.phpunit.result.cache -/coverage.xml \ No newline at end of file +/coverage.xml +composer.phar + diff --git a/src/Api/Operator.php b/src/Api/Operator.php index 3cc0ec5d..110e25e5 100755 --- a/src/Api/Operator.php +++ b/src/Api/Operator.php @@ -112,8 +112,8 @@ protected function getItems($structClass, $infoTag, $field = null, $value = null */ protected function _getId( $field = null, $value = null ) { - $packet = $this->_client->getPacket(); - $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); + $packet = $this->client->getPacket(); + $getTag = $packet->addChild($this->wrapperTag)->addChild('get'); $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { @@ -122,7 +122,7 @@ protected function _getId( $field = null, $value = null ) $getTag->addChild('dataset'); - $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); + $response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); $ids = []; foreach ($response->xpath('//result') as $xmlResult) { diff --git a/src/Api/Operator/Certificate.php b/src/Api/Operator/Certificate.php index 538eebc3..daf70bfa 100755 --- a/src/Api/Operator/Certificate.php +++ b/src/Api/Operator/Certificate.php @@ -30,13 +30,13 @@ public function generate(array $properties): Struct\Info */ public function getAll($field, $value ) { - $packet = $this->_client->getPacket(); - $getTag = $packet->addChild($this->_wrapperTag)->addChild('get-pool'); + $packet = $this->client->getPacket(); + $getTag = $packet->addChild($this->wrapperTag)->addChild('get-pool'); $filterTag = $getTag->addChild('filter'); $filterTag->addChild($field, $value); - $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); + $response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); $items = []; foreach ($response->xpath('//result/certificates') as $xmlResult) { @@ -54,8 +54,8 @@ public function getAll($field, $value ) */ public function install($properties) { - $packet = $this->_client->getPacket(); - $install = $packet->addChild($this->_wrapperTag)->addChild('install'); + $packet = $this->client->getPacket(); + $install = $packet->addChild($this->wrapperTag)->addChild('install'); foreach ($properties as $name => $value) { if ($name == 'content') { @@ -71,7 +71,7 @@ public function install($properties) $install->addChild($name, $value); } - $response = $this->_client->request($packet); + $response = $this->client->request($packet); return new Struct\InstallInfo($response); } @@ -82,8 +82,8 @@ public function install($properties) */ public function remove($properties) { - $packet = $this->_client->getPacket(); - $removeNode = $packet->addChild($this->_wrapperTag)->addChild('remove'); + $packet = $this->client->getPacket(); + $removeNode = $packet->addChild($this->wrapperTag)->addChild('remove'); foreach ($properties as $key => $value) { if( $key == 'filter' ) { @@ -99,7 +99,7 @@ public function remove($properties) $removeNode->addChild($key, $value); } - $response = $this->_client->request($packet); + $response = $this->client->request($packet); return new Struct\RemoveInfo( $response ); } diff --git a/src/Api/Operator/FtpUser.php b/src/Api/Operator/FtpUser.php index fbf7809d..77207a54 100755 --- a/src/Api/Operator/FtpUser.php +++ b/src/Api/Operator/FtpUser.php @@ -14,15 +14,15 @@ class FtpUser extends \PleskX\Api\Operator { * @return \PleskX\Api\XmlResponse */ private function _get($command, $field, $value) { - $packet = $this->_client->getPacket(); - $getTag = $packet->addChild($this->_wrapperTag)->addChild($command); + $packet = $this->client->getPacket(); + $getTag = $packet->addChild($this->wrapperTag)->addChild($command); $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { $filterTag->addChild($field, $value); } - $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); + $response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); return $response; } @@ -32,8 +32,8 @@ private function _get($command, $field, $value) { * @param string $newPassword */ public function updateFtpPassword( $ftpUser, $newPassword ) { - $packet = $this->_client->getPacket(); - $set = $packet->addChild( $this->_wrapperTag )->addChild( 'set' ); + $packet = $this->client->getPacket(); + $set = $packet->addChild( $this->wrapperTag )->addChild( 'set' ); $filter = $set->addChild( 'filter' ); $filter->addChild( 'name', $ftpUser ); @@ -41,7 +41,7 @@ public function updateFtpPassword( $ftpUser, $newPassword ) { $values = $set->addChild( 'values' ); $values->addChild( 'password', $newPassword ); - $this->_client->request($packet); + $this->client->request($packet); } diff --git a/src/Api/Operator/PhpHandler.php b/src/Api/Operator/PhpHandler.php index 37ce7faa..97b2c15a 100755 --- a/src/Api/Operator/PhpHandler.php +++ b/src/Api/Operator/PhpHandler.php @@ -63,12 +63,12 @@ public function getAll($field = null, $value = null): array * @return Struct\GeneralInfo[] */ public function getHandler( $handlerId ) { - $packet = $this->_client->getPacket(); - $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); + $packet = $this->client->getPacket(); + $getTag = $packet->addChild($this->wrapperTag)->addChild('get'); $filterTag = $getTag->addChild('filter'); $filterTag->addChild('id', $handlerId); - $response = $this->_client->request( $packet ); + $response = $this->client->request( $packet ); $item = []; diff --git a/src/Api/Operator/Server.php b/src/Api/Operator/Server.php index 6ce53b13..9ab78b66 100755 --- a/src/Api/Operator/Server.php +++ b/src/Api/Operator/Server.php @@ -147,10 +147,10 @@ private function getInfo(string $operation): XmlResponse * @return Struct\LicenseInfo */ public function getLicenseInfo() { - $packet = $this->_client->getPacket(); - $packet->addChild( $this->_wrapperTag )->addChild( 'get' )->addChild( 'key' ); + $packet = $this->client->getPacket(); + $packet->addChild( $this->wrapperTag )->addChild( 'get' )->addChild( 'key' ); - $response = $this->_client->request( $packet ); + $response = $this->client->request( $packet ); return new Struct\LicenseInfo( $response ); } @@ -161,10 +161,10 @@ public function getLicenseInfo() { * @return Struct\LicenseAdditionalInfo */ public function getAdditionalLicensesInfo() { - $packet = $this->_client->getPacket(); - $packet->addChild( $this->_wrapperTag )->addChild( 'get_additional_key' ); + $packet = $this->client->getPacket(); + $packet->addChild( $this->wrapperTag )->addChild( 'get_additional_key' ); - $response = new Struct\LicenseAdditionalInfo( $this->_client->request( $packet ) ); + $response = new Struct\LicenseAdditionalInfo( $this->client->request( $packet ) ); if( !is_null( $response->error_code ) or !empty( $response->error_message ) ) { throw new Exception( $response->error_message, $response->error_code ); @@ -181,8 +181,8 @@ public function getAdditionalLicensesInfo() { * @return Struct\LicenseInstall */ public function installLicense( $activationCode, $isAdditionalLicense = false ) { - $packet = $this->_client->getPacket(); - $server = $packet->addChild( $this->_wrapperTag ); + $packet = $this->client->getPacket(); + $server = $packet->addChild( $this->wrapperTag ); $licInstall = $server->addChild( 'lic_install' ); $licInstall->addChild( 'activation-code', $activationCode ); @@ -191,7 +191,7 @@ public function installLicense( $activationCode, $isAdditionalLicense = false ) $licInstall->addChild( 'additional_key' ); } - $response = new Struct\LicenseInstall( $this->_client->request( $packet ) ); + $response = new Struct\LicenseInstall( $this->client->request( $packet ) ); if( !is_null( $response->error_code ) or !empty( $response->error_message ) ) { throw new Exception( $response->error_message, $response->error_code ); diff --git a/src/Api/Operator/Site.php b/src/Api/Operator/Site.php index d930f220..c925d701 100755 --- a/src/Api/Operator/Site.php +++ b/src/Api/Operator/Site.php @@ -97,6 +97,6 @@ public function getAll(): array */ public function getAllWebspaceInfos() { - return $this->_getItems(Struct\CompleteGeneralInfo::class, 'gen_info'); + return $this->getItems(Struct\CompleteGeneralInfo::class, 'gen_info'); } } diff --git a/src/Api/Struct/Certificate/InstallInfo.php b/src/Api/Struct/Certificate/InstallInfo.php index b2102a96..6157a7e5 100755 --- a/src/Api/Struct/Certificate/InstallInfo.php +++ b/src/Api/Struct/Certificate/InstallInfo.php @@ -3,14 +3,16 @@ namespace PleskX\Api\Struct\Certificate; -class InstallInfo extends \PleskX\Api\Struct +use PleskX\Api\AbstractStruct; + +class InstallInfo extends AbstractStruct { /** @var string */ public $status; public function __construct($apiResponse) { - $this->_initScalarProperties($apiResponse, [ + $this->initScalarProperties($apiResponse, [ 'status', ]); } diff --git a/src/Api/Struct/Certificate/PoolInfo.php b/src/Api/Struct/Certificate/PoolInfo.php index d500c3b8..9fca568f 100755 --- a/src/Api/Struct/Certificate/PoolInfo.php +++ b/src/Api/Struct/Certificate/PoolInfo.php @@ -3,14 +3,16 @@ namespace PleskX\Api\Struct\Certificate; -class PoolInfo extends \PleskX\Api\Struct +use PleskX\Api\AbstractStruct; + +class PoolInfo extends AbstractStruct { /** @var string */ public $name; public function __construct($apiResponse) { - $this->_initScalarProperties($apiResponse, [ + $this->initScalarProperties($apiResponse, [ ['name' => 'name'], ]); } diff --git a/src/Api/Struct/Certificate/RemoveInfo.php b/src/Api/Struct/Certificate/RemoveInfo.php index cfedfc54..53eaee9e 100755 --- a/src/Api/Struct/Certificate/RemoveInfo.php +++ b/src/Api/Struct/Certificate/RemoveInfo.php @@ -3,14 +3,16 @@ namespace PleskX\Api\Struct\Certificate; -class RemoveInfo extends \PleskX\Api\Struct +use PleskX\Api\AbstractStruct; + +class RemoveInfo extends AbstractStruct { /** @var string */ public $status; public function __construct($apiResponse) { - $this->_initScalarProperties($apiResponse, [ + $this->initScalarProperties($apiResponse, [ 'status', ]); } diff --git a/src/Api/Struct/FtpUser/Info.php b/src/Api/Struct/FtpUser/Info.php index 4fa0c70c..cd6e0dd8 100644 --- a/src/Api/Struct/FtpUser/Info.php +++ b/src/Api/Struct/FtpUser/Info.php @@ -2,7 +2,9 @@ namespace PleskX\Api\Struct\FtpUser; -class Info extends \PleskX\Api\Struct +use PleskX\Api\AbstractStruct; + +class Info extends AbstractStruct { /** @var integer */ @@ -19,7 +21,7 @@ class Info extends \PleskX\Api\Struct public function __construct( $apiResponse ) { - $this->_initScalarProperties($apiResponse, [ + $this->initScalarProperties($apiResponse, [ 'id', 'name', 'home', diff --git a/src/Api/Struct/Server/License/keyInfo.php b/src/Api/Struct/Server/License/keyInfo.php index 944ff1f8..c1ec1a89 100644 --- a/src/Api/Struct/Server/License/keyInfo.php +++ b/src/Api/Struct/Server/License/keyInfo.php @@ -2,13 +2,14 @@ namespace PleskX\Api\Struct\Server\License; +use PleskX\Api\AbstractStruct; use PleskX\Api\Struct\Server\LicensePropertyInfo; /** * Struttura dati per le informazioni su una licenza */ -class keyInfo extends \PleskX\Api\Struct { +class keyInfo extends AbstractStruct { /** @var \PleskX\Api\Struct\Server\LicensePropertyInfo[] Collezione di proprietà della licenza */ public $properties; diff --git a/src/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php b/src/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php index 7adf3eda..2ec5f989 100644 --- a/src/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php +++ b/src/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php @@ -2,13 +2,14 @@ namespace PleskX\Api\Struct\Server\LicenseAdditional; +use PleskX\Api\AbstractStruct; use PleskX\Api\Struct\Server\LicensePropertyInfo; /** * Struttura dati per le informazioni su una licenza */ -class keyAdditionalInfo extends \PleskX\Api\Struct { +class keyAdditionalInfo extends AbstractStruct { /** @var string Numero completo della licenza */ public $key_number; @@ -30,7 +31,7 @@ class keyAdditionalInfo extends \PleskX\Api\Struct { * @param \SimpleXMLElement $apiResponse */ public function __construct( $apiResponse ) { - $this->_initScalarProperties( $apiResponse, [ + $this->initScalarProperties( $apiResponse, [ ['number' => 'key_number'], ['name' => 'full_name'], ['active' => 'active'], diff --git a/src/Api/Struct/Server/LicenseAdditionalInfo.php b/src/Api/Struct/Server/LicenseAdditionalInfo.php index 280fd86e..1a2078de 100755 --- a/src/Api/Struct/Server/LicenseAdditionalInfo.php +++ b/src/Api/Struct/Server/LicenseAdditionalInfo.php @@ -2,13 +2,14 @@ namespace PleskX\Api\Struct\Server; +use PleskX\Api\AbstractStruct; use PleskX\Api\Struct\Server\LicenseAdditional\keyAdditionalInfo; /** * Struttura dati per le informazioni su una licenza aggiuntiva */ -class LicenseAdditionalInfo extends \PleskX\Api\Struct { +class LicenseAdditionalInfo extends AbstractStruct { /** @var string Stato della licenza */ public $status; @@ -19,7 +20,7 @@ class LicenseAdditionalInfo extends \PleskX\Api\Struct { /** @var string Messaggio di errore in caso di fallimento della richiesta */ public $error_message; - /** @var \PleskX\Api\Struct\Server\License\keyAdditionalInfo Licenza aggiuntiva */ + /** @var $key \PleskX\Api\Struct\Server\LicenseAdditional\keyAdditionalInfo */ public $key; @@ -27,7 +28,7 @@ class LicenseAdditionalInfo extends \PleskX\Api\Struct { * @param \SimpleXMLElement $apiResponse Oggetto xml a partire da */ public function __construct( $apiResponse ) { - $this->_initScalarProperties( $apiResponse, [ + $this->initScalarProperties( $apiResponse, [ 'status', ]); diff --git a/src/Api/Struct/Server/LicenseInfo.php b/src/Api/Struct/Server/LicenseInfo.php index e4576186..62881384 100755 --- a/src/Api/Struct/Server/LicenseInfo.php +++ b/src/Api/Struct/Server/LicenseInfo.php @@ -2,13 +2,14 @@ namespace PleskX\Api\Struct\Server; +use PleskX\Api\AbstractStruct; use PleskX\Api\Struct\Server\License\keyInfo; /** * Struttura dati per le informazioni sulla licenza installata */ -class LicenseInfo extends \PleskX\Api\Struct { +class LicenseInfo extends AbstractStruct { /** @var string Stato della licenza */ public $status; @@ -21,7 +22,7 @@ class LicenseInfo extends \PleskX\Api\Struct { * @param \SimpleXMLElement $apiResponse Oggetto xml a partire da */ public function __construct( $apiResponse ) { - $this->_initScalarProperties( $apiResponse, [ + $this->initScalarProperties( $apiResponse, [ 'status', ]); diff --git a/src/Api/Struct/Server/LicenseInstall.php b/src/Api/Struct/Server/LicenseInstall.php index 0c13a778..df3ed777 100755 --- a/src/Api/Struct/Server/LicenseInstall.php +++ b/src/Api/Struct/Server/LicenseInstall.php @@ -3,10 +3,12 @@ namespace PleskX\Api\Struct\Server; +use PleskX\Api\AbstractStruct; + /** * Struttura dati per la response di installazione licenza principale o aggiuntiva */ -class LicenseInstall extends \PleskX\Api\Struct { +class LicenseInstall extends AbstractStruct { /** @var string Stato della licenza */ public $status; @@ -22,7 +24,7 @@ class LicenseInstall extends \PleskX\Api\Struct { * @param \SimpleXMLElement $apiResponse */ public function __construct( $apiResponse ) { - $this->_initScalarProperties( $apiResponse, [ + $this->initScalarProperties( $apiResponse, [ [ 'status' => 'status'], ]); diff --git a/src/Api/Struct/Server/LicensePropertyInfo.php b/src/Api/Struct/Server/LicensePropertyInfo.php index c17b4d6d..8fd4ea0b 100755 --- a/src/Api/Struct/Server/LicensePropertyInfo.php +++ b/src/Api/Struct/Server/LicensePropertyInfo.php @@ -3,10 +3,12 @@ namespace PleskX\Api\Struct\Server; +use PleskX\Api\AbstractStruct; + /** * Struttura dati per le informazioni su una proprietà di una licenza */ -class LicensePropertyInfo extends \PleskX\Api\Struct { +class LicensePropertyInfo extends AbstractStruct { /** @var string Nome della proprietà */ public $name; @@ -19,7 +21,7 @@ class LicensePropertyInfo extends \PleskX\Api\Struct { * @param \SimpleXMLElement $apiResponse */ public function __construct( $apiResponse ) { - $this->_initScalarProperties( $apiResponse, [ + $this->initScalarProperties( $apiResponse, [ 'name', 'value', ]); diff --git a/src/Api/Struct/Site/CompleteGeneralInfo.php b/src/Api/Struct/Site/CompleteGeneralInfo.php index 7afa2fd2..7b204b3d 100755 --- a/src/Api/Struct/Site/CompleteGeneralInfo.php +++ b/src/Api/Struct/Site/CompleteGeneralInfo.php @@ -3,7 +3,9 @@ namespace PleskX\Api\Struct\Site; -class CompleteGeneralInfo extends \PleskX\Api\Struct +use PleskX\Api\AbstractStruct; + +class CompleteGeneralInfo extends AbstractStruct { /** * Nome della subscription. E' il nome a dominio diff --git a/src/Api/Struct/Webspace/CompleteGeneralInfo.php b/src/Api/Struct/Webspace/CompleteGeneralInfo.php index f3dd3807..f4126e04 100755 --- a/src/Api/Struct/Webspace/CompleteGeneralInfo.php +++ b/src/Api/Struct/Webspace/CompleteGeneralInfo.php @@ -3,7 +3,9 @@ namespace PleskX\Api\Struct\Webspace; -class CompleteGeneralInfo extends \PleskX\Api\Struct +use PleskX\Api\AbstractStruct; + +class CompleteGeneralInfo extends AbstractStruct { /** * Nome della subscription. E' il nome a dominio diff --git a/src/Api/Struct/Webspace/HostingSetting.php b/src/Api/Struct/Webspace/HostingSetting.php index 40944e7f..af17d174 100755 --- a/src/Api/Struct/Webspace/HostingSetting.php +++ b/src/Api/Struct/Webspace/HostingSetting.php @@ -2,7 +2,9 @@ namespace PleskX\Api\Struct\Webspace; -class HostingSetting extends \PleskX\Api\Struct +use PleskX\Api\AbstractStruct; + +class HostingSetting extends AbstractStruct { /** @var array */ public $properties; From 89e226160874010365f88701107f5fb7e69b748f Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Thu, 4 Jan 2024 14:50:54 +0100 Subject: [PATCH 40/40] Fix reset() use --- src/Api/Operator/Webspace.php | 6 +++--- src/Api/Struct/Webspace/HostingSetting.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Api/Operator/Webspace.php b/src/Api/Operator/Webspace.php index 86a6f4ef..5e1cd791 100755 --- a/src/Api/Operator/Webspace.php +++ b/src/Api/Operator/Webspace.php @@ -137,7 +137,7 @@ public function getStatus( $webspaceId ) return null; } - return trim( reset( $response->data->gen_info->status ) ); + return trim( $response->data->gen_info->status ); } @@ -253,7 +253,7 @@ public function getPlanGuid( $guid ) return null; } - return trim( reset( $response->data->subscriptions->subscription->plan->$guidPropertyName ) ); + return trim( $response->data->subscriptions->subscription->plan->$guidPropertyName ); } @@ -369,7 +369,7 @@ public function getCurrentCertificate( $filters ) { foreach( $responseProperties as $property ) { if( $property->name == 'certificate_name' ) { - return trim( reset( $property->value ) ); + return trim( $property->value ); } } diff --git a/src/Api/Struct/Webspace/HostingSetting.php b/src/Api/Struct/Webspace/HostingSetting.php index af17d174..6ad51327 100755 --- a/src/Api/Struct/Webspace/HostingSetting.php +++ b/src/Api/Struct/Webspace/HostingSetting.php @@ -18,7 +18,7 @@ public function __construct($apiResponse) } foreach ($apiResponse->vrt_hst->property as $propertyInfo) { - $this->properties[reset( $propertyInfo->name)] = reset( $propertyInfo->value ); + $this->properties[$propertyInfo->name] = $propertyInfo->value; } } } \ No newline at end of file