Source
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Interface with DNS "%1$s" cannot have empty IP address.', $interface['dns']));
<?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 host interfaces.
*/
class CHostInterface extends CApiService {
public const ACCESS_RULES = [
'get' => ['min_user_type' => USER_TYPE_ZABBIX_USER],
'create' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN],
'update' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN],
'delete' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN],
'replacehostinterfaces' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN],
'massadd' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN],
'massremove' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN]
];
protected $tableName = 'interface';
protected $tableAlias = 'hi';
protected $sortColumns = ['interfaceid', 'dns', 'ip'];
/**
* Get interface data.
*
* @param array $options
* @param array $options['hostids'] Interface IDs
* @param bool $options['editable'] only with read-write permission. Ignored for SuperAdmins
* @param bool $options['selectHosts'] select Interface hosts
* @param bool $options['selectItems'] select Items
* @param int $options['count'] count Interfaces, returned column name is rowscount
* @param string $options['pattern'] search hosts by pattern in Interface name
* @param int $options['limit'] limit selection
* @param string $options['sortfield'] field to sort by
* @param string $options['sortorder'] sort order
*
* @return array|boolean Interface data as array or false if error
*/
public function get(array $options = []) {
$result = [];
$sqlParts = [
'select' => ['interface' => 'hi.interfaceid'],
'from' => ['interface' => 'interface hi'],
'where' => [],
'group' => [],
'order' => [],
'limit' => null
];
$defOptions = [
'groupids' => null,
'hostids' => null,
'interfaceids' => null,
'itemids' => null,
'triggerids' => null,
'editable' => false,
'nopermissions' => null,
// filter
'filter' => null,
'search' => null,
'searchByAny' => null,
'startSearch' => false,
'excludeSearch' => false,
'searchWildcardsEnabled' => null,
// output
'output' => API_OUTPUT_EXTEND,
'selectHosts' => null,
'selectItems' => null,
'countOutput' => false,
'groupCount' => false,
'preservekeys' => false,
'sortfield' => '',
'sortorder' => '',
'limit' => null,
'limitSelects' => null
];
$options = zbx_array_merge($defOptions, $options);