Skip to content
This repository was archived by the owner on May 11, 2023. It is now read-only.
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ Simple usage
```php
use VestaAPI\Facades\Vesta;

$backups = Vesta::server('testVDS')->user('MyUserName')->listUserBackups();
$backups = Vesta::server('testVDS')->setUserName('MyUserName')->listUserBackups();

1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
],
"type": "library",
"require": {
"guzzlehttp/guzzle": "^6.2",
"laravel/framework": "^5.0"
},
"license": "GPL-3.0",
Expand Down
24 changes: 9 additions & 15 deletions src/Services/BD.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ trait BD
*/
public function listBD()
{
$this->returnCode = 'no';

return json_decode($this->send('v-list-databases', $this->userName, 'json'), true);
return $this->setReturnCode(self::RETURN_CODE_NO)->toArray($this->send('v-list-databases', $this->getUserName(), 'json'));
}

/**
* Change user database.
*
* @param $database
* @param $dbuser
* @param $dbUser
*
* @return mixed
*/
public function changeDbUser($database, $dbuser)
public function changeDbUser($database, $dbUser)
{
return $this->send('v-change-database-user', $this->userName, $database, $dbuser);
return $this->toString($this->send('v-change-database-user', $this->getUserName(), $database, $dbUser));
}

/**
Expand All @@ -39,7 +37,7 @@ public function changeDbUser($database, $dbuser)
*/
public function changeDbPassword($database, $password)
{
return $this->send('v-change-database-password', $this->userName, $database, $password);
return $this->toString($this->send('v-change-database-password', $this->getUserName(), $database, $password));
}

/**
Expand All @@ -51,11 +49,7 @@ public function changeDbPassword($database, $password)
*/
public function listOnlyBD($database)
{
$this->returnCode = 'no';
$listBd = $this->send('v-list-database', $this->userName, $database, 'json');
$data = json_decode($listBd, true);

return $data;
return $this->setReturnCode(self::RETURN_CODE_NO)->toArray($this->send('v-list-database', $this->getUserName(), $database, 'json'));
}

/**
Expand All @@ -71,8 +65,8 @@ public function listOnlyBD($database)
*/
public function addDateBase($database, $dbuser, $password, $type, $charset)
{
return $this->send('v-add-database', $this->userName, $database, $dbuser, $password, $type,
'localhost', $charset);
return $this->toString($this->send('v-add-database', $this->getUserName(), $database, $dbuser, $password, $type,
'localhost', $charset));
}

/**
Expand All @@ -84,6 +78,6 @@ public function addDateBase($database, $dbuser, $password, $type, $charset)
*/
public function deleteDateBase($database)
{
return $this->send('v-delete-database', $this->userName, $database);
return $this->toString($this->send('v-delete-database', $this->getUserName(), $database));
}
}
20 changes: 5 additions & 15 deletions src/Services/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ trait Cron
*/
public function listCron()
{
$this->returnCode = 'no';
$listDns = $this->send('v-list-cron-jobs', $this->userName, 'json');
$data = json_decode($listDns, true);

return $data;
return $this->setReturnCode(self::RETURN_CODE_NO)->toArray($this->send('v-list-cron-jobs', $this->getUserName(), 'json'));
}

/**
Expand All @@ -32,8 +28,7 @@ public function listCron()
*/
public function addCron($min, $hour, $day, $month, $wday, $cmd)
{
return $this->send('v-add-cron-job', $this->userName, $min, $hour, $day, $month, $wday,
$cmd);
return $this->toString($this->send('v-add-cron-job', $this->getUserName(), $min, $hour, $day, $month, $wday, $cmd));
}

/**
Expand All @@ -45,11 +40,7 @@ public function addCron($min, $hour, $day, $month, $wday, $cmd)
*/
public function showCron($job)
{
$this->returnCode = 'no';
$request = $this->send('v-list-cron-job', $this->userName, $job, 'json');
$data = json_decode($request, true);

return $data;
return $this->setReturnCode(self::RETURN_CODE_NO)->toArray($this->send('v-list-cron-job', $this->getUserName(), $job, 'json'));
}

/**
Expand All @@ -61,7 +52,7 @@ public function showCron($job)
*/
public function deleteCron($job)
{
return $this->send('v-delete-cron-job', $this->userName, $job);
return $this->toString($this->send('v-delete-cron-job', $this->getUserName(), $job));
}

/**
Expand All @@ -79,7 +70,6 @@ public function deleteCron($job)
*/
public function editCron($job, $min, $hour, $day, $month, $wday, $cmd)
{
return $this->send('v-change-cron-job', $this->userName, $job, $min, $hour, $day, $month,
$wday, $cmd);
return $this->toString($this->send('v-change-cron-job', $this->getUserName(), $job, $min, $hour, $day, $month, $wday, $cmd));
}
}
41 changes: 16 additions & 25 deletions src/Services/DNS.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ trait DNS
*/
public function listDNS()
{
$this->returnCode = 'no';
$listDns = $this->send('v-list-dns-domains', $this->userName, 'json');
$data = json_decode($listDns, true);

return $data;
return $this->setReturnCode(self::RETURN_CODE_NO)->toArray($this->send('v-list-dns-domains', $this->getUserName(), 'json'));
}

/**
Expand All @@ -27,11 +23,7 @@ public function listDNS()
*/
public function listOnlyDNS($dns)
{
$this->returnCode = 'no';
$listDNS = $this->send('v-list-dns-domain', $this->userName, $dns, 'json');
$data = json_decode($listDNS, true);

return $data;
return $this->setReturnCode(self::RETURN_CODE_NO)->toArray($this->send('v-list-dns-domain', $this->getUserName(), $dns, 'json'));
}

/**
Expand All @@ -43,7 +35,7 @@ public function listOnlyDNS($dns)
*/
public function deleteDNDDomain($domain)
{
return $this->send('v-delete-dns-domain', $this->userName, $domain);
return $this->toString($this->send('v-delete-dns-domain', $this->getUserName(), $domain));
}

/**
Expand All @@ -56,7 +48,7 @@ public function deleteDNDDomain($domain)
*/
public function deleteDNSRecord($domain, $recordId)
{
return $this->send('v-delete-dns-record', $this->userName, $domain, $recordId);
return $this->toString($this->send('v-delete-dns-record', $this->getUserName(), $domain, $recordId));
}

/**
Expand All @@ -73,8 +65,8 @@ public function deleteDNSRecord($domain, $recordId)
*/
public function addDNSDomain($domain, $ip, $ns1, $ns2, $ns3 = null, $ns4 = null)
{
return $this->send('v-add-dns-domain', $this->userName, $domain, $ip, $ns1, $ns2, $ns3,
$ns4, 'no');
return $this->toString($this->send('v-add-dns-domain', $this->getUserName(), $domain, $ip, $ns1, $ns2, $ns3, $ns4,
'no'));
}

/**
Expand All @@ -87,7 +79,7 @@ public function addDNSDomain($domain, $ip, $ns1, $ns2, $ns3 = null, $ns4 = null)
*/
public function changeDNSDomainExp($domain, $exp)
{
return $this->send('v-change-dns-domain-exp', $this->userName, $domain, $exp, 'no');
return $this->toString($this->send('v-change-dns-domain-exp', $this->getUserName(), $domain, $exp, 'no'));
}

/**
Expand All @@ -100,7 +92,7 @@ public function changeDNSDomainExp($domain, $exp)
*/
public function changeDNSDomainTtl($domain, $ttl)
{
return $this->send('v-change-dns-domain-ttl', $this->userName, $domain, $ttl, 'no');
return $this->toString($this->send('v-change-dns-domain-ttl', $this->getUserName(), $domain, $ttl, 'no'));
}

/**
Expand All @@ -112,11 +104,7 @@ public function changeDNSDomainTtl($domain, $ttl)
*/
public function listDNSRecords($domain)
{
$this->returnCode = 'no';
$data = $this->send('v-list-dns-records', $this->userName, $domain, 'json');
$data = json_decode($data, true);

return $data;
return $this->setReturnCode(self::RETURN_CODE_NO)->toArray($this->send('v-list-dns-records', $this->getUserName(), $domain, 'json'));
}

/**
Expand All @@ -131,19 +119,20 @@ public function listDNSRecords($domain)
*/
public function changeDNSDomainRecord($domain, $recordId, $val, $priority)
{
return $this->send('v-change-dns-record', $this->userName, $domain, $recordId, $val,
$priority);
return $this->toString($this->send('v-change-dns-record', $this->getUserName(), $domain, $recordId, $val, $priority));
}

/**
* Remove DNS record.
*
* @param $domain
* @param $recordId
*
* @return string
*/
public function removeDNSRecord($domain, $recordId)
{
$this->send('v-delete-dns-record', $this->userName, $domain, $recordId);
return $this->toString($this->send('v-delete-dns-record', $this->getUserName(), $domain, $recordId));
}

/**
Expand All @@ -154,9 +143,11 @@ public function removeDNSRecord($domain, $recordId)
* @param $type
* @param $val
* @param $priority
*
* @return string
*/
public function addDNSRecord($domain, $rec, $type, $val, $priority)
{
$this->send('v-add-dns-record', $this->userName, $domain, $rec, $type, $val, $priority);
return $this->toString($this->send('v-add-dns-record', $this->getUserName(), $domain, $rec, $type, $val, $priority));
}
}
Loading