bulk-delete-roles.asciidoc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. [role="xpack"]
  2. [[security-api-bulk-delete-role]]
  3. === Bulk delete roles API
  4. preview::[]
  5. ++++
  6. <titleabbrev>Bulk delete roles API</titleabbrev>
  7. ++++
  8. Bulk deletes roles in the native realm.
  9. [[security-api-bulk-delete-role-request]]
  10. ==== {api-request-title}
  11. `DELETE /_security/role/`
  12. [[security-api-bulk-delete-role-prereqs]]
  13. ==== {api-prereq-title}
  14. * To use this API, you must have at least the `manage_security` cluster
  15. privilege.
  16. [[security-api-bulk-delete-role-desc]]
  17. ==== {api-description-title}
  18. The role management APIs are generally the preferred way to manage roles, rather than using
  19. <<roles-management-file,file-based role management>>. The bulk delete roles API cannot delete
  20. roles that are defined in roles files.
  21. [[security-api-bulk-delete-role-path-params]]
  22. ==== {api-path-parms-title}
  23. `refresh`::
  24. Optional setting of the {ref}/docs-refresh.html[refresh policy] for the write request. Defaults to Immediate.
  25. [[security-api-bulk-delete-role-request-body]]
  26. ==== {api-request-body-title}
  27. The following parameters can be specified in the body of a DELETE request
  28. and pertain to deleting a set of roles:
  29. `names`::
  30. (list) A list of role names to delete.
  31. [[security-bulk-api-delete-role-example]]
  32. ==== {api-examples-title}
  33. The following example deletes a `my_admin_role` and `my_user_role` roles:
  34. [source,console]
  35. --------------------------------------------------
  36. DELETE /_security/role
  37. {
  38. "names": ["my_admin_role", "my_user_role"]
  39. }
  40. --------------------------------------------------
  41. // TEST[setup:admin_role,user_role]
  42. If the roles are successfully deleted, the request returns:
  43. [source,console-result]
  44. --------------------------------------------------
  45. {
  46. "deleted": [
  47. "my_admin_role",
  48. "my_user_role"
  49. ]
  50. }
  51. --------------------------------------------------
  52. If a role cannot be found, the not found roles are grouped under `not_found`:
  53. [source,console]
  54. --------------------------------------------------
  55. DELETE /_security/role
  56. {
  57. "names": ["my_admin_role", "not_an_existing_role"]
  58. }
  59. --------------------------------------------------
  60. // TEST[setup:admin_role]
  61. [source,console-result]
  62. --------------------------------------------------
  63. {
  64. "deleted": [
  65. "my_admin_role"
  66. ],
  67. "not_found": [
  68. "not_an_existing_role"
  69. ]
  70. }
  71. --------------------------------------------------
  72. If a request fails or is invalid, the errors are grouped under `errors`:
  73. [source,console]
  74. --------------------------------------------------
  75. DELETE /_security/role
  76. {
  77. "names": ["my_admin_role", "superuser"]
  78. }
  79. --------------------------------------------------
  80. // TEST[setup:admin_role]
  81. [source,console-result]
  82. --------------------------------------------------
  83. {
  84. "deleted": [
  85. "my_admin_role"
  86. ],
  87. "errors": {
  88. "count": 1,
  89. "details": {
  90. "superuser": {
  91. "type": "illegal_argument_exception",
  92. "reason": "role [superuser] is reserved and cannot be deleted"
  93. }
  94. }
  95. }
  96. }
  97. --------------------------------------------------