Skip to content

Commit

Permalink
Use OriginClient for enterprise search transport action internal ops
Browse files Browse the repository at this point in the history
These previously used the regular client, however, this means that a user may run into warnings
about operations that are not considered "internal". This would make the operations "internal"
  • Loading branch information
dakrone committed Sep 6, 2024
1 parent 7a328ba commit b05ca83
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.client.internal.OriginSettingClient;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.application.connector.ConnectorIndexService;

import static org.elasticsearch.xpack.core.ClientHelper.ENT_SEARCH_ORIGIN;

public class TransportDeleteConnectorAction extends HandledTransportAction<DeleteConnectorAction.Request, AcknowledgedResponse> {

protected final ConnectorIndexService connectorIndexService;
Expand All @@ -31,7 +34,7 @@ public TransportDeleteConnectorAction(TransportService transportService, ActionF
DeleteConnectorAction.Request::new,
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
this.connectorIndexService = new ConnectorIndexService(client);
this.connectorIndexService = new ConnectorIndexService(new OriginSettingClient(client, ENT_SEARCH_ORIGIN));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.client.internal.OriginSettingClient;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.application.connector.ConnectorIndexService;

import static org.elasticsearch.xpack.core.ClientHelper.ENT_SEARCH_ORIGIN;

public class TransportGetConnectorAction extends HandledTransportAction<GetConnectorAction.Request, GetConnectorAction.Response> {
protected final ConnectorIndexService connectorIndexService;

Expand All @@ -29,7 +32,7 @@ public TransportGetConnectorAction(TransportService transportService, ActionFilt
GetConnectorAction.Request::new,
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
this.connectorIndexService = new ConnectorIndexService(client);
this.connectorIndexService = new ConnectorIndexService(new OriginSettingClient(client, ENT_SEARCH_ORIGIN));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.client.internal.OriginSettingClient;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.application.connector.ConnectorIndexService;

import static org.elasticsearch.xpack.core.ClientHelper.ENT_SEARCH_ORIGIN;

public class TransportPostConnectorAction extends HandledTransportAction<PostConnectorAction.Request, ConnectorCreateActionResponse> {

protected final ConnectorIndexService connectorIndexService;
Expand All @@ -30,7 +33,7 @@ public TransportPostConnectorAction(TransportService transportService, ActionFil
PostConnectorAction.Request::new,
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
this.connectorIndexService = new ConnectorIndexService(client);
this.connectorIndexService = new ConnectorIndexService(new OriginSettingClient(client, ENT_SEARCH_ORIGIN));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.client.internal.OriginSettingClient;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.application.connector.ConnectorIndexService;

import static org.elasticsearch.xpack.core.ClientHelper.ENT_SEARCH_ORIGIN;

public class TransportPutConnectorAction extends HandledTransportAction<PutConnectorAction.Request, ConnectorCreateActionResponse> {

protected final ConnectorIndexService connectorIndexService;
Expand All @@ -30,7 +33,7 @@ public TransportPutConnectorAction(TransportService transportService, ActionFilt
PutConnectorAction.Request::new,
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
this.connectorIndexService = new ConnectorIndexService(client);
this.connectorIndexService = new ConnectorIndexService(new OriginSettingClient(client, ENT_SEARCH_ORIGIN));
}

@Override
Expand Down

0 comments on commit b05ca83

Please sign in to comment.