@param string $site
@param string $env
@param string $domain

@return \Acquia\Cloud\Api\Response\Task

@throws \Guzzle\Http\Exception\ClientErrorResponseException

@see http://cloudapi.acquia.com/#POST__sites__site_envs__env_domains__domain-instance_route
547872
public function addDomain($site, $env, $domain)
    {
      $variables = array(
        'site' => $site,
        'env' => $env,
        'domain' => $domain,
      );
      $request = $this->post(array('{+base_path}/sites/{site}/envs/{env}/domains/{domain}.json', $variables));
      return new Response\Task($request);
    }
763584
public function getSiteNotAvailableRedirectUrl(Site $site)
    {
        if ($site->isSiteAvailable()) {
            return null;
        }

        $defaultDomain = $this->domainService->getDefaultDomainName();

        if (empty($defaultDomain)) {
            return null;
        }

        if ($defaultDomain == $site->getDomain()->getDomainName()) {
            return null;
        }

        return $defaultDomain;
    }
409177
public function enableLiveDev($site, $env, $discard = false)
    {
        return $this->liveDev($site, $env, self::LIVEDEV_ENABLE, $discard);
    }
641647
public function createDomain($environmentUuid, $hostname)
    {

        $options = [
            'form_params' => [
                'hostname' => $hostname,
            ],
        ];

        return new OperationResponse(
            $this->connector->request('post', "/environments/${environmentUuid}/domains", $this->query, $options)
        );
    }
679963
function runSingle(task, domain) {
        try {
            task();

        } catch (e) {
            if (isNodeJS) {
                // In node, uncaught exceptions are considered fatal errors.
                // Re-throw them synchronously to interrupt flushing!

                // Ensure continuation if the uncaught exception is suppressed
                // listening "uncaughtException" events (as domains does).
                // Continue in next event to avoid tick recursion.
                if (domain) {
                    domain.exit();
                }
                setTimeout(flush, 0);
                if (domain) {
                    domain.enter();
                }

                throw e;

            } else {
                // In browsers, uncaught exceptions are not fatal.
                // Re-throw them asynchronously to avoid slow-downs.
                setTimeout(function () {
                    throw e;
                }, 0);
            }
        }

        if (domain) {
            domain.exit();
        }
    }
198133
public function getoneConfigActivity(string $env):Renderer
    {
        if (!in_array($env, array("dev", "prod"))) {
            throw new Server500(new \ArrayObject(array("explain" => "Undefined environment $env", "solution" =>
            "Environment must be [dev or prod]")));
        }

        $file = (array) JL::open(FEnv::get("framework.config").'hosts/hosts.'.$env.'.json');
        if (!(isset($file['allowed'])) || !(isset($file['denied']))) {
            throw new Server500(new \ArrayObject(array("explain" => "Undefined key allowed or denied in host.dev.json",
                "solution" => "Add the correct tags [allowed, denied]")));
        }

        $allowed = ((array)$file['allowed']);
        $denied = ((array)$file['denied']);


        return ((new Renderer())->jsonRenderer(array("code" => 200,
            "results" => array("allowed" => implode(";", $allowed), "denied" => implode(";", $denied)))));
    }
848957
public function newDomainAction(Domain $domain = null, Site $site = null)
    {
        $this->view->assignMultiple([
            'domain' => $domain,
            'site' => $site,
            'schemes' => [null => '', 'http' => 'HTTP', 'https' => 'HTTPS']
        ]);
    }
1277468
public Task pollTask(String taskType, String workerId, String domain) {
        Preconditions.checkArgument(StringUtils.isNotBlank(taskType), "Task type cannot be blank");
        Preconditions.checkArgument(StringUtils.isNotBlank(domain), "Domain cannot be blank");
        Preconditions.checkArgument(StringUtils.isNotBlank(workerId), "Worker id cannot be blank");

        Object[] params = new Object[]{"workerid", workerId, "domain", domain};
        Task task = getForEntity("tasks/poll/{taskType}", params, Task.class, taskType);
        populateTaskInput(task);
        return task;
    }
303023
private function createV1Website($name, $ipAddress, $https, array $domains, array...$siteApps)
    {

        return $this->send('create_website', $name, $ipAddress, $https, $domains, ...$siteApps);
    }
510351
def call(env)
      if env[:method] == :get && env[:url].to_s.size > 2000
        env[:request_headers][HEADER] = 'GET'
        env[:request_headers]['Content-Type'] =
          'application/x-www-form-urlencoded'
        env[:body] = env[:url].query
        env[:url].query = nil
        env[:method] = :post
      end

      @app.call(env)
    end
1336613
public function domainAction()
    {
        $request = $this->getRequest();
        $type    = $request->getParam( 'type' );
        $domain  = $request->getParam( 'domain' );

        if ( ! $request instanceof ConsoleRequest )
        {
            throw new \RuntimeException( sprintf(
                '%s can only be used from a console.',
                __METHOD__
            ) );
        }

        $siteInfo = $this->getServiceLocator()
                         ->get( 'SiteInfo' );

        if ( $domain != $siteInfo->getDomain() )
        {
            throw new \RuntimeException( sprintf(
                '%s: domain mismatch. Detected "%s", while enforced "%s".',
                __METHOD__,
                $siteInfo->getDomain(),
                $domain
            ) );
        }

        $locator    = $this->getServiceLocator();
        $config     = $locator->get( 'Configuration' );

        if ( empty( $config['modules']['Grid\Core']['cron'] ) )
        {
            return '';
        }

        $result     = '';
        $keys       = array( 'site' );
        $cronConfig = $config['modules']['Grid\Core']['cron'];
        $modules    = $locator->get( 'Zend\ModuleManager\ModuleManagerInterface' )
                              ->getModules();

        if ( ! in_array( 'Grid\MultisitePlatform', $modules ) ||
               in_array( 'Grid\MultisiteCentral',  $modules ) )
        {
            $keys[] = 'once';
        }

        foreach ( $keys as $key )
        {
            if ( ! empty( $cronConfig[$key][$type] ) )
            {
                foreach ( $cronConfig[$key][$type] as $service )
                {
                    if ( is_scalar( $service ) )
                    {
                        $service = array(
                            'service' => $service,
                        );
                    }

                    if ( ! empty( $service['service'] ) )
                    {
                        $return = call_user_func_array(
                            array(
                                $this->getServiceLocator()
                                     ->get( $service['service'] ),
                                empty( $service['method'] )
                                    ? '__invoke'
                                    : (string) $service['method']
                            ),
                            empty( $service['arguments'] )
                                ? array()
                                : (array) $service['arguments']
                        );

                        $result .= sprintf(
                            'Service "%s" / %s / %s ',
                            $service['service'],
                            $key,
                            $type
                        );

                        if ( ! empty( $service['method'] ) )
                        {
                            $result .= sprintf( 'called "%s" ', $service['method'] );
                        }

                        if ( ! empty( $service['arguments'] ) )
                        {
                            $result .= Debug::dump(
                                $service['arguments'],
                                'with',
                                false
                            );
                        }

                        $result .= Debug::dump( $return, 'returned', false );
                    }
                }
            }
        }

        return $result;
    }
1048060
def route(self, environ, start_response):
        
        urls = self.url_map.bind_to_environ(environ)
        request = WsgiRequest(environ)
        try:
            endpoint, args = urls.match()
        except HTTPException as e:
            return self.error(e.code, request)(environ, start_response)
        else:
            procedure = getattr(self, endpoint)
            response = procedure(request, args)
            return response(environ, start_response)
49674
public function collectEnvVars(array $env)
    {
        $envCollector = new CiEnvVarsCollector($this->config);

        try {
            $this->jsonFile->fillJobs($envCollector->collect($env));
        } catch (\PhpCoveralls\Bundle\CoverallsBundle\Entity\Exception\RequirementsNotSatisfiedException $e) {
            $e->setReadEnv($envCollector->getReadEnv());

            throw $e;
        }

        return $this;
    }
471848
public function task($site, $taskId)
    {
        $variables = array(
            'site' => $site,
            'task' => $taskId,
        );
        $request = $this->get(array('{+base_path}/sites/{site}/tasks/{task}.json', $variables));
        return new Response\Task($request);
    }
157295
public function publish(string $appname, string $env)
    {
        $this->clear($appname, $env);
        if ($appname == "_all") {
            $dirs = scandir(FEnv::get("framework.apps"));
            foreach ($dirs as $dir) {
                if ($dir == ".") {
                    continue;
                }
                if ($dir == "..") {
                    continue;
                }
                if (!is_dir(FEnv::get("framework.root") . "apps/" . $dir)) {
                    continue;
                }
                if (in_array(strtolower($env), array("dev", "prod", "all"))) {
                    if (file_exists(FEnv::get("framework.root") . "apps/" . $dir . "/Front/Resources/")) {
                        if (strtolower($env) === "dev") {
                            Server::copy(
                                FEnv::get("framework.apps") . $dir . "/Front/Resources/",
                                FEnv::get("framework.root") . "public/components/apps/dev/" . strtolower($dir),
                                'directory',
                                true
                            );
                        } elseif (strtolower($env) == "prod") {
                            Server::copy(
                                FEnv::get("framework.apps"). $dir . "/Front/Resources/",
                                FEnv::get("framework.root") .
                                "public/components/apps/prod/" . strtolower($dir),
                                'directory',
                                false
                            );
                        } else {
                            if (Server::exist(FEnv::get("framework.root") .
                                "apps/" . $dir . "/Front/Resources/")) {
                                Server::copy(FEnv::get("framework.root") .
                                    "apps/" . $dir . "/Front/Resources/", FEnv::get("framework.root") .
                                    "public/components/apps/dev/" . strtolower($dir), 'directory', true);
                                Server::copy(FEnv::get("framework.root") .
                                    "apps/" . $dir . "/Front/Resources/", FEnv::get("framework.root") .
                                    "public/components/apps/prod/" . strtolower($dir), 'directory', false);
                            }
                        }
                    }
                }
            }
        } elseif ($appname !== "") {
            if (in_array(strtolower($env), array("dev", "prod", "all"))) {
                if (file_exists(FEnv::get("framework.root")."apps/" . ($appname) . "/Front/Resources/")) {
                    if (strtolower($env) === "dev") {
                        Server::copy(FEnv::get("framework.root") .
                            "apps/" . ($appname) . "/Front/Resources/", FEnv::get("framework.root") .
                            "public/components/apps/dev/" . strtolower($appname), 'directory', true);
                    } elseif (strtolower($env) == "prod") {
                        Server::copy(FEnv::get("framework.root") .
                            "apps/" . ($appname) . "/Front/Resources/", FEnv::get("framework.root") .
                            "public/components/apps/prod/" . strtolower($appname), 'directory', false);
                    } else {
                        Server::copy(FEnv::get("framework.root") .
                            "apps/" . ($appname) . "/Front/Resources/", FEnv::get("framework.root") .
                            "public/components/apps/dev/" . strtolower($appname), 'directory', true);
                        Server::copy(FEnv::get("framework.root") .
                            "apps/" . ($appname) . "/Front/Resources/", FEnv::get("framework.root") .
                            "public/components/apps/prod/" . strtolower($appname), 'directory', false);
                    }
                }
            }
        }
    }
534810
public function sshKeys($site)
    {
        $variables = array('site' => $site);
        $request = $this->get(array('{+base_path}/sites/{site}/sshkeys.json', $variables));
        return new Response\SshKeys($request);
    }
167106
public function validateZone(CNabuSiteTarget $nb_site_target)
    {
        $nb_engine = CNabuEngine::getEngine();

        if (!(($nb_site = $nb_site_target->getSite()) instanceof CNabuSite)) {
            throw new ENabuCoreException(ENabuCoreException::ERROR_SITE_NOT_FOUND);
        }

        $this->zone = ($this->nb_user !== null ? 'P' : 'O');
        $nb_engine->traceLog("Request Zone", ($this->zone === 'P' ? 'Private' : 'Public'));

        $site_target_zone = $nb_site_target->getZone();
        $nb_engine->traceLog(
                "Page Zone",
                ($site_target_zone === 'P' ? 'Private' : ($site_target_zone === 'O' ? 'Public' : 'Both'))
        );

        $retval = ($site_target_zone === 'B') ||
                  ($site_target_zone !== null && $site_target_zone === $this->zone);

        if ($retval && $this->zone === 'P' && $nb_site->getRequirePoliciesAfterLogin() === 'T') {
            if ($this->nb_user->getPoliciesAccepted() === 'T') {
                $nb_engine->traceLog('Policies', 'Accepted');
            } else {
                $nb_engine->traceLog('Policies', 'Not accepted');
                if ($nb_site_target->getIgnorePolicies() === 'F' &&
                    ($link = $nb_site->getPoliciesTargetLink())->isLinkable() &&
                    !($link->matchTarget($nb_site_target))
                ) {
                    throw new ENabuRedirectionException(428, new CNabuHTTPRedirection(428, $link->getBestQualifiedURL()));
                }
            }
        }

        return $retval;
    }