required changes after merging in upstream branch
This commit is contained in:
parent
1951cdf1cb
commit
0353eb9291
|
@ -77,6 +77,7 @@ public class ClusterPrivilegeResolver {
|
|||
Collections.unmodifiableSet(Sets.newHashSet("cluster:admin/slm/*", StartILMAction.NAME, StopILMAction.NAME, GetStatusAction.NAME));
|
||||
private static final Set<String> READ_SLM_PATTERN = Collections.unmodifiableSet(Sets.newHashSet(GetSnapshotLifecycleAction.NAME,
|
||||
GetStatusAction.NAME));
|
||||
private static final Set<String> MANAGE_ENRICH_AUTOMATON = Collections.unmodifiableSet(Sets.newHashSet("cluster:admin/xpack/enrich/*"));
|
||||
|
||||
public static final NamedClusterPrivilege NONE = new ActionClusterPrivilege("none", Collections.emptySet(), Collections.emptySet());
|
||||
public static final NamedClusterPrivilege ALL = new ActionClusterPrivilege("all", ALL_CLUSTER_PATTERN);
|
||||
|
@ -113,6 +114,7 @@ public class ClusterPrivilegeResolver {
|
|||
public static final NamedClusterPrivilege READ_ILM = new ActionClusterPrivilege("read_ilm", READ_ILM_PATTERN);
|
||||
public static final NamedClusterPrivilege MANAGE_SLM = new ActionClusterPrivilege("manage_slm", MANAGE_SLM_PATTERN);
|
||||
public static final NamedClusterPrivilege READ_SLM = new ActionClusterPrivilege("read_slm", READ_SLM_PATTERN);
|
||||
public static final NamedClusterPrivilege MANAGE_ENRICH = new ActionClusterPrivilege("manage_enrich", MANAGE_ENRICH_AUTOMATON);
|
||||
|
||||
private static final Map<String, NamedClusterPrivilege> VALUES = Collections.unmodifiableMap(
|
||||
Stream.of(
|
||||
|
@ -143,7 +145,8 @@ public class ClusterPrivilegeResolver {
|
|||
MANAGE_ILM,
|
||||
READ_ILM,
|
||||
MANAGE_SLM,
|
||||
READ_SLM).collect(Collectors.toMap(cp -> cp.name(), cp -> cp)));
|
||||
READ_SLM,
|
||||
MANAGE_ENRICH).collect(Collectors.toMap(cp -> cp.name(), cp -> cp)));
|
||||
|
||||
/**
|
||||
* Resolves a {@link NamedClusterPrivilege} from a given name if it exists.
|
||||
|
|
|
@ -182,14 +182,13 @@ public class PrivilegeTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testManageEnrichPrivilege() {
|
||||
Predicate<String> predicate = ClusterPrivilege.MANAGE_ENRICH.predicate();
|
||||
assertThat(predicate.test(DeleteEnrichPolicyAction.NAME), is(true));
|
||||
assertThat(predicate.test(ExecuteEnrichPolicyAction.NAME), is(true));
|
||||
assertThat(predicate.test(GetEnrichPolicyAction.NAME), is(true));
|
||||
assertThat(predicate.test(ListEnrichPolicyAction.NAME), is(true));
|
||||
assertThat(predicate.test(PutEnrichPolicyAction.NAME), is(true));
|
||||
assertThat(predicate.test("cluster:admin/xpack/enrich/brand_new_api"), is(true));
|
||||
assertThat(predicate.test("cluster:admin/xpack/whatever"), is(false));
|
||||
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, DeleteEnrichPolicyAction.NAME);
|
||||
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, ExecuteEnrichPolicyAction.NAME);
|
||||
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, GetEnrichPolicyAction.NAME);
|
||||
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, ListEnrichPolicyAction.NAME);
|
||||
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, PutEnrichPolicyAction.NAME);
|
||||
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, "cluster:admin/xpack/enrich/brand_new_api");
|
||||
verifyClusterActionDenied(ClusterPrivilegeResolver.MANAGE_ENRICH, "cluster:admin/xpack/whatever");
|
||||
}
|
||||
|
||||
public void testIlmPrivileges() {
|
||||
|
|
|
@ -132,11 +132,11 @@ public class EnrichPlugin extends Plugin implements ActionPlugin, IngestPlugin {
|
|||
}
|
||||
|
||||
return Arrays.asList(
|
||||
new RestGetEnrichPolicyAction(settings, restController),
|
||||
new RestDeleteEnrichPolicyAction(settings, restController),
|
||||
new RestListEnrichPolicyAction(settings, restController),
|
||||
new RestPutEnrichPolicyAction(settings, restController),
|
||||
new RestExecuteEnrichPolicyAction(settings, restController)
|
||||
new RestGetEnrichPolicyAction(restController),
|
||||
new RestDeleteEnrichPolicyAction(restController),
|
||||
new RestListEnrichPolicyAction(restController),
|
||||
new RestPutEnrichPolicyAction(restController),
|
||||
new RestExecuteEnrichPolicyAction(restController)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
package org.elasticsearch.xpack.enrich.rest;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
|
@ -17,8 +16,7 @@ import java.io.IOException;
|
|||
|
||||
public class RestDeleteEnrichPolicyAction extends BaseRestHandler {
|
||||
|
||||
public RestDeleteEnrichPolicyAction(final Settings settings, final RestController controller) {
|
||||
super(settings);
|
||||
public RestDeleteEnrichPolicyAction(final RestController controller) {
|
||||
controller.registerHandler(RestRequest.Method.DELETE, "/_enrich/policy/{name}", this);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
package org.elasticsearch.xpack.enrich.rest;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
|
@ -17,8 +16,7 @@ import java.io.IOException;
|
|||
|
||||
public class RestExecuteEnrichPolicyAction extends BaseRestHandler {
|
||||
|
||||
public RestExecuteEnrichPolicyAction(final Settings settings, final RestController controller) {
|
||||
super(settings);
|
||||
public RestExecuteEnrichPolicyAction(final RestController controller) {
|
||||
controller.registerHandler(RestRequest.Method.PUT, "/_enrich/policy/{name}/_execute", this);
|
||||
controller.registerHandler(RestRequest.Method.POST, "/_enrich/policy/{name}/_execute", this);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
package org.elasticsearch.xpack.enrich.rest;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
|
@ -17,8 +16,7 @@ import java.io.IOException;
|
|||
|
||||
public class RestGetEnrichPolicyAction extends BaseRestHandler {
|
||||
|
||||
public RestGetEnrichPolicyAction(final Settings settings, final RestController controller) {
|
||||
super(settings);
|
||||
public RestGetEnrichPolicyAction(final RestController controller) {
|
||||
controller.registerHandler(RestRequest.Method.GET, "/_enrich/policy/{name}", this);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
package org.elasticsearch.xpack.enrich.rest;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
|
@ -17,8 +16,7 @@ import java.io.IOException;
|
|||
|
||||
public class RestListEnrichPolicyAction extends BaseRestHandler {
|
||||
|
||||
public RestListEnrichPolicyAction(final Settings settings, final RestController controller) {
|
||||
super(settings);
|
||||
public RestListEnrichPolicyAction(final RestController controller) {
|
||||
controller.registerHandler(RestRequest.Method.GET, "/_enrich/policy", this);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
package org.elasticsearch.xpack.enrich.rest;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
|
@ -18,8 +17,7 @@ import java.io.IOException;
|
|||
|
||||
public class RestPutEnrichPolicyAction extends BaseRestHandler {
|
||||
|
||||
public RestPutEnrichPolicyAction(final Settings settings, final RestController controller) {
|
||||
super(settings);
|
||||
public RestPutEnrichPolicyAction(final RestController controller) {
|
||||
controller.registerHandler(RestRequest.Method.PUT, "/_enrich/policy/{name}", this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue