protected function execute($arguments = array(), $options = array())
 {
     $this->configuration = ProjectConfiguration::getApplicationConfiguration($options['app'], $options['env'], true);
     if (!sfConfig::get('app_sf_amazon_plugin_access_key', false)) {
         throw new sfException(sprintf('You have not set an amazon access key'));
     }
     if (!sfConfig::get('app_sf_amazon_plugin_secret_key', false)) {
         throw new sfException(sprintf('You have not set an amazon secret key'));
     }
     $s3 = new AmazonS3(sfConfig::get('app_sf_amazon_plugin_access_key'), sfConfig::get('app_sf_amazon_plugin_secret_key'));
     $this->s3_response = $s3->create_bucket($arguments['bucket'], $options['region'], $options['acl']);
     if ($this->s3_response->isOk()) {
         $this->log('Bucketed is being created...');
         /* Since AWS follows an "eventual consistency" model, sleep and poll
            until the bucket is available. */
         $exists = $s3->if_bucket_exists($arguments['bucket']);
         while (!$exists) {
             // Not yet? Sleep for 1 second, then check again
             sleep(1);
             $exists = $s3->if_bucket_exists($arguments['bucket']);
         }
         $this->logSection('Bucket+', sprintf('"%s" created successfully', $arguments['bucket']));
     } else {
         throw new sfException($this->s3_response->body->Message);
     }
 }
 /**
  * Parse Amazon response
  * @param \CFResponse $response
  * @return string
  * @throws \RuntimeException
  */
 protected function parseResponse(\CFResponse $response)
 {
     if ($response->isOk()) {
         return $response->body;
     } else {
         throw new \RuntimeException($response->body->Error->Message);
     }
 }
Exemple #3
0
 /**
  * Read the XML response into the $_items array if this is a supported
  * action.
  *
  * \note Currently this only supports AWS SDB actions: GetAttributesResult
  *      and SelectResult
  */
 public function __construct($header, $body, $status = null)
 {
     parent::__construct($header, $body, $status);
     if (isset($this->body->GetAttributesResult)) {
         $this->_getAttributesResult();
     } elseif (isset($this->body->SelectResult)) {
         $this->_getSelectResult();
     } elseif (isset($this->body->ListDomainsResult)) {
         $this->_getListDomainsResult();
     }
     $this->rewind();
 }