Source
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* Class containing methods for operations with configuration.
*/
class CConfiguration extends CApiService {
public const ACCESS_RULES = [
'export' => ['min_user_type' => USER_TYPE_ZABBIX_USER],
'import' => ['min_user_type' => USER_TYPE_ZABBIX_USER],
'importcompare' => ['min_user_type' => USER_TYPE_ZABBIX_USER]
];
/**
* @param array $params
*
* @return string
*/
private function exportCompare(array $params) {
$this->validateExport($params, true);
return $this->exportForce($params);
}
/**
* @param array $params
*
* @return string
*/
public function export(array $params) {
$this->validateExport($params);
return $this->exportForce($params);
}
/**
* Validate input parameters for export() and exportCompare() methods.
*
* @param array $params
* @param bool $with_unlinked_parent_templates
*
* @throws APIException if the input is invalid.
*/
private function validateExport(array &$params, bool $with_unlinked_parent_templates = false): void {
$api_input_rules = ['type' => API_OBJECT, 'fields' => [
'format' => ['type' => API_STRING_UTF8, 'flags' => API_REQUIRED, 'in' => implode(',', [CExportWriterFactory::YAML, CExportWriterFactory::XML, CExportWriterFactory::JSON, CExportWriterFactory::RAW])],
'prettyprint' => ['type' => API_BOOLEAN, 'default' => false],
'options' => ['type' => API_OBJECT, 'flags' => API_REQUIRED, 'fields' => [
'hosts' => ['type' => API_IDS],