$apiResponse = new APIViewData(1, $deployment, "Unable to detect note parameter (note about updates or changes)");
        $app->halt(404, $apiResponse->returnJson());
    }
    $currentRev = RevDeploy::getDeploymentRev($deployment);
    RevDeploy::setDeploymentRevs($deployment, $currentRev, $revisionInfo['revision'], $revisionInfo['note']);
    VarnishCache::invalidate($deployment);
    $apiResponse = new APIViewData(0, $deployment, "Successfully Activated Revision [ " . $revisionInfo['revision'] . " ] Replacing Revision [ " . $currentRev . " ]");
    $apiResponse->printJson();
})->name('saigon-api-change-revisions');
$app->delete('/sapi/deployment/:deployment/revisions/:revisions', function ($deployment, $revisions) use($app) {
    check_deployment_exists($app, $deployment);
    check_auth($app, $deployment);
    if (preg_match('/,/', $revisions)) {
        $revisions = preg_split('/\\s?,\\s?/', $revisions);
    }
    $protected_revisions = array_values(RevDeploy::getDeploymentRevs($deployment));
    // Now lets see if our revision(s) are protected (prev,current,staged)
    if (is_array($revisions)) {
        foreach ($revisions as $revision) {
            if (in_array($revision, $protected_revisions)) {
                $apiResponse = new APIViewData(1, $deployment, "Unable to delete the following revision as it is protected: [ {$revision} ]");
                $app->halt(404, $apiResponse->returnJson());
            }
        }
    } else {
        if (in_array($revisions, $protected_revisions)) {
            $apiResponse = new APIViewData(1, $deployment, "Unable to delete the following revision as it is protected: [ {$revisions} ]");
            $app->halt(404, $apiResponse->returnJson());
        }
    }
    RevDeploy::deleteDeploymentRev($deployment, $revisions);
Exemple #2
0
        $deployRev = $revs['nextrev'];
    } else {
        $deployRev = RevDeploy::getDeploymentRev($deployment);
    }
    $apiResponse = new APIViewData(0, $deployment, false);
    if ($commonMerge == 1) {
        $apiResponse->setExtraResponseData('contacts', RevDeploy::getCommonMergedDeploymentContacts($deployment, $deployRev));
    } else {
        $apiResponse->setExtraResponseData('contacts', RevDeploy::getDeploymentContactswInfo($deployment, $deployRev));
    }
    $apiResponse->printJson();
})->name('saigon-api-get-contacts');
$app->get('/sapi/contact/:deployment/:contact(/:staged)', function ($deployment, $contact, $staged = false) use($app) {
    check_deployment_exists($app, $deployment);
    if ($staged == 1) {
        $revs = RevDeploy::getDeploymentRevs($deployment);
        if ($revs['currrev'] == $revs['nextrev']) {
            $apiResponse = new APIViewData(1, $deployment, "Unable to detect staged revision to reference");
            $app->halt(404, $apiResponse->returnJson());
        }
        $deployRev = $revs['nextrev'];
    } else {
        $deployRev = RevDeploy::getDeploymentRev($deployment);
    }
    if (preg_match('/,/', $contact)) {
        $contacts = preg_split('/\\s?,\\s?/', $contact);
        $results = array();
        foreach ($contacts as $ctemp) {
            if (RevDeploy::existsDeploymentContact($deployment, $ctemp, $deployRev) === true) {
                $results[$ctemp] = RevDeploy::getDeploymentContact($deployment, $ctemp, $deployRev);
            }
 /**
  * del_rev_stage - delete revision stage view / routine
  * 
  * @access public
  * @return void
  */
 public function del_rev_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('deployment_error');
     if (!RevDeploy::existsDeployment($deployment)) {
         $viewData->header = $this->getErrorHeader('deployment_error');
         $viewData->error = 'Unable to find deployment specified in data store';
         $this->sendError('generic_error', $viewData);
     }
     $viewData->revs = RevDeploy::getDeploymentRevs($deployment);
     $viewData->allrevs = RevDeploy::getDeploymentAllRevs($deployment);
     $viewData->deployment = $deployment;
     $this->sendResponse('deployment_del_rev_stage', $viewData);
 }