获取

描述

integer/array mediatype.get(object parameters)

此方法用于检索给定参数和符合条件的媒介类型。

此方法对于任何用户可用。可以在用户角色设置中撤销调用该方法的权限。更多信息请查看 用户角色

参数

(object) 参数定义了所需的输出。

此方法支持以下参数。

参数类型描述
mediatypeidsstring/array只返回带有给定ID列表的媒介类型。
mediaidsstring/array仅返回给定媒介使用的媒介类型。
useridsstring/array仅返回给定用户使用的媒介类型。
selectMessageTemplatesquery返回一个包含消息模板消息数组的属性。
selectUsersquery返回使用媒介类型的用户属性。
sortfieldstring/array按给定属性对结果进行排序。

可用值:mediatypeid
countOutputboolean这些参数对所有的 get 方法是通用的,详情请参阅 参考说明
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

返回值

(整型/数组) 返回其中之一:

  • 一个对象数组;
  • 如果使用countOutput参数,返回被检索对象的数量。

示例

检索媒介类型

检索所有配置的媒介类型。

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "mediatype.get",
  4. "params": {
  5. "output": "extend",
  6. "selectMessageTemplates": "extend"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "mediatypeid": "1",
  6. "type": "0",
  7. "name": "Email",
  8. "smtp_server": "mail.example.com",
  9. "smtp_helo": "example.com",
  10. "smtp_email": "[email protected]",
  11. "exec_path": "",
  12. "gsm_modem": "",
  13. "username": "",
  14. "passwd": "",
  15. "status": "0",
  16. "smtp_port": "25",
  17. "smtp_security": "0",
  18. "smtp_verify_peer": "0",
  19. "smtp_verify_host": "0",
  20. "smtp_authentication": "0",
  21. "exec_params": "",
  22. "maxsessions": "1",
  23. "maxattempts": "3",
  24. "attempt_interval": "10s",
  25. "content_type": "0",
  26. "script": "",
  27. "timeout": "30s",
  28. "process_tags": "0",
  29. "show_event_menu": "1",
  30. "event_menu_url": "",
  31. "event_menu_name": "",
  32. "description": "",
  33. "message_templates": [
  34. {
  35. "eventsource": "0",
  36. "recovery": "0",
  37. "subject": "Problem: {EVENT.NAME}",
  38. "message": "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\nHost: {HOST.NAME}\r\nSeverity: {EVENT.SEVERITY}\r\nOperational data: {EVENT.OPDATA}\r\nOriginal problem ID: {EVENT.ID}\r\n{TRIGGER.URL}"
  39. },
  40. {
  41. "eventsource": "0",
  42. "recovery": "1",
  43. "subject": "Resolved: {EVENT.NAME}",
  44. "message": "Problem has been resolved at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}\r\nProblem name: {EVENT.NAME}\r\nHost: {HOST.NAME}\r\nSeverity: {EVENT.SEVERITY}\r\n\r\nOriginal problem ID: {EVENT.ID}\r\n{TRIGGER.URL}"
  45. },
  46. {
  47. "eventsource": "0",
  48. "recovery": "2",
  49. "subject": "Updated problem: {EVENT.NAME}",
  50. "message": "{USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.\r\n{EVENT.UPDATE.MESSAGE}\r\n\r\nCurrent problem status is {EVENT.STATUS}, acknowledged: {EVENT.ACK.STATUS}."
  51. },
  52. {
  53. "eventsource": "1",
  54. "recovery": "0",
  55. "subject": "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}",
  56. "message": "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}\r\nDevice DNS: {DISCOVERY.DEVICE.DNS}\r\nDevice status: {DISCOVERY.DEVICE.STATUS}\r\nDevice uptime: {DISCOVERY.DEVICE.UPTIME}\r\n\r\nDevice service name: {DISCOVERY.SERVICE.NAME}\r\nDevice service port: {DISCOVERY.SERVICE.PORT}\r\nDevice service status: {DISCOVERY.SERVICE.STATUS}\r\nDevice service uptime: {DISCOVERY.SERVICE.UPTIME}"
  57. },
  58. {
  59. "eventsource": "2",
  60. "recovery": "0",
  61. "subject": "Autoregistration: {HOST.HOST}",
  62. "message": "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}"
  63. }
  64. ],
  65. "parameters": []
  66. },
  67. {
  68. "mediatypeid": "3",
  69. "type": "2",
  70. "name": "SMS",
  71. "smtp_server": "",
  72. "smtp_helo": "",
  73. "smtp_email": "",
  74. "exec_path": "",
  75. "gsm_modem": "/dev/ttyS0",
  76. "username": "",
  77. "passwd": "",
  78. "status": "0",
  79. "smtp_port": "25",
  80. "smtp_security": "0",
  81. "smtp_verify_peer": "0",
  82. "smtp_verify_host": "0",
  83. "smtp_authentication": "0",
  84. "exec_params": "",
  85. "maxsessions": "1",
  86. "maxattempts": "3",
  87. "attempt_interval": "10s",
  88. "content_type": "1",
  89. "script": "",
  90. "timeout": "30s",
  91. "process_tags": "0",
  92. "show_event_menu": "1",
  93. "event_menu_url": "",
  94. "event_menu_name": "",
  95. "description": "",
  96. "message_templates": [
  97. {
  98. "eventsource": "0",
  99. "recovery": "0",
  100. "subject": "",
  101. "message": "{EVENT.SEVERITY}: {EVENT.NAME}\r\nHost: {HOST.NAME}\r\n{EVENT.DATE} {EVENT.TIME}"
  102. },
  103. {
  104. "eventsource": "0",
  105. "recovery": "1",
  106. "subject": "",
  107. "message": "RESOLVED: {EVENT.NAME}\r\nHost: {HOST.NAME}\r\n{EVENT.DATE} {EVENT.TIME}"
  108. },
  109. {
  110. "eventsource": "0",
  111. "recovery": "2",
  112. "subject": "",
  113. "message": "{USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}"
  114. },
  115. {
  116. "eventsource": "1",
  117. "recovery": "0",
  118. "subject": "",
  119. "message": "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}"
  120. },
  121. {
  122. "eventsource": "2",
  123. "recovery": "0",
  124. "subject": "",
  125. "message": "Autoregistration: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}"
  126. }
  127. ],
  128. "parameters": []
  129. }
  130. ],
  131. "id": 1
  132. }

参见

来源

ui/include/classes/api/services/CMediaType.php 中的 CMediaType::get()。