2022 Zabbix中国峰会
2022 Zabbix中国峰会

usermedia.get

Description描述

integer/array usermedia.get(object parameters)

The method allows to retrieve media according to the given parameters.该方法允许根据给定的参数来检索媒体。

This method is deprecated and will be removed in the future.此方法已被弃用,将来会被删除。 Please use user.get instead.请改用user.get。

Parameters参数

(object) Parameters defining the desired output.定义所需输出的参数。

The method supports the following parameters.该方法支持以下参数。

参数 类 描述
mediaids string/array Return only media with the given IDs.只返回具有给定ID的媒体。
usrgrpids string/array Return only media that are used by users in the given user groups. 只返回给定用户组中用户使用的媒体。
userids string/array Return only media that are used by the given users. 只返回给定用户使用的媒体。
mediatypeids string/array Return only media that use the given media types.只返回使用给定媒体类型的媒体。
sortfield string/array Sort the result by the given properties. 按照给定的属性对结果进行排序。

Possible values are: 可能的值是:mediaid, userid and mediatypeid.
countOutput flag These parameters being common for all get methods are described in detail in the reference commentary. 这些参数对于所有的“get”方法是常见的,在参考评论中有详细描述
editable boolean
excludeSearch flag
filter object
limit integer
output query
preservekeys flag
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch flag

Return values返回值

(integer/array) Returns either:返回:

  • an array of objects;一组对象;
  • the count of retrieved objects, if the countOutput parameter has been used.如果已经使用“countOutput”参数,则检索到的对象的计数。

Examples示例

Retrieving media by user 用户检索媒体

Retrieve all media for the given user.检索给定用户的所有媒体。

Request:

{
           "jsonrpc": "2.0",
           "method": "usermedia.get",
           "params": {
               "output": "extend",
               "userids": "1"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "mediaid": "8",
                   "userid": "1",
                   "mediatypeid": "3",
                   "sendto": "+3711231233",
                   "active": "0",
                   "severity": "48",
                   "period": "1-5,09:00-18:00"
               },
               {
                   "mediaid": "9",
                   "userid": "1",
                   "mediatypeid": "1",
                   "sendto": "[email protected]",
                   "active": "0",
                   "severity": "63",
                   "period": "1-7,00:00-24:00"
               }
           ],
           "id": 1
       }

Source来源

CUserMedia::get() in frontends/php/include/classes/api/services/CUserMedia.php.