get-role-mappings.asciidoc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. [role="xpack"]
  2. [[security-api-get-role-mapping]]
  3. === Get role mappings API
  4. ++++
  5. <titleabbrev>Get role mappings</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. Retrieves role mappings.
  13. [[security-api-get-role-mapping-request]]
  14. ==== {api-request-title}
  15. `GET /_security/role_mapping` +
  16. `GET /_security/role_mapping/<name>`
  17. [[security-api-get-role-mapping-prereqs]]
  18. ==== {api-prereq-title}
  19. * To use this API, you must have at least the `read_security` cluster privilege.
  20. [[security-api-get-role-mapping-desc]]
  21. ==== {api-description-title}
  22. Role mappings define which roles are assigned to each user. For more information,
  23. see <<mapping-roles>>.
  24. The role mapping APIs are generally the preferred way to manage role mappings
  25. rather than using <<mapping-roles-file,role mapping files>>.
  26. The get role mappings API cannot retrieve role mappings that are defined
  27. in role mapping files.
  28. [[security-api-get-role-mapping-path-params]]
  29. ==== {api-path-parms-title}
  30. `name`::
  31. (Optional, string) The distinct name that identifies the role mapping. The name
  32. is used solely as an identifier to facilitate interaction via the API; it does
  33. not affect the behavior of the mapping in any way. You can specify multiple
  34. mapping names as a comma-separated list. If you do not specify this
  35. parameter, the API returns information about all role mappings.
  36. [[security-api-get-role-mapping-response-body]]
  37. ==== {api-response-body-title}
  38. A successful call retrieves an object, where the keys are the
  39. names of the request mappings, and the values are the JSON representation of
  40. those mappings. For more information, see
  41. <<role-mapping-resources>>.
  42. [[security-api-get-role-mapping-response-codes]]
  43. ==== {api-response-codes-title}
  44. If there is no mapping with the requested name, the
  45. response will have status code `404`.
  46. [[security-api-get-role-mapping-example]]
  47. ==== {api-examples-title}
  48. The following example retrieves information about the `mapping1` role mapping:
  49. [source,console]
  50. --------------------------------------------------
  51. GET /_security/role_mapping/mapping1
  52. --------------------------------------------------
  53. // TEST[setup:role_mapping]
  54. [source,console-result]
  55. --------------------------------------------------
  56. {
  57. "mapping1": {
  58. "enabled": true,
  59. "roles": [
  60. "user"
  61. ],
  62. "rules": {
  63. "field": {
  64. "username": "*"
  65. }
  66. },
  67. "metadata": {}
  68. }
  69. }
  70. --------------------------------------------------