1
0

bulk-delete-roles.asciidoc 3.0 KB

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