org.elasticsearch.client.indices.PutComposableIndexTemplateRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-rest-high-level-client Show documentation
Show all versions of elasticsearch-rest-high-level-client Show documentation
Elasticsearch subproject :client:rest-high-level
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.client.indices;
import org.elasticsearch.client.TimedRequest;
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
import org.elasticsearch.common.Strings;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import java.io.IOException;
/**
* A request to create an index template.
*/
public class PutComposableIndexTemplateRequest extends TimedRequest implements ToXContentObject {
private String name;
private String cause = "";
private boolean create;
private ComposableIndexTemplate indexTemplate;
/**
* Sets the name of the index template.
*/
public PutComposableIndexTemplateRequest name(String name) {
if (Strings.isNullOrEmpty(name)) {
throw new IllegalArgumentException("name cannot be null or empty");
}
this.name = name;
return this;
}
/**
* The name of the index template.
*/
public String name() {
return this.name;
}
/**
* Set to {@code true} to force only creation, not an update of an index template. If it already
* exists, it will fail with an {@link IllegalArgumentException}.
*/
public PutComposableIndexTemplateRequest create(boolean create) {
this.create = create;
return this;
}
public boolean create() {
return create;
}
/**
* The index template to create.
*/
public PutComposableIndexTemplateRequest indexTemplate(ComposableIndexTemplate indexTemplate) {
this.indexTemplate = indexTemplate;
return this;
}
/**
* The cause for this index template creation.
*/
public PutComposableIndexTemplateRequest cause(String cause) {
this.cause = cause;
return this;
}
public String cause() {
return this.cause;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (indexTemplate != null) {
indexTemplate.toXContent(builder, params);
}
return builder;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy