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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.hypertrace.graphql.label.application.rules.dao;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.hypertrace.graphql.label.application.rules.request.LabelApplicationRuleCreateRequest;
import org.hypertrace.graphql.label.application.rules.request.LabelApplicationRuleDeleteRequest;
Expand Down Expand Up @@ -47,11 +48,14 @@ public DeleteLabelApplicationRuleRequest convertDeleteRequest(

private LabelApplicationRuleData convertLabelApplicationRuleData(
org.hypertrace.graphql.label.application.rules.schema.shared.LabelApplicationRuleData data) {
return LabelApplicationRuleData.newBuilder()
.setName(data.name())
.setMatchingCondition(convertConditionList(data.conditionList()))
.setLabelAction(convertLabelAction(data.action()))
.build();
LabelApplicationRuleData.Builder convertedDataBuilder =
LabelApplicationRuleData.newBuilder()
.setName(data.name())
.setMatchingCondition(convertConditionList(data.conditionList()))
.setLabelAction(convertLabelAction(data.action()))
.setEnabled(data.enabled());
Optional.ofNullable(data.description()).ifPresent(convertedDataBuilder::setDescription);
return convertedDataBuilder.build();
}

private Action.Operation getOperationFromAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ private Optional<LabelApplicationRuleData> convertLabelApplicationRuleData(
}
return action.map(
labelAction ->
new ConvertedLabelApplicationRuleData(data.getName(), conditionList, labelAction));
new ConvertedLabelApplicationRuleData(
data.getName(),
conditionList,
labelAction,
data.getEnabled(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we handle backwards compat at the config layer? Or planning to handle it manually since this full feature isn't exposed yet? Current impl will default any pre-existing rules to disabled since that's the default value of the new boolean.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no existing label application rule. Checked in saas-dev.

data.hasDescription() ? data.getDescription() : null));
}

private Optional<Action.Operation> convertOperationInAction(
Expand Down Expand Up @@ -259,6 +264,8 @@ private static class ConvertedLabelApplicationRuleData implements LabelApplicati
String name;
List<Condition> conditionList;
Action action;
boolean enabled;
String description;
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ private static class LabelApplicationRuleDataArgument implements LabelApplicatio

@JsonProperty(ACTION_KEY)
Action action;

@JsonProperty(ENABLED_KEY)
boolean enabled;

@JsonProperty(DESCRIPTION_KEY)
String description;
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ private static class LabelApplicationRuleDataArgument implements LabelApplicatio

@JsonProperty(ACTION_KEY)
Action action;

@JsonProperty(ENABLED_KEY)
boolean enabled;

@JsonProperty(DESCRIPTION_KEY)
String description;
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import graphql.annotations.annotationTypes.GraphQLName;
import graphql.annotations.annotationTypes.GraphQLNonNull;
import java.util.List;
import javax.annotation.Nullable;

@GraphQLName(LabelApplicationRuleData.TYPE_NAME)
public interface LabelApplicationRuleData {
Expand All @@ -13,6 +14,8 @@ public interface LabelApplicationRuleData {
String NAME_KEY = "name";
String CONDITION_LIST_KEY = "conditionList";
String ACTION_KEY = "action";
String ENABLED_KEY = "enabled";
String DESCRIPTION_KEY = "description";

@GraphQLField
@GraphQLNonNull
Expand All @@ -28,4 +31,14 @@ public interface LabelApplicationRuleData {
@GraphQLNonNull
@GraphQLName(ACTION_KEY)
Action action();

@GraphQLField
@GraphQLNonNull
@GraphQLName(ENABLED_KEY)
boolean enabled();

@GraphQLField
@Nullable
@GraphQLName(DESCRIPTION_KEY)
String description();
}
2 changes: 1 addition & 1 deletion hypertrace-graphql-platform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ dependencies {
api("org.hypertrace.entity.service:entity-type-service-rx-client:0.5.6")
api("org.hypertrace.config.service:spaces-config-service-api:0.1.1")
api("org.hypertrace.config.service:labels-config-service-api:0.1.15")
api("org.hypertrace.config.service:label-application-rule-config-service-api:0.1.15")
api("org.hypertrace.config.service:label-application-rule-config-service-api:0.1.16")
}
}