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

mediatype.get

Description描述

integer/array mediatype.get(object parameters)

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

Parameters参数

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

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

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

Possible values are:可能的值: 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 types检索媒体类型

Retrieve all configured media types.检索所有配置的媒体类型。

Request:

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

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "mediatypeid": "1",
                   "type": "0",
                   "description": "Email",
                   "smtp_server": "mail.company.com",
                   "smtp_helo": "company.com",
                   "smtp_email": "[email protected]",
                   "exec_path": "",
                   "gsm_modem": "",
                   "username": "",
                   "passwd": "",
                   "status": "0"
               },
               {
                   "mediatypeid": "2",
                   "type": "3",
                   "description": "Jabber",
                   "smtp_server": "",
                   "smtp_helo": "",
                   "smtp_email": "",
                   "exec_path": "",
                   "gsm_modem": "",
                   "username": "[email protected]",
                   "passwd": "zabbix",
                   "status": "0"
               },
               {
                   "mediatypeid": "3",
                   "type": "2",
                   "description": "SMS",
                   "smtp_server": "",
                   "smtp_helo": "",
                   "smtp_email": "",
                   "exec_path": "",
                   "gsm_modem": "/dev/ttyS0",
                   "username": "",
                   "passwd": "",
                   "status": "0"
               }
           ],
           "id": 1
       }

See also参见

Source来源

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