12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- --
- :api: put-user
- :request: PutUserRequest
- :response: PutUserResponse
- --
- [role="xpack"]
- [id="{upid}-{api}"]
- === Create or update user API
- [id="{upid}-{api}-request"]
- ==== Request
- The +{request}+ class is used to create or update a user in the Native Realm.
- There are 3 different factory methods for creating a request.
- ===== Create or Update User with a Password
- If you wish to create a new user (or update an existing user) and directly specifying the user's new password, use the
- `withPassword` method as shown below:
- ["source","java",subs="attributes,callouts,macros"]
- --------------------------------------------------
- include-tagged::{doc-tests-file}[{api}-password-request]
- --------------------------------------------------
- ===== Create or Update User with a Hashed Password
- If you wish to create a new user (or update an existing user) and perform password hashing on the client,
- then use the `withPasswordHash` method:
- ["source","java",subs="attributes,callouts,macros"]
- --------------------------------------------------
- include-tagged::{doc-tests-file}[{api}-hash-request]
- --------------------------------------------------
- ===== Update a User without changing their password
- If you wish to update an existing user, and do not wish to change the user's password,
- then use the `updateUserProperties` method:
- ["source","java",subs="attributes,callouts,macros"]
- --------------------------------------------------
- include-tagged::{doc-tests-file}[{api}-update-request]
- --------------------------------------------------
- include::../execution.asciidoc[]
- [id="{upid}-{api}-response"]
- ==== Response
- The returned `PutUserResponse` contains a single field, `created`. This field
- serves as an indication if a user was created or if an existing entry was updated.
- ["source","java",subs="attributes,callouts,macros"]
- --------------------------------------------------
- include-tagged::{doc-tests}/SecurityDocumentationIT.java[put-user-response]
- --------------------------------------------------
- <1> `created` is a boolean indicating whether the user was created or updated
|