put-role-mapping.asciidoc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. [[java-rest-high-security-put-role-mapping]]
  2. === Put Role Mapping API
  3. [[java-rest-high-security-put-role-mapping-execution]]
  4. ==== Execution
  5. Creating and updating a role mapping can be performed using the `security().putRoleMapping()`
  6. method:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/SecurityDocumentationIT.java[put-role-mapping-execute]
  10. --------------------------------------------------
  11. [[java-rest-high-security-put-role-mapping-response]]
  12. ==== Response
  13. The returned `PutRoleMappingResponse` contains a single field, `created`. This field
  14. serves as an indication if a role mapping was created or if an existing entry was updated.
  15. ["source","java",subs="attributes,callouts,macros"]
  16. --------------------------------------------------
  17. include-tagged::{doc-tests}/SecurityDocumentationIT.java[put-role-mapping-response]
  18. --------------------------------------------------
  19. <1> `created` is a boolean indicating whether the role mapping was created or updated
  20. [[java-rest-high-security-put-role-mapping-async]]
  21. ==== Asynchronous Execution
  22. This request can be executed asynchronously using the `security().putRoleMappingAsync()`
  23. method:
  24. ["source","java",subs="attributes,callouts,macros"]
  25. --------------------------------------------------
  26. include-tagged::{doc-tests}/SecurityDocumentationIT.java[put-role-mapping-execute-async]
  27. --------------------------------------------------
  28. <1> The `PutRoleMappingRequest` to execute and the `ActionListener` to use when
  29. the execution completes
  30. The asynchronous method does not block and returns immediately. Once the request
  31. has completed the `ActionListener` is called back using the `onResponse` method
  32. if the execution successfully completed or using the `onFailure` method if
  33. it failed.
  34. A typical listener for a `PutRoleMappingResponse` looks like:
  35. ["source","java",subs="attributes,callouts,macros"]
  36. --------------------------------------------------
  37. include-tagged::{doc-tests}/SecurityDocumentationIT.java[put-role-mapping-execute-listener]
  38. --------------------------------------------------
  39. <1> Called when the execution is successfully completed. The response is
  40. provided as an argument
  41. <2> Called in case of failure. The raised exception is provided as an argument