Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing graphql apis for label application rules #108

Merged
merged 16 commits into from
Nov 5, 2021
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private Action convertLabelAction(
Action.Operation operation = getOperationFromAction(action);
Action.Builder actionBuilder =
Action.newBuilder().setOperation(operation).addAllEntityTypes(action.entityTypes());
switch (action.valueType()) {
switch (action.labelApplicationActionType()) {
case STATIC_LABELS:
return actionBuilder
.setStaticLabels(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ private Optional<Action> convertAction(
return operation.map(
op ->
new ConvertedAction(
entityTypes, op, staticLabels, null, Action.ValueType.STATIC_LABELS));
entityTypes,
op,
staticLabels,
null,
Action.LabelApplicationActionType.STATIC_LABELS));
case DYNAMIC_LABEL_KEY:
return operation.map(
op ->
Expand All @@ -109,7 +113,7 @@ private Optional<Action> convertAction(
op,
null,
action.getDynamicLabelKey(),
Action.ValueType.STATIC_LABELS));
Action.LabelApplicationActionType.STATIC_LABELS));
default:
log.error("Unrecognized Value type in Action {}", action.getValueCase().name());
return Optional.empty();
Expand Down Expand Up @@ -268,7 +272,7 @@ private static class ConvertedAction implements Action {
Operation operation;
StaticLabels staticLabels;
String dynamicLabelKey;
ValueType valueType;
LabelApplicationActionType labelApplicationActionType;
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ private static class ActionArgument implements Action {
@JsonProperty(DYNAMIC_LABEL_KEY_KEY)
String dynamicLabelKey;

@JsonProperty(VALUE_TYPE_KEY)
ValueType valueType;
@JsonProperty(LABEL_APPLICATION_ACTION_TYPE)
LabelApplicationActionType labelApplicationActionType;
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ private static class ActionArgument implements Action {
@JsonProperty(DYNAMIC_LABEL_KEY_KEY)
String dynamicLabelKey;

@JsonProperty(VALUE_TYPE_KEY)
ValueType valueType;
@JsonProperty(LABEL_APPLICATION_ACTION_TYPE)
LabelApplicationActionType labelApplicationActionType;
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ public interface Action {
String OPERATION_KEY = "operation";
String STATIC_LABELS = "staticLabels";
String DYNAMIC_LABEL_KEY_KEY = "dynamicLabelKey";
String VALUE_TYPE_KEY = "actionType";
String LABEL_APPLICATION_ACTION_TYPE = "actionType";

@GraphQLName(Operation.TYPE_NAME)
enum Operation {
OPERATION_MERGE;
private static final String TYPE_NAME = "LabelApplicationActionOperator";
}

@GraphQLName(ValueType.TYPE_NAME)
enum ValueType {
@GraphQLName(LabelApplicationActionType.TYPE_NAME)
enum LabelApplicationActionType {
STATIC_LABELS,
DYNAMIC_LABEL_KEY;
private static final String TYPE_NAME = "LabelApplicationValueType";
Expand Down Expand Up @@ -51,6 +51,6 @@ enum ValueType {

@GraphQLField
@GraphQLNonNull
@GraphQLName(VALUE_TYPE_KEY)
ValueType valueType();
@GraphQLName(LABEL_APPLICATION_ACTION_TYPE)
LabelApplicationActionType labelApplicationActionType();
}