$app->halt(404, $apiResponse->returnJson());
    } elseif (preg_match_all('/[^\\w.-]/s', $serviceDependencyInfo['name'], $forbidden)) {
        $apiResponse = new APIViewData(1, $deployment, "Unable to use service dependency name specified, detected forbidden characters " . implode('', array_unique($forbidden[0])));
        $app->halt(404, $apiResponse->returnJson());
    }
    // Lets make sure we have the minimum required keys for defining a service dependency
    foreach ($required_keys as $rkey) {
        if (!isset($serviceDependencyInfo[$rkey]) || empty($serviceDependencyInfo[$rkey])) {
            $apiResponse = new APIViewData(1, $deployment, "Unable to detect required parameter {$rkey} " . servicedependency_rkeyMessage($rkey));
            $app->halt(404, $apiResponse->returnJson());
        }
    }
    $serviceDependencyInfo = servicedependency_validate($app, $deployment, $serviceDependencyInfo);
    $deployRev = RevDeploy::getDeploymentNextRev($deployment);
    if (RevDeploy::existsDeploymentSvcDependency($deployment, $serviceDependencyInfo['name'], $deployRev) === true) {
        RevDeploy::modifyDeploymentSvcDependency($deployment, $serviceDependencyInfo['name'], $serviceDependencyInfo, $deployRev);
        $apiResponse = new APIViewData(0, $deployment, "Successfully Modified Service Dependency " . $serviceDependencyInfo['name']);
    } else {
        RevDeploy::createDeploymentSvcDependency($deployment, $serviceDependencyInfo['name'], $serviceDependencyInfo, $deployRev);
        $apiResponse = new APIViewData(0, $deployment, "Successfully Created Service Dependency " . $serviceDependencyInfo['name']);
    }
    $apiResponse->printJson();
})->name('saigon-api-create-service-dependency');
$app->delete('/sapi/servicedependency/:deployment/:servicedependency', function ($deployment, $servicedependency) use($app) {
    check_deployment_exists($app, $deployment);
    check_auth($app, $deployment);
    check_revision_status($deployment);
    $deployRev = RevDeploy::getDeploymentNextRev($deployment);
    if (preg_match('/,/', $servicedependency)) {
        $servicedependencys = preg_split('/\\s?,\\s?/', $servicedependency);
        foreach ($servicedependencys as $stemp) {
Exemplo n.º 2
0
 public function modify_write()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('svc_dep_error');
     $this->checkGroupAuth($deployment);
     $this->checkDeploymentRevStatus($deployment);
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $viewData->deployment = $deployment;
     $svcDepInfo = $this->fetchSvcDepInfo($deployment, 'modify_write', $modrevision);
     $svcDepName = $svcDepInfo['name'];
     if (RevDeploy::modifyDeploymentSvcDependency($deployment, $svcDepName, $svcDepInfo, $modrevision) === false) {
         $viewData->header = $this->getErrorHeader('svc_dep_error');
         $viewData->error = 'Unable to write service group information for ' . $svcDepName . ' into ' . $deployment . ' Deployment';
         $this->sendError('generic_error', $viewData);
     }
     $viewData->svc = $svcDepName;
     $this->sendResponse('svc_dep_write', $viewData);
 }