$revisionInfo = $request->getBody(); $revisionInfo = json_decode($revisionInfo, true); } elseif (preg_match("/form-(data|urlencoded)/", $contentType)) { $revisionInfo['revision'] = $request->post('revision'); $revisionInfo['note'] = $request->post('note'); } if (!isset($revisionInfo['revision']) || empty($revisionInfo['revision'])) { $apiResponse = new APIViewData(1, $deployment, "Unable to detect revision parameter (revision number we should activate)"); $app->halt(404, $apiResponse->returnJson()); } elseif (!isset($revisionInfo['note']) || empty($revisionInfo['note'])) { $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} ]");
public function invalidate_cache() { $viewData = new ViewData(); $deployment = $this->getDeployment('deployment_error'); $this->checkGroupAuth($deployment); VarnishCache::invalidate($deployment); $viewData->deployment = $deployment; $this->sendResponse('deployment_invalidate_cache', $viewData); }