角色.获取

说明

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. "auth": "3a57200802b24cda67c4e4010b50c065",
  10. "id": 1
  11. }

响应:

  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": "monitoring.services",
  33. "status": "1"
  34. },
  35. {
  36. "name": "inventory.overview",
  37. "status": "1"
  38. },
  39. {
  40. "name": "inventory.hosts",
  41. "status": "1"
  42. },
  43. {
  44. "name": "reports.availability_report",
  45. "status": "1"
  46. },
  47. {
  48. "name": "reports.top_triggers",
  49. "status": "1"
  50. },
  51. {
  52. "name": "monitoring.discovery",
  53. "status": "1"
  54. },
  55. {
  56. "name": "reports.notifications",
  57. "status": "1"
  58. },
  59. {
  60. "name": "reports.scheduled_reports",
  61. "status": "1"
  62. },
  63. {
  64. "name": "configuration.host_groups",
  65. "status": "1"
  66. },
  67. {
  68. "name": "configuration.templates",
  69. "status": "1"
  70. },
  71. {
  72. "name": "configuration.hosts",
  73. "status": "1"
  74. },
  75. {
  76. "name": "configuration.maintenance",
  77. "status": "1"
  78. },
  79. {
  80. "name": "configuration.actions",
  81. "status": "1"
  82. },
  83. {
  84. "name": "configuration.discovery",
  85. "status": "1"
  86. },
  87. {
  88. "name": "reports.system_info",
  89. "status": "1"
  90. },
  91. {
  92. "name": "reports.audit",
  93. "status": "1"
  94. },
  95. {
  96. "name": "reports.action_log",
  97. "status": "1"
  98. },
  99. {
  100. "name": "configuration.event_correlation",
  101. "status": "1"
  102. },
  103. {
  104. "name": "administration.general",
  105. "status": "1"
  106. },
  107. {
  108. "name": "administration.proxies",
  109. "status": "1"
  110. },
  111. {
  112. "name": "administration.authentication",
  113. "status": "1"
  114. },
  115. {
  116. "name": "administration.user_groups",
  117. "status": "1"
  118. },
  119. {
  120. "name": "administration.user_roles",
  121. "status": "1"
  122. },
  123. {
  124. "name": "administration.users",
  125. "status": "1"
  126. },
  127. {
  128. "name": "administration.media_types",
  129. "status": "1"
  130. },
  131. {
  132. "name": "administration.scripts",
  133. "status": "1"
  134. },
  135. {
  136. "name": "administration.queue",
  137. "status": "1"
  138. }
  139. ],
  140. "ui.default_access": "1",
  141. "services.read.mode": "1",
  142. "services.read.list": [],
  143. "services.read.tag": {
  144. "tag": "",
  145. "value": ""
  146. },
  147. "services.write.mode": "1",
  148. "services.write.list": [],
  149. "services.write.tag": {
  150. "tag": "",
  151. "value": ""
  152. },
  153. "modules": [],
  154. "modules.default_access": "1",
  155. "api.access": "1",
  156. "api.mode": "0",
  157. "api": [],
  158. "actions": [
  159. {
  160. "name": "edit_dashboards",
  161. "status": "1"
  162. },
  163. {
  164. "name": "edit_maps",
  165. "status": "1"
  166. },
  167. {
  168. "name": "acknowledge_problems",
  169. "status": "1"
  170. },
  171. {
  172. "name": "close_problems",
  173. "status": "1"
  174. },
  175. {
  176. "name": "change_severity",
  177. "status": "1"
  178. },
  179. {
  180. "name": "add_problem_comments",
  181. "status": "1"
  182. },
  183. {
  184. "name": "execute_scripts",
  185. "status": "1"
  186. },
  187. {
  188. "name": "manage_api_tokens",
  189. "status": "1"
  190. },
  191. {
  192. "name": "edit_maintenance",
  193. "status": "1"
  194. },
  195. {
  196. "name": "manage_scheduled_reports",
  197. "status": "1"
  198. }
  199. ],
  200. "actions.default_access": "1"
  201. }
  202. }
  203. ],
  204. "id": 1
  205. }

另请参考

参考来源

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