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.

The method supports the following parameters.

ParameterTypeDescription
mediatypeidsstring/arrayReturn only media types with the given IDs.
mediaidsstring/arrayReturn only media types used by the given media.
useridsstring/arrayReturn only media types used by the given users.
selectMessageTemplatesqueryReturn a message_templates property with an array of media type messages.
selectUsersqueryReturn a users property with the users that use the media type.
sortfieldstring/arraySort the result by the given properties.

Possible values are: mediatypeid.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary.
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

Return values

(integer/array) Returns either:

  • an array of objects;

  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Retrieving media types

Retrieve all configured media types.

Request:

  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. }

Response:

  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. }

See also

Source

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