获取

说明

integer/array role.get(object parameters)

该方法允许用户通过给予一定参数用来检索职责用户信息。

该方法允许任何类型的用户使用。用户可以在用户角色设置中对该方式的使用权限进行设定修改。请参考 用户角色以获取更多信息。

参数

(object) 该参数表明了用户想得到的数据结果。 该方法支持以下参数。

参数类型说明
roleids字符串/数组根据提供的ID号返回角色用户。
selectRules询问根据角色用户 属性返回角色规则。
selectUsers询问选择分配给该角色的用户
sortfield字符串/数组根据用户罗列的属性对反馈结果进行分类。

可配置的参数包括:roleidname
countOutput布尔值该参数在get方式中应用广泛,具体内容可参考评论引用页面。
editable布尔值
excludeSearch布尔值
filter对象
limit整数
output询问
preservekeys布尔值
search对象
searchByAny布尔值
searchWildcardsEnabled布尔值
sortorder字符串/数组
startSearch布尔值

返回值

(integer/array) 返回下列两种之一:

-- 一组对象; - 在countOutput参数应用的情况下,返回检索对象的数量。

示例

检索角色数据

检索单个 “超级用户角色” 角色数据和其访问规则。 请求:

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

响应:

  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.latest_data",
  25. "status": "1"
  26. },
  27. {
  28. "name": "monitoring.maps",
  29. "status": "1"
  30. },
  31. {
  32. "name": "services.services",
  33. "status": "1"
  34. },
  35. {
  36. "name": "services.sla_report",
  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": "services.sla",
  61. "status": "1"
  62. },
  63. {
  64. "name": "reports.scheduled_reports",
  65. "status": "1"
  66. },
  67. {
  68. "name": "reports.notifications",
  69. "status": "1"
  70. },
  71. {
  72. "name": "configuration.template_groups",
  73. "status": "1"
  74. },
  75. {
  76. "name": "configuration.host_groups",
  77. "status": "1"
  78. },
  79. {
  80. "name": "configuration.templates",
  81. "status": "1"
  82. },
  83. {
  84. "name": "configuration.hosts",
  85. "status": "1"
  86. },
  87. {
  88. "name": "configuration.maintenance",
  89. "status": "1"
  90. },
  91. {
  92. "name": "configuration.discovery",
  93. "status": "1"
  94. },
  95. {
  96. "name": "configuration.trigger_actions",
  97. "status": "1"
  98. },
  99. {
  100. "name": "configuration.service_actions",
  101. "status": "1"
  102. },
  103. {
  104. "name": "configuration.discovery_actions",
  105. "status": "1"
  106. },
  107. {
  108. "name": "configuration.autoregistration_actions",
  109. "status": "1"
  110. },
  111. {
  112. "name": "configuration.internal_actions",
  113. "status": "1"
  114. },
  115. {
  116. "name": "reports.system_info",
  117. "status": "1"
  118. },
  119. {
  120. "name": "reports.audit",
  121. "status": "1"
  122. },
  123. {
  124. "name": "reports.action_log",
  125. "status": "1"
  126. },
  127. {
  128. "name": "configuration.event_correlation",
  129. "status": "1"
  130. },
  131. {
  132. "name": "administration.media_types",
  133. "status": "1"
  134. },
  135. {
  136. "name": "administration.scripts",
  137. "status": "1"
  138. },
  139. {
  140. "name": "administration.user_groups",
  141. "status": "1"
  142. },
  143. {
  144. "name": "administration.user_roles",
  145. "status": "1"
  146. },
  147. {
  148. "name": "administration.users",
  149. "status": "1"
  150. },
  151. {
  152. "name": "administration.api_tokens",
  153. "status": "1"
  154. },
  155. {
  156. "name": "administration.authentication",
  157. "status": "1"
  158. },
  159. {
  160. "name": "administration.general",
  161. "status": "1"
  162. },
  163. {
  164. "name": "administration.audit_log",
  165. "status": "1"
  166. },
  167. {
  168. "name": "administration.housekeeping",
  169. "status": "1"
  170. },
  171. {
  172. "name": "administration.proxies",
  173. "status": "1"
  174. },
  175. {
  176. "name": "administration.macros",
  177. "status": "1"
  178. },
  179. {
  180. "name": "administration.queue",
  181. "status": "1"
  182. }
  183. ],
  184. "ui.default_access": "1",
  185. "services.read.mode": "1",
  186. "services.read.list": [],
  187. "services.read.tag": {
  188. "tag": "",
  189. "value": ""
  190. },
  191. "services.write.mode": "1",
  192. "services.write.list": [],
  193. "services.write.tag": {
  194. "tag": "",
  195. "value": ""
  196. },
  197. "modules": [],
  198. "modules.default_access": "1",
  199. "api.access": "1",
  200. "api.mode": "0",
  201. "api": [],
  202. "actions": [
  203. {
  204. "name": "edit_dashboards",
  205. "status": "1"
  206. },
  207. {
  208. "name": "edit_maps",
  209. "status": "1"
  210. },
  211. {
  212. "name": "acknowledge_problems",
  213. "status": "1"
  214. },
  215. {
  216. "name": "suppress_problems",
  217. "status": "1"
  218. },
  219. {
  220. "name": "close_problems",
  221. "status": "1"
  222. },
  223. {
  224. "name": "change_severity",
  225. "status": "1"
  226. },
  227. {
  228. "name": "add_problem_comments",
  229. "status": "1"
  230. },
  231. {
  232. "name": "execute_scripts",
  233. "status": "1"
  234. },
  235. {
  236. "name": "manage_api_tokens",
  237. "status": "1"
  238. },
  239. {
  240. "name": "edit_maintenance",
  241. "status": "1"
  242. },
  243. {
  244. "name": "manage_scheduled_reports",
  245. "status": "1"
  246. },
  247. {
  248. "name": "manage_sla",
  249. "status": "1"
  250. },
  251. {
  252. "name": "invoke_execute_now",
  253. "status": "1"
  254. }
  255. ],
  256. "actions.default_access": "1"
  257. }
  258. }
  259. ],
  260. "id": 1
  261. }

另请参考

参考来源

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