Skip to content

Feature/t 2016 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/PleskX/Api/Client.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@ public function webspace()
return $this->_getOperator('Webspace');
}

/**
* @return Operator\PhpHandler
*/
public function phpHandler()
{
return $this->_getOperator('PhpHandler');
}

/**
* @return Operator\Subdomain
*/
Expand Down
33 changes: 33 additions & 0 deletions src/PleskX/Api/Operator/PhpHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
// Copyright 1999-2016. Parallels IP Holdings GmbH.

namespace PleskX\Api\Operator;


class PhpHandler extends \PleskX\Api\Operator
{

/**
* 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;
}
}
1 change: 1 addition & 0 deletions src/PleskX/Api/Operator/ServicePlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/PleskX/Api/Operator/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

}
83 changes: 77 additions & 6 deletions src/PleskX/Api/Operator/Webspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -134,7 +141,59 @@ 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 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( reset( $response->data->subscriptions->subscription->plan->$guidPropertyName ) );
}


/**
* Restituisce l'ID della subscription (diverso dal GUID)
* @param string $name
* @return string
*/
Expand All @@ -151,17 +210,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 );

Expand All @@ -170,11 +229,23 @@ 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()
{
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' );
}
}
82 changes: 82 additions & 0 deletions src/PleskX/Api/Struct/Site/CompleteGeneralInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

namespace PleskX\Api\Struct\Site;


class CompleteGeneralInfo extends \PleskX\Api\Struct
{
/**
* Nome della subscription. E' il nome a dominio
* @var string
*/
public $Name;

/**
* Data creazione subscription. Formato YYYY-MM-DD
* @var string
*/
public $CreationDate;

/**
* Nome della subscription in formato ASCII. E' il nome a dominio in formato ASCII
* @var string
*/
public $AsciiName;

/**
* Codice dello stato della subscription
* Allowed values:
* 0 (active)
* 4 (under backup/restore)
* 16 (disabled by Plesk Administrator)
* 32 (disabled by Plesk reseller)
* 64 (disabled by Plesk customer)
* 256 (expired)
* @var string
*/
public $Status;

/**
* Dimensione della subscription (bytes)
* @var string unsignedLong
*/
public $RealSize;

/**
* Subscription GUID
* @var string
*/
public $Guid;


/**
* @param \SimpleXMLElement $apiResponse
*/
public function __construct( $apiResponse )
{
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';
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;
}
}
}
82 changes: 82 additions & 0 deletions src/PleskX/Api/Struct/Webspace/CompleteGeneralInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

namespace PleskX\Api\Struct\Webspace;


class CompleteGeneralInfo extends \PleskX\Api\Struct
{
/**
* Nome della subscription. E' il nome a dominio
* @var string
*/
public $Name;

/**
* Data creazione subscription. Formato YYYY-MM-DD
* @var string
*/
public $CreationDate;

/**
* Nome della subscription in formato ASCII. E' il nome a dominio in formato ASCII
* @var string
*/
public $AsciiName;

/**
* Codice dello stato della subscription
* Allowed values:
* 0 (active)
* 4 (under backup/restore)
* 16 (disabled by Plesk Administrator)
* 32 (disabled by Plesk reseller)
* 64 (disabled by Plesk customer)
* 256 (expired)
* @var string
*/
public $Status;

/**
* Dimensione della subscription (bytes)
* @var string unsignedLong
*/
public $RealSize;

/**
* Subscription GUID
* @var string
*/
public $Guid;


/**
* @param \SimpleXMLElement $apiResponse
*/
public function __construct( $apiResponse )
{
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';
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;
}
}
}
22 changes: 22 additions & 0 deletions src/PleskX/Api/Struct/Webspace/HostingSetting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace PleskX\Api\Struct\Webspace;

class HostingSetting extends \PleskX\Api\Struct
{
/** @var array */
public $properties;

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 );
}
}
}
Loading