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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ Generate api key
```bash
bash /usr/local/vesta/bin/v-generate-api-key
```
Or you can view existing keys

```sh
ls -l /usr/local/vesta/data/keys/
```

## Usage

Expand All @@ -47,5 +51,5 @@ Simple usage
```php
use VestaAPI\Facades\Vesta;

$backups = Vesta::server('testVDS')->user('MyUserName')->listUserBackups();
$backups = Vesta::server('testVDS')->setUserName($userThatUWantToView)->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
1 change: 1 addition & 0 deletions config/vesta.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'servers' => [
'testVDS' => [
'host' => '0.0.0.0',
'admin' => 'admin',
'key' => 'secretString',
],
],
Expand Down
50 changes: 20 additions & 30 deletions src/Services/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,75 +11,65 @@ 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'));
}

/**
* Add Cron.
*
* @param $min
* @param $hour
* @param $day
* @param $month
* @param $wday
* @param $cmd
* @param $min
* @param $hour
* @param $day
* @param $month
* @param $wday
* @param $cmd
*
* @return mixed
*/
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));
}

/**
* Show Cron.
*
* @param $job
* @param $job
*
* @return mixed
*/
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'));
}

/**
* Delete cron.
*
* @param $job
* @param $job
*
* @return mixed
*/
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));
}

/**
* Edit cron.
*
* @param $job
* @param $min
* @param $hour
* @param $day
* @param $month
* @param $wday
* @param $cmd
* @param $job
* @param $min
* @param $hour
* @param $day
* @param $month
* @param $wday
* @param $cmd
*
* @return mixed
*/
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));
}
}
162 changes: 0 additions & 162 deletions src/Services/DNS.php

This file was deleted.

28 changes: 11 additions & 17 deletions src/Services/BD.php → src/Services/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace VestaAPI\Services;

trait BD
trait Db
{
/**
* List data base.
Expand All @@ -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,19 +65,19 @@ 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));
}

/**
* Delete data base.
*
* @param $database
* @param $database
*
* @return mixed
*/
public function deleteDateBase($database)
{
return $this->send('v-delete-database', $this->userName, $database);
return $this->toString($this->send('v-delete-database', $this->getUserName(), $database));
}
}
Loading