This is a translation of the original English documentation page. Help us make it better.

usermacro.get

Leírás

integer/array usermacro.get(objektumparaméterek)

A módszer lehetővé teszi a gazdagép és a globális makrók lekérését a adott paramétereket.

Ez a módszer bármilyen típusú felhasználó számára elérhető. Engedélyek A metódus meghívása a felhasználói szerepkör beállításaiban visszavonható. Lásd: User roles további információért.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

Parameter Type Description
globalmacro flag Return global macros instead of host macros.
globalmacroids string/array Return only global macros with the given IDs.
groupids string/array Return only host macros that belong to hosts or templates from the given host groups.
hostids string/array Return only macros that belong to the given hosts or templates.
hostmacroids string/array Return only host macros with the given IDs.
inherited boolean If set to true return only host prototype user macros inherited from a template.
selectGroups query Return host groups that the host macro belongs to in the groups property.

Used only when retrieving host macros.
selectHosts query Return hosts that the host macro belongs to in the hosts property.

Used only when retrieving host macros.
selectTemplates query Return templates that the host macro belongs to in the templates property.

Used only when retrieving host macros.
sortfield string/array Sort the result by the given properties.

Possible value: macro.
countOutput boolean These parameters being common for all get methods are described in detail in the reference commentary page.
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

Visszatérési értékek

(integer/array) A következőket adja vissza:

  • objektumok tömbje;
  • a letöltött objektumok száma, ha a countOutput paramétert használták.

Példák

Retrieving host macros for a host

Retrieve all host macros defined for host "10198".

Request:

{
           "jsonrpc": "2.0",
           "method": "usermacro.get",
           "params": {
               "output": "extend",
               "hostids": "10198"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "hostmacroid": "9",
                   "hostid": "10198",
                   "macro": "{$INTERFACE}",
                   "value": "eth0",
                   "description": "",
                   "type": "0"
               },
               {
                   "hostmacroid": "11",
                   "hostid": "10198",
                   "macro": "{$SNMP_COMMUNITY}",
                   "value": "public",
                   "description": "",
                   "type": "0"
               }
           ],
           "id": 1
       }

Retrieving global macros

Retrieve all global macros.

Request:

{
           "jsonrpc": "2.0",
           "method": "usermacro.get",
           "params": {
               "output": "extend",
               "globalmacro": true
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "globalmacroid": "6",
                   "macro": "{$SNMP_COMMUNITY}",
                   "value": "public",
                   "description": "",
                   "type": "0"
               }
           ],
           "id": 1
       }

Forrás

CUserMacro::get() az ui/include/classes/api/services/CUserMacro.php fájlban.