put-user.asciidoc 2.1 KB

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