create_repository.asciidoc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. [[java-rest-high-snapshot-create-repository]]
  2. === Snapshot Create RepositoryAPI
  3. The Snapshot Create RepositoryAPI allows to register a snapshot repository.
  4. [[java-rest-high-snapshot-create-repository-request]]
  5. ==== Snapshot Create RepositoryRequest
  6. A `PutRepositoryRequest`:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-request]
  10. --------------------------------------------------
  11. ==== Repository Settings
  12. Settings requirements will differ based on the repository backend chosen.
  13. ["source","java",subs="attributes,callouts,macros"]
  14. --------------------------------------------------
  15. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-request-repository-settings]
  16. --------------------------------------------------
  17. <1> Sets the repository settings
  18. ==== Providing the Settings
  19. The settings to be applied can be provided in different ways:
  20. ["source","java",subs="attributes,callouts,macros"]
  21. --------------------------------------------------
  22. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-create-settings]
  23. --------------------------------------------------
  24. <1> Settings provided as `Settings`
  25. ["source","java",subs="attributes,callouts,macros"]
  26. --------------------------------------------------
  27. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-settings-builder]
  28. --------------------------------------------------
  29. <1> Settings provided as `Settings.Builder`
  30. ["source","java",subs="attributes,callouts,macros"]
  31. --------------------------------------------------
  32. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-settings-source]
  33. --------------------------------------------------
  34. <1> Settings provided as `String`
  35. ["source","java",subs="attributes,callouts,macros"]
  36. --------------------------------------------------
  37. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-settings-map]
  38. --------------------------------------------------
  39. <1> Settings provided as a `Map`
  40. ==== Required Arguments
  41. The following arguments must be provided:
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-request-name]
  45. --------------------------------------------------
  46. <1> The name of the repository
  47. ["source","java",subs="attributes,callouts,macros"]
  48. --------------------------------------------------
  49. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-request-type]
  50. --------------------------------------------------
  51. <1> The type of the repository
  52. ==== Optional Arguments
  53. The following arguments can optionally be provided:
  54. ["source","java",subs="attributes,callouts,macros"]
  55. --------------------------------------------------
  56. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-request-timeout]
  57. --------------------------------------------------
  58. <1> Timeout to wait for the all the nodes to acknowledge the settings were applied
  59. as a `TimeValue`
  60. <2> Timeout to wait for the all the nodes to acknowledge the settings were applied
  61. as a `String`
  62. ["source","java",subs="attributes,callouts,macros"]
  63. --------------------------------------------------
  64. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-request-masterTimeout]
  65. --------------------------------------------------
  66. <1> Timeout to connect to the master node as a `TimeValue`
  67. <2> Timeout to connect to the master node as a `String`
  68. ["source","java",subs="attributes,callouts,macros"]
  69. --------------------------------------------------
  70. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-request-verify]
  71. --------------------------------------------------
  72. <1> Verify after creation as a `Boolean`
  73. [[java-rest-high-snapshot-create-repository-sync]]
  74. ==== Synchronous Execution
  75. ["source","java",subs="attributes,callouts,macros"]
  76. --------------------------------------------------
  77. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-execute]
  78. --------------------------------------------------
  79. [[java-rest-high-snapshot-create-repository-async]]
  80. ==== Asynchronous Execution
  81. The asynchronous execution of a repository put settings requires both the
  82. `PutRepositoryRequest` instance and an `ActionListener` instance to be
  83. passed to the asynchronous method:
  84. ["source","java",subs="attributes,callouts,macros"]
  85. --------------------------------------------------
  86. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-execute-async]
  87. --------------------------------------------------
  88. <1> The `PutRepositoryRequest` to execute and the `ActionListener`
  89. to use when the execution completes
  90. The asynchronous method does not block and returns immediately. Once it is
  91. completed the `ActionListener` is called back using the `onResponse` method
  92. if the execution successfully completed or using the `onFailure` method if
  93. it failed.
  94. A typical listener for `PutRepositoryResponse` looks like:
  95. ["source","java",subs="attributes,callouts,macros"]
  96. --------------------------------------------------
  97. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-execute-listener]
  98. --------------------------------------------------
  99. <1> Called when the execution is successfully completed. The response is
  100. provided as an argument
  101. <2> Called in case of a failure. The raised exception is provided as an argument
  102. [[java-rest-high-snapshot-create-repository-response]]
  103. ==== Snapshot Create RepositoryResponse
  104. The returned `PutRepositoryResponse` allows to retrieve information about the
  105. executed operation as follows:
  106. ["source","java",subs="attributes,callouts,macros"]
  107. --------------------------------------------------
  108. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-repository-response]
  109. --------------------------------------------------
  110. <1> Indicates the node has acknowledged the request