diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchDataSourceActionRequest.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchDataSourceActionRequest.java index 2c97c12509..f43f11dcec 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchDataSourceActionRequest.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchDataSourceActionRequest.java @@ -17,7 +17,7 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.core.common.io.stream.StreamInput; -public class PatchDataSourceActionRequest extends DataSourceActionRequest { +public class PatchDataSourceActionRequest extends PatchableDataSourceActionRequest { @Getter private Map dataSourceData; diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchDataSourceActionResponse.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchDataSourceActionResponse.java index f80d091c37..6c71e84a84 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchDataSourceActionResponse.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchDataSourceActionResponse.java @@ -14,7 +14,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; @RequiredArgsConstructor -public class PatchDataSourceActionResponse extends DataSourceActionResponse { +public class PatchDataSourceActionResponse extends PatchableDataSourceActionResponse { @Getter private final String result; diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionRequest.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchableDataSourceActionRequest.java similarity index 73% rename from datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionRequest.java rename to datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchableDataSourceActionRequest.java index f19f4def10..bd1e394bcb 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionRequest.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchableDataSourceActionRequest.java @@ -5,9 +5,9 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.core.common.io.stream.StreamInput; -public class DataSourceActionRequest extends ActionRequest { +public class PatchableDataSourceActionRequest extends ActionRequest { - public DataSourceActionRequest(StreamInput in) throws IOException { + public PatchableDataSourceActionRequest(StreamInput in) throws IOException { super(in); } @@ -16,7 +16,7 @@ public ActionRequestValidationException validate() { return null; } - public DataSourceActionRequest() {} + public PatchableDataSourceActionRequest() {} // public DataSourceMetadata getSourceMetadata() { // return null; diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionResponse.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchableDataSourceActionResponse.java similarity index 66% rename from datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionResponse.java rename to datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchableDataSourceActionResponse.java index 603eeb4840..5461ef4670 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DataSourceActionResponse.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/PatchableDataSourceActionResponse.java @@ -6,12 +6,12 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -public class DataSourceActionResponse extends ActionResponse { +public class PatchableDataSourceActionResponse extends ActionResponse { @Getter String result; - public DataSourceActionResponse() {} + public PatchableDataSourceActionResponse() {} - public DataSourceActionResponse(StreamInput in) throws IOException { + public PatchableDataSourceActionResponse(StreamInput in) throws IOException { super(in); } diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionRequest.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionRequest.java index 49acb549e8..4fa6f1c55a 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionRequest.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionRequest.java @@ -15,7 +15,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.sql.datasource.model.DataSourceMetadata; -public class UpdateDataSourceActionRequest extends DataSourceActionRequest { +public class UpdateDataSourceActionRequest extends PatchableDataSourceActionRequest { @Getter private DataSourceMetadata dataSourceMetadata; diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionResponse.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionResponse.java index b7eaf14cf8..48a6ea70c1 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionResponse.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionResponse.java @@ -14,7 +14,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; @RequiredArgsConstructor -public class UpdateDataSourceActionResponse extends DataSourceActionResponse { +public class UpdateDataSourceActionResponse extends PatchableDataSourceActionResponse { @Getter private final String result; diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java index f8f6498e32..b50ef13757 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java @@ -197,12 +197,12 @@ private RestChannelConsumer executeUpdateRequest(RestRequest restRequest, NodeCl nodeClient, () -> nodeClient.execute( - TransportDataSourceAction.ACTION_TYPE, + TransportPatchableDataSourceAction.ACTION_TYPE, new UpdateDataSourceActionRequest(dataSourceMetadata), new ActionListener<>() { @Override public void onResponse( - DataSourceActionResponse updateDataSourceActionResponse) { + PatchableDataSourceActionResponse updateDataSourceActionResponse) { restChannel.sendResponse( new BytesRestResponse( RestStatus.OK, @@ -225,11 +225,12 @@ private RestChannelConsumer executePatchRequest(RestRequest restRequest, NodeCli nodeClient, () -> { nodeClient.execute( - TransportDataSourceAction.ACTION_TYPE, + TransportPatchableDataSourceAction.ACTION_TYPE, new PatchDataSourceActionRequest(dataSourceData), new ActionListener<>() { @Override - public void onResponse(DataSourceActionResponse patchDataSourceActionResponse) { + public void onResponse( + PatchableDataSourceActionResponse patchDataSourceActionResponse) { restChannel.sendResponse( new BytesRestResponse( RestStatus.OK, diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDataSourceAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportPatchableDataSourceAction.java similarity index 84% rename from datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDataSourceAction.java rename to datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportPatchableDataSourceAction.java index 3b3795d391..87c9816985 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDataSourceAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportPatchableDataSourceAction.java @@ -22,12 +22,13 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; -public class TransportDataSourceAction - extends HandledTransportAction { +public class TransportPatchableDataSourceAction + extends HandledTransportAction< + PatchableDataSourceActionRequest, PatchableDataSourceActionResponse> { public static final String NAME = "cluster:admin/opensearch/ql/datasources/update"; - public static final ActionType ACTION_TYPE = - new ActionType<>(NAME, DataSourceActionResponse::new); + public static final ActionType ACTION_TYPE = + new ActionType<>(NAME, PatchableDataSourceActionResponse::new); private DataSourceService dataSourceService; @@ -39,23 +40,23 @@ public class TransportDataSourceAction * @param dataSourceService dataSourceService. */ @Inject - public TransportDataSourceAction( + public TransportPatchableDataSourceAction( TransportService transportService, ActionFilters actionFilters, DataSourceServiceImpl dataSourceService) { super( - TransportDataSourceAction.NAME, + TransportPatchableDataSourceAction.NAME, transportService, actionFilters, - DataSourceActionRequest::new); + PatchableDataSourceActionRequest::new); this.dataSourceService = dataSourceService; } @Override protected void doExecute( Task task, - DataSourceActionRequest request, - ActionListener actionListener) { + PatchableDataSourceActionRequest request, + ActionListener actionListener) { try { if (request instanceof UpdateDataSourceActionRequest) { UpdateDataSourceActionRequest request1 = (UpdateDataSourceActionRequest) request; diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportDataSourceActionTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportDataSourceActionTest.java index c0e287ee44..ab0f6a2ef1 100644 --- a/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportDataSourceActionTest.java +++ b/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportDataSourceActionTest.java @@ -18,7 +18,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.sql.datasource.model.DataSourceMetadata; import org.opensearch.sql.datasource.model.DataSourceType; -import org.opensearch.sql.datasources.model.transport.DataSourceActionResponse; +import org.opensearch.sql.datasources.model.transport.PatchableDataSourceActionResponse; import org.opensearch.sql.datasources.model.transport.UpdateDataSourceActionRequest; import org.opensearch.sql.datasources.model.transport.UpdateDataSourceActionResponse; import org.opensearch.sql.datasources.service.DataSourceServiceImpl; @@ -29,10 +29,10 @@ public class TransportDataSourceActionTest { @Mock private TransportService transportService; - @Mock private TransportDataSourceAction action; + @Mock private TransportPatchableDataSourceAction action; @Mock private DataSourceServiceImpl dataSourceService; @Mock private Task task; - @Mock private ActionListener actionListener; + @Mock private ActionListener actionListener; @Captor private ArgumentCaptor @@ -43,7 +43,7 @@ public class TransportDataSourceActionTest { @BeforeEach public void setUp() { action = - new TransportDataSourceAction( + new TransportPatchableDataSourceAction( transportService, new ActionFilters(new HashSet<>()), dataSourceService); } diff --git a/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java b/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java index be78c92254..bf9315dd6f 100644 --- a/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java +++ b/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java @@ -169,12 +169,9 @@ public List getRestHandlers( new ActionType<>(TransportGetDataSourceAction.NAME, GetDataSourceActionResponse::new), TransportGetDataSourceAction.class), new ActionHandler<>( - new ActionType<>(TransportDataSourceAction.NAME, DataSourceActionResponse::new), - TransportDataSourceAction.class), - // new ActionHandler<>( - // new ActionType<>( - // TransportPatchDataSourceAction.NAME, PatchDataSourceActionResponse::new), - // TransportPatchDataSourceAction.class), + new ActionType<>( + TransportPatchableDataSourceAction.NAME, PatchableDataSourceActionResponse::new), + TransportPatchableDataSourceAction.class), new ActionHandler<>( new ActionType<>( TransportDeleteDataSourceAction.NAME, DeleteDataSourceActionResponse::new),