/** * @param JsonData $variables JSON encoded structure * @throws Scalr_Exception_Core * @throws Scalr_Exception_InsufficientPermissions * @throws \Scalr\Exception\ValidationErrorException */ public function xSaveVariablesAction(JsonData $variables) { if ($this->user->isAdmin()) { throw new Scalr_Exception_InsufficientPermissions(); } $this->request->restrictAccess(Acl::RESOURCE_GLOBAL_VARIABLES_ENVIRONMENT, Acl::PERM_GLOBAL_VARIABLES_ENVIRONMENT_MANAGE); $vars = new Scalr_Scripting_GlobalVariables($this->user->getAccountId(), $this->getEnvironmentId(), ScopeInterface::SCOPE_ENVIRONMENT); $result = $vars->setValues($variables, 0, 0, 0, '', false); if ($result === true) { $this->response->success('Variables saved'); $this->response->data(['defaults' => $vars->getUiDefaults()]); } else { $this->response->failure(); $this->response->data(array('errors' => array('variables' => $result))); } }