批量删除角色 API
编辑批量删除角色 API
编辑批量删除原生域中的角色。
请求
编辑DELETE /_security/role/
前提条件
编辑- 要使用此 API,您必须至少拥有
manage_security
集群特权。
示例
编辑以下示例删除 my_admin_role
和 my_user_role
角色
resp = client.security.bulk_delete_role( names=[ "my_admin_role", "my_user_role" ], ) print(resp)
const response = await client.security.bulkDeleteRole({ names: ["my_admin_role", "my_user_role"], }); console.log(response);
DELETE /_security/role { "names": ["my_admin_role", "my_user_role"] }
如果角色成功删除,则请求返回
{ "deleted": [ "my_admin_role", "my_user_role" ] }
如果找不到角色,则找不到的角色将分组在 not_found
下
resp = client.security.bulk_delete_role( names=[ "my_admin_role", "not_an_existing_role" ], ) print(resp)
const response = await client.security.bulkDeleteRole({ names: ["my_admin_role", "not_an_existing_role"], }); console.log(response);
DELETE /_security/role { "names": ["my_admin_role", "not_an_existing_role"] }
{ "deleted": [ "my_admin_role" ], "not_found": [ "not_an_existing_role" ] }
如果请求失败或无效,则错误将分组在 errors
下
resp = client.security.bulk_delete_role( names=[ "my_admin_role", "superuser" ], ) print(resp)
const response = await client.security.bulkDeleteRole({ names: ["my_admin_role", "superuser"], }); console.log(response);
DELETE /_security/role { "names": ["my_admin_role", "superuser"] }
{ "deleted": [ "my_admin_role" ], "errors": { "count": 1, "details": { "superuser": { "type": "illegal_argument_exception", "reason": "role [superuser] is reserved and cannot be deleted" } } } }