[comment]: # translation:outdated

[comment]: # ({a0f60ec7-a0f60ec7})
# role.update

[comment]: # ({/a0f60ec7-a0f60ec7})

[comment]: # ({63875138-63875138})
### Описание

`object role.update(объект/массив roles)`

Этот метод позволяет обновлять существующие роли.

::: noteclassic
Этот метод доступен только пользователю с типом доступа *Супер-администратор*.
Разрешения на вызов метода можно отозвать в настройках ролей пользователя.
Дополнительную информацию см. в разделе [Роли пользователей](/manual/web_interface/frontend_sections/administration/user_roles).
:::

[comment]: # ({/63875138-63875138})

[comment]: # ({new-fa5c3d93})
### Parameters

`(object/array)` Role properties to be updated.

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.

Additionally to the [standard role properties](object#role) the method
accepts the following parameters.

|Parameter|[Type](/manual/api/reference_commentary#data_types)|Description|
|---------|---------------------------------------------------|-----------|
|rules|array|Access [rules](object#role_rules) to replace the current access rules assigned to the role.|

[comment]: # ({/new-fa5c3d93})

[comment]: # ({12d196f6-12d196f6})
### Возвращаемые значения

`(object)` Возвращает объект, содержащий идентификаторы обновлённых ролей, указанных 
в свойстве `roleids`.

[comment]: # ({/12d196f6-12d196f6})

[comment]: # ({b41637d2-b41637d2})
### Примеры

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({new-1ce1fe70})
#### Disabling ability to execute scripts

Update role with ID "5", disable ability to execute scripts.

Request:

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

Response:

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

[comment]: # ({/new-1ce1fe70})

[comment]: # ({new-a6349165})
#### Limiting access to API

Update role with ID "5", deny to call any "create", "update" or "delete"
methods.

Request:

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

Response:

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

[comment]: # ({/new-a6349165})

[comment]: # ({36db1bd2-36db1bd2})
### Источник

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

[comment]: # ({/36db1bd2-36db1bd2})
