x-pack-usage.asciidoc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. [[java-rest-high-x-pack-usage]]
  2. === X-Pack Usage API
  3. [[java-rest-high-x-pack-usage-execution]]
  4. ==== Execution
  5. Detailed information about the usage of features from {xpack} can be
  6. retrieved using the `usage()` method:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[x-pack-usage-execute]
  10. --------------------------------------------------
  11. [[java-rest-high-x-pack-usage-response]]
  12. ==== Response
  13. The returned `XPackUsageResponse` contains a `Map` keyed by feature name.
  14. Every feature map has an `available` key, indicating whether that
  15. feature is available given the current license, and an `enabled` key,
  16. indicating whether that feature is currently enabled. Other keys
  17. are specific to each feature.
  18. ["source","java",subs="attributes,callouts,macros"]
  19. --------------------------------------------------
  20. include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[x-pack-usage-response]
  21. --------------------------------------------------
  22. [[java-rest-high-x-pack-usage-async]]
  23. ==== Asynchronous Execution
  24. This request can be executed asynchronously:
  25. ["source","java",subs="attributes,callouts,macros"]
  26. --------------------------------------------------
  27. include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[x-pack-usage-execute-async]
  28. --------------------------------------------------
  29. <1> The call to execute the usage api and the `ActionListener` to use when
  30. the execution completes
  31. The asynchronous method does not block and returns immediately. Once it is
  32. completed the `ActionListener` is called back using the `onResponse` method
  33. if the execution successfully completed or using the `onFailure` method if
  34. it failed.
  35. A typical listener for `XPackUsageResponse` looks like:
  36. ["source","java",subs="attributes,callouts,macros"]
  37. --------------------------------------------------
  38. include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[x-pack-usage-execute-listener]
  39. --------------------------------------------------
  40. <1> Called when the execution is successfully completed. The response is
  41. provided as an argument
  42. <2> Called in case of failure. The raised exception is provided as an argument