role.get

Description

integer/array role.get(object parameters)

The method allows to retrieve roles according to the given parameters.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
roleidsstring/arrayReturn only roles with the given IDs.
selectRulesqueryReturn role rules in the rules property.
selectUsersquerySelect users this role is assigned to.
sortfieldstring/arraySort the result by the given properties.

Possible values are: roleid, name.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary page.
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 role data

Retrieve “Super admin role” role data and its access rules.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "role.get",
  4. "params": [
  5. "output": "extend",
  6. "selectRules": "extend",
  7. "roleids": "3"
  8. ],
  9. "auth": "3a57200802b24cda67c4e4010b50c065",
  10. "id": 1
  11. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "roleid": "3",
  6. "name": "Super Admin role",
  7. "type": "3",
  8. "readonly": "1",
  9. "rules": {
  10. "ui": [
  11. {
  12. "name": "monitoring.dashboard",
  13. "status": "1"
  14. },
  15. {
  16. "name": "monitoring.problems",
  17. "status": "1"
  18. },
  19. {
  20. "name": "monitoring.hosts",
  21. "status": "1"
  22. },
  23. {
  24. "name": "monitoring.overview",
  25. "status": "1"
  26. },
  27. {
  28. "name": "monitoring.latest_data",
  29. "status": "1"
  30. },
  31. {
  32. "name": "monitoring.maps",
  33. "status": "1"
  34. },
  35. {
  36. "name": "monitoring.services",
  37. "status": "1"
  38. },
  39. {
  40. "name": "inventory.overview",
  41. "status": "1"
  42. },
  43. {
  44. "name": "inventory.hosts",
  45. "status": "1"
  46. },
  47. {
  48. "name": "reports.availability_report",
  49. "status": "1"
  50. },
  51. {
  52. "name": "reports.top_triggers",
  53. "status": "1"
  54. },
  55. {
  56. "name": "monitoring.discovery",
  57. "status": "1"
  58. },
  59. {
  60. "name": "reports.notifications",
  61. "status": "1"
  62. },
  63. {
  64. "name": "reports.scheduled_reports",
  65. "status": "1"
  66. },
  67. {
  68. "name": "configuration.host_groups",
  69. "status": "1"
  70. },
  71. {
  72. "name": "configuration.templates",
  73. "status": "1"
  74. },
  75. {
  76. "name": "configuration.hosts",
  77. "status": "1"
  78. },
  79. {
  80. "name": "configuration.maintenance",
  81. "status": "1"
  82. },
  83. {
  84. "name": "configuration.actions",
  85. "status": "1"
  86. },
  87. {
  88. "name": "configuration.discovery",
  89. "status": "1"
  90. },
  91. {
  92. "name": "configuration.services",
  93. "status": "1"
  94. },
  95. {
  96. "name": "reports.system_info",
  97. "status": "1"
  98. },
  99. {
  100. "name": "reports.audit",
  101. "status": "1"
  102. },
  103. {
  104. "name": "reports.action_log",
  105. "status": "1"
  106. },
  107. {
  108. "name": "configuration.event_correlation",
  109. "status": "1"
  110. },
  111. {
  112. "name": "administration.general",
  113. "status": "1"
  114. },
  115. {
  116. "name": "administration.proxies",
  117. "status": "1"
  118. },
  119. {
  120. "name": "administration.authentication",
  121. "status": "1"
  122. },
  123. {
  124. "name": "administration.user_groups",
  125. "status": "1"
  126. },
  127. {
  128. "name": "administration.user_roles",
  129. "status": "1"
  130. },
  131. {
  132. "name": "administration.users",
  133. "status": "1"
  134. },
  135. {
  136. "name": "administration.media_types",
  137. "status": "1"
  138. },
  139. {
  140. "name": "administration.scripts",
  141. "status": "1"
  142. },
  143. {
  144. "name": "administration.queue",
  145. "status": "1"
  146. }
  147. ],
  148. "ui.default_access": "1",
  149. "modules": [],
  150. "modules.default_access": "1",
  151. "api.access": "1",
  152. "api.mode": "0",
  153. "api": [],
  154. "actions": [
  155. {
  156. "name": "edit_dashboards",
  157. "status": "1"
  158. },
  159. {
  160. "name": "edit_maps",
  161. "status": "1"
  162. },
  163. {
  164. "name": "acknowledge_problems",
  165. "status": "1"
  166. },
  167. {
  168. "name": "close_problems",
  169. "status": "1"
  170. },
  171. {
  172. "name": "change_severity",
  173. "status": "1"
  174. },
  175. {
  176. "name": "add_problem_comments",
  177. "status": "1"
  178. },
  179. {
  180. "name": "execute_scripts",
  181. "status": "1"
  182. },
  183. {
  184. "name": "edit_maintenance",
  185. "status": "1"
  186. },
  187. {
  188. "name": "manage_scheduled_reports",
  189. "status": "1"
  190. }
  191. ],
  192. "actions.default_access": "1"
  193. }
  194. }
  195. ],
  196. "id": 1
  197. }

See also

Source

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