|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License; |
| 4 | + * you may not use this file except in compliance with the Elastic License. |
| 5 | + */ |
| 6 | + |
| 7 | +package org.elasticsearch.xpack.core.datastreams; |
| 8 | + |
| 9 | +import org.elasticsearch.action.ActionFuture; |
| 10 | +import org.elasticsearch.action.ActionListener; |
| 11 | +import org.elasticsearch.action.support.PlainActionFuture; |
| 12 | +import org.elasticsearch.action.support.master.AcknowledgedResponse; |
| 13 | +import org.elasticsearch.client.ElasticsearchClient; |
| 14 | +import org.elasticsearch.xpack.core.action.CreateDataStreamAction; |
| 15 | +import org.elasticsearch.xpack.core.action.DataStreamsStatsAction; |
| 16 | +import org.elasticsearch.xpack.core.action.DeleteDataStreamAction; |
| 17 | +import org.elasticsearch.xpack.core.action.GetDataStreamAction; |
| 18 | + |
| 19 | +import java.util.Objects; |
| 20 | + |
| 21 | +public class DataStreamClient { |
| 22 | + |
| 23 | + private final ElasticsearchClient client; |
| 24 | + |
| 25 | + public DataStreamClient(ElasticsearchClient client) { |
| 26 | + this.client = Objects.requireNonNull(client); |
| 27 | + } |
| 28 | + |
| 29 | + public void createDataStream(CreateDataStreamAction.Request request, ActionListener<AcknowledgedResponse> listener) { |
| 30 | + client.execute(CreateDataStreamAction.INSTANCE, request, listener); |
| 31 | + } |
| 32 | + |
| 33 | + public ActionFuture<AcknowledgedResponse> createDataStream(CreateDataStreamAction.Request request) { |
| 34 | + final PlainActionFuture<AcknowledgedResponse> listener = PlainActionFuture.newFuture(); |
| 35 | + client.execute(CreateDataStreamAction.INSTANCE, request, listener); |
| 36 | + return listener; |
| 37 | + } |
| 38 | + |
| 39 | + public void getDataStream(GetDataStreamAction.Request request, ActionListener<GetDataStreamAction.Response> listener) { |
| 40 | + client.execute(GetDataStreamAction.INSTANCE, request, listener); |
| 41 | + } |
| 42 | + |
| 43 | + public ActionFuture<GetDataStreamAction.Response> getDataStream(GetDataStreamAction.Request request) { |
| 44 | + final PlainActionFuture<GetDataStreamAction.Response> listener = PlainActionFuture.newFuture(); |
| 45 | + client.execute(GetDataStreamAction.INSTANCE, request, listener); |
| 46 | + return listener; |
| 47 | + } |
| 48 | + |
| 49 | + public void deleteDataStream(DeleteDataStreamAction.Request request, ActionListener<AcknowledgedResponse> listener) { |
| 50 | + client.execute(DeleteDataStreamAction.INSTANCE, request, listener); |
| 51 | + } |
| 52 | + |
| 53 | + public ActionFuture<AcknowledgedResponse> deleteDataStream(DeleteDataStreamAction.Request request) { |
| 54 | + final PlainActionFuture<AcknowledgedResponse> listener = PlainActionFuture.newFuture(); |
| 55 | + client.execute(DeleteDataStreamAction.INSTANCE, request, listener); |
| 56 | + return listener; |
| 57 | + } |
| 58 | + |
| 59 | + public void dataStreamsStats(DataStreamsStatsAction.Request request, ActionListener<DataStreamsStatsAction.Response> listener) { |
| 60 | + client.execute(DataStreamsStatsAction.INSTANCE, request, listener); |
| 61 | + } |
| 62 | + |
| 63 | + public ActionFuture<DataStreamsStatsAction.Response> dataStreamsStats(DataStreamsStatsAction.Request request) { |
| 64 | + final PlainActionFuture<DataStreamsStatsAction.Response> listener = PlainActionFuture.newFuture(); |
| 65 | + client.execute(DataStreamsStatsAction.INSTANCE, request, listener); |
| 66 | + return listener; |
| 67 | + } |
| 68 | +} |
0 commit comments