put-license.asciidoc 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. [[java-rest-high-put-license]]
  2. === Update License
  3. [[java-rest-high-put-license-execution]]
  4. ==== Execution
  5. The license can be added or updated using the `putLicense()` method:
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/LicensingDocumentationIT.java[put-license-execute]
  9. --------------------------------------------------
  10. <1> Set the categories of information to retrieve. The default is to
  11. return no information which is useful for checking if {xpack} is installed
  12. but not much else.
  13. <2> A JSON document containing the license information.
  14. [[java-rest-high-put-license-response]]
  15. ==== Response
  16. The returned `PutLicenseResponse` contains the `LicensesStatus`,
  17. `acknowledged` flag and possible acknowledge messages. The acknowledge messages
  18. are present if you previously had a license with more features than one you
  19. are trying to update and you didn't set the `acknowledge` flag to `true`. In this case
  20. you need to display the messages to the end user and if they agree, resubmit the
  21. license with the `acknowledge` flag set to `true`. Please note that the request will
  22. still return a 200 return code even if requires an acknowledgement. So, it is
  23. necessary to check the `acknowledged` flag.
  24. ["source","java",subs="attributes,callouts,macros"]
  25. --------------------------------------------------
  26. include-tagged::{doc-tests}/LicensingDocumentationIT.java[put-license-response]
  27. --------------------------------------------------
  28. <1> The status of the license
  29. <2> Make sure that the license is valid.
  30. <3> Check the acknowledge flag. It should be true if license is acknowledged.
  31. <4> Otherwise we can see the acknowledge messages in `acknowledgeHeader()`
  32. <5> and check component-specific messages in `acknowledgeMessages()`.
  33. [[java-rest-high-put-license-async]]
  34. ==== Asynchronous Execution
  35. This request can be executed asynchronously:
  36. ["source","java",subs="attributes,callouts,macros"]
  37. --------------------------------------------------
  38. include-tagged::{doc-tests}/LicensingDocumentationIT.java[put-license-execute-async]
  39. --------------------------------------------------
  40. <1> The `PutLicenseRequest` to execute and the `ActionListener` to use when
  41. the execution completes
  42. The asynchronous method does not block and returns immediately. Once it is
  43. completed the `ActionListener` is called back using the `onResponse` method
  44. if the execution successfully completed or using the `onFailure` method if
  45. it failed.
  46. A typical listener for `PutLicenseResponse` looks like:
  47. ["source","java",subs="attributes,callouts,macros"]
  48. --------------------------------------------------
  49. include-tagged::{doc-tests}/LicensingDocumentationIT.java[put-license-execute-listener]
  50. --------------------------------------------------
  51. <1> Called when the execution is successfully completed. The response is
  52. provided as an argument
  53. <2> Called in case of failure. The raised exception is provided as an argument