2022 Zabbix中国峰会
2022 Zabbix中国峰会

role.update

角色.更新

Description

说明

object role.update(object/array roles)

This method allows to update existing roles. 用户使用该方法可以用来更新存在的角色用户。 ::: noteclassic This method is only available to Super admin user type. Permissions to call the method can be revoked in user role settings. See User roles for more information. ::: ::: 请注意 该方式仅对_超级管理员_类型的用户生效。 用户可以在用户角色设置中对该方式的使用权限进行设定修改。请参考 用户角色以获取更多信息。 :::

Parameters

参数

(object/array) Role properties to be updated. (object/array) 要更新的角色属性。

The roleid property must be defined for each role, all other properties are optional. Only the passed properties will be updated, all others will remain unchanged. The roleid 该属性为必要配置参数,需要为每个规划报告定义,其它属性则为可选配置。只有符合要求的属性更改才会更新,其它属性则会保持不变。 Additionally to the standard role properties the method accepts the following parameters. 除此之外,根据标准规划报告属性,该方法接受如下参数。 |参数|类型|说明| |---------|---------------------------------------------------|-----------| |rules|数组|将当前赋予该职责用户的访问规则修改为新的访问规则。|

Return values

返回值

(object) Returns an object containing the IDs of the updated roles under the roleids property. 根据roleids的特性,(object)返回一个包含已更新职责用户ID的对象。

Examples

示例

Disabling ability to execute scripts

关闭运行脚本功能

Update role with ID "5", disable ability to execute scripts. 更新ID号为5的角色,关闭其运行脚本的功能。 Request: 请求:

{
           "jsonrpc": "2.0",
           "method": "role.update",
           "params": [
               {
                   "roleid": "5",
                   "rules": {
                       "actions": [
                           {
                               "name": "execute_scripts",
                               "status": "0"
                           }
                       ]
                   }
               }
           ],
           "id": 1
       }

Response: 响应:

{
           "jsonrpc": "2.0",
           "result": {
               "roleids": [
                   "5"
               ]
           },
           "id": 1
       }

Limiting access to API

限制对API的访问

Update role with ID "5", deny to call any "create", "update" or "delete" methods. 更新ID号为5的角色,拒绝任何 "创建", "更新" 或者 "删除" 方式。 Request: 请求:

{
           "jsonrpc": "2.0",
           "method": "role.update",
           "params": [
               {
                   "roleid": "5",
                   "rules": {
                       "api.access": "1",
                       "api.mode": "0",
                       "api": ["*.create", "*.update", "*.delete"]
                   }
               }
           ],
           "id": 1
       }

Response: 响应:

{
           "jsonrpc": "2.0",
           "result": {
               "roleids": [
                   "5"
               ]
           },
           "id": 1
       }

参考来源

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