Source
<?php declare(strict_types = 0);
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
class CControllerSlaUpdate extends CControllerSlaCreateUpdate {
/**
* @var array
*/
private $schedule = [];
protected function init(): void {
$this->setPostContentType(self::POST_CONTENT_TYPE_JSON);
}
protected function checkInput(): bool {
$fields = [
'slaid' => 'required|id',
'name' => 'required|string|not_empty',
'slo' => 'required|string|not_empty',
'period' => 'required|in '.implode(',', [ZBX_SLA_PERIOD_DAILY, ZBX_SLA_PERIOD_WEEKLY, ZBX_SLA_PERIOD_MONTHLY, ZBX_SLA_PERIOD_QUARTERLY, ZBX_SLA_PERIOD_ANNUALLY]),
'timezone' => 'required|in '.implode(',', array_merge([ZBX_DEFAULT_TIMEZONE], array_keys(CTimezoneHelper::getList()))),
'schedule_mode' => 'required|in '.implode(',', [CSlaHelper::SCHEDULE_MODE_24X7, CSlaHelper::SCHEDULE_MODE_CUSTOM]),
'schedule_enabled' => 'array',
'schedule_periods' => 'array',
'effective_date' => 'required|abs_date',
'service_tags' => 'required|array',
'description' => 'required|string',
'status' => 'in '.ZBX_SLA_STATUS_ENABLED,
'excluded_downtimes' => 'array'
];
$ret = $this->validateInput($fields);
if ($ret) {
if ($this->getInput('schedule_mode') == CSlaHelper::SCHEDULE_MODE_CUSTOM) {
try {
$this->schedule = self::validateCustomSchedule($this->getInput('schedule_enabled', []),
$this->getInput('schedule_periods', [])
);
}
catch (InvalidArgumentException $e) {
info($e->getMessage());
$ret = false;
}
}