Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions core/src/main/java/io/kestra/core/models/QueryFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ public List<Op> supportedOp() {
return List.of(Op.EQUALS, Op.NOT_EQUALS);
}
},
ENABLED("enabled") {
@Override
public List<Op> supportedOp() {
return List.of(Op.EQUALS);
}
},
USERNAME("username") {
@Override
public List<Op> supportedOp() {
Expand Down Expand Up @@ -401,6 +407,12 @@ public List<Field> supportedField() {
return List.of(Field.QUERY, Field.NAMESPACE, Field.TYPE);
}
},
SECURITY_INTEGRATION {
@Override
public List<Field> supportedField() {
return List.of(Field.ENABLED);
}
},
SECRET_METADATA {
@Override
public List<Field> supportedField() {
Expand Down
23 changes: 23 additions & 0 deletions core/src/test/java/io/kestra/core/models/QueryFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ static Stream<Arguments> validOperationFilters() {
Set.of()
),

buildQueryFiltersForOperations(Field.ENABLED, Resource.SECURITY_INTEGRATION,
Set.of(
Op.EQUALS
)
),

buildQueryFiltersForOperations(Field.NAME, Resource.ROLE,
Set.of(
Op.EQUALS
Expand Down Expand Up @@ -757,6 +763,23 @@ static Stream<Arguments> invalidOperationFilters() {
)
),

buildQueryFiltersForOperations(Field.ENABLED, Resource.SECURITY_INTEGRATION,
Set.of(
Op.NOT_EQUALS,
Op.GREATER_THAN,
Op.LESS_THAN,
Op.GREATER_THAN_OR_EQUAL_TO,
Op.LESS_THAN_OR_EQUAL_TO,
Op.IN,
Op.NOT_IN,
Op.STARTS_WITH,
Op.ENDS_WITH,
Op.CONTAINS,
Op.REGEX,
Op.PREFIX
)
),

buildQueryFiltersForOperations(Field.NAME, Resource.GROUP,
Set.of(
Op.GREATER_THAN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ protected Condition getConditionOnField(
return getDateCondition(value, operation, dateColumn);
}

if (field == QueryFilter.Field.ENABLED) {
return getEnabledCondition(value, operation);
}

if (field == QueryFilter.Field.STATUS) {
return statusCondition(value, operation);
}
Expand Down Expand Up @@ -341,6 +345,7 @@ protected Condition getConditionOnField(
return findMetadataCondition((Map<?, ?>) value, operation);
}


return defaultHandlers(field, value, operation);
}

Expand Down Expand Up @@ -377,7 +382,7 @@ private Condition getDateCondition(Object value, Op operation, String dateColumn
return applyDateCondition(dateTime, operation, dateColumn);
}

private static Object primitiveOrToString(Object o) {
protected static Object primitiveOrToString(Object o) {
if (o == null) return null;

if (o instanceof Boolean
Expand Down Expand Up @@ -406,6 +411,10 @@ protected Condition findMetadataCondition(Map<?, ?> metadata, QueryFilter.Op ope
throw new InvalidQueryFiltersException("Unsupported operation: " + operation);
}

protected Condition getEnabledCondition(Object value, Op operation) {
return defaultHandlers(QueryFilter.Field.ENABLED, value, operation);
}

// Generate the condition for Field.STATE
@SuppressWarnings("unchecked")
private Condition generateStateCondition(Object value, QueryFilter.Op operation) {
Expand Down
1 change: 1 addition & 0 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10395,6 +10395,7 @@ components:
- PATH
- PARENT_PATH
- VERSION
- ENABLED
- USERNAME
- NAME
- GROUP
Expand Down
Loading