Inheritance: extends Guzzle\Service\Client, implements Acquia\Rest\ServiceManagerAware
コード例 #1
0
ファイル: TagDeploy.php プロジェクト: rabellamy/flo
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $tag = $input->getArgument('tag');
     $GitHub = $this->getGithub(FALSE);
     $is_environment_available = FALSE;
     if (!$input->getOption('pre-release')) {
         try {
             $release = $GitHub->api('repo')->releases()->showTag($this->getConfigParameter('organization'), $this->getConfigParameter('repository'), $tag);
         } catch (\Exception $e) {
             $output->writeln("<error>Tag: {$tag} does not exists.</error>");
             return 1;
         }
         // If the release is already marked "prerelease" fail.
         if (!empty($release['prerelease']) && $release['prerelease'] == 1) {
             $output->writeln("<error>Tag: {$tag} is marked as pre-release. Please certify before deploying</error>");
             return 1;
         }
     }
     $env = $input->getArgument('env');
     $tag = 'tags/' . $input->getArgument('tag');
     $acquia = $this->getConfigParameter('acquia');
     $subscription = $this->getConfigParameter('subscription');
     if (empty($acquia['username']) || empty($acquia['username']) || empty($subscription)) {
         $output->writeln("<error>You must have your acquia username/password/subscription configured in your flo config to run deploys.</error>");
         return 1;
     }
     $cloud_api = CloudApiClient::factory(array('username' => $acquia['username'], 'password' => $acquia['password']));
     $acquia_environments = $cloud_api->environments($subscription);
     foreach ($acquia_environments as $acquia_env) {
         if ($acquia_env->name() == $env) {
             $is_environment_available = TRUE;
             break;
         }
     }
     if (!$is_environment_available) {
         $output->writeln("<error>Environment: {$env} does not exists on Acquia Cloud.</error>");
         return 1;
     }
     $task = $cloud_api->pushCode($subscription, $env, $tag);
     $progress = new ProgressBar($output, 100);
     $progress->start();
     while (!$task->completed()) {
         $progress->advance();
         // Lets not kill their api.
         sleep(2);
         $task = $cloud_api->task($subscription, $task);
     }
     $progress->finish();
     if ($task->state() == 'failed') {
         $output->writeln("\n<error>Task: {$task->id()} failed.</error>");
         $output->writeln($task->logs());
         return 1;
     }
     $output->writeln("\n<info>Tag: {$tag} deployed.</info>");
     $output->writeln($task->logs());
 }
コード例 #2
0
<?php

/**
 * @file
 * Example usage of the Acquia Cloud SDK for PHP.
 */
require_once 'vendor/autoload.php';
require_once 'config.php';
use Acquia\Cloud\Api\CloudApiClient;
$cloudapi = CloudApiClient::factory(array('username' => getenv('ACQUIA_CLOUD_USERNAME'), 'password' => getenv('ACQUIA_CLOUD_PASSWORD')));
// Get all available sites.
// $sites = $cloudapi->sites();
// Get information about a site.
// $site = $cloudapi->site($site);
// Get all available environments.
// $environments = $cloudapi->environments($site);
// Get information about an environment.
// $environment = $cloudapi->environment($site, 'test');
// Get information about all databases.
// $databases = $cloudapi->databases($site);
// Get information about an environment's database.
// $database = $cloudapi->database($site, $database);
// Back up an environment's database.
// $backup = $cloudapi->createDatabaseBackup($site, 'test', $database, '12345');
// Get a list of all an environment's database backups.
$backups = $cloudapi->databaseBackups($site, 'test', $database);
print_r($backups);
コード例 #3
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testRequirePassword()
 {
     CloudApiClient::factory(array('username' => 'test-username'));
 }