bulk-delete-roles.asciidoc 3.1 KB

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