
co.elastic.clients.elasticsearch.transform.ElasticsearchTransformClient 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.ApiClient;
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.Endpoint;
import co.elastic.clients.transport.JsonEndpoint;
import co.elastic.clients.transport.Transport;
import co.elastic.clients.transport.TransportOptions;
import co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr;
import co.elastic.clients.util.ObjectBuilder;
import java.io.IOException;
import java.lang.reflect.Type;
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.
//
//----------------------------------------------------------------
/**
* Client for the transform namespace.
*/
public class ElasticsearchTransformClient extends ApiClient {
public ElasticsearchTransformClient(ElasticsearchTransport transport) {
super(transport, null);
}
public ElasticsearchTransformClient(ElasticsearchTransport transport, @Nullable TransportOptions transportOptions) {
super(transport, transportOptions);
}
@Override
public ElasticsearchTransformClient withTransportOptions(@Nullable TransportOptions transportOptions) {
return new ElasticsearchTransformClient(this.transport, transportOptions);
}
// ----- Endpoint: transform.delete_transform
/**
* Delete a transform. Deletes a transform.
*
* @see Documentation
* on elastic.co
*/
public DeleteTransformResponse deleteTransform(DeleteTransformRequest request)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) DeleteTransformRequest._ENDPOINT;
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Delete a transform. Deletes a transform.
*
* @param fn
* a function that initializes a builder to create the
* {@link DeleteTransformRequest}
* @see Documentation
* on elastic.co
*/
public final DeleteTransformResponse deleteTransform(
Function> fn)
throws IOException, ElasticsearchException {
return deleteTransform(fn.apply(new DeleteTransformRequest.Builder()).build());
}
// ----- Endpoint: transform.get_transform
/**
* Get transforms. Retrieves configuration information for transforms.
*
* @see Documentation
* on elastic.co
*/
public GetTransformResponse getTransform(GetTransformRequest request) throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) GetTransformRequest._ENDPOINT;
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Get transforms. Retrieves configuration information for transforms.
*
* @param fn
* a function that initializes a builder to create the
* {@link GetTransformRequest}
* @see Documentation
* on elastic.co
*/
public final GetTransformResponse getTransform(
Function> fn)
throws IOException, ElasticsearchException {
return getTransform(fn.apply(new GetTransformRequest.Builder()).build());
}
/**
* Get transforms. Retrieves configuration information for transforms.
*
* @see Documentation
* on elastic.co
*/
public GetTransformResponse getTransform() throws IOException, ElasticsearchException {
return this.transport.performRequest(new GetTransformRequest.Builder().build(), GetTransformRequest._ENDPOINT,
this.transportOptions);
}
// ----- Endpoint: transform.get_transform_stats
/**
* Get transform stats. Retrieves usage information for transforms.
*
* @see Documentation
* on elastic.co
*/
public GetTransformStatsResponse getTransformStats(GetTransformStatsRequest request)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) GetTransformStatsRequest._ENDPOINT;
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Get transform stats. Retrieves usage information for transforms.
*
* @param fn
* a function that initializes a builder to create the
* {@link GetTransformStatsRequest}
* @see Documentation
* on elastic.co
*/
public final GetTransformStatsResponse getTransformStats(
Function> fn)
throws IOException, ElasticsearchException {
return getTransformStats(fn.apply(new GetTransformStatsRequest.Builder()).build());
}
// ----- Endpoint: transform.preview_transform
/**
* Preview a transform. Generates a preview of the results that you will get
* when you create a transform with the same configuration.
*
* It returns a maximum of 100 results. The calculations are based on all the
* current data in the source index. It also generates a list of mappings and
* settings for the destination index. These values are determined based on the
* field types of the source index and the transform aggregations.
*
* @see Documentation
* on elastic.co
*/
public PreviewTransformResponse previewTransform(PreviewTransformRequest request,
Class tTransformClass) throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint, ErrorResponse>) PreviewTransformRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
"co.elastic.clients:Deserializer:transform.preview_transform.Response.TTransform",
getDeserializer(tTransformClass));
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Preview a transform. Generates a preview of the results that you will get
* when you create a transform with the same configuration.
*
* It returns a maximum of 100 results. The calculations are based on all the
* current data in the source index. It also generates a list of mappings and
* settings for the destination index. These values are determined based on the
* field types of the source index and the transform aggregations.
*
* @param fn
* a function that initializes a builder to create the
* {@link PreviewTransformRequest}
* @see Documentation
* on elastic.co
*/
public final PreviewTransformResponse previewTransform(
Function> fn,
Class tTransformClass) throws IOException, ElasticsearchException {
return previewTransform(fn.apply(new PreviewTransformRequest.Builder()).build(), tTransformClass);
}
/**
* Preview a transform. Generates a preview of the results that you will get
* when you create a transform with the same configuration.
*
* It returns a maximum of 100 results. The calculations are based on all the
* current data in the source index. It also generates a list of mappings and
* settings for the destination index. These values are determined based on the
* field types of the source index and the transform aggregations.
*
* @see Documentation
* on elastic.co
*/
public PreviewTransformResponse previewTransform(PreviewTransformRequest request,
Type tTransformType) throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint, ErrorResponse>) PreviewTransformRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
"co.elastic.clients:Deserializer:transform.preview_transform.Response.TTransform",
getDeserializer(tTransformType));
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Preview a transform. Generates a preview of the results that you will get
* when you create a transform with the same configuration.
*
* It returns a maximum of 100 results. The calculations are based on all the
* current data in the source index. It also generates a list of mappings and
* settings for the destination index. These values are determined based on the
* field types of the source index and the transform aggregations.
*
* @param fn
* a function that initializes a builder to create the
* {@link PreviewTransformRequest}
* @see Documentation
* on elastic.co
*/
public final PreviewTransformResponse previewTransform(
Function> fn, Type tTransformType)
throws IOException, ElasticsearchException {
return previewTransform(fn.apply(new PreviewTransformRequest.Builder()).build(), tTransformType);
}
// ----- Endpoint: transform.put_transform
/**
* Create a transform. 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 Documentation
* on elastic.co
*/
public PutTransformResponse putTransform(PutTransformRequest request) throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutTransformRequest._ENDPOINT;
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Create a transform. 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.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutTransformRequest}
* @see Documentation
* on elastic.co
*/
public final PutTransformResponse putTransform(
Function> fn)
throws IOException, ElasticsearchException {
return putTransform(fn.apply(new PutTransformRequest.Builder()).build());
}
// ----- Endpoint: transform.reset_transform
/**
* Reset a transform. Resets a transform. Before you can reset it, you must stop
* it; alternatively, use the force
query parameter. If the
* destination index was created by the transform, it is deleted.
*
* @see Documentation
* on elastic.co
*/
public ResetTransformResponse resetTransform(ResetTransformRequest request)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) ResetTransformRequest._ENDPOINT;
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Reset a transform. Resets a transform. Before you can reset it, you must stop
* it; alternatively, use the force
query parameter. If the
* destination index was created by the transform, it is deleted.
*
* @param fn
* a function that initializes a builder to create the
* {@link ResetTransformRequest}
* @see Documentation
* on elastic.co
*/
public final ResetTransformResponse resetTransform(
Function> fn)
throws IOException, ElasticsearchException {
return resetTransform(fn.apply(new ResetTransformRequest.Builder()).build());
}
// ----- Endpoint: transform.schedule_now_transform
/**
* Schedule a transform to start now. Instantly runs a transform to process
* data.
*
* If you _schedule_now a transform, it will process the new data instantly,
* without waiting for the configured frequency interval. After _schedule_now
* API is called, the transform will be processed again at now + frequency
* unless _schedule_now API is called again in the meantime.
*
* @see Documentation
* on elastic.co
*/
public ScheduleNowTransformResponse scheduleNowTransform(ScheduleNowTransformRequest request)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) ScheduleNowTransformRequest._ENDPOINT;
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Schedule a transform to start now. Instantly runs a transform to process
* data.
*
* If you _schedule_now a transform, it will process the new data instantly,
* without waiting for the configured frequency interval. After _schedule_now
* API is called, the transform will be processed again at now + frequency
* unless _schedule_now API is called again in the meantime.
*
* @param fn
* a function that initializes a builder to create the
* {@link ScheduleNowTransformRequest}
* @see Documentation
* on elastic.co
*/
public final ScheduleNowTransformResponse scheduleNowTransform(
Function> fn)
throws IOException, ElasticsearchException {
return scheduleNowTransform(fn.apply(new ScheduleNowTransformRequest.Builder()).build());
}
// ----- Endpoint: transform.start_transform
/**
* Start a transform. Starts a transform.
*
* When you start a transform, it creates the destination index if it does not
* already exist. The number_of_shards
is set to 1
and
* the auto_expand_replicas
is set to 0-1
. If it is a
* pivot transform, it deduces the mapping definitions for the destination index
* from the source indices and the transform aggregations. If fields in the
* destination index are derived from scripts (as in the case of
* scripted_metric
or bucket_script
aggregations), the
* transform uses dynamic mappings unless an index template exists. If it is a
* latest transform, it does not deduce mapping definitions; it uses dynamic
* mappings. To use explicit mappings, create the destination index before you
* start the transform. Alternatively, you can create an index template, though
* it does not affect the deduced mappings in a pivot transform.
*
* When the transform starts, a series of validations occur to ensure its
* success. If you deferred validation when you created the transform, they
* occur when you start the transform—with the exception of privilege checks.
* 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.
*
* @see Documentation
* on elastic.co
*/
public StartTransformResponse startTransform(StartTransformRequest request)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) StartTransformRequest._ENDPOINT;
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Start a transform. Starts a transform.
*
* When you start a transform, it creates the destination index if it does not
* already exist. The number_of_shards
is set to 1
and
* the auto_expand_replicas
is set to 0-1
. If it is a
* pivot transform, it deduces the mapping definitions for the destination index
* from the source indices and the transform aggregations. If fields in the
* destination index are derived from scripts (as in the case of
* scripted_metric
or bucket_script
aggregations), the
* transform uses dynamic mappings unless an index template exists. If it is a
* latest transform, it does not deduce mapping definitions; it uses dynamic
* mappings. To use explicit mappings, create the destination index before you
* start the transform. Alternatively, you can create an index template, though
* it does not affect the deduced mappings in a pivot transform.
*
* When the transform starts, a series of validations occur to ensure its
* success. If you deferred validation when you created the transform, they
* occur when you start the transform—with the exception of privilege checks.
* 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.
*
* @param fn
* a function that initializes a builder to create the
* {@link StartTransformRequest}
* @see Documentation
* on elastic.co
*/
public final StartTransformResponse startTransform(
Function> fn)
throws IOException, ElasticsearchException {
return startTransform(fn.apply(new StartTransformRequest.Builder()).build());
}
// ----- Endpoint: transform.stop_transform
/**
* Stop transforms. Stops one or more transforms.
*
* @see Documentation
* on elastic.co
*/
public StopTransformResponse stopTransform(StopTransformRequest request)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) StopTransformRequest._ENDPOINT;
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Stop transforms. Stops one or more transforms.
*
* @param fn
* a function that initializes a builder to create the
* {@link StopTransformRequest}
* @see Documentation
* on elastic.co
*/
public final StopTransformResponse stopTransform(
Function> fn)
throws IOException, ElasticsearchException {
return stopTransform(fn.apply(new StopTransformRequest.Builder()).build());
}
// ----- Endpoint: transform.update_transform
/**
* Update a transform. Updates certain properties of a transform.
*
* All updated properties except description
do not take effect
* until after the transform starts the next checkpoint, thus there is data
* consistency in each checkpoint. To use this API, you must have
* read
and view_index_metadata
privileges for the
* source indices. You must also have index
and read
* privileges for the destination index. When Elasticsearch security features
* are enabled, the transform remembers which roles the user who updated it had
* at the time of update and runs with those privileges.
*
* @see Documentation
* on elastic.co
*/
public UpdateTransformResponse updateTransform(UpdateTransformRequest request)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) UpdateTransformRequest._ENDPOINT;
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Update a transform. Updates certain properties of a transform.
*
* All updated properties except description
do not take effect
* until after the transform starts the next checkpoint, thus there is data
* consistency in each checkpoint. To use this API, you must have
* read
and view_index_metadata
privileges for the
* source indices. You must also have index
and read
* privileges for the destination index. When Elasticsearch security features
* are enabled, the transform remembers which roles the user who updated it had
* at the time of update and runs with those privileges.
*
* @param fn
* a function that initializes a builder to create the
* {@link UpdateTransformRequest}
* @see Documentation
* on elastic.co
*/
public final UpdateTransformResponse updateTransform(
Function> fn)
throws IOException, ElasticsearchException {
return updateTransform(fn.apply(new UpdateTransformRequest.Builder()).build());
}
// ----- Endpoint: transform.upgrade_transforms
/**
* Upgrades all transforms. This API identifies transforms that have a legacy
* configuration format and upgrades them to the latest version. It also cleans
* up the internal data structures that store the transform state and
* checkpoints. The upgrade does not affect the source and destination indices.
* The upgrade also does not affect the roles that transforms use when
* Elasticsearch security features are enabled; the role used to read source
* data and write to the destination index remains unchanged.
*
* @see Documentation
* on elastic.co
*/
public UpgradeTransformsResponse upgradeTransforms(UpgradeTransformsRequest request)
throws IOException, ElasticsearchException {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) UpgradeTransformsRequest._ENDPOINT;
return this.transport.performRequest(request, endpoint, this.transportOptions);
}
/**
* Upgrades all transforms. This API identifies transforms that have a legacy
* configuration format and upgrades them to the latest version. It also cleans
* up the internal data structures that store the transform state and
* checkpoints. The upgrade does not affect the source and destination indices.
* The upgrade also does not affect the roles that transforms use when
* Elasticsearch security features are enabled; the role used to read source
* data and write to the destination index remains unchanged.
*
* @param fn
* a function that initializes a builder to create the
* {@link UpgradeTransformsRequest}
* @see Documentation
* on elastic.co
*/
public final UpgradeTransformsResponse upgradeTransforms(
Function> fn)
throws IOException, ElasticsearchException {
return upgradeTransforms(fn.apply(new UpgradeTransformsRequest.Builder()).build());
}
/**
* Upgrades all transforms. This API identifies transforms that have a legacy
* configuration format and upgrades them to the latest version. It also cleans
* up the internal data structures that store the transform state and
* checkpoints. The upgrade does not affect the source and destination indices.
* The upgrade also does not affect the roles that transforms use when
* Elasticsearch security features are enabled; the role used to read source
* data and write to the destination index remains unchanged.
*
* @see Documentation
* on elastic.co
*/
public UpgradeTransformsResponse upgradeTransforms() throws IOException, ElasticsearchException {
return this.transport.performRequest(new UpgradeTransformsRequest.Builder().build(),
UpgradeTransformsRequest._ENDPOINT, this.transportOptions);
}
}