co.elastic.clients.elasticsearch.transform.DeleteTransformRequest Maven / Gradle / Ivy
Show all versions of elasticsearch-java Show documentation
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.clients.elasticsearch.transform;
import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.elasticsearch._types.RequestBase;
import co.elastic.clients.elasticsearch._types.Time;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.transport.Endpoint;
import co.elastic.clients.transport.endpoints.SimpleEndpoint;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.Boolean;
import java.lang.String;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;
//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------------------
//
// This code is generated from the Elasticsearch API specification
// at https://github.com/elastic/elasticsearch-specification
//
// Manual updates to this file will be lost when the code is
// re-generated.
//
// If you find a property that is missing or wrongly typed, please
// open an issue or a PR on the API specification repository.
//
//----------------------------------------------------------------
// typedef: transform.delete_transform.Request
/**
* Delete a transform. Deletes a transform.
*
* @see API
* specification
*/
public class DeleteTransformRequest extends RequestBase {
@Nullable
private final Boolean deleteDestIndex;
@Nullable
private final Boolean force;
@Nullable
private final Time timeout;
private final String transformId;
// ---------------------------------------------------------------------------------------------
private DeleteTransformRequest(Builder builder) {
this.deleteDestIndex = builder.deleteDestIndex;
this.force = builder.force;
this.timeout = builder.timeout;
this.transformId = ApiTypeHelper.requireNonNull(builder.transformId, this, "transformId");
}
public static DeleteTransformRequest of(Function> fn) {
return fn.apply(new Builder()).build();
}
/**
* If this value is true, the destination index is deleted together with the
* transform. If false, the destination index will not be deleted
*
* API name: {@code delete_dest_index}
*/
@Nullable
public final Boolean deleteDestIndex() {
return this.deleteDestIndex;
}
/**
* If this value is false, the transform must be stopped before it can be
* deleted. If true, the transform is deleted regardless of its current state.
*
* API name: {@code force}
*/
@Nullable
public final Boolean force() {
return this.force;
}
/**
* Period to wait for a response. If no response is received before the timeout
* expires, the request fails and returns an error.
*
* API name: {@code timeout}
*/
@Nullable
public final Time timeout() {
return this.timeout;
}
/**
* Required - Identifier for the transform.
*
* API name: {@code transform_id}
*/
public final String transformId() {
return this.transformId;
}
// ---------------------------------------------------------------------------------------------
/**
* Builder for {@link DeleteTransformRequest}.
*/
public static class Builder extends RequestBase.AbstractBuilder
implements
ObjectBuilder {
@Nullable
private Boolean deleteDestIndex;
@Nullable
private Boolean force;
@Nullable
private Time timeout;
private String transformId;
/**
* If this value is true, the destination index is deleted together with the
* transform. If false, the destination index will not be deleted
*
* API name: {@code delete_dest_index}
*/
public final Builder deleteDestIndex(@Nullable Boolean value) {
this.deleteDestIndex = value;
return this;
}
/**
* If this value is false, the transform must be stopped before it can be
* deleted. If true, the transform is deleted regardless of its current state.
*
* API name: {@code force}
*/
public final Builder force(@Nullable Boolean value) {
this.force = value;
return this;
}
/**
* Period to wait for a response. If no response is received before the timeout
* expires, the request fails and returns an error.
*
* API name: {@code timeout}
*/
public final Builder timeout(@Nullable Time value) {
this.timeout = value;
return this;
}
/**
* Period to wait for a response. If no response is received before the timeout
* expires, the request fails and returns an error.
*
* API name: {@code timeout}
*/
public final Builder timeout(Function> fn) {
return this.timeout(fn.apply(new Time.Builder()).build());
}
/**
* Required - Identifier for the transform.
*
* API name: {@code transform_id}
*/
public final Builder transformId(String value) {
this.transformId = value;
return this;
}
@Override
protected Builder self() {
return this;
}
/**
* Builds a {@link DeleteTransformRequest}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public DeleteTransformRequest build() {
_checkSingleUse();
return new DeleteTransformRequest(this);
}
}
// ---------------------------------------------------------------------------------------------
/**
* Endpoint "{@code transform.delete_transform}".
*/
public static final Endpoint _ENDPOINT = new SimpleEndpoint<>(
"es/transform.delete_transform",
// Request method
request -> {
return "DELETE";
},
// Request path
request -> {
final int _transformId = 1 << 0;
int propsSet = 0;
propsSet |= _transformId;
if (propsSet == (_transformId)) {
StringBuilder buf = new StringBuilder();
buf.append("/_transform");
buf.append("/");
SimpleEndpoint.pathEncode(request.transformId, buf);
return buf.toString();
}
throw SimpleEndpoint.noPathTemplateFound("path");
},
// Path parameters
request -> {
Map params = new HashMap<>();
final int _transformId = 1 << 0;
int propsSet = 0;
propsSet |= _transformId;
if (propsSet == (_transformId)) {
params.put("transformId", request.transformId);
}
return params;
},
// Request parameters
request -> {
Map params = new HashMap<>();
if (request.deleteDestIndex != null) {
params.put("delete_dest_index", String.valueOf(request.deleteDestIndex));
}
if (request.force != null) {
params.put("force", String.valueOf(request.force));
}
if (request.timeout != null) {
params.put("timeout", request.timeout._toJsonString());
}
return params;
}, SimpleEndpoint.emptyMap(), false, DeleteTransformResponse._DESERIALIZER);
}