Source
if ($interface_type !== null && array_key_exists($interface_type, $interfaces['default_interfaces'][$host])) {
<?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/>.
**/
require_once 'vendor/autoload.php';
require_once dirname(__FILE__).'/../../../include/defines.inc.php';
require_once dirname(__FILE__).'/../../../include/hosts.inc.php';
require_once dirname(__FILE__).'/../../../include/db.inc.php';
class CDataHelper extends CAPIHelper {
protected static $data = null;
protected static $request = [];
protected static $response = [];
/**
* Prepare request for API call and make API call (@see callRaw).
*
* @param string $method API method to be called.
* @param mixed $params API call params.
*
* @return array
*
* @throws Exception on API error
*/
public static function call($method, $params) {
global $URL;
if (!$URL) {
$URL = PHPUNIT_URL.'api_jsonrpc.php';
}
static::$request = [];
static::$response = [];
if (CAPIHelper::getSessionId() === null) {
CAPIHelper::createSessionId();
}
$response = CAPIHelper::call($method, $params);
if (array_key_exists('error', $response)) {
throw new Exception('API call failed: '.json_encode($response['error'], JSON_PRETTY_PRINT));
}
if (!array_key_exists('result', $response)) {
throw new Exception('API call failed: result is not present');
}
static::$request = (CTestArrayHelper::isAssociative($params)) ? [$params] : $params;
static::$response = $response['result'];