Skip to content

Commit

Permalink
update actions
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
  • Loading branch information
stephen-crawford committed Jun 14, 2023
1 parent f0ff432 commit 777ba97
Show file tree
Hide file tree
Showing 268 changed files with 415 additions and 1,158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ public String toString() {
return "PainlessContextClassBindingInfo{"
+ "declaring='"
+ declaring
+ '\''
+ '\
+ ", name='"
+ name
+ '\''
+ '\
+ ", rtn='"
+ rtn
+ '\''
+ '\
+ ", readOnly="
+ readOnly
+ ", parameters="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public String toString() {
return "PainlessContextClassInfo{"
+ "name='"
+ name
+ '\''
+ '\
+ ", imported="
+ imported
+ ", constructors="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public int hashCode() {

@Override
public String toString() {
return "PainlessContextConstructorInfo{" + "declaring='" + declaring + '\'' + ", parameters=" + parameters + '}';
return "PainlessContextConstructorInfo{" + "declaring='" + declaring + '\ + ", parameters=" + parameters + '}';
}

public String getDeclaring() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public int hashCode() {

@Override
public String toString() {
return "PainlessContextFieldInfo{" + "declaring='" + declaring + '\'' + ", name='" + name + '\'' + ", type='" + type + '\'' + '}';
return "PainlessContextFieldInfo{" + "declaring='" + declaring + '\ + ", name='" + name + '\ + ", type='" + type + '\ + '}';
}

public String getDeclaring() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public String toString() {
return "PainlessContextInfo{"
+ "name='"
+ name
+ '\''
+ '\
+ ", classes="
+ classes
+ ", importedMethods="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ public String toString() {
return "PainlessContextInstanceBindingInfo{"
+ "declaring='"
+ declaring
+ '\''
+ '\
+ ", name='"
+ name
+ '\''
+ '\
+ ", rtn='"
+ rtn
+ '\''
+ '\
+ ", parameters="
+ parameters
+ '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ public String toString() {
return "PainlessContextMethodInfo{"
+ "declaring='"
+ declaring
+ '\''
+ '\
+ ", name='"
+ name
+ '\''
+ '\
+ ", rtn='"
+ rtn
+ '\''
+ '\
+ ", parameters="
+ parameters
+ '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public String toString() {
return "ContextSetup{"
+ ", index='"
+ index
+ '\''
+ '\
+ ", document="
+ document
+ ", query="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ public void testGetPrincipal_otherType() {

public void testSetAndGetScopesShouldPass() {

List<Scope> testScopes = List.of(ActionScope.INDEX_READ);
List<Scope> testScopes = List.of(ActionScope.READ);
// Set scopes for a subject
subject.setScopes(testScopes);
assertEquals(subject.getScopes(), testScopes);

List<Scope> testScopes2 = List.of(ActionScope.INDEX_SEARCH);
List<Scope> testScopes2 = List.of(ActionScope.ALL);
subject.setScopes(testScopes2);
assertEquals(subject.getScopes(), testScopes2);
assertFalse(subject.getScopes().contains(ActionScope.INDEX_READ)); // Verify that setScopes overwrites completely
assertFalse(subject.getScopes().contains(ActionScope.READ)); // Verify that setScopes overwrites completely
}

public void testSetScopeGetActionAreaName() {
Expand All @@ -98,14 +98,14 @@ public void testSetScopeGetActionAreaName() {
assertEquals(ActionScope.ALL.getArea(), ScopeEnums.ScopeArea.ALL);
assertEquals(ActionScope.ALL.getNamespace(), ScopeEnums.ScopeNamespace.ACTION);

assertEquals(ActionScope.INDEX_READ.getAction(), "READ");
assertEquals(ActionScope.INDEX_READ.getArea(), ScopeEnums.ScopeArea.INDEX);
assertEquals(ActionScope.INDEX_READ.getNamespace(), ScopeEnums.ScopeNamespace.ACTION);
assertEquals(ActionScope.READ.getAction(), "READ");
assertEquals(ActionScope.READ.getArea(), ScopeEnums.ScopeArea.INDEX);
assertEquals(ActionScope.READ.getNamespace(), ScopeEnums.ScopeNamespace.ACTION);
}

public void testIsAllowedShouldPass() {

List<Scope> testScopes = List.of(ActionScope.INDEX_READ);
List<Scope> testScopes = List.of(ActionScope.READ);
// Set scopes for a subject
subject.setScopes(testScopes);
assertEquals(subject.getScopes(), testScopes);
Expand All @@ -118,7 +118,7 @@ public void testIsAllowedShouldPass() {

public void testIsAllowedShouldFail() {

List<Scope> testScopes = List.of(ActionScope.INDEX_READ);
List<Scope> testScopes = List.of(ActionScope.READ);
// Set scopes for a subject
subject.setScopes(testScopes);
assertEquals(subject.getScopes(), testScopes);
Expand Down
7 changes: 1 addition & 6 deletions server/src/main/java/org/opensearch/action/ActionScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@
*/
public enum ActionScope implements Scope {
ALL(ScopeArea.ALL, "ALL"),
CLUSTER_READ(ScopeArea.CLUSTER, "READ"),
CLUSTER_ALL(ScopeArea.ALL, "ALL"),
INDEX_READ(ScopeArea.INDEX, "READ"),
INDEX_READWRITE(ScopeArea.INDEX, "READWRITE"),
INDEX_SEARCH(ScopeArea.INDEX, "SEARCH"),
INDEX_ALL(ScopeArea.INDEX, "ALL");
READ(ScopeArea.ALL, "READ");

public final ScopeArea area;
public final String action;
Expand Down
3 changes: 2 additions & 1 deletion server/src/main/java/org/opensearch/action/ActionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public int hashCode() {
return name.hashCode();
}

public List<Scope> allowedScopes() {
public List<Scope>
allowedScopes() {
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ private ClusterAllocationExplainAction() {
super(NAME, ClusterAllocationExplainResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_Read, ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,4 @@ public final class AddVotingConfigExclusionsAction extends ActionType<AddVotingC
private AddVotingConfigExclusionsAction() {
super(NAME, AddVotingConfigExclusionsResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,5 @@ private ClearVotingConfigExclusionsAction() {
super(NAME, ClearVotingConfigExclusionsResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,5 @@ private DeleteDecommissionStateAction() {
super(NAME, DeleteDecommissionStateResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@ private GetDecommissionStateAction() {
super(NAME, GetDecommissionStateResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,5 @@ private DecommissionAction() {
super(NAME, DecommissionResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ private ClusterHealthAction() {
super(NAME, ClusterHealthResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_Read, ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ private NodesHotThreadsAction() {
super(NAME, NodesHotThreadsResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_Read, ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ private NodesInfoAction() {
super(NAME, NodesInfoResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_Read, ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ private NodesReloadSecureSettingsAction() {
super(NAME, NodesReloadSecureSettingsResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ private NodesStatsAction() {
super(NAME, NodesStatsResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_Read, ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ private CancelTasksAction() {
super(NAME, CancelTasksResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,5 @@ private GetTaskAction() {
super(NAME, GetTaskResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_Read, ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ private ListTasksAction() {
super(NAME, ListTasksResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_Read, ActionScope.Cluster_ALL, ActionScope.ALL);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ protected NodesUsageAction() {
super(NAME, NodesUsageResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_Read, ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ public RemoteInfoAction() {
super(NAME, RemoteInfoResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_Read, ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@ private RestoreRemoteStoreAction() {
super(NAME, RestoreRemoteStoreResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@ private RemoteStoreStatsAction() {
super(NAME, RemoteStoreStatsResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,5 @@ private CleanupRepositoryAction() {
super(NAME, CleanupRepositoryResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ private DeleteRepositoryAction() {
super(NAME, AcknowledgedResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ private GetRepositoriesAction() {
super(NAME, GetRepositoriesResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_Read, ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ private PutRepositoryAction() {
super(NAME, AcknowledgedResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ private VerifyRepositoryAction() {
super(NAME, VerifyRepositoryResponse::new);
}

@Override
public List<Scope> allowedScopes() {
return List.of(ActionScope.Cluster_ALL, ActionScope.ALL);
}

}
Loading

0 comments on commit 777ba97

Please sign in to comment.