get_templates.asciidoc 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. [[java-rest-high-get-templates]]
  2. === Get Templates API
  3. The Get Templates API allows to retrieve a list of index templates by name.
  4. [[java-rest-high-get-templates-request]]
  5. ==== Get Index Templates Request
  6. A `GetIndexTemplatesRequest` specifies one or several names of the index templates to get.
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-templates-request]
  10. --------------------------------------------------
  11. <1> A single index template name
  12. <2> Multiple index template names
  13. <3> An index template name using wildcard
  14. ["source","java",subs="attributes,callouts,macros"]
  15. --------------------------------------------------
  16. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-templates-request-masterTimeout]
  17. --------------------------------------------------
  18. <1> Timeout to connect to the master node as a `TimeValue`
  19. <2> Timeout to connect to the master node as a `String`
  20. [[java-rest-high-get-templates-sync]]
  21. ==== Synchronous Execution
  22. ["source","java",subs="attributes,callouts,macros"]
  23. --------------------------------------------------
  24. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-templates-execute]
  25. --------------------------------------------------
  26. [[java-rest-high-get-templates-async]]
  27. ==== Asynchronous Execution
  28. The asynchronous execution of a get index templates request requires a `GetTemplatesRequest`
  29. instance and an `ActionListener` instance to be passed to the asynchronous
  30. method:
  31. ["source","java",subs="attributes,callouts,macros"]
  32. --------------------------------------------------
  33. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-templates-execute-async]
  34. --------------------------------------------------
  35. <1> The `GetTemplatesRequest` to execute and the `ActionListener` to use when
  36. the execution completes
  37. The asynchronous method does not block and returns immediately. Once it is
  38. completed the `ActionListener` is called back using the `onResponse` method
  39. if the execution successfully completed or using the `onFailure` method if
  40. it failed.
  41. A typical listener for `GetTemplatesResponse` looks like:
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-templates-execute-listener]
  45. --------------------------------------------------
  46. <1> Called when the execution is successfully completed. The response is
  47. provided as an argument
  48. <2> Called in case of failure. The raised exception is provided as an argument
  49. [[java-rest-high-get-templates-response]]
  50. ==== Get Templates Response
  51. The returned `GetTemplatesResponse` consists a list of matching index templates.
  52. ["source","java",subs="attributes,callouts,macros"]
  53. --------------------------------------------------
  54. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-templates-response]
  55. --------------------------------------------------
  56. <1> A list of matching index templates