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]
public function export(array $params) {
$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' => [
'groups' => ['type' => API_IDS],
'hosts' => ['type' => API_IDS],
'images' => ['type' => API_IDS],
'maps' => ['type' => API_IDS],
'mediaTypes' => ['type' => API_IDS],
'templates' => ['type' => API_IDS]
if (!CApiInputValidator::validate($api_input_rules, $params, '/', $error)) {
self::exception(ZBX_API_ERROR_PARAMETERS, $error);
if ($params['format'] === CExportWriterFactory::XML) {
$lib_xml = (new CFrontendSetup())->checkPhpLibxml();
if ($lib_xml['result'] == CFrontendSetup::CHECK_FATAL) {
self::exception(ZBX_API_ERROR_INTERNAL, $lib_xml['error']);
$xml_writer = (new CFrontendSetup())->checkPhpXmlWriter();