2018-09-07 13:51:37 -04:00
|
|
|
[[java-rest-high-security-put-user]]
|
|
|
|
=== Put User API
|
2018-09-05 12:56:30 -04:00
|
|
|
|
2018-09-07 13:51:37 -04:00
|
|
|
[[java-rest-high-security-put-user-execution]]
|
2018-09-05 12:56:30 -04:00
|
|
|
==== Execution
|
|
|
|
|
|
|
|
Creating and updating a user can be performed using the `security().putUser()`
|
|
|
|
method:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-09-07 13:51:37 -04:00
|
|
|
include-tagged::{doc-tests}/SecurityDocumentationIT.java[put-user-execute]
|
2018-09-05 12:56:30 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
2018-09-07 13:51:37 -04:00
|
|
|
[[java-rest-high-security-put-user-response]]
|
2018-09-05 12:56:30 -04:00
|
|
|
==== 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"]
|
|
|
|
--------------------------------------------------
|
2018-09-07 13:51:37 -04:00
|
|
|
include-tagged::{doc-tests}/SecurityDocumentationIT.java[put-user-response]
|
2018-09-05 12:56:30 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> `created` is a boolean indicating whether the user was created or updated
|
|
|
|
|
2018-09-07 13:51:37 -04:00
|
|
|
[[java-rest-high-security-put-user-async]]
|
2018-09-05 12:56:30 -04:00
|
|
|
==== Asynchronous Execution
|
|
|
|
|
|
|
|
This request can be executed asynchronously:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-09-07 13:51:37 -04:00
|
|
|
include-tagged::{doc-tests}/SecurityDocumentationIT.java[put-user-execute-async]
|
2018-09-05 12:56:30 -04:00
|
|
|
--------------------------------------------------
|
2018-09-07 13:51:37 -04:00
|
|
|
<1> The `PutUserRequest` to execute and the `ActionListener` to use when
|
|
|
|
the execution completes.
|
2018-09-05 12:56:30 -04:00
|
|
|
|
|
|
|
The asynchronous method does not block and returns immediately. Once the request
|
|
|
|
has completed the `ActionListener` is called back using the `onResponse` method
|
|
|
|
if the execution successfully completed or using the `onFailure` method if
|
|
|
|
it failed.
|
|
|
|
|
|
|
|
A typical listener for a `PutUserResponse` looks like:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-09-07 13:51:37 -04:00
|
|
|
include-tagged::{doc-tests}/SecurityDocumentationIT.java[put-user-execute-listener]
|
2018-09-05 12:56:30 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> Called when the execution is successfully completed. The response is
|
2018-09-07 13:51:37 -04:00
|
|
|
provided as an argument.
|
|
|
|
<2> Called in case of failure. The raised exception is provided as an argument.
|