| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 | [[java-rest-high-snapshot-create-snapshot]]=== Create Snapshot APIUse the Create Snapshot API to create a new snapshot.[[java-rest-high-snapshot-create-snapshot-request]]==== Create Snapshot RequestA `CreateSnapshotRequest`:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request]--------------------------------------------------==== Required ArgumentsThe following arguments are mandatory:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-repositoryName]--------------------------------------------------<1> The name of the repository.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-snapshotName]--------------------------------------------------<1> The name of the snapshot.==== Optional ArgumentsThe following arguments are optional:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-indices]--------------------------------------------------<1> A list of indices the snapshot is applied to.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-indicesOptions]--------------------------------------------------<1> Options applied to the indices.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-partial]--------------------------------------------------<1> Set `partial` to `true` to allow a successful snapshot without theavailability of all the indices primary shards. Defaults to `false`.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-includeGlobalState]--------------------------------------------------<1> Set `includeGlobalState` to `false` to prevent writing the cluster's globalstate as part of the snapshot. Defaults to `true`.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-masterTimeout]--------------------------------------------------<1> Timeout to connect to the master node as a `TimeValue`.<2> Timeout to connect to the master node as a `String`.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-waitForCompletion]--------------------------------------------------<1> Waits for the snapshot to be completed before a response is returned.[[java-rest-high-snapshot-create-snapshot-sync]]==== Synchronous ExecutionExecute a `CreateSnapshotRequest` synchronously to receive a `CreateSnapshotResponse`.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-execute]--------------------------------------------------Retrieve the `SnapshotInfo` from a `CreateSnapshotResponse` when the snapshot is fully created.(The `waitForCompletion` parameter is `true`).["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-response-snapshot-info]--------------------------------------------------<1> The `SnapshotInfo` object.[[java-rest-high-snapshot-create-snapshot-async]]==== Asynchronous ExecutionThe asynchronous execution of a create snapshot request requires both the`CreateSnapshotRequest` instance and an `ActionListener` instance to bepassed as arguments to the asynchronous method:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-execute-async]--------------------------------------------------<1> The `CreateSnapshotRequest` to execute and the `ActionListener` to use whenthe execution completes.The asynchronous method does not block and returns immediately. Once it iscompleted the `ActionListener` is called back with the `onResponse` methodif the execution is successful or the `onFailure` method if the executionfailed.A typical listener for `CreateSnapshotResponse` looks like:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-execute-listener]--------------------------------------------------<1> Called when the execution is successfully completed. The response isprovided as an argument.<2> Called in case of a failure. The raised exception is provided as anargument.[[java-rest-high-snapshot-create-snapshot-response]]==== Snapshot Create ResponseUse the `CreateSnapshotResponse` to retrieve information about the evaluatedrequest:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-response]--------------------------------------------------<1> Indicates the node has started the request.
 |