summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java')
-rw-r--r--core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java
index a7bbd02ee5..9d8ed49aaa 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java
@@ -313,19 +313,35 @@ public class RestoreSnapshotRequest extends MasterNodeRequest<RestoreSnapshotReq
}
/**
- * Sets repository-specific restore settings in JSON, YAML or properties format
+ * Sets repository-specific restore settings in JSON or YAML format
* <p>
* See repository documentation for more information.
*
* @param source repository-specific snapshot settings
* @return this request
+ * @deprecated use {@link #settings(String, XContentType)} to avoid content type detection
*/
+ @Deprecated
public RestoreSnapshotRequest settings(String source) {
this.settings = Settings.builder().loadFromSource(source).build();
return this;
}
/**
+ * Sets repository-specific restore settings in JSON or YAML format
+ * <p>
+ * See repository documentation for more information.
+ *
+ * @param source repository-specific snapshot settings
+ * @param xContentType the content type of the source
+ * @return this request
+ */
+ public RestoreSnapshotRequest settings(String source, XContentType xContentType) {
+ this.settings = Settings.builder().loadFromSource(source, xContentType).build();
+ return this;
+ }
+
+ /**
* Sets repository-specific restore settings
* <p>
* See repository documentation for more information.
@@ -337,7 +353,7 @@ public class RestoreSnapshotRequest extends MasterNodeRequest<RestoreSnapshotReq
try {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.map(source);
- settings(builder.string());
+ settings(builder.string(), builder.contentType());
} catch (IOException e) {
throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
}
@@ -436,7 +452,9 @@ public class RestoreSnapshotRequest extends MasterNodeRequest<RestoreSnapshotReq
/**
* Sets settings that should be added/changed in all restored indices
+ * @deprecated use {@link #indexSettings(String, XContentType)} to avoid content type detection
*/
+ @Deprecated
public RestoreSnapshotRequest indexSettings(String source) {
this.indexSettings = Settings.builder().loadFromSource(source).build();
return this;
@@ -445,11 +463,19 @@ public class RestoreSnapshotRequest extends MasterNodeRequest<RestoreSnapshotReq
/**
* Sets settings that should be added/changed in all restored indices
*/
+ public RestoreSnapshotRequest indexSettings(String source, XContentType xContentType) {
+ this.indexSettings = Settings.builder().loadFromSource(source, xContentType).build();
+ return this;
+ }
+
+ /**
+ * Sets settings that should be added/changed in all restored indices
+ */
public RestoreSnapshotRequest indexSettings(Map<String, Object> source) {
try {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.map(source);
- indexSettings(builder.string());
+ indexSettings(builder.string(), builder.contentType());
} catch (IOException e) {
throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
}