All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.elastic.clients.elasticsearch.transform.PutTransformRequest Maven / Gradle / Ivy

There is a newer version: 8.17.0
Show newest version
/*
 * 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.
 */

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

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.JsonData;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.JsonpSerializable;
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 co.elastic.clients.util.WithJsonObjectBuilderBase;
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;

// typedef: transform.put_transform.Request

/**
 * Creates a transform.
 * 

* A transform copies data from source indices, transforms it, and persists it * into an entity-centric destination index. You can also think of the * destination index as a two-dimensional tabular data structure (known as a * data frame). The ID for each document in the data frame is generated from a * hash of the entity, so there is a unique row per entity. *

* You must choose either the latest or pivot method for your transform; you * cannot use both in a single transform. If you choose to use the pivot method * for your transform, the entities are defined by the set of * group_by fields in the pivot object. If you choose to use the * latest method, the entities are defined by the unique_key field * values in the latest object. *

* You must have create_index, index, and * read privileges on the destination index and read * and view_index_metadata privileges on the source indices. When * Elasticsearch security features are enabled, the transform remembers which * roles the user that created it had at the time of creation and uses those * same roles. If those roles do not have the required privileges on the source * and destination indices, the transform fails when it attempts unauthorized * operations. *

* NOTE: You must use Kibana or this API to create a transform. Do not add a * transform directly into any .transform-internal* indices using * the Elasticsearch index API. If Elasticsearch security features are enabled, * do not give users any privileges on .transform-internal* * indices. If you used transforms prior to 7.5, also do not give users any * privileges on .data-frame-internal* indices. * * @see API * specification */ @JsonpDeserializable public class PutTransformRequest extends RequestBase implements JsonpSerializable { private final Map meta; @Nullable private final Boolean deferValidation; @Nullable private final String description; private final Destination dest; @Nullable private final Time frequency; @Nullable private final Latest latest; @Nullable private final Pivot pivot; @Nullable private final RetentionPolicy retentionPolicy; @Nullable private final Settings settings; private final Source source; @Nullable private final Sync sync; @Nullable private final Time timeout; private final String transformId; // --------------------------------------------------------------------------------------------- private PutTransformRequest(Builder builder) { this.meta = ApiTypeHelper.unmodifiable(builder.meta); this.deferValidation = builder.deferValidation; this.description = builder.description; this.dest = ApiTypeHelper.requireNonNull(builder.dest, this, "dest"); this.frequency = builder.frequency; this.latest = builder.latest; this.pivot = builder.pivot; this.retentionPolicy = builder.retentionPolicy; this.settings = builder.settings; this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); this.sync = builder.sync; this.timeout = builder.timeout; this.transformId = ApiTypeHelper.requireNonNull(builder.transformId, this, "transformId"); } public static PutTransformRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Defines optional transform metadata. *

* API name: {@code _meta} */ public final Map meta() { return this.meta; } /** * When the transform is created, a series of validations occur to ensure its * success. For example, there is a check for the existence of the source * indices and a check that the destination index is not part of the source * index pattern. You can use this parameter to skip the checks, for example * when the source index does not exist until after the transform is created. * The validations are always run when you start the transform, however, with * the exception of privilege checks. *

* API name: {@code defer_validation} */ @Nullable public final Boolean deferValidation() { return this.deferValidation; } /** * Free text description of the transform. *

* API name: {@code description} */ @Nullable public final String description() { return this.description; } /** * Required - The destination for the transform. *

* API name: {@code dest} */ public final Destination dest() { return this.dest; } /** * The interval between checks for changes in the source indices when the * transform is running continuously. Also determines the retry interval in the * event of transient failures while the transform is searching or indexing. The * minimum value is 1s and the maximum is 1h. *

* API name: {@code frequency} */ @Nullable public final Time frequency() { return this.frequency; } /** * The latest method transforms the data by finding the latest document for each * unique key. *

* API name: {@code latest} */ @Nullable public final Latest latest() { return this.latest; } /** * The pivot method transforms the data by aggregating and grouping it. These * objects define the group by fields and the aggregation to reduce the data. *

* API name: {@code pivot} */ @Nullable public final Pivot pivot() { return this.pivot; } /** * Defines a retention policy for the transform. Data that meets the defined * criteria is deleted from the destination index. *

* API name: {@code retention_policy} */ @Nullable public final RetentionPolicy retentionPolicy() { return this.retentionPolicy; } /** * Defines optional transform settings. *

* API name: {@code settings} */ @Nullable public final Settings settings() { return this.settings; } /** * Required - The source of the data for the transform. *

* API name: {@code source} */ public final Source source() { return this.source; } /** * Defines the properties transforms require to run continuously. *

* API name: {@code sync} */ @Nullable public final Sync sync() { return this.sync; } /** * 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. This identifier can contain * lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It * has a 64 character limit and must start and end with alphanumeric characters. *

* API name: {@code transform_id} */ public final String transformId() { return this.transformId; } /** * Serialize this object to JSON. */ public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); generator.writeEnd(); } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.meta)) { generator.writeKey("_meta"); generator.writeStartObject(); for (Map.Entry item0 : this.meta.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.description != null) { generator.writeKey("description"); generator.write(this.description); } generator.writeKey("dest"); this.dest.serialize(generator, mapper); if (this.frequency != null) { generator.writeKey("frequency"); this.frequency.serialize(generator, mapper); } if (this.latest != null) { generator.writeKey("latest"); this.latest.serialize(generator, mapper); } if (this.pivot != null) { generator.writeKey("pivot"); this.pivot.serialize(generator, mapper); } if (this.retentionPolicy != null) { generator.writeKey("retention_policy"); this.retentionPolicy.serialize(generator, mapper); } if (this.settings != null) { generator.writeKey("settings"); this.settings.serialize(generator, mapper); } generator.writeKey("source"); this.source.serialize(generator, mapper); if (this.sync != null) { generator.writeKey("sync"); this.sync.serialize(generator, mapper); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link PutTransformRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private Map meta; @Nullable private Boolean deferValidation; @Nullable private String description; private Destination dest; @Nullable private Time frequency; @Nullable private Latest latest; @Nullable private Pivot pivot; @Nullable private RetentionPolicy retentionPolicy; @Nullable private Settings settings; private Source source; @Nullable private Sync sync; @Nullable private Time timeout; private String transformId; /** * Defines optional transform metadata. *

* API name: {@code _meta} *

* Adds all entries of map to meta. */ public final Builder meta(Map map) { this.meta = _mapPutAll(this.meta, map); return this; } /** * Defines optional transform metadata. *

* API name: {@code _meta} *

* Adds an entry to meta. */ public final Builder meta(String key, JsonData value) { this.meta = _mapPut(this.meta, key, value); return this; } /** * When the transform is created, a series of validations occur to ensure its * success. For example, there is a check for the existence of the source * indices and a check that the destination index is not part of the source * index pattern. You can use this parameter to skip the checks, for example * when the source index does not exist until after the transform is created. * The validations are always run when you start the transform, however, with * the exception of privilege checks. *

* API name: {@code defer_validation} */ public final Builder deferValidation(@Nullable Boolean value) { this.deferValidation = value; return this; } /** * Free text description of the transform. *

* API name: {@code description} */ public final Builder description(@Nullable String value) { this.description = value; return this; } /** * Required - The destination for the transform. *

* API name: {@code dest} */ public final Builder dest(Destination value) { this.dest = value; return this; } /** * Required - The destination for the transform. *

* API name: {@code dest} */ public final Builder dest(Function> fn) { return this.dest(fn.apply(new Destination.Builder()).build()); } /** * The interval between checks for changes in the source indices when the * transform is running continuously. Also determines the retry interval in the * event of transient failures while the transform is searching or indexing. The * minimum value is 1s and the maximum is 1h. *

* API name: {@code frequency} */ public final Builder frequency(@Nullable Time value) { this.frequency = value; return this; } /** * The interval between checks for changes in the source indices when the * transform is running continuously. Also determines the retry interval in the * event of transient failures while the transform is searching or indexing. The * minimum value is 1s and the maximum is 1h. *

* API name: {@code frequency} */ public final Builder frequency(Function> fn) { return this.frequency(fn.apply(new Time.Builder()).build()); } /** * The latest method transforms the data by finding the latest document for each * unique key. *

* API name: {@code latest} */ public final Builder latest(@Nullable Latest value) { this.latest = value; return this; } /** * The latest method transforms the data by finding the latest document for each * unique key. *

* API name: {@code latest} */ public final Builder latest(Function> fn) { return this.latest(fn.apply(new Latest.Builder()).build()); } /** * The pivot method transforms the data by aggregating and grouping it. These * objects define the group by fields and the aggregation to reduce the data. *

* API name: {@code pivot} */ public final Builder pivot(@Nullable Pivot value) { this.pivot = value; return this; } /** * The pivot method transforms the data by aggregating and grouping it. These * objects define the group by fields and the aggregation to reduce the data. *

* API name: {@code pivot} */ public final Builder pivot(Function> fn) { return this.pivot(fn.apply(new Pivot.Builder()).build()); } /** * Defines a retention policy for the transform. Data that meets the defined * criteria is deleted from the destination index. *

* API name: {@code retention_policy} */ public final Builder retentionPolicy(@Nullable RetentionPolicy value) { this.retentionPolicy = value; return this; } /** * Defines a retention policy for the transform. Data that meets the defined * criteria is deleted from the destination index. *

* API name: {@code retention_policy} */ public final Builder retentionPolicy(Function> fn) { return this.retentionPolicy(fn.apply(new RetentionPolicy.Builder()).build()); } /** * Defines optional transform settings. *

* API name: {@code settings} */ public final Builder settings(@Nullable Settings value) { this.settings = value; return this; } /** * Defines optional transform settings. *

* API name: {@code settings} */ public final Builder settings(Function> fn) { return this.settings(fn.apply(new Settings.Builder()).build()); } /** * Required - The source of the data for the transform. *

* API name: {@code source} */ public final Builder source(Source value) { this.source = value; return this; } /** * Required - The source of the data for the transform. *

* API name: {@code source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new Source.Builder()).build()); } /** * Defines the properties transforms require to run continuously. *

* API name: {@code sync} */ public final Builder sync(@Nullable Sync value) { this.sync = value; return this; } /** * Defines the properties transforms require to run continuously. *

* API name: {@code sync} */ public final Builder sync(Function> fn) { return this.sync(fn.apply(new Sync.Builder()).build()); } /** * 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. This identifier can contain * lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It * has a 64 character limit and must start and end with alphanumeric characters. *

* 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 PutTransformRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public PutTransformRequest build() { _checkSingleUse(); return new PutTransformRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link PutTransformRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer .lazy(Builder::new, PutTransformRequest::setupPutTransformRequestDeserializer); protected static void setupPutTransformRequestDeserializer(ObjectDeserializer op) { op.add(Builder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_meta"); op.add(Builder::description, JsonpDeserializer.stringDeserializer(), "description"); op.add(Builder::dest, Destination._DESERIALIZER, "dest"); op.add(Builder::frequency, Time._DESERIALIZER, "frequency"); op.add(Builder::latest, Latest._DESERIALIZER, "latest"); op.add(Builder::pivot, Pivot._DESERIALIZER, "pivot"); op.add(Builder::retentionPolicy, RetentionPolicy._DESERIALIZER, "retention_policy"); op.add(Builder::settings, Settings._DESERIALIZER, "settings"); op.add(Builder::source, Source._DESERIALIZER, "source"); op.add(Builder::sync, Sync._DESERIALIZER, "sync"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code transform.put_transform}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( "es/transform.put_transform", // Request method request -> { return "PUT"; }, // 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"); }, // Request parameters request -> { Map params = new HashMap<>(); if (request.deferValidation != null) { params.put("defer_validation", String.valueOf(request.deferValidation)); } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } return params; }, SimpleEndpoint.emptyMap(), true, PutTransformResponse._DESERIALIZER); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy