}
    validateContacts($app, $deployment, $serviceEscalationInfo);
    // Lets make sure we have the minimum required keys for defining a service escalation
    foreach ($required_keys as $rkey) {
        if (!isset($serviceEscalationInfo[$rkey]) || empty($serviceEscalationInfo[$rkey])) {
            $apiResponse = new APIViewData(1, $deployment, "Unable to detect required parameter {$rkey} " . serviceescalation_rkeyMessage($rkey));
            $app->halt(404, $apiResponse->returnJson());
        }
    }
    $serviceEscalationInfo = serviceescalation_validate($app, $deployment, $serviceEscalationInfo);
    $deployRev = RevDeploy::getDeploymentNextRev($deployment);
    if (RevDeploy::existsDeploymentSvcEscalation($deployment, $serviceEscalationInfo['name'], $deployRev) === true) {
        RevDeploy::modifyDeploymentSvcEscalation($deployment, $serviceEscalationInfo['name'], $serviceEscalationInfo, $deployRev);
        $apiResponse = new APIViewData(0, $deployment, "Successfully Modified Service Escalation " . $serviceEscalationInfo['name']);
    } else {
        RevDeploy::createDeploymentSvcEscalation($deployment, $serviceEscalationInfo['name'], $serviceEscalationInfo, $deployRev);
        $apiResponse = new APIViewData(0, $deployment, "Successfully Created Service Escalation " . $serviceEscalationInfo['name']);
    }
    $apiResponse->printJson();
})->name('saigon-api-create-service-escalation');
$app->delete('/sapi/serviceescalation/:deployment/:serviceescalation', function ($deployment, $serviceescalation) use($app) {
    check_deployment_exists($app, $deployment);
    check_auth($app, $deployment);
    check_revision_status($deployment);
    $deployRev = RevDeploy::getDeploymentNextRev($deployment);
    if (preg_match('/,/', $serviceescalation)) {
        $serviceescalations = preg_split('/\\s?,\\s?/', $serviceescalation);
        foreach ($serviceescalations as $stemp) {
            RevDeploy::deleteDeploymentSvcEscalation($deployment, $stemp, $deployRev);
        }
    } else {
Exemplo n.º 2
0
 private static function copyServiceEscalations($deployment, $revision, array $seInfo)
 {
     if (self::$init === false) {
         self::init();
     }
     foreach ($seInfo as $se => $seArray) {
         if ($seArray['deployment'] == self::$m_commonrepo && $seArray['deployment'] == 'common') {
             continue;
         }
         if ($seArray['deployment'] == self::$m_commonrepo) {
             continue;
         }
         unset($seArray['deployment']);
         foreach ($seArray as $key => $value) {
             if (is_array($seArray[$key])) {
                 $seArray[$key] = implode(',', $seArray[$key]);
             }
         }
         RevDeploy::createDeploymentSvcEscalation($deployment, $se, $seArray, $revision);
     }
 }
Exemplo n.º 3
0
 public function copy_write()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('svc_esc_error');
     $this->checkGroupAuth($deployment);
     $this->checkDeploymentRevStatus($deployment);
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $svcEscInfo = $this->fetchSvcEscInfo($deployment, 'copy_write', $modrevision);
     $svcEscName = $svcEscInfo['name'];
     if (RevDeploy::existsDeploymentSvcEscalation($deployment, $svcEscName, $modrevision) === true) {
         $viewData->error = 'Service Escalation information exists for ' . $svcEscName . ' in ' . $deployment . ' Deployment';
         $viewData->svcs = RevDeploy::getCommonMergedDeploymentSvcs($deployment, $modrevision);
         $viewData->timeperiods = RevDeploy::getCommonMergedDeploymentTimeperiods($deployment, $modrevision);
         $viewData->contacts = RevDeploy::getCommonMergedDeploymentContacts($deployment, $modrevision);
         $viewData->contactgrps = RevDeploy::getCommonMergedDeploymentContactGroups($deployment, $modrevision);
         $viewData->svcescinfo = $svcEscInfo;
         $viewData->deployment = $deployment;
         $viewData->action = 'copy_write';
         $this->sendResponse('svc_esc_action_stage', $viewData);
     }
     if (RevDeploy::createDeploymentSvcEscalation($deployment, $svcEscName, $svcEscInfo, $modrevision) === false) {
         $viewData->header = $this->getErrorHeader('svc_esc_error');
         $viewData->error = 'Unable to write service escalation information for ' . $svcEscName . ' into ' . $deployment . ' Deployment';
         $this->sendError('generic_error', $viewData);
     }
     $viewData->deployment = $deployment;
     $viewData->svcesc = $svcEscName;
     $this->sendResponse('svc_esc_write', $viewData);
 }