put-user.asciidoc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --
  2. :api: put-user
  3. :request: PutUserRequest
  4. :response: PutUserResponse
  5. --
  6. [role="xpack"]
  7. [id="{upid}-{api}"]
  8. === Create or update user API
  9. [id="{upid}-{api}-request"]
  10. ==== Request
  11. The +{request}+ class is used to create or update a user in the Native Realm.
  12. There are 3 different factory methods for creating a request.
  13. ===== Create or Update User with a Password
  14. If you wish to create a new user (or update an existing user) and directly specifying the user's new password, use the
  15. `withPassword` method as shown below:
  16. ["source","java",subs="attributes,callouts,macros"]
  17. --------------------------------------------------
  18. include-tagged::{doc-tests-file}[{api}-password-request]
  19. --------------------------------------------------
  20. ===== Create or Update User with a Hashed Password
  21. If you wish to create a new user (or update an existing user) and perform password hashing on the client,
  22. then use the `withPasswordHash` method:
  23. ["source","java",subs="attributes,callouts,macros"]
  24. --------------------------------------------------
  25. include-tagged::{doc-tests-file}[{api}-hash-request]
  26. --------------------------------------------------
  27. ===== Update a User without changing their password
  28. If you wish to update an existing user, and do not wish to change the user's password,
  29. then use the `updateUserProperties` method:
  30. ["source","java",subs="attributes,callouts,macros"]
  31. --------------------------------------------------
  32. include-tagged::{doc-tests-file}[{api}-update-request]
  33. --------------------------------------------------
  34. include::../execution.asciidoc[]
  35. [id="{upid}-{api}-response"]
  36. ==== Response
  37. The returned `PutUserResponse` contains a single field, `created`. This field
  38. serves as an indication if a user was created or if an existing entry was updated.
  39. ["source","java",subs="attributes,callouts,macros"]
  40. --------------------------------------------------
  41. include-tagged::{doc-tests}/SecurityDocumentationIT.java[put-user-response]
  42. --------------------------------------------------
  43. <1> `created` is a boolean indicating whether the user was created or updated