コード例 #1
0
ファイル: Organization.php プロジェクト: mikevanwinkle/cli
 public function removeSite(Site $site)
 {
     $workflow = new Workflow('remove_organization_site_membership', 'organizations', $this);
     $workflow->setParams(array('site_id' => $site->getId()));
     $workflow->setMethod("POST");
     $workflow->start();
     $workflow->wait();
     return $workflow;
 }
コード例 #2
0
ファイル: Site.php プロジェクト: spleshka/cli
 /**
  * Create a new Site
  * @param $options (array)
  *   @param $options label(string)
  *   @param $options name(string)
  *   @option $options organization_id(string)
  *   @option product_id(string)
  *
  * @return Workflow
  *
  */
 static function create($options = array())
 {
     $data = array('label' => $options['label'], 'site_name' => $options['name']);
     if (isset($options['organization_id'])) {
         $data['organization_id'] = $options['organization_id'];
     }
     if (isset($options['product_id'])) {
         $data['deploy_product'] = array('product_id' => $options['product_id']);
     }
     $workflow = Workflow::createWorkflow('create_site', 'users', new User());
     $workflow->setMethod('POST');
     $workflow->setParams($data);
     $workflow->start();
     return $workflow;
 }
コード例 #3
0
ファイル: sites.php プロジェクト: xwp/pantheon-cli
 /**
  * Create a new site
  *
  * ## OPTIONS
  *
  * [--product=<productid>]
  * : Specify the product to create
  *
  * [--name=<name>]
  * : (deprecated) use --site instead
  *
  * [--site=<site>]
  * : Name of the site to create (machine-readable)
  *
  * [--label=<label>]
  * : Label for the site
  *
  * [--org=<org>]
  * : UUID of organization to add this site to; or "None"
  *
  * [--import=<url>]
  * : A url to import a valid archive from
  */
 public function create($args, $assoc_args)
 {
     $sites = SiteFactory::instance();
     // setup data
     $data = array();
     $data['label'] = Input::string($assoc_args, 'label', "Human readable label for the site");
     $slug = Utils\sanitize_name($data['label']);
     // this ugly logic is temporarily if to handle the deprecated --name flag and preserve backward compatibility. it can be removed in the next major release.
     if (array_key_exists('name', $assoc_args)) {
         $data['site_name'] = $assoc_args['name'];
     } elseif (array_key_exists('site', $assoc_args)) {
         $data['site_name'] = $assoc_args['site'];
     } else {
         $data['site_name'] = Input::string($assoc_args, 'site', "Machine name of the site; used as part of the default URL [ if left blank will be {$slug}]", $slug);
     }
     if ($orgid = Input::orgid($assoc_args, 'org', false)) {
         $data['organization_id'] = $orgid;
     }
     if (!isset($assoc_args['import'])) {
         $product = Input::product($assoc_args, 'product');
         $data['deploy_product'] = array('product_id' => $product['id']);
         Terminus::line(sprintf("Creating new %s installation ... ", $product['longname']));
     }
     $params = array('body' => json_encode($data), 'headers' => array('Content-type' => 'application/json'));
     // run the workflow
     $workflow = Workflow::createWorkflow('create_site', 'users', new User());
     $workflow->setMethod('POST');
     $workflow->setParams($data);
     $workflow->start();
     $workflow->refresh();
     $details = $workflow->status();
     $site_id = $details->final_task->site_id;
     if ($details->result !== 'failed' and $details->result !== 'aborted') {
         Terminus\Loggers\Regular::coloredOutput('%G' . vsprintf('New "site" %s now building with "UUID" %s', array($data['site_name'], $site_id)));
     }
     $workflow->wait();
     Terminus::success("Pow! You created a new site!");
     $this->cache->flush(null, 'session');
     if (isset($assoc_args['import'])) {
         Terminus::launch_self('site', array('import'), array('url' => $assoc_args['import'], 'site' => $data['site_name'], 'element' => 'all', 'nocache' => True));
     }
     return true;
 }