public function modify_write() { $viewData = new ViewData(); $deployment = $this->getDeployment('svc_template_error'); $this->checkGroupAuth($deployment); $this->checkDeploymentRevStatus($deployment); $viewData->deployment = $deployment; $modrevision = RevDeploy::getDeploymentNextRev($deployment); $svcName = $this->getParam('svcName'); $svcInfo = $this->fetchSvcTemplateInfo($deployment, 'modify_write', $modrevision); if (RevDeploy::modifyDeploymentSvcTemplate($deployment, $svcName, $svcInfo, $modrevision) === false) { $viewData->header = $this->getErrorHeader('svc_template_error'); $viewData->error = 'Unable to write service template information for ' . $svcName . ' into ' . $deployment . ' Deployment'; $this->sendError('generic_error', $viewData); } $viewData->svc = $svcName; $this->sendResponse('svc_template_write', $viewData); }
} // You get a pass if you have the use template key defined... if (!isset($serviceTemplateInfo['use']) || empty($serviceTemplateInfo['use'])) { // Lets make sure we have the minimum required keys for defining a service template validateContacts($app, $deployment, $serviceTemplateInfo); foreach ($required_keys as $rkey) { if (!isset($serviceTemplateInfo[$rkey]) || empty($serviceTemplateInfo[$rkey])) { $apiResponse = new APIViewData(1, $deployment, "Unable to detect required parameter {$rkey} " . servicetemplate_rkeyMessage($rkey)); $app->halt(404, $apiResponse->returnJson()); } } } $serviceTemplateInfo = servicetemplate_validate($app, $deployment, $serviceTemplateInfo); $deployRev = RevDeploy::getDeploymentNextRev($deployment); if (RevDeploy::existsDeploymentSvcTemplate($deployment, $serviceTemplateInfo['name'], $deployRev) === true) { RevDeploy::modifyDeploymentSvcTemplate($deployment, $serviceTemplateInfo['name'], $serviceTemplateInfo, $deployRev); $apiResponse = new APIViewData(0, $deployment, "Successfully Modified Service Template " . $serviceTemplateInfo['name']); } else { RevDeploy::createDeploymentSvcTemplate($deployment, $serviceTemplateInfo['name'], $serviceTemplateInfo, $deployRev); $apiResponse = new APIViewData(0, $deployment, "Successfully Created Service Template " . $serviceTemplateInfo['name']); } $apiResponse->printJson(); })->name('saigon-api-create-service-template'); $app->delete('/sapi/servicetemplate/:deployment/:servicetemplate', function ($deployment, $servicetemplate) use($app) { check_deployment_exists($app, $deployment); check_auth($app, $deployment); check_revision_status($deployment); $deployRev = RevDeploy::getDeploymentNextRev($deployment); if (preg_match('/,/', $servicetemplate)) { $servicetemplates = preg_split('/\\s?,\\s?/', $servicetemplate); foreach ($servicetemplates as $stemp) {