获取

说明

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参数应用的情况下,返回检索对象的数量。

示例

检索角色数据

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

{
           "jsonrpc": "2.0",
           "method": "role.get",
           "params": {
               "output": "extend",
               "selectRules": "extend",
               "roleids": "3"
           },
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "roleid": "3",
                   "name": "Super admin role",
                   "type": "3",
                   "readonly": "1",
                   "rules": {
                       "ui": [
                           {
                               "name": "monitoring.dashboard",
                               "status": "1"
                           },
                           {
                               "name": "monitoring.problems",
                               "status": "1"
                           },
                           {
                               "name": "monitoring.hosts",
                               "status": "1"
                           },
                           {
                               "name": "monitoring.latest_data",
                               "status": "1"
                           },
                           {
                               "name": "monitoring.maps",
                               "status": "1"
                           },
                           {
                               "name": "services.services",
                               "status": "1"
                           },
                           {
                               "name": "services.sla_report",
                               "status": "1"
                           },
                           {
                               "name": "inventory.overview",
                               "status": "1"
                           },
                           {
                               "name": "inventory.hosts",
                               "status": "1"
                           },
                           {
                               "name": "reports.availability_report",
                               "status": "1"
                           },
                           {
                               "name": "reports.top_triggers",
                               "status": "1"
                           },
                           {
                               "name": "monitoring.discovery",
                               "status": "1"
                           },
                           {
                               "name": "services.sla",
                               "status": "1"
                           },
                           {
                               "name": "reports.scheduled_reports",
                               "status": "1"
                           },
                           {
                               "name": "reports.notifications",
                               "status": "1"
                           },
                           {
                               "name": "configuration.template_groups",
                               "status": "1"
                           },
                           {
                               "name": "configuration.host_groups",
                               "status": "1"
                           },
                           {
                               "name": "configuration.templates",
                               "status": "1"
                           },
                           {
                               "name": "configuration.hosts",
                               "status": "1"
                           },
                           {
                               "name": "configuration.maintenance",
                               "status": "1"
                           },
                           {
                               "name": "configuration.discovery",
                               "status": "1"
                           },
                           {
                               "name": "configuration.trigger_actions",
                               "status": "1"
                           },
                           {
                               "name": "configuration.service_actions",
                               "status": "1"
                           },
                           {
                               "name": "configuration.discovery_actions",
                               "status": "1"
                           },
                           {
                               "name": "configuration.autoregistration_actions",
                               "status": "1"
                           },
                           {
                               "name": "configuration.internal_actions",
                               "status": "1"
                           },
                           {
                               "name": "reports.system_info",
                               "status": "1"
                           },
                           {
                               "name": "reports.audit",
                               "status": "1"
                           },
                           {
                               "name": "reports.action_log",
                               "status": "1"
                           },
                           {
                               "name": "configuration.event_correlation",
                               "status": "1"
                           },
                           {
                               "name": "administration.media_types",
                               "status": "1"
                           },
                           {
                               "name": "administration.scripts",
                               "status": "1"
                           },
                           {
                               "name": "administration.user_groups",
                               "status": "1"
                           },
                           {
                               "name": "administration.user_roles",
                               "status": "1"
                           },
                           {
                               "name": "administration.users",
                               "status": "1"
                           },
                           {
                               "name": "administration.api_tokens",
                               "status": "1"
                           },
                           {
                               "name": "administration.authentication",
                               "status": "1"
                           },
                           {
                               "name": "administration.general",
                               "status": "1"
                           },
                           {
                               "name": "administration.audit_log",
                               "status": "1"
                           },
                           {
                               "name": "administration.housekeeping",
                               "status": "1"
                           },
                           {
                               "name": "administration.proxies",
                               "status": "1"
                           },
                           {
                               "name": "administration.macros",
                               "status": "1"
                           },
                           {
                               "name": "administration.queue",
                               "status": "1"
                           }
                       ],
                       "ui.default_access": "1",
                       "services.read.mode": "1",
                       "services.read.list": [],
                       "services.read.tag": {
                           "tag": "",
                           "value": ""
                       },
                       "services.write.mode": "1",
                       "services.write.list": [],
                       "services.write.tag": {
                           "tag": "",
                           "value": ""
                       },
                       "modules": [],
                       "modules.default_access": "1",
                       "api.access": "1",
                       "api.mode": "0",
                       "api": [],
                       "actions": [
                           {
                               "name": "edit_dashboards",
                               "status": "1"
                           },
                           {
                               "name": "edit_maps",
                               "status": "1"
                           },
                           {
                               "name": "acknowledge_problems",
                               "status": "1"
                           },
                           {
                               "name": "suppress_problems",
                               "status": "1"
                           },
                           {
                               "name": "close_problems",
                               "status": "1"
                           },
                           {
                               "name": "change_severity",
                               "status": "1"
                           },
                           {
                               "name": "add_problem_comments",
                               "status": "1"
                           },
                           {
                               "name": "execute_scripts",
                               "status": "1"
                           },
                           {
                               "name": "manage_api_tokens",
                               "status": "1"
                           },
                           {
                               "name": "edit_maintenance",
                               "status": "1"
                           },
                           {
                               "name": "manage_scheduled_reports",
                               "status": "1"
                           },
                           {
                               "name": "manage_sla",
                               "status": "1"
                           },
                           {
                               "name": "invoke_execute_now",
                               "status": "1"
                           }
                       ],
                       "actions.default_access": "1"
                   }
               }
           ],
           "id": 1
       }

另请参考

参考来源

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