Skip to content

Commit

Permalink
Allows PHPCS to pass and updates other commands for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Mar 21, 2020
1 parent aaca391 commit decd499
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 29 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ To generate an API access token, login to [https://cloud.acquia.com](https://clo
Alternatively, follow the below steps for a manual installation.
1. Copy the `default.acquiacli.yml` file to your project root and name it `acquiacli.yml`.
1. Add your Acquia key and secret to the `acquiacli.yml` file.
1. Optionally add your Cloudflare email address and API key to the `acquiacli.yml` file.


## Configuration
Expand Down Expand Up @@ -86,11 +85,6 @@ Some of the following commands have aliases for simplicity e.g. `environment:inf
# Add a user to a team and assign roles (Use role:list to obtain the role UUIDs).
./bin/acquiacli team:invite d2693c6e-58e7-47e5-8867-e2db88c71b8c '[email protected]' f0b89594-0fc5-4609-935f-1f18c313c6c7
# Get a list of DNS records for the foobar.com domain in Cloudflare
./bin/acquiacli cf:list foobar.com
# Add a record for www.foobar.com to point to 127.0.0.1 in Cloudflare.
./bin/acquiacli cf:add foobar.com A www 127.0.0.1
````

## See it in action
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typhonius/acquia_cli",
"description": "A Robo CLI tool for integrating with Acquia CloudAPI and Cloudflare",
"description": "A Robo CLI tool for integrating with Acquia CloudAPI",
"authors": [
{
"name": "Adam Malone",
Expand Down
3 changes: 0 additions & 3 deletions default.acquiacli.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
acquia:
key: 'd0697bfc-7f56-4942-9205-b5686bf5b3f5'
secret: 'D5UfO/4FfNBWn4+0cUwpLOoFzfP7Qqib4AoY+wYGsKE='
cloudflare:
mail: 'username@email'
key: 'Cloudflare key here'
extraconfig:
timezone: 'Australia/Sydney'
format: 'Y-m-d H:i:s'
Expand Down
40 changes: 37 additions & 3 deletions src/Commands/DbCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use AcquiaCloudApi\CloudApi\Connector;
use AcquiaCloudApi\Response\EnvironmentResponse;
use AcquiaCloudApi\Endpoints\Databases;
use AcquiaCloudApi\Endpoints\DatabaseBackups;
use Symfony\Component\Console\Helper\Table;

/**
Expand Down Expand Up @@ -49,16 +51,18 @@ public function acquiaBackupDb($uuid, $environment)
*/
public function acquiaDbBackupList($uuid, $environment)
{

$databases = $this->cloudapi->environmentDatabases($environment->uuid);
$dbAdapter = new Databases($this->cloudapi);
$databases = $dbAdapter->getAll($uuid);

$table = new Table($this->output());
$table->setHeaders(['ID', 'Type', 'Timestamp']);

foreach ($databases as $database) {
$dbName = $database->name;
$this->yell($dbName);
$backups = $this->cloudapi->databaseBackups($environment->uuid, $dbName);
$dbBackupsAdapter = new DatabaseBackups($this->cloudapi);
$backups = $dbBackupsAdapter->getAll($environment->uuid, $dbName);

foreach ($backups as $backup) {
$table
->addRows([
Expand Down Expand Up @@ -108,4 +112,34 @@ public function acquiaDbBackupLink($uuid, $environment, $dbName, $backupId)
$this->say(Connector::BASE_URI .
"/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}/actions/download");
}

/**
* Downloads a database backup.
*
* @param string $uuid
* @param EnvironmentResponse $environment
* @param string $dbName
* @param int $backupId
*
* @command db:backup:download
*/
public function acquiaDbBackupDownload($uuid, $environment, $dbName, $backupId, $path = null)
{

$dbAdapter = new DatabaseBackups($this->cloudapi);
$envName = $environment->name;
$backupName = "${envName}-${dbName}-${backupId}";
$backup = $dbAdapter->download($environment->uuid, $dbName, $backupId);

if (null === $path) {
$location = tempnam(sys_get_temp_dir(), $backupName) . '.tar.gz';
} else {
$location = $path . $backupName . ".tar.gz";
}
if (file_put_contents($location, $backup, LOCK_EX)) {
$this->say("Database backup downloaded to ${location}");
} else {
$this->say('Unable to download database backup.');
}
}
}
1 change: 0 additions & 1 deletion src/Commands/DomainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public function acquiaMoveDomain($uuid, $domain, $environmentFrom, $environmentT

$addResponse = $domainAdapter->create($environment->uuid, $domain);
$this->waitForNotification($addResponse);

}
}
}
11 changes: 9 additions & 2 deletions src/Commands/LogstreamCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ class LogstreamCommand extends AcquiaCommand
*
* @command log:stream
*/
public function streamLogs($uuid, EnvironmentResponse $environment, $opts = ['colourise|c' => false, 'logtypes|t' => [], 'servers|s' => []])
{
public function streamLogs(
$uuid,
EnvironmentResponse $environment,
$opts = [
'colourise|c' => false,
'logtypes|t' => [],
'servers|s' => []
]
) {
$logsAdapter = new Logs($this->cloudapi);
$stream = $logsAdapter->stream($environment->uuid);
$params = $stream->logstream->params;
Expand Down
13 changes: 0 additions & 13 deletions src/Commands/SetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,6 @@ private function createConfigYaml($location)
],
];


if ($this->confirm('Do you want to enter Cloudflare information?')) {
$cfmail = $this->ask('What is your Cloudflare email address?');
$cfkey = $this->askHidden('What is your Cloudflare API key?');

$config = $config + [
'cloudflare' => [
'mail' => $cfmail,
'key' => $cfkey,
],
];
}

$yaml = Yaml::dump($config, 3, 2);

if (!is_dir(dirname($location))) {
Expand Down

0 comments on commit decd499

Please sign in to comment.