Source
['if' => ['field' => 'type', 'in' => implode(',', [ZBX_MACRO_TYPE_VAULT])], 'type' => API_VAULT_SECRET, 'provider' => CSettingsHelper::get(CSettingsHelper::VAULT_PROVIDER), 'length' => DB::getFieldLength('hostmacro', 'value')]
<?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 user macro.
*/
class CUserMacro 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],
'createglobal' => ['min_user_type' => USER_TYPE_SUPER_ADMIN],
'updateglobal' => ['min_user_type' => USER_TYPE_SUPER_ADMIN],
'deleteglobal' => ['min_user_type' => USER_TYPE_SUPER_ADMIN]
];
protected $tableName = 'hostmacro';
protected $tableAlias = 'hm';
protected $sortColumns = ['macro'];
/**
* Get UserMacros data.
*
* @param array $options
* @param array $options['groupids'] usermacrosgroup ids
* @param array $options['hostids'] host ids
* @param array $options['hostmacroids'] host macros ids
* @param array $options['globalmacroids'] global macros ids
* @param array $options['templateids'] template ids
* @param boolean $options['globalmacro'] only global macros
* @param boolean $options['selectHostGroups'] select host groups
* @param boolean $options['selectTemplateGroups'] select template groups
* @param boolean $options['selectHosts'] select hosts
* @param boolean $options['selectTemplates'] select templates
*
* @return array|boolean UserMacros data as array or false if error
*/
public function get($options = []) {
$result = [];
$sqlParts = [
'select' => ['macros' => 'hm.hostmacroid'],
'from' => ['hostmacro hm'],
'where' => [],
'order' => [],
'limit' => null
];
$sqlPartsGlobal = [
'select' => ['macros' => 'gm.globalmacroid'],
'from' => ['globalmacro gm'],
'where' => [],
'order' => [],
'limit' => null
];
$defOptions = [
'groupids' => null,
'hostids' => null,
'hostmacroids' => null,
'globalmacroids' => null,
'templateids' => null,
'globalmacro' => null,
'inherited' => null,
'editable' => false,
'nopermissions' => null,
// filter
'filter' => null,
'search' => null,
'searchByAny' => null,
'startSearch' => false,
'excludeSearch' => false,
'searchWildcardsEnabled' => null,
// output
'output' => API_OUTPUT_EXTEND,
'selectHostGroups' => null,