更新
描述
object role.update(object/array roles)
此方法允许您更新现有角色。
此方法仅适用于 Super admin 用户类型。 调用该方法的权限可以在用户角色设置中撤销。有关更多信息,请参见 用户 角色。
参数
(object/array) 要更新的角色属性。
必须为每个角色定义 roleid 属性,所有其他属性均为可选。
只有传入的属性会被更新,其他所有属性将保持不变。
除了标准角色属性之外,该方法还接受以下参数。
返回值
根据roleids的特性,(object)返回一个包含已更新职责用户ID的对象
示例
关闭运行脚本功能
更新ID号为5的角色,关闭其运行脚本的功能。 请求:
{
"jsonrpc": "2.0",
"method": "role.update",
"params": [
{
"roleid": "5",
"rules": {
"actions": [
{
"name": "execute_scripts",
"status": "0"
}
]
}
}
],
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": {
"roleids": [
"5"
]
},
"id": 1
}
限制对API的访问
更新ID号为5的角色,拒绝任何 "创建", "更新" 或者 "删除" 方式。 请求:
{
"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.