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

role.create

角色.创建

Description

说明

object role.create(object/array roles)

This method allows to create new 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) Roles to create. 要创建的角色用户。

Additionally to the standard role properties, the method accepts the following parameters. 除此之外,根据[标准用户角色特性]( 该方式接受下列参数配置。 |Parameter|Type|Description| |--|--|------| |rules|array|Role rules to be created for the role.|

参数 类型 描述
rules 数组 [角色 [角色规则]用于创建新的角色用户。

Return values

返回值

(object) Returns an object containing the IDs of the created roles under the roleids property. The order of the returned IDs matches the order of the passed roles. 根据roleids特性,(object) 会返回一个对象,包含创建的角色用户的ID号。返回的ID号顺序对应查询的角色用户次序。

Examples

示例

Creating a role

创建角色

Create a role with type "User" and denied access to two UI elements. 创建一个类型为“User”的角色 ,并禁止其访问两个UI元素。 Request: 请求:

{
           "jsonrpc": "2.0",
           "method": "role.create",
           "params": {
               "name": "Operator",
               "type": "1",
               "rules": {
                   "ui": [
                       {
                           "name": "monitoring.hosts",
                           "status": "0"
                       },
                       {
                           "name": "monitoring.maps",
                           "status": "0"
                       }
                   ]
               }
           },
           "id": 1
       }

Response:

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

See also

另见

Source

来源

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