This is a translation of the original English documentation page. Help us make it better.

role.create

Description

object role.create(object/array roles)

This method allows to create new roles.

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.

Valori di ritorno

(object) Restituisce un oggetto contenente gli ID dei ruoli creati sotto la proprietà roleids. L'ordine degli ID restituiti corrisponde all' ordine dei ruoli passati.

Esempi

Creating a role

Create a role with type "User" and denied access to two UI elements.

Request:

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

Response:

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

Guarda anche

Fonte

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