mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
Restrict Connector APIs to manage/monitor_connector privileges (#119863)
* Reapply "Restrict Connector APIs to manage/monitor_connector privileges (#119389)" (#119833)
This reverts commit e0cefb8ff0
.
* Update docs/changelog/119863.yaml
* Update docs/changelog/119863.yaml
* Update changelog
* Fix changelog
---------
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
9a11f139de
commit
79713f5e99
37 changed files with 224 additions and 221 deletions
11
docs/changelog/119863.yaml
Normal file
11
docs/changelog/119863.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
pr: 119863
|
||||||
|
summary: Restrict Connector APIs to manage/monitor_connector privileges
|
||||||
|
area: Extract&Transform
|
||||||
|
type: breaking
|
||||||
|
issues: []
|
||||||
|
breaking:
|
||||||
|
title: Restrict Connector APIs to manage/monitor_connector privileges
|
||||||
|
area: REST API
|
||||||
|
details: Connector APIs now enforce the manage_connector and monitor_connector privileges (introduced in 8.15), replacing the previous reliance on index-level permissions for .elastic-connectors and .elastic-connectors-sync-jobs in API calls.
|
||||||
|
impact: Connector APIs now require manage_connector and monitor_connector privileges
|
||||||
|
notable: false
|
|
@ -4,13 +4,12 @@ admin:
|
||||||
- manage_behavioral_analytics
|
- manage_behavioral_analytics
|
||||||
- manage
|
- manage
|
||||||
- monitor
|
- monitor
|
||||||
|
- manage_connector
|
||||||
indices:
|
indices:
|
||||||
- names: [
|
- names: [
|
||||||
# indices and search applications
|
# indices and search applications
|
||||||
"test-*",
|
"test-*",
|
||||||
"another-test-search-application",
|
"another-test-search-application",
|
||||||
".elastic-connectors-v1",
|
|
||||||
".elastic-connectors-sync-jobs-v1"
|
|
||||||
]
|
]
|
||||||
privileges: [ "manage", "write", "read" ]
|
privileges: [ "manage", "write", "read" ]
|
||||||
|
|
||||||
|
@ -20,6 +19,7 @@ user:
|
||||||
- manage_api_key
|
- manage_api_key
|
||||||
- read_connector_secrets
|
- read_connector_secrets
|
||||||
- write_connector_secrets
|
- write_connector_secrets
|
||||||
|
- monitor_connector
|
||||||
indices:
|
indices:
|
||||||
- names: [
|
- names: [
|
||||||
"test-index1",
|
"test-index1",
|
||||||
|
@ -27,9 +27,7 @@ user:
|
||||||
"test-search-application-1",
|
"test-search-application-1",
|
||||||
"test-search-application-with-aggs",
|
"test-search-application-with-aggs",
|
||||||
"test-search-application-with-list",
|
"test-search-application-with-list",
|
||||||
"test-search-application-with-list-invalid",
|
"test-search-application-with-list-invalid"
|
||||||
".elastic-connectors-v1",
|
|
||||||
".elastic-connectors-sync-jobs-v1"
|
|
||||||
]
|
]
|
||||||
privileges: [ "read" ]
|
privileges: [ "read" ]
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.elasticsearch.action.support.WriteRequest;
|
||||||
import org.elasticsearch.action.update.UpdateRequest;
|
import org.elasticsearch.action.update.UpdateRequest;
|
||||||
import org.elasticsearch.action.update.UpdateResponse;
|
import org.elasticsearch.action.update.UpdateResponse;
|
||||||
import org.elasticsearch.client.internal.Client;
|
import org.elasticsearch.client.internal.Client;
|
||||||
|
import org.elasticsearch.client.internal.OriginSettingClient;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.index.IndexNotFoundException;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
|
@ -74,13 +75,15 @@ import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.elasticsearch.xpack.application.connector.ConnectorFiltering.fromXContentBytesConnectorFiltering;
|
import static org.elasticsearch.xpack.application.connector.ConnectorFiltering.fromXContentBytesConnectorFiltering;
|
||||||
import static org.elasticsearch.xpack.application.connector.ConnectorFiltering.sortFilteringRulesByOrder;
|
import static org.elasticsearch.xpack.application.connector.ConnectorFiltering.sortFilteringRulesByOrder;
|
||||||
import static org.elasticsearch.xpack.application.connector.ConnectorTemplateRegistry.MANAGED_CONNECTOR_INDEX_PREFIX;
|
import static org.elasticsearch.xpack.application.connector.ConnectorTemplateRegistry.MANAGED_CONNECTOR_INDEX_PREFIX;
|
||||||
|
import static org.elasticsearch.xpack.core.ClientHelper.CONNECTORS_ORIGIN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A service that manages persistent {@link Connector} configurations.
|
* A service that manages persistent {@link Connector} configurations.
|
||||||
*/
|
*/
|
||||||
public class ConnectorIndexService {
|
public class ConnectorIndexService {
|
||||||
|
|
||||||
private final Client client;
|
// The client to interact with the system index (internal user).
|
||||||
|
private final Client clientWithOrigin;
|
||||||
|
|
||||||
public static final String CONNECTOR_INDEX_NAME = ConnectorTemplateRegistry.CONNECTOR_INDEX_NAME_PATTERN;
|
public static final String CONNECTOR_INDEX_NAME = ConnectorTemplateRegistry.CONNECTOR_INDEX_NAME_PATTERN;
|
||||||
|
|
||||||
|
@ -88,7 +91,7 @@ public class ConnectorIndexService {
|
||||||
* @param client A client for executing actions on the connector index
|
* @param client A client for executing actions on the connector index
|
||||||
*/
|
*/
|
||||||
public ConnectorIndexService(Client client) {
|
public ConnectorIndexService(Client client) {
|
||||||
this.client = client;
|
this.clientWithOrigin = new OriginSettingClient(client, CONNECTORS_ORIGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,7 +137,7 @@ public class ConnectorIndexService {
|
||||||
indexRequest = indexRequest.id(connectorId);
|
indexRequest = indexRequest.id(connectorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
client.index(
|
clientWithOrigin.index(
|
||||||
indexRequest,
|
indexRequest,
|
||||||
listener.delegateFailureAndWrap(
|
listener.delegateFailureAndWrap(
|
||||||
(ll, indexResponse) -> ll.onResponse(
|
(ll, indexResponse) -> ll.onResponse(
|
||||||
|
@ -201,7 +204,7 @@ public class ConnectorIndexService {
|
||||||
try {
|
try {
|
||||||
final GetRequest getRequest = new GetRequest(CONNECTOR_INDEX_NAME).id(connectorId).realtime(true);
|
final GetRequest getRequest = new GetRequest(CONNECTOR_INDEX_NAME).id(connectorId).realtime(true);
|
||||||
|
|
||||||
client.get(getRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, getResponse) -> {
|
clientWithOrigin.get(getRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, getResponse) -> {
|
||||||
if (getResponse.isExists() == false) {
|
if (getResponse.isExists() == false) {
|
||||||
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
return;
|
return;
|
||||||
|
@ -248,13 +251,16 @@ public class ConnectorIndexService {
|
||||||
.id(connectorId)
|
.id(connectorId)
|
||||||
.source(Map.of(Connector.IS_DELETED_FIELD.getPreferredName(), true))
|
.source(Map.of(Connector.IS_DELETED_FIELD.getPreferredName(), true))
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, l, (ll, updateResponse) -> {
|
clientWithOrigin.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, l, (ll, updateResponse) -> {
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (shouldDeleteSyncJobs) {
|
if (shouldDeleteSyncJobs) {
|
||||||
new ConnectorSyncJobIndexService(client).deleteAllSyncJobsByConnectorId(connectorId, ll.map(r -> updateResponse));
|
new ConnectorSyncJobIndexService(clientWithOrigin).deleteAllSyncJobsByConnectorId(
|
||||||
|
connectorId,
|
||||||
|
ll.map(r -> updateResponse)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
ll.onResponse(updateResponse);
|
ll.onResponse(updateResponse);
|
||||||
}
|
}
|
||||||
|
@ -294,7 +300,7 @@ public class ConnectorIndexService {
|
||||||
.fetchSource(true)
|
.fetchSource(true)
|
||||||
.sort(Connector.INDEX_NAME_FIELD.getPreferredName(), SortOrder.ASC);
|
.sort(Connector.INDEX_NAME_FIELD.getPreferredName(), SortOrder.ASC);
|
||||||
final SearchRequest req = new SearchRequest(CONNECTOR_INDEX_NAME).source(source);
|
final SearchRequest req = new SearchRequest(CONNECTOR_INDEX_NAME).source(source);
|
||||||
client.search(req, new ActionListener<>() {
|
clientWithOrigin.search(req, new ActionListener<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(SearchResponse searchResponse) {
|
public void onResponse(SearchResponse searchResponse) {
|
||||||
try {
|
try {
|
||||||
|
@ -476,7 +482,7 @@ public class ConnectorIndexService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, l, (ll, updateResponse) -> {
|
clientWithOrigin.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, l, (ll, updateResponse) -> {
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
return;
|
return;
|
||||||
|
@ -513,13 +519,16 @@ public class ConnectorIndexService {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
l.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
l.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -541,13 +550,16 @@ public class ConnectorIndexService {
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
||||||
.source(request.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS))
|
.source(request.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS))
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
l.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
l.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -568,13 +580,16 @@ public class ConnectorIndexService {
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
||||||
.source(Map.of(Connector.FILTERING_FIELD.getPreferredName(), filtering))
|
.source(Map.of(Connector.FILTERING_FIELD.getPreferredName(), filtering))
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
l.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
l.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -595,13 +610,16 @@ public class ConnectorIndexService {
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
||||||
.source(Map.of(Connector.FEATURES_FIELD.getPreferredName(), features))
|
.source(Map.of(Connector.FEATURES_FIELD.getPreferredName(), features))
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
l.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
l.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -657,13 +675,16 @@ public class ConnectorIndexService {
|
||||||
.source(Map.of(Connector.FILTERING_FIELD.getPreferredName(), List.of(connectorFilteringWithUpdatedDraft)))
|
.source(Map.of(Connector.FILTERING_FIELD.getPreferredName(), List.of(connectorFilteringWithUpdatedDraft)))
|
||||||
);
|
);
|
||||||
|
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (ll, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (ll, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
ll.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
ll.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -705,7 +726,7 @@ public class ConnectorIndexService {
|
||||||
.source(Map.of(Connector.FILTERING_FIELD.getPreferredName(), List.of(activatedConnectorFiltering)))
|
.source(Map.of(Connector.FILTERING_FIELD.getPreferredName(), List.of(activatedConnectorFiltering)))
|
||||||
);
|
);
|
||||||
|
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, l, (ll, updateResponse) -> {
|
clientWithOrigin.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, l, (ll, updateResponse) -> {
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
return;
|
return;
|
||||||
|
@ -762,7 +783,7 @@ public class ConnectorIndexService {
|
||||||
.source(Map.of(Connector.FILTERING_FIELD.getPreferredName(), List.of(activatedConnectorFiltering)))
|
.source(Map.of(Connector.FILTERING_FIELD.getPreferredName(), List.of(activatedConnectorFiltering)))
|
||||||
);
|
);
|
||||||
|
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, l, (ll, updateResponse) -> {
|
clientWithOrigin.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, l, (ll, updateResponse) -> {
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
return;
|
return;
|
||||||
|
@ -790,13 +811,16 @@ public class ConnectorIndexService {
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
||||||
.source(Map.of(Connector.LAST_SEEN_FIELD.getPreferredName(), Instant.now()))
|
.source(Map.of(Connector.LAST_SEEN_FIELD.getPreferredName(), Instant.now()))
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
l.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
l.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -817,13 +841,16 @@ public class ConnectorIndexService {
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
||||||
.source(request.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS))
|
.source(request.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS))
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
l.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
l.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -887,13 +914,16 @@ public class ConnectorIndexService {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (ll, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (ll, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
ll.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
ll.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
ll.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
}));
|
}));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
|
@ -916,13 +946,16 @@ public class ConnectorIndexService {
|
||||||
.source(Map.of(Connector.PIPELINE_FIELD.getPreferredName(), request.getPipeline()))
|
.source(Map.of(Connector.PIPELINE_FIELD.getPreferredName(), request.getPipeline()))
|
||||||
.source(request.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS))
|
.source(request.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS))
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
l.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
l.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -981,7 +1014,7 @@ public class ConnectorIndexService {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
client.update(
|
clientWithOrigin.update(
|
||||||
updateRequest,
|
updateRequest,
|
||||||
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (lll, updateResponse) -> {
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (lll, updateResponse) -> {
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
|
@ -1014,13 +1047,16 @@ public class ConnectorIndexService {
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
||||||
.source(Map.of(Connector.SCHEDULING_FIELD.getPreferredName(), request.getScheduling()))
|
.source(Map.of(Connector.SCHEDULING_FIELD.getPreferredName(), request.getScheduling()))
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
l.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
l.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -1056,7 +1092,7 @@ public class ConnectorIndexService {
|
||||||
)
|
)
|
||||||
|
|
||||||
);
|
);
|
||||||
client.update(
|
clientWithOrigin.update(
|
||||||
updateRequest,
|
updateRequest,
|
||||||
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (updateListener, updateResponse) -> {
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (updateListener, updateResponse) -> {
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
|
@ -1099,7 +1135,7 @@ public class ConnectorIndexService {
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
||||||
.source(Map.of(Connector.STATUS_FIELD.getPreferredName(), request.getStatus()))
|
.source(Map.of(Connector.STATUS_FIELD.getPreferredName(), request.getStatus()))
|
||||||
);
|
);
|
||||||
client.update(
|
clientWithOrigin.update(
|
||||||
updateRequest,
|
updateRequest,
|
||||||
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (updateListener, updateResponse) -> {
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (updateListener, updateResponse) -> {
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
|
@ -1127,13 +1163,16 @@ public class ConnectorIndexService {
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
||||||
.source(request.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS))
|
.source(request.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS))
|
||||||
);
|
);
|
||||||
client.update(updateRequest, new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
clientWithOrigin.update(
|
||||||
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
updateRequest,
|
||||||
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
new DelegatingIndexNotFoundActionListener<>(connectorId, listener, (l, updateResponse) -> {
|
||||||
return;
|
if (updateResponse.getResult() == UpdateResponse.Result.NOT_FOUND) {
|
||||||
}
|
l.onFailure(new ResourceNotFoundException(connectorNotFoundErrorMsg(connectorId)));
|
||||||
l.onResponse(updateResponse);
|
return;
|
||||||
}));
|
}
|
||||||
|
l.onResponse(updateResponse);
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -1211,7 +1250,7 @@ public class ConnectorIndexService {
|
||||||
final SearchSourceBuilder searchSource = new SearchSourceBuilder().query(boolFilterQueryBuilder);
|
final SearchSourceBuilder searchSource = new SearchSourceBuilder().query(boolFilterQueryBuilder);
|
||||||
|
|
||||||
final SearchRequest searchRequest = new SearchRequest(CONNECTOR_INDEX_NAME).source(searchSource);
|
final SearchRequest searchRequest = new SearchRequest(CONNECTOR_INDEX_NAME).source(searchSource);
|
||||||
client.search(searchRequest, new ActionListener<>() {
|
clientWithOrigin.search(searchRequest, new ActionListener<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(SearchResponse searchResponse) {
|
public void onResponse(SearchResponse searchResponse) {
|
||||||
boolean indexNameIsInUse = searchResponse.getHits().getTotalHits().value() > 0L;
|
boolean indexNameIsInUse = searchResponse.getHits().getTotalHits().value() > 0L;
|
||||||
|
|
|
@ -9,12 +9,9 @@ package org.elasticsearch.xpack.application.connector.action;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequest;
|
import org.elasticsearch.action.ActionRequest;
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
import org.elasticsearch.action.ActionRequestValidationException;
|
||||||
import org.elasticsearch.action.IndicesRequest;
|
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
|
||||||
import org.elasticsearch.cluster.metadata.MetadataCreateIndexService;
|
import org.elasticsearch.cluster.metadata.MetadataCreateIndexService;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.indices.InvalidIndexNameException;
|
import org.elasticsearch.indices.InvalidIndexNameException;
|
||||||
import org.elasticsearch.xpack.application.connector.ConnectorTemplateRegistry;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -22,10 +19,9 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||||
import static org.elasticsearch.xpack.application.connector.ConnectorTemplateRegistry.MANAGED_CONNECTOR_INDEX_PREFIX;
|
import static org.elasticsearch.xpack.application.connector.ConnectorTemplateRegistry.MANAGED_CONNECTOR_INDEX_PREFIX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for action requests targeting the connectors index. Implements {@link org.elasticsearch.action.IndicesRequest}
|
* Abstract base class for action requests targeting the connectors index.
|
||||||
* to ensure index-level privilege support. This class defines the connectors index as the target for all derived action requests.
|
|
||||||
*/
|
*/
|
||||||
public abstract class ConnectorActionRequest extends ActionRequest implements IndicesRequest {
|
public abstract class ConnectorActionRequest extends ActionRequest {
|
||||||
|
|
||||||
public ConnectorActionRequest() {
|
public ConnectorActionRequest() {
|
||||||
super();
|
super();
|
||||||
|
@ -78,14 +74,4 @@ public abstract class ConnectorActionRequest extends ActionRequest implements In
|
||||||
}
|
}
|
||||||
return validationException;
|
return validationException;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] indices() {
|
|
||||||
return new String[] { ConnectorTemplateRegistry.CONNECTOR_INDEX_NAME_PATTERN };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IndicesOptions indicesOptions() {
|
|
||||||
return IndicesOptions.lenientExpandHidden();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.elasticsearch.xcontent.ParseField;
|
||||||
import org.elasticsearch.xcontent.ToXContentObject;
|
import org.elasticsearch.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.xcontent.XContentBuilder;
|
import org.elasticsearch.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xcontent.XContentParser;
|
import org.elasticsearch.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.application.connector.ConnectorTemplateRegistry;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -28,7 +27,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class DeleteConnectorAction {
|
public class DeleteConnectorAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/delete";
|
public static final String NAME = "cluster:admin/xpack/connector/delete";
|
||||||
public static final ActionType<AcknowledgedResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<AcknowledgedResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private DeleteConnectorAction() {/* no instances */}
|
private DeleteConnectorAction() {/* no instances */}
|
||||||
|
@ -71,14 +70,6 @@ public class DeleteConnectorAction {
|
||||||
return deleteSyncJobs;
|
return deleteSyncJobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] indices() {
|
|
||||||
// When deleting a connector, corresponding sync jobs can also be deleted
|
|
||||||
return new String[] {
|
|
||||||
ConnectorTemplateRegistry.CONNECTOR_SYNC_JOBS_INDEX_NAME_PATTERN,
|
|
||||||
ConnectorTemplateRegistry.CONNECTOR_INDEX_NAME_PATTERN };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
super.writeTo(out);
|
super.writeTo(out);
|
||||||
|
|
|
@ -30,7 +30,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class GetConnectorAction {
|
public class GetConnectorAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/read/xpack/connector/get";
|
public static final String NAME = "cluster:admin/xpack/connector/get";
|
||||||
public static final ActionType<GetConnectorAction.Response> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<GetConnectorAction.Response> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private GetConnectorAction() {/* no instances */}
|
private GetConnectorAction() {/* no instances */}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class ListConnectorAction {
|
public class ListConnectorAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/read/xpack/connector/list";
|
public static final String NAME = "cluster:admin/xpack/connector/list";
|
||||||
public static final ActionType<ListConnectorAction.Response> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ListConnectorAction.Response> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private ListConnectorAction() {/* no instances */}
|
private ListConnectorAction() {/* no instances */}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class PostConnectorAction {
|
public class PostConnectorAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/post";
|
public static final String NAME = "cluster:admin/xpack/connector/post";
|
||||||
public static final ActionType<ConnectorCreateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorCreateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private PostConnectorAction() {/* no instances */}
|
private PostConnectorAction() {/* no instances */}
|
||||||
|
|
|
@ -9,7 +9,6 @@ package org.elasticsearch.xpack.application.connector.action;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
import org.elasticsearch.action.ActionRequestValidationException;
|
||||||
import org.elasticsearch.action.ActionType;
|
import org.elasticsearch.action.ActionType;
|
||||||
import org.elasticsearch.action.IndicesRequest;
|
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
|
@ -27,12 +26,12 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class PutConnectorAction {
|
public class PutConnectorAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/put";
|
public static final String NAME = "cluster:admin/xpack/connector/put";
|
||||||
public static final ActionType<ConnectorCreateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorCreateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private PutConnectorAction() {/* no instances */}
|
private PutConnectorAction() {/* no instances */}
|
||||||
|
|
||||||
public static class Request extends ConnectorActionRequest implements IndicesRequest, ToXContentObject {
|
public static class Request extends ConnectorActionRequest implements ToXContentObject {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String connectorId;
|
private final String connectorId;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||||
|
|
||||||
public class UpdateConnectorActiveFilteringAction {
|
public class UpdateConnectorActiveFilteringAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_filtering/activate";
|
public static final String NAME = "cluster:admin/xpack/connector/update_filtering/activate";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorActiveFilteringAction() {/* no instances */}
|
private UpdateConnectorActiveFilteringAction() {/* no instances */}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class UpdateConnectorApiKeyIdAction {
|
public class UpdateConnectorApiKeyIdAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_api_key_id";
|
public static final String NAME = "cluster:admin/xpack/connector/update_api_key_id";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorApiKeyIdAction() {/* no instances */}
|
private UpdateConnectorApiKeyIdAction() {/* no instances */}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class UpdateConnectorConfigurationAction {
|
public class UpdateConnectorConfigurationAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_configuration";
|
public static final String NAME = "cluster:admin/xpack/connector/update_configuration";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorConfigurationAction() {/* no instances */}
|
private UpdateConnectorConfigurationAction() {/* no instances */}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class UpdateConnectorErrorAction {
|
public class UpdateConnectorErrorAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_error";
|
public static final String NAME = "cluster:admin/xpack/connector/update_error";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorErrorAction() {/* no instances */}
|
private UpdateConnectorErrorAction() {/* no instances */}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class UpdateConnectorFeaturesAction {
|
public class UpdateConnectorFeaturesAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_features";
|
public static final String NAME = "cluster:admin/xpack/connector/update_features";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorFeaturesAction() {/* no instances */}
|
private UpdateConnectorFeaturesAction() {/* no instances */}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class UpdateConnectorFilteringAction {
|
public class UpdateConnectorFilteringAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_filtering";
|
public static final String NAME = "cluster:admin/xpack/connector/update_filtering";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorFilteringAction() {/* no instances */}
|
private UpdateConnectorFilteringAction() {/* no instances */}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class UpdateConnectorFilteringValidationAction {
|
public class UpdateConnectorFilteringValidationAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_filtering/draft_validation";
|
public static final String NAME = "cluster:admin/xpack/connector/update_filtering/draft_validation";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorFilteringValidationAction() {/* no instances */}
|
private UpdateConnectorFilteringValidationAction() {/* no instances */}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class UpdateConnectorIndexNameAction {
|
public class UpdateConnectorIndexNameAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_index_name";
|
public static final String NAME = "cluster:admin/xpack/connector/update_index_name";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorIndexNameAction() {/* no instances */}
|
private UpdateConnectorIndexNameAction() {/* no instances */}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||||
|
|
||||||
public class UpdateConnectorLastSeenAction {
|
public class UpdateConnectorLastSeenAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_last_seen";
|
public static final String NAME = "cluster:admin/xpack/connector/update_last_seen";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorLastSeenAction() {/* no instances */}
|
private UpdateConnectorLastSeenAction() {/* no instances */}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class UpdateConnectorLastSyncStatsAction {
|
public class UpdateConnectorLastSyncStatsAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_last_sync_stats";
|
public static final String NAME = "cluster:admin/xpack/connector/update_last_sync_stats";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorLastSyncStatsAction() {/* no instances */}
|
private UpdateConnectorLastSyncStatsAction() {/* no instances */}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class UpdateConnectorNameAction {
|
public class UpdateConnectorNameAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_name";
|
public static final String NAME = "cluster:admin/xpack/connector/update_name";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorNameAction() {/* no instances */}
|
private UpdateConnectorNameAction() {/* no instances */}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class UpdateConnectorNativeAction {
|
public class UpdateConnectorNativeAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_native";
|
public static final String NAME = "cluster:admin/xpack/connector/update_native";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorNativeAction() {/* no instances */}
|
private UpdateConnectorNativeAction() {/* no instances */}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class UpdateConnectorPipelineAction {
|
public class UpdateConnectorPipelineAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_pipeline";
|
public static final String NAME = "cluster:admin/xpack/connector/update_pipeline";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorPipelineAction() {/* no instances */}
|
private UpdateConnectorPipelineAction() {/* no instances */}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class UpdateConnectorSchedulingAction {
|
public class UpdateConnectorSchedulingAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_scheduling";
|
public static final String NAME = "cluster:admin/xpack/connector/update_scheduling";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorSchedulingAction() {/* no instances */}
|
private UpdateConnectorSchedulingAction() {/* no instances */}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class UpdateConnectorServiceTypeAction {
|
public class UpdateConnectorServiceTypeAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_service_type";
|
public static final String NAME = "cluster:admin/xpack/connector/update_service_type";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorServiceTypeAction() {/* no instances */}
|
private UpdateConnectorServiceTypeAction() {/* no instances */}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class UpdateConnectorStatusAction {
|
public class UpdateConnectorStatusAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/update_status";
|
public static final String NAME = "cluster:admin/xpack/connector/update_status";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
public UpdateConnectorStatusAction() {/* no instances */}
|
public UpdateConnectorStatusAction() {/* no instances */}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.action.support.WriteRequest;
|
||||||
import org.elasticsearch.action.update.UpdateRequest;
|
import org.elasticsearch.action.update.UpdateRequest;
|
||||||
import org.elasticsearch.action.update.UpdateResponse;
|
import org.elasticsearch.action.update.UpdateResponse;
|
||||||
import org.elasticsearch.client.internal.Client;
|
import org.elasticsearch.client.internal.Client;
|
||||||
|
import org.elasticsearch.client.internal.OriginSettingClient;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.index.IndexNotFoundException;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.index.engine.DocumentMissingException;
|
import org.elasticsearch.index.engine.DocumentMissingException;
|
||||||
|
@ -68,6 +69,7 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.elasticsearch.xpack.application.connector.ConnectorIndexService.CONNECTOR_INDEX_NAME;
|
import static org.elasticsearch.xpack.application.connector.ConnectorIndexService.CONNECTOR_INDEX_NAME;
|
||||||
|
import static org.elasticsearch.xpack.core.ClientHelper.CONNECTORS_ORIGIN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A service that manages persistent {@link ConnectorSyncJob} configurations.
|
* A service that manages persistent {@link ConnectorSyncJob} configurations.
|
||||||
|
@ -76,7 +78,8 @@ public class ConnectorSyncJobIndexService {
|
||||||
|
|
||||||
private static final Long ZERO = 0L;
|
private static final Long ZERO = 0L;
|
||||||
|
|
||||||
private final Client client;
|
// The client to interact with the system index (internal user).
|
||||||
|
private final Client clientWithOrigin;
|
||||||
|
|
||||||
public static final String CONNECTOR_SYNC_JOB_INDEX_NAME = ConnectorTemplateRegistry.CONNECTOR_SYNC_JOBS_INDEX_NAME_PATTERN;
|
public static final String CONNECTOR_SYNC_JOB_INDEX_NAME = ConnectorTemplateRegistry.CONNECTOR_SYNC_JOBS_INDEX_NAME_PATTERN;
|
||||||
|
|
||||||
|
@ -84,7 +87,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
* @param client A client for executing actions on the connectors sync jobs index.
|
* @param client A client for executing actions on the connectors sync jobs index.
|
||||||
*/
|
*/
|
||||||
public ConnectorSyncJobIndexService(Client client) {
|
public ConnectorSyncJobIndexService(Client client) {
|
||||||
this.client = client;
|
this.clientWithOrigin = new OriginSettingClient(client, CONNECTORS_ORIGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +152,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
|
|
||||||
indexRequest.source(syncJob.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS));
|
indexRequest.source(syncJob.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS));
|
||||||
|
|
||||||
client.index(
|
clientWithOrigin.index(
|
||||||
indexRequest,
|
indexRequest,
|
||||||
l.delegateFailureAndWrap(
|
l.delegateFailureAndWrap(
|
||||||
(ll, indexResponse) -> ll.onResponse(new PostConnectorSyncJobAction.Response(indexResponse.getId()))
|
(ll, indexResponse) -> ll.onResponse(new PostConnectorSyncJobAction.Response(indexResponse.getId()))
|
||||||
|
@ -175,7 +178,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.delete(
|
clientWithOrigin.delete(
|
||||||
deleteRequest,
|
deleteRequest,
|
||||||
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(connectorSyncJobId, listener, (l, deleteResponse) -> {
|
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(connectorSyncJobId, listener, (l, deleteResponse) -> {
|
||||||
if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) {
|
if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) {
|
||||||
|
@ -205,7 +208,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
).doc(Map.of(ConnectorSyncJob.LAST_SEEN_FIELD.getPreferredName(), newLastSeen));
|
).doc(Map.of(ConnectorSyncJob.LAST_SEEN_FIELD.getPreferredName(), newLastSeen));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.update(
|
clientWithOrigin.update(
|
||||||
updateRequest,
|
updateRequest,
|
||||||
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(connectorSyncJobId, listener, (l, updateResponse) -> {
|
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(connectorSyncJobId, listener, (l, updateResponse) -> {
|
||||||
if (updateResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) {
|
if (updateResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) {
|
||||||
|
@ -230,7 +233,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
final GetRequest getRequest = new GetRequest(CONNECTOR_SYNC_JOB_INDEX_NAME).id(connectorSyncJobId).realtime(true);
|
final GetRequest getRequest = new GetRequest(CONNECTOR_SYNC_JOB_INDEX_NAME).id(connectorSyncJobId).realtime(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.get(
|
clientWithOrigin.get(
|
||||||
getRequest,
|
getRequest,
|
||||||
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(connectorSyncJobId, listener, (l, getResponse) -> {
|
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(connectorSyncJobId, listener, (l, getResponse) -> {
|
||||||
if (getResponse.isExists() == false) {
|
if (getResponse.isExists() == false) {
|
||||||
|
@ -306,7 +309,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
WriteRequest.RefreshPolicy.IMMEDIATE
|
WriteRequest.RefreshPolicy.IMMEDIATE
|
||||||
).doc(syncJobFieldsToUpdate);
|
).doc(syncJobFieldsToUpdate);
|
||||||
|
|
||||||
client.update(
|
clientWithOrigin.update(
|
||||||
updateRequest,
|
updateRequest,
|
||||||
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(
|
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(
|
||||||
connectorSyncJobId,
|
connectorSyncJobId,
|
||||||
|
@ -355,7 +358,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
|
|
||||||
final SearchRequest searchRequest = new SearchRequest(CONNECTOR_SYNC_JOB_INDEX_NAME).source(searchSource);
|
final SearchRequest searchRequest = new SearchRequest(CONNECTOR_SYNC_JOB_INDEX_NAME).source(searchSource);
|
||||||
|
|
||||||
client.search(searchRequest, new ActionListener<>() {
|
clientWithOrigin.search(searchRequest, new ActionListener<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(SearchResponse searchResponse) {
|
public void onResponse(SearchResponse searchResponse) {
|
||||||
try {
|
try {
|
||||||
|
@ -474,7 +477,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
).doc(fieldsToUpdate);
|
).doc(fieldsToUpdate);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.update(
|
clientWithOrigin.update(
|
||||||
updateRequest,
|
updateRequest,
|
||||||
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(syncJobId, listener, (l, updateResponse) -> {
|
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(syncJobId, listener, (l, updateResponse) -> {
|
||||||
if (updateResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) {
|
if (updateResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) {
|
||||||
|
@ -501,7 +504,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
|
|
||||||
final GetRequest request = new GetRequest(CONNECTOR_INDEX_NAME, connectorId);
|
final GetRequest request = new GetRequest(CONNECTOR_INDEX_NAME, connectorId);
|
||||||
|
|
||||||
client.get(request, new ActionListener<>() {
|
clientWithOrigin.get(request, new ActionListener<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(GetResponse response) {
|
public void onResponse(GetResponse response) {
|
||||||
final boolean connectorDoesNotExist = response.isExists() == false;
|
final boolean connectorDoesNotExist = response.isExists() == false;
|
||||||
|
@ -594,7 +597,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
client.update(
|
clientWithOrigin.update(
|
||||||
updateRequest,
|
updateRequest,
|
||||||
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(
|
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(
|
||||||
connectorSyncJobId,
|
connectorSyncJobId,
|
||||||
|
@ -629,7 +632,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
)
|
)
|
||||||
).setRefresh(true).setIndicesOptions(IndicesOptions.fromOptions(true, true, false, false));
|
).setRefresh(true).setIndicesOptions(IndicesOptions.fromOptions(true, true, false, false));
|
||||||
|
|
||||||
client.execute(DeleteByQueryAction.INSTANCE, deleteByQueryRequest, listener.delegateFailureAndWrap((l, r) -> {
|
clientWithOrigin.execute(DeleteByQueryAction.INSTANCE, deleteByQueryRequest, listener.delegateFailureAndWrap((l, r) -> {
|
||||||
final List<BulkItemResponse.Failure> bulkDeleteFailures = r.getBulkFailures();
|
final List<BulkItemResponse.Failure> bulkDeleteFailures = r.getBulkFailures();
|
||||||
if (bulkDeleteFailures.isEmpty() == false) {
|
if (bulkDeleteFailures.isEmpty() == false) {
|
||||||
l.onFailure(
|
l.onFailure(
|
||||||
|
@ -681,7 +684,7 @@ public class ConnectorSyncJobIndexService {
|
||||||
WriteRequest.RefreshPolicy.IMMEDIATE
|
WriteRequest.RefreshPolicy.IMMEDIATE
|
||||||
).doc(document);
|
).doc(document);
|
||||||
|
|
||||||
client.update(
|
clientWithOrigin.update(
|
||||||
updateRequest,
|
updateRequest,
|
||||||
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(
|
new DelegatingIndexNotFoundOrDocumentMissingActionListener<>(
|
||||||
connectorSyncJobId,
|
connectorSyncJobId,
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static org.elasticsearch.xpack.application.connector.syncjob.ConnectorSyn
|
||||||
|
|
||||||
public class CancelConnectorSyncJobAction {
|
public class CancelConnectorSyncJobAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/sync_job/cancel";
|
public static final String NAME = "cluster:admin/xpack/connector/sync_job/cancel";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<ConnectorUpdateActionResponse>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<ConnectorUpdateActionResponse>(NAME);
|
||||||
|
|
||||||
private CancelConnectorSyncJobAction() {/* no instances */}
|
private CancelConnectorSyncJobAction() {/* no instances */}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class CheckInConnectorSyncJobAction {
|
public class CheckInConnectorSyncJobAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/sync_job/check_in";
|
public static final String NAME = "cluster:admin/xpack/connector/sync_job/check_in";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private CheckInConnectorSyncJobAction() {/* no instances */}
|
private CheckInConnectorSyncJobAction() {/* no instances */}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class ClaimConnectorSyncJobAction {
|
public class ClaimConnectorSyncJobAction {
|
||||||
public static final ParseField CONNECTOR_SYNC_JOB_ID_FIELD = new ParseField("connector_sync_job_id");
|
public static final ParseField CONNECTOR_SYNC_JOB_ID_FIELD = new ParseField("connector_sync_job_id");
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/sync_job/claim";
|
public static final String NAME = "cluster:admin/xpack/connector/sync_job/claim";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private ClaimConnectorSyncJobAction() {/* no instances */}
|
private ClaimConnectorSyncJobAction() {/* no instances */}
|
||||||
|
|
|
@ -8,19 +8,14 @@
|
||||||
package org.elasticsearch.xpack.application.connector.syncjob.action;
|
package org.elasticsearch.xpack.application.connector.syncjob.action;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequest;
|
import org.elasticsearch.action.ActionRequest;
|
||||||
import org.elasticsearch.action.IndicesRequest;
|
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.xpack.application.connector.ConnectorTemplateRegistry;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for action requests targeting the connector sync job index.
|
* Abstract base class for action requests targeting the connector sync job index.
|
||||||
* Implements {@link org.elasticsearch.action.IndicesRequest} to ensure index-level privilege support.
|
|
||||||
* This class defines the connectors sync job index as the target for all derived action requests.
|
|
||||||
*/
|
*/
|
||||||
public abstract class ConnectorSyncJobActionRequest extends ActionRequest implements IndicesRequest {
|
public abstract class ConnectorSyncJobActionRequest extends ActionRequest {
|
||||||
|
|
||||||
public ConnectorSyncJobActionRequest() {
|
public ConnectorSyncJobActionRequest() {
|
||||||
super();
|
super();
|
||||||
|
@ -29,14 +24,4 @@ public abstract class ConnectorSyncJobActionRequest extends ActionRequest implem
|
||||||
public ConnectorSyncJobActionRequest(StreamInput in) throws IOException {
|
public ConnectorSyncJobActionRequest(StreamInput in) throws IOException {
|
||||||
super(in);
|
super(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] indices() {
|
|
||||||
return new String[] { ConnectorTemplateRegistry.CONNECTOR_SYNC_JOBS_INDEX_NAME_PATTERN };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IndicesOptions indicesOptions() {
|
|
||||||
return IndicesOptions.lenientExpandHidden();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class DeleteConnectorSyncJobAction {
|
public class DeleteConnectorSyncJobAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/sync_job/delete";
|
public static final String NAME = "cluster:admin/xpack/connector/sync_job/delete";
|
||||||
public static final ActionType<AcknowledgedResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<AcknowledgedResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private DeleteConnectorSyncJobAction() {/* no instances */}
|
private DeleteConnectorSyncJobAction() {/* no instances */}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class GetConnectorSyncJobAction {
|
public class GetConnectorSyncJobAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/read/xpack/connector/sync_job/get";
|
public static final String NAME = "cluster:admin/xpack/connector/sync_job/get";
|
||||||
public static final ActionType<GetConnectorSyncJobAction.Response> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<GetConnectorSyncJobAction.Response> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private GetConnectorSyncJobAction() {/* no instances */}
|
private GetConnectorSyncJobAction() {/* no instances */}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class ListConnectorSyncJobsAction {
|
public class ListConnectorSyncJobsAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/read/xpack/connector/sync_job/list";
|
public static final String NAME = "cluster:admin/xpack/connector/sync_job/list";
|
||||||
public static final ActionType<ListConnectorSyncJobsAction.Response> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ListConnectorSyncJobsAction.Response> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private ListConnectorSyncJobsAction() {/* no instances */}
|
private ListConnectorSyncJobsAction() {/* no instances */}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.elasticsearch.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.xcontent.XContentBuilder;
|
import org.elasticsearch.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xcontent.XContentParser;
|
import org.elasticsearch.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.application.connector.Connector;
|
import org.elasticsearch.xpack.application.connector.Connector;
|
||||||
import org.elasticsearch.xpack.application.connector.ConnectorTemplateRegistry;
|
|
||||||
import org.elasticsearch.xpack.application.connector.syncjob.ConnectorSyncJob;
|
import org.elasticsearch.xpack.application.connector.syncjob.ConnectorSyncJob;
|
||||||
import org.elasticsearch.xpack.application.connector.syncjob.ConnectorSyncJobTriggerMethod;
|
import org.elasticsearch.xpack.application.connector.syncjob.ConnectorSyncJobTriggerMethod;
|
||||||
import org.elasticsearch.xpack.application.connector.syncjob.ConnectorSyncJobType;
|
import org.elasticsearch.xpack.application.connector.syncjob.ConnectorSyncJobType;
|
||||||
|
@ -32,7 +31,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
||||||
|
|
||||||
public class PostConnectorSyncJobAction {
|
public class PostConnectorSyncJobAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/sync_job/post";
|
public static final String NAME = "cluster:admin/xpack/connector/sync_job/post";
|
||||||
public static final ActionType<PostConnectorSyncJobAction.Response> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<PostConnectorSyncJobAction.Response> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private PostConnectorSyncJobAction() {/* no instances */}
|
private PostConnectorSyncJobAction() {/* no instances */}
|
||||||
|
@ -140,14 +139,6 @@ public class PostConnectorSyncJobAction {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id, jobType, triggerMethod);
|
return Objects.hash(id, jobType, triggerMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] indices() {
|
|
||||||
// Creating a new sync job requires reading from connector index
|
|
||||||
return new String[] {
|
|
||||||
ConnectorTemplateRegistry.CONNECTOR_SYNC_JOBS_INDEX_NAME_PATTERN,
|
|
||||||
ConnectorTemplateRegistry.CONNECTOR_INDEX_NAME_PATTERN };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Response extends ActionResponse implements ToXContentObject {
|
public static class Response extends ActionResponse implements ToXContentObject {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
||||||
|
|
||||||
public class UpdateConnectorSyncJobErrorAction {
|
public class UpdateConnectorSyncJobErrorAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/sync_job/update_error";
|
public static final String NAME = "cluster:admin/xpack/connector/sync_job/update_error";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorSyncJobErrorAction() {/* no instances */}
|
private UpdateConnectorSyncJobErrorAction() {/* no instances */}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import static org.elasticsearch.xpack.application.connector.syncjob.ConnectorSyn
|
||||||
|
|
||||||
public class UpdateConnectorSyncJobIngestionStatsAction {
|
public class UpdateConnectorSyncJobIngestionStatsAction {
|
||||||
|
|
||||||
public static final String NAME = "indices:data/write/xpack/connector/sync_job/update_stats";
|
public static final String NAME = "cluster:admin/xpack/connector/sync_job/update_stats";
|
||||||
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
public static final ActionType<ConnectorUpdateActionResponse> INSTANCE = new ActionType<>(NAME);
|
||||||
|
|
||||||
private UpdateConnectorSyncJobIngestionStatsAction() {/* no instances */}
|
private UpdateConnectorSyncJobIngestionStatsAction() {/* no instances */}
|
||||||
|
|
|
@ -134,40 +134,40 @@ public class Constants {
|
||||||
"cluster:admin/xpack/ccr/auto_follow_pattern/put",
|
"cluster:admin/xpack/ccr/auto_follow_pattern/put",
|
||||||
"cluster:admin/xpack/ccr/pause_follow",
|
"cluster:admin/xpack/ccr/pause_follow",
|
||||||
"cluster:admin/xpack/ccr/resume_follow",
|
"cluster:admin/xpack/ccr/resume_follow",
|
||||||
"indices:data/write/xpack/connector/delete",
|
"cluster:admin/xpack/connector/delete",
|
||||||
"indices:data/read/xpack/connector/get",
|
"cluster:admin/xpack/connector/get",
|
||||||
"indices:data/read/xpack/connector/list",
|
"cluster:admin/xpack/connector/list",
|
||||||
"indices:data/write/xpack/connector/post",
|
"cluster:admin/xpack/connector/post",
|
||||||
"indices:data/write/xpack/connector/put",
|
"cluster:admin/xpack/connector/put",
|
||||||
"indices:data/write/xpack/connector/update_api_key_id",
|
"cluster:admin/xpack/connector/update_api_key_id",
|
||||||
"indices:data/write/xpack/connector/update_configuration",
|
"cluster:admin/xpack/connector/update_configuration",
|
||||||
"indices:data/write/xpack/connector/update_error",
|
"cluster:admin/xpack/connector/update_error",
|
||||||
"indices:data/write/xpack/connector/update_features",
|
"cluster:admin/xpack/connector/update_features",
|
||||||
"indices:data/write/xpack/connector/update_filtering",
|
"cluster:admin/xpack/connector/update_filtering",
|
||||||
"indices:data/write/xpack/connector/update_filtering/activate",
|
"cluster:admin/xpack/connector/update_filtering/activate",
|
||||||
"indices:data/write/xpack/connector/update_filtering/draft_validation",
|
"cluster:admin/xpack/connector/update_filtering/draft_validation",
|
||||||
"indices:data/write/xpack/connector/update_index_name",
|
"cluster:admin/xpack/connector/update_index_name",
|
||||||
"indices:data/write/xpack/connector/update_last_seen",
|
"cluster:admin/xpack/connector/update_last_seen",
|
||||||
"indices:data/write/xpack/connector/update_last_sync_stats",
|
"cluster:admin/xpack/connector/update_last_sync_stats",
|
||||||
"indices:data/write/xpack/connector/update_name",
|
"cluster:admin/xpack/connector/update_name",
|
||||||
"indices:data/write/xpack/connector/update_native",
|
"cluster:admin/xpack/connector/update_native",
|
||||||
"indices:data/write/xpack/connector/update_pipeline",
|
"cluster:admin/xpack/connector/update_pipeline",
|
||||||
"indices:data/write/xpack/connector/update_scheduling",
|
"cluster:admin/xpack/connector/update_scheduling",
|
||||||
"indices:data/write/xpack/connector/update_service_type",
|
"cluster:admin/xpack/connector/update_service_type",
|
||||||
"indices:data/write/xpack/connector/update_status",
|
"cluster:admin/xpack/connector/update_status",
|
||||||
"cluster:admin/xpack/connector/secret/delete",
|
"cluster:admin/xpack/connector/secret/delete",
|
||||||
"cluster:admin/xpack/connector/secret/get",
|
"cluster:admin/xpack/connector/secret/get",
|
||||||
"cluster:admin/xpack/connector/secret/post",
|
"cluster:admin/xpack/connector/secret/post",
|
||||||
"cluster:admin/xpack/connector/secret/put",
|
"cluster:admin/xpack/connector/secret/put",
|
||||||
"indices:data/write/xpack/connector/sync_job/cancel",
|
"cluster:admin/xpack/connector/sync_job/cancel",
|
||||||
"indices:data/write/xpack/connector/sync_job/check_in",
|
"cluster:admin/xpack/connector/sync_job/check_in",
|
||||||
"indices:data/write/xpack/connector/sync_job/claim",
|
"cluster:admin/xpack/connector/sync_job/claim",
|
||||||
"indices:data/write/xpack/connector/sync_job/delete",
|
"cluster:admin/xpack/connector/sync_job/delete",
|
||||||
"indices:data/read/xpack/connector/sync_job/get",
|
"cluster:admin/xpack/connector/sync_job/get",
|
||||||
"indices:data/read/xpack/connector/sync_job/list",
|
"cluster:admin/xpack/connector/sync_job/list",
|
||||||
"indices:data/write/xpack/connector/sync_job/post",
|
"cluster:admin/xpack/connector/sync_job/post",
|
||||||
"indices:data/write/xpack/connector/sync_job/update_error",
|
"cluster:admin/xpack/connector/sync_job/update_error",
|
||||||
"indices:data/write/xpack/connector/sync_job/update_stats",
|
"cluster:admin/xpack/connector/sync_job/update_stats",
|
||||||
"cluster:admin/xpack/deprecation/info",
|
"cluster:admin/xpack/deprecation/info",
|
||||||
"cluster:admin/xpack/deprecation/nodes/info",
|
"cluster:admin/xpack/deprecation/nodes/info",
|
||||||
"cluster:admin/xpack/enrich/delete",
|
"cluster:admin/xpack/enrich/delete",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue