diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 73ee258c..4408ef08 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -# vendor /vendor/ - -# tests /phpunit.xml +.idea +/nbproject/ /.phpunit.result.cache -/coverage.xml \ No newline at end of file +/coverage.xml +composer.phar + diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 25fa379a..8cf9126c --- a/README.md +++ b/README.md @@ -6,62 +6,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 -`composer require plesk/api-php-lib` +See Pull Requests: -## Usage Examples +- 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 -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); +Methods in Operators and new Struct for: -$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 diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 index ef6f9710..b056e4b8 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "plesk/api-php-lib", + "name": "shellrent/plesk-api-php-lib", "type": "library", "description": "PHP object-oriented library for Plesk XML-RPC API", "license": "Apache-2.0", diff --git a/package.json b/package.json new file mode 100644 index 00000000..a9da5275 --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "plesk-api-php-lib", + "version": "1.0.0", + "devDependencies": { + "grunt": "~0.4.5", + "grunt-contrib-watch": "~0.6.1", + "grunt-phpunit": "~0.3.5" + } +} \ No newline at end of file diff --git a/src/Api/Client.php b/src/Api/Client.php old mode 100644 new mode 100755 index 0562d73c..78095614 --- a/src/Api/Client.php +++ b/src/Api/Client.php @@ -412,6 +412,9 @@ public function webspace(): Operator\Webspace return $this->getOperator('Webspace'); } + /** + * @return Operator\Subdomain + */ public function subdomain(): Operator\Subdomain { return $this->getOperator('Subdomain'); diff --git a/src/Api/Operator.php b/src/Api/Operator.php old mode 100644 new mode 100755 index 778da474..110e25e5 --- a/src/Api/Operator.php +++ b/src/Api/Operator.php @@ -103,4 +103,33 @@ protected function getItems($structClass, $infoTag, $field = null, $value = null 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'); + + $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/Api/Operator/Certificate.php b/src/Api/Operator/Certificate.php old mode 100644 new mode 100755 index b019bfc2..daf70bfa --- a/src/Api/Operator/Certificate.php +++ b/src/Api/Operator/Certificate.php @@ -20,4 +20,88 @@ public function generate(array $properties): Struct\Info 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 + * @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); + } + + + /** + * @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 ); + } } + diff --git a/src/Api/Operator/FtpUser.php b/src/Api/Operator/FtpUser.php new file mode 100755 index 00000000..77207a54 --- /dev/null +++ b/src/Api/Operator/FtpUser.php @@ -0,0 +1,61 @@ +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 + */ + public function updateFtpPassword( $ftpUser, $newPassword ) { + $packet = $this->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 ); + + $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/Api/Operator/PhpHandler.php b/src/Api/Operator/PhpHandler.php old mode 100644 new mode 100755 index 4409d45f..97b2c15a --- a/src/Api/Operator/PhpHandler.php +++ b/src/Api/Operator/PhpHandler.php @@ -56,4 +56,28 @@ public function getAll($field = null, $value = null): array 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/Api/Operator/Server.php b/src/Api/Operator/Server.php old mode 100644 new mode 100755 index 4a2ffb71..9ab78b66 --- a/src/Api/Operator/Server.php +++ b/src/Api/Operator/Server.php @@ -4,6 +4,7 @@ namespace PleskX\Api\Operator; use PleskX\Api\Struct\Server as Struct; +use PleskX\Api\Exception; use PleskX\Api\XmlResponse; class Server extends \PleskX\Api\Operator @@ -139,4 +140,63 @@ private function getInfo(string $operation): XmlResponse 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 = 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 $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/Api/Operator/ServicePlan.php b/src/Api/Operator/ServicePlan.php index 8e0f38eb..3f1a598a 100644 --- a/src/Api/Operator/ServicePlan.php +++ b/src/Api/Operator/ServicePlan.php @@ -26,6 +26,7 @@ public function delete(string $field, $value): bool } /** + * Restituisce i dettagli di un servizio a listino * @param string $field * @param int|string $value * diff --git a/src/Api/Operator/Site.php b/src/Api/Operator/Site.php old mode 100644 new mode 100755 index 96955ce5..c925d701 --- a/src/Api/Operator/Site.php +++ b/src/Api/Operator/Site.php @@ -81,7 +81,8 @@ function (\SimpleXMLElement $node) { return empty($items) ? null : reset($items); } - + + /** * @return Struct\GeneralInfo[] */ @@ -89,4 +90,13 @@ public function getAll(): array { 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/Api/Operator/Webspace.php b/src/Api/Operator/Webspace.php old mode 100644 new mode 100755 index a3f0563b..5e1cd791 --- a/src/Api/Operator/Webspace.php +++ b/src/Api/Operator/Webspace.php @@ -5,6 +5,7 @@ use PleskX\Api\Operator; use PleskX\Api\Struct\Webspace as Struct; +use PleskX\Api\XmlResponse; class Webspace extends Operator { @@ -14,7 +15,14 @@ public function getPermissionDescriptor(): Struct\PermissionDescriptor 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(): Struct\LimitDescriptor { $response = $this->request('get-limit-descriptor.filter'); @@ -49,6 +57,7 @@ public function getPhpSettings(string $field, $value): Struct\PhpSettings } /** + * ORIGINAL PLESK IMPLEMENTATION * @param string $field * @param int|string $value * @@ -105,7 +114,85 @@ public function create(array $properties, array $hostingProperties = null, strin return new Struct\Info($response, $properties['name'] ?? ''); } - + + + /** + * @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( $response->data->gen_info->status ); + } + + + /** + * 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 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 * @param int|string $value @@ -129,15 +216,94 @@ public function get(string $field, $value): Struct\GeneralInfo return reset($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 reset($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'; + + if( !isset( $response->data->subscriptions->subscription->plan->$guidPropertyName ) ) { + return null; + } + + return trim( $response->data->subscriptions->subscription->plan->$guidPropertyName ); + } + + + /** + * Restituisce l'ID della subscription (diverso dal GUID) + * @param string $name + * @return string + */ + public function getIdByName( $name ) { + $result = $this->_getId( 'name', $name ); + + if( isset( $result[0] ) ) { + return $result[0]; + } + + return null; + } + + + /** + * Esegue il cambio piano di un hosting + * @param int $webspaceId Id della Subscription + * @param string $planGuid + * @return XmlResponse + */ + 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', $planGuid ); + + $response = $this->client->request( $packet ); + + return $response; + } + + + /** + * 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(): array { return $this->getItems(Struct\GeneralInfo::class, 'gen_info'); } - + + /** * @param string $field * @param int|string $value @@ -150,6 +316,65 @@ public function getDiskUsage(string $field, $value): Struct\DiskUsage return reset($items); } + + + /** + * @param array $filters + * @param string|null $certificateName + * @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; + } + + + /** + * @param array $filters + * @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( $property->value ); + } + } + + return null; + } /** * @param string $field diff --git a/src/Api/Operator/Webuser.php b/src/Api/Operator/Webuser.php new file mode 100755 index 00000000..9581e01c --- /dev/null +++ b/src/Api/Operator/Webuser.php @@ -0,0 +1,11 @@ +initScalarProperties($apiResponse, [ + 'status', + ]); + } +} \ No newline at end of file diff --git a/src/Api/Struct/Certificate/PoolInfo.php b/src/Api/Struct/Certificate/PoolInfo.php new file mode 100755 index 00000000..9fca568f --- /dev/null +++ b/src/Api/Struct/Certificate/PoolInfo.php @@ -0,0 +1,19 @@ +initScalarProperties($apiResponse, [ + ['name' => 'name'], + ]); + } +} \ No newline at end of file diff --git a/src/Api/Struct/Certificate/RemoveInfo.php b/src/Api/Struct/Certificate/RemoveInfo.php new file mode 100755 index 00000000..53eaee9e --- /dev/null +++ b/src/Api/Struct/Certificate/RemoveInfo.php @@ -0,0 +1,19 @@ +initScalarProperties($apiResponse, [ + 'status', + ]); + } +} \ No newline at end of file diff --git a/src/Api/Struct/FtpUser/Info.php b/src/Api/Struct/FtpUser/Info.php new file mode 100644 index 00000000..cd6e0dd8 --- /dev/null +++ b/src/Api/Struct/FtpUser/Info.php @@ -0,0 +1,31 @@ +initScalarProperties($apiResponse, [ + 'id', + 'name', + 'home', + 'webspace_id', + ]); + } +} \ No newline at end of file diff --git a/src/Api/Struct/Server/License/keyInfo.php b/src/Api/Struct/Server/License/keyInfo.php new file mode 100644 index 00000000..c1ec1a89 --- /dev/null +++ b/src/Api/Struct/Server/License/keyInfo.php @@ -0,0 +1,30 @@ +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/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php b/src/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php new file mode 100644 index 00000000..2ec5f989 --- /dev/null +++ b/src/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php @@ -0,0 +1,53 @@ +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/Api/Struct/Server/LicenseAdditionalInfo.php b/src/Api/Struct/Server/LicenseAdditionalInfo.php new file mode 100755 index 00000000..1a2078de --- /dev/null +++ b/src/Api/Struct/Server/LicenseAdditionalInfo.php @@ -0,0 +1,48 @@ + + */ + 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/Api/Struct/Server/LicenseInfo.php b/src/Api/Struct/Server/LicenseInfo.php new file mode 100755 index 00000000..62881384 --- /dev/null +++ b/src/Api/Struct/Server/LicenseInfo.php @@ -0,0 +1,33 @@ + + */ + 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/Api/Struct/Server/LicenseInstall.php b/src/Api/Struct/Server/LicenseInstall.php new file mode 100755 index 00000000..df3ed777 --- /dev/null +++ b/src/Api/Struct/Server/LicenseInstall.php @@ -0,0 +1,40 @@ +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/Api/Struct/Server/LicensePropertyInfo.php b/src/Api/Struct/Server/LicensePropertyInfo.php new file mode 100755 index 00000000..8fd4ea0b --- /dev/null +++ b/src/Api/Struct/Server/LicensePropertyInfo.php @@ -0,0 +1,29 @@ +initScalarProperties( $apiResponse, [ + 'name', + 'value', + ]); + } +} \ No newline at end of file diff --git a/src/Api/Struct/Site/CompleteGeneralInfo.php b/src/Api/Struct/Site/CompleteGeneralInfo.php new file mode 100755 index 00000000..7b204b3d --- /dev/null +++ b/src/Api/Struct/Site/CompleteGeneralInfo.php @@ -0,0 +1,84 @@ +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 diff --git a/src/Api/Struct/Webspace/CompleteGeneralInfo.php b/src/Api/Struct/Webspace/CompleteGeneralInfo.php new file mode 100755 index 00000000..f4126e04 --- /dev/null +++ b/src/Api/Struct/Webspace/CompleteGeneralInfo.php @@ -0,0 +1,84 @@ +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 diff --git a/src/Api/Struct/Webspace/HostingSetting.php b/src/Api/Struct/Webspace/HostingSetting.php new file mode 100755 index 00000000..6ad51327 --- /dev/null +++ b/src/Api/Struct/Webspace/HostingSetting.php @@ -0,0 +1,24 @@ +properties = []; + + if( !isset( $apiResponse->vrt_hst->property ) ) { + return; + } + + foreach ($apiResponse->vrt_hst->property as $propertyInfo) { + $this->properties[$propertyInfo->name] = $propertyInfo->value; + } + } +} \ No newline at end of file diff --git a/src/Api/Struct/Webspace/Limit.php b/src/Api/Struct/Webspace/Limit.php old mode 100644 new mode 100755 index 0d12fa14..bb8ddf77 --- a/src/Api/Struct/Webspace/Limit.php +++ b/src/Api/Struct/Webspace/Limit.php @@ -1,5 +1,4 @@