Remove Rollout(Group) builders (#2603)
* Fix entityManager.merge for ds and sm Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com> * Remove Rollout(Group) builders Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com> * Remove EntityFactory Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com> --------- Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -21,13 +21,13 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.builder.ActionStatusCreate;
|
||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.InvalidTargetAttributeException;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionStatusCreate;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.AutoConfirmationStatus;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import org.eclipse.hawkbit.repository.builder.ActionStatusBuilder;
|
||||
import org.eclipse.hawkbit.repository.builder.RolloutBuilder;
|
||||
import org.eclipse.hawkbit.repository.builder.RolloutGroupBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
|
||||
/**
|
||||
* Central {@link BaseEntity} generation service. Objects are created but not persisted.
|
||||
*/
|
||||
public interface EntityFactory {
|
||||
|
||||
/**
|
||||
* @return {@link ActionStatusBuilder} object
|
||||
*/
|
||||
ActionStatusBuilder actionStatus();
|
||||
|
||||
/**
|
||||
* @return {@link RolloutGroupBuilder} object
|
||||
*/
|
||||
RolloutGroupBuilder rolloutGroup();
|
||||
|
||||
/**
|
||||
* @return {@link RolloutBuilder} object
|
||||
*/
|
||||
RolloutBuilder rollout();
|
||||
}
|
||||
@@ -11,46 +11,54 @@ package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.eclipse.hawkbit.im.authentication.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.builder.DynamicRolloutGroupTemplate;
|
||||
import org.eclipse.hawkbit.repository.builder.RolloutCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.RolloutGroupCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.RolloutUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupsValidation;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* RolloutManagement to control rollouts e.g. like creating, starting, resuming
|
||||
* and pausing rollouts. This service secures all the functionality based on the
|
||||
* {@link PreAuthorize} annotation on methods.
|
||||
* RolloutManagement to control rollouts e.g. like creating, starting, resuming and pausing rollouts. This service secures all the
|
||||
* functionality based on the {@link PreAuthorize} annotation on methods.
|
||||
*/
|
||||
public interface RolloutManagement {
|
||||
|
||||
/**
|
||||
* Counts all {@link Rollout}s in the repository that are not marked as deleted.
|
||||
*
|
||||
* @return number of roll outs
|
||||
* @return number of rollouts
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
long count();
|
||||
@@ -96,7 +104,7 @@ public interface RolloutManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_CREATE)
|
||||
Rollout create(
|
||||
@NotNull @Valid RolloutCreate create, int amountGroup, boolean confirmationRequired,
|
||||
@NotNull @Valid Create create, int amountGroup, boolean confirmationRequired,
|
||||
@NotNull RolloutGroupConditions conditions, DynamicRolloutGroupTemplate dynamicRolloutGroupTemplate);
|
||||
|
||||
/**
|
||||
@@ -126,7 +134,7 @@ public interface RolloutManagement {
|
||||
* exceeded.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_CREATE)
|
||||
Rollout create(@NotNull @Valid RolloutCreate create, int amountGroup, boolean confirmationRequired,
|
||||
Rollout create(@NotNull @Valid Create create, int amountGroup, boolean confirmationRequired,
|
||||
@NotNull RolloutGroupConditions conditions);
|
||||
|
||||
/**
|
||||
@@ -157,25 +165,7 @@ public interface RolloutManagement {
|
||||
* exceeded.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_CREATE)
|
||||
Rollout create(@Valid @NotNull RolloutCreate rollout, @NotNull @Valid List<RolloutGroupCreate> groups,
|
||||
RolloutGroupConditions conditions);
|
||||
|
||||
/**
|
||||
* Calculates how many targets are addressed by each rollout group and
|
||||
* returns the validation information.
|
||||
*
|
||||
* @param groups a list of rollout groups
|
||||
* @param targetFilter the rollout
|
||||
* @param createdAt timestamp when the rollout was created
|
||||
* @param dsTypeId ID of the type of distribution set of the rollout
|
||||
* @return the validation information
|
||||
* @throws RolloutIllegalStateException thrown when no targets are targeted by the rollout
|
||||
* @throws ConstraintViolationException if fields are not filled as specified. Check
|
||||
* {@link RolloutGroupCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
CompletableFuture<RolloutGroupsValidation> validateTargetsInGroups(
|
||||
@Valid List<RolloutGroupCreate> groups, String targetFilter, Long createdAt, @NotNull Long dsTypeId);
|
||||
Rollout create(@Valid @NotNull Create rollout, @NotNull @Valid List<GroupCreate> groups, RolloutGroupConditions conditions);
|
||||
|
||||
/**
|
||||
* Retrieves all rollouts.
|
||||
@@ -274,45 +264,36 @@ public interface RolloutManagement {
|
||||
* running will be untouched. {@link RolloutGroup}s which are
|
||||
* {@link RolloutGroupStatus#SCHEDULED} will not be started and keep in
|
||||
* {@link RolloutGroupStatus#SCHEDULED} state until the rollout is
|
||||
* {@link RolloutManagement#resumeRollout(Rollout)}.
|
||||
*
|
||||
* Switching the rollout status to {@link RolloutStatus#PAUSED} is
|
||||
* sufficient due the {@link #checkRunningRollouts(long)} will not check
|
||||
* this rollout anymore.
|
||||
* {@link RolloutManagement#resumeRollout(long)}.
|
||||
* <p/>
|
||||
* Switching the rollout status to {@link RolloutStatus#PAUSED} is sufficient.
|
||||
*
|
||||
* @param rolloutId the rollout to be paused.
|
||||
* @throws EntityNotFoundException if rollout or group with given ID does not exist
|
||||
* @throws RolloutIllegalStateException if given rollout is not in {@link RolloutStatus#RUNNING}.
|
||||
* Only running rollouts can be paused.
|
||||
* @throws RolloutIllegalStateException if given rollout is not in {@link RolloutStatus#RUNNING}. Only running rollouts can be paused.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_HANDLE)
|
||||
void pauseRollout(long rolloutId);
|
||||
|
||||
/**
|
||||
* Resumes a paused rollout. The rollout switches back to
|
||||
* {@link RolloutStatus#RUNNING} state which is then picked up again by the
|
||||
* {@link #checkRunningRollouts(long)}.
|
||||
* Resumes a paused rollout. The rollout switches back to {@link RolloutStatus#RUNNING} state which is then picked up again executor.
|
||||
*
|
||||
* @param rolloutId the rollout to be resumed
|
||||
* @throws EntityNotFoundException if rollout with given ID does not exist
|
||||
* @throws RolloutIllegalStateException if given rollout is not in {@link RolloutStatus#PAUSED}. Only
|
||||
* paused rollouts can be resumed.
|
||||
* @throws RolloutIllegalStateException if given rollout is not in {@link RolloutStatus#PAUSED}. Only paused rollouts can be resumed.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_HANDLE)
|
||||
void resumeRollout(long rolloutId);
|
||||
|
||||
/**
|
||||
* Approves or denies a created rollout being in state
|
||||
* {@link RolloutStatus#WAITING_FOR_APPROVAL}. If the rollout is approved,
|
||||
* it switches state to {@link RolloutStatus#READY}, otherwise it switches
|
||||
* to state {@link RolloutStatus#APPROVAL_DENIED}
|
||||
* Approves or denies a created rollout being in state {@link RolloutStatus#WAITING_FOR_APPROVAL}. If the rollout is approved,
|
||||
* it switches state to {@link RolloutStatus#READY}, otherwise it switches to state {@link RolloutStatus#APPROVAL_DENIED}
|
||||
*
|
||||
* @param rolloutId the rollout to be approved or denied.
|
||||
* @param decision decision whether a rollout is approved or denied.
|
||||
* @return approved or denied rollout
|
||||
* @throws EntityNotFoundException if rollout with given ID does not exist
|
||||
* @throws RolloutIllegalStateException if given rollout is not in
|
||||
* {@link RolloutStatus#WAITING_FOR_APPROVAL}. Only rollouts
|
||||
* @throws RolloutIllegalStateException if given rollout is not in {@link RolloutStatus#WAITING_FOR_APPROVAL}. Only rollouts
|
||||
* waiting for approval can be acted upon.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_APPROVE)
|
||||
@@ -362,7 +343,7 @@ public interface RolloutManagement {
|
||||
* reference
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_UPDATE)
|
||||
Rollout update(@NotNull @Valid RolloutUpdate update);
|
||||
Rollout update(@NotNull @Valid Update update);
|
||||
|
||||
/**
|
||||
* Deletes a rollout. A rollout might be deleted asynchronously by
|
||||
@@ -394,4 +375,149 @@ public interface RolloutManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_UPDATE)
|
||||
void triggerNextGroup(long rolloutId);
|
||||
|
||||
@SuperBuilder
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
final class Create extends UpdateCreate {
|
||||
|
||||
@ValidString
|
||||
@Size(min = 1, max = TargetFilterQuery.QUERY_MAX_SIZE)
|
||||
@NotNull
|
||||
private String targetFilterQuery;
|
||||
@NotNull
|
||||
private DistributionSet distributionSet;
|
||||
private boolean dynamic;
|
||||
@Builder.Default
|
||||
@NotNull
|
||||
private Action.ActionType actionType = Action.ActionType.FORCED;
|
||||
private Long forcedTime;
|
||||
private Long startAt;
|
||||
@Min(Action.WEIGHT_MIN)
|
||||
@Max(Action.WEIGHT_MAX)
|
||||
private Integer weight;
|
||||
}
|
||||
|
||||
@SuperBuilder
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
final class Update extends UpdateCreate implements Identifiable<Long> {
|
||||
|
||||
@NotNull
|
||||
private Long id;
|
||||
}
|
||||
|
||||
@SuperBuilder
|
||||
@Getter
|
||||
class UpdateCreate {
|
||||
|
||||
@ValidString
|
||||
@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE)
|
||||
@NotNull(groups = Create.class)
|
||||
private String name;
|
||||
@ValidString
|
||||
@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE)
|
||||
private String description;
|
||||
}
|
||||
|
||||
@Getter
|
||||
class GroupCreate {
|
||||
|
||||
@ValidString
|
||||
@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE)
|
||||
@NotNull
|
||||
private final String name;
|
||||
@ValidString
|
||||
@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE)
|
||||
private final String description;
|
||||
@ValidString
|
||||
@Size(min = 1, max = TargetFilterQuery.QUERY_MAX_SIZE)
|
||||
private final String targetFilterQuery;
|
||||
private final Float targetPercentage;
|
||||
private final boolean confirmationRequired;
|
||||
|
||||
// Conditions and actions for the rollout group
|
||||
private final RolloutGroup.RolloutGroupSuccessCondition successCondition;
|
||||
private final String successConditionExp;
|
||||
private final RolloutGroup.RolloutGroupSuccessAction successAction;
|
||||
private final String successActionExp;
|
||||
private final RolloutGroup.RolloutGroupErrorCondition errorCondition;
|
||||
private final String errorConditionExp;
|
||||
private final RolloutGroup.RolloutGroupErrorAction errorAction;
|
||||
private final String errorActionExp;
|
||||
|
||||
private GroupCreate(
|
||||
final String name, final String description, final String targetFilterQuery, final Float targetPercentage,
|
||||
final RolloutGroupConditions conditions, final boolean confirmationRequired) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.targetFilterQuery = targetFilterQuery;
|
||||
this.targetPercentage = targetPercentage;
|
||||
|
||||
this.successCondition = conditions.getSuccessCondition();
|
||||
this.successConditionExp = conditions.getSuccessConditionExp();
|
||||
this.successAction = conditions.getSuccessAction();
|
||||
this.successActionExp = conditions.getSuccessActionExp();
|
||||
this.errorCondition = conditions.getErrorCondition();
|
||||
this.errorConditionExp = conditions.getErrorConditionExp();
|
||||
this.errorAction = conditions.getErrorAction();
|
||||
this.errorActionExp = conditions.getErrorActionExp();
|
||||
|
||||
this.confirmationRequired = confirmationRequired;
|
||||
}
|
||||
|
||||
public static GroupCreateBuilder builder() {
|
||||
return new GroupCreateBuilder();
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Accessors(fluent = true)
|
||||
public static class GroupCreateBuilder {
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String targetFilterQuery;
|
||||
private Float targetPercentage;
|
||||
private RolloutGroupConditions conditions;
|
||||
private boolean confirmationRequired;
|
||||
|
||||
public GroupCreate build() {
|
||||
return new GroupCreate(
|
||||
name, description, targetFilterQuery, targetPercentage,
|
||||
conditions == null ? new RolloutGroupConditionBuilder().withDefaults().build() : conditions,
|
||||
confirmationRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder to create a new dynamic rollout group secret
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
class DynamicRolloutGroupTemplate {
|
||||
|
||||
/**
|
||||
* The name suffix, by default "" is used.
|
||||
*/
|
||||
@NotNull
|
||||
private String nameSuffix = "";
|
||||
|
||||
/**
|
||||
* The count of matching Targets that should be assigned to this Group
|
||||
*/
|
||||
private long targetCount;
|
||||
|
||||
/**
|
||||
* The group conditions
|
||||
*/
|
||||
private RolloutGroupConditions conditions;
|
||||
|
||||
/**
|
||||
* If confirmation is required for this rollout group (considered with confirmation flow active)
|
||||
*/
|
||||
private boolean confirmationRequired;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
|
||||
/**
|
||||
* Builder for {@link ActionStatus}.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ActionStatusBuilder {
|
||||
|
||||
/**
|
||||
* @param actionId the status is for
|
||||
* @return create builder
|
||||
*/
|
||||
ActionStatusCreate create(long actionId);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
|
||||
/**
|
||||
* Builder to create a new {@link ActionStatus} entry. Defines all fields that
|
||||
* can be set at creation time. Other fields are set by the repository
|
||||
* automatically, e.g. {@link BaseEntity#getCreatedAt()}.
|
||||
*/
|
||||
public interface ActionStatusCreate {
|
||||
|
||||
/**
|
||||
* @param status {@link ActionStatus#getStatus()}
|
||||
* @return updated {@link ActionStatusCreate} object
|
||||
*/
|
||||
ActionStatusCreate status(@NotNull Status status);
|
||||
|
||||
/**
|
||||
* @param occurredAt for {@link ActionStatus#getOccurredAt()}
|
||||
* @return updated {@link ActionStatusCreate} object
|
||||
*/
|
||||
ActionStatusCreate occurredAt(long occurredAt);
|
||||
|
||||
ActionStatusCreate code(int code);
|
||||
|
||||
/**
|
||||
* @param messages for {@link ActionStatus#getMessages()}
|
||||
* @return updated {@link ActionStatusCreate} object
|
||||
*/
|
||||
ActionStatusCreate messages(Collection<String> messages);
|
||||
|
||||
/**
|
||||
* @param message for {@link ActionStatus#getMessages()}
|
||||
* @return updated {@link ActionStatusCreate} object
|
||||
*/
|
||||
ActionStatusCreate message(String message);
|
||||
|
||||
/**
|
||||
* @return peek on current state of {@link ActionStatus} in the builder
|
||||
*/
|
||||
ActionStatus build();
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||
|
||||
/**
|
||||
* Builder to create a new dynamic rollout group secret
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class DynamicRolloutGroupTemplate {
|
||||
|
||||
/**
|
||||
* The name suffix, by default "" is used.
|
||||
*/
|
||||
@NotNull
|
||||
private String nameSuffix = "";
|
||||
|
||||
/**
|
||||
* The count of matching Targets that should be assigned to this Group
|
||||
*/
|
||||
private long targetCount;
|
||||
|
||||
/**
|
||||
* The group conditions
|
||||
*/
|
||||
private RolloutGroupConditions conditions;
|
||||
|
||||
/**
|
||||
* If confirmation is required for this rollout group (considered with confirmation flow active)
|
||||
*/
|
||||
private boolean confirmationRequired;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
|
||||
/**
|
||||
* Builder for {@link Rollout}.
|
||||
*/
|
||||
public interface RolloutBuilder {
|
||||
|
||||
/**
|
||||
* @param id of the updatable entity
|
||||
* @return builder instance
|
||||
*/
|
||||
RolloutUpdate update(long id);
|
||||
|
||||
/**
|
||||
* @return builder instance
|
||||
*/
|
||||
RolloutCreate create();
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
|
||||
/**
|
||||
* Builder to create a new {@link Rollout} entry. Defines all fields that can be
|
||||
* set at creation time. Other fields are set by the repository automatically,
|
||||
* e.g. {@link BaseEntity#getCreatedAt()}.
|
||||
*/
|
||||
public interface RolloutCreate {
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param name for {@link Rollout#getName()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
|
||||
|
||||
/**
|
||||
* Set description
|
||||
*
|
||||
* @param description for {@link Rollout#getDescription()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
|
||||
|
||||
/**
|
||||
* Set the {@link DistributionSet}
|
||||
*
|
||||
* @param set for {@link Rollout#getDistributionSet()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
default RolloutCreate distributionSetId(final DistributionSet set) {
|
||||
return distributionSetId(Optional.ofNullable(set).map(DistributionSet::getId).orElse(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the id of the {@link DistributionSet}
|
||||
*
|
||||
* @param distributionSetId for {@link Rollout#getDistributionSet()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutCreate distributionSetId(long distributionSetId);
|
||||
|
||||
/**
|
||||
* Set the {@link TargetFilterQuery}
|
||||
*
|
||||
* @param targetFilterQuery for {@link Rollout#getTargetFilterQuery()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutCreate targetFilterQuery(
|
||||
@Size(min = 1, max = TargetFilterQuery.QUERY_MAX_SIZE) @NotNull String targetFilterQuery);
|
||||
|
||||
/**
|
||||
* Set the {@link ActionType}
|
||||
*
|
||||
* @param actionType for {@link Rollout#getActionType()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutCreate actionType(@NotNull ActionType actionType);
|
||||
|
||||
/**
|
||||
* Set the forcedTime of the resulting {@link org.eclipse.hawkbit.repository.model.Action}s
|
||||
*
|
||||
* @param forcedTime for {@link Rollout#getForcedTime()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutCreate forcedTime(Long forcedTime);
|
||||
|
||||
/**
|
||||
* Set the weight of the resulting {@link org.eclipse.hawkbit.repository.model.Action}s
|
||||
*
|
||||
* @param weight for {@link Rollout#getWeight()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutCreate weight(Integer weight);
|
||||
|
||||
/**
|
||||
* Set if the rollout shall be dynamic
|
||||
*
|
||||
* @param dynamic for {@link Rollout#isDynamic()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutCreate dynamic(boolean dynamic);
|
||||
|
||||
/**
|
||||
* Set start at
|
||||
*
|
||||
* @param startAt for {@link Rollout#getStartAt()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutCreate startAt(Long startAt);
|
||||
|
||||
/**
|
||||
* @return peek on current state of {@link Rollout} in the builder
|
||||
*/
|
||||
Rollout build();
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
|
||||
/**
|
||||
* Builder for {@link Rollout}.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface RolloutGroupBuilder {
|
||||
|
||||
/**
|
||||
* @return builder instance
|
||||
*/
|
||||
RolloutGroupCreate create();
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
|
||||
/**
|
||||
* Builder to create a new {@link RolloutGroup} entry. Defines all fields that
|
||||
* can be set at creation time. Other fields are set by the repository
|
||||
* automatically, e.g. {@link BaseEntity#getCreatedAt()}.
|
||||
*/
|
||||
public interface RolloutGroupCreate {
|
||||
|
||||
/**
|
||||
* @param name for {@link Rollout#getName()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
|
||||
|
||||
/**
|
||||
* @param description for {@link Rollout#getDescription()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
|
||||
|
||||
/**
|
||||
* @param targetFilterQuery for {@link Rollout#getTargetFilterQuery()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate targetFilterQuery(
|
||||
@Size(min = 1, max = TargetFilterQuery.QUERY_MAX_SIZE) @NotNull String targetFilterQuery);
|
||||
|
||||
/**
|
||||
* @param targetPercentage the percentage of matching Targets that should be assigned to this Group
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate targetPercentage(Float targetPercentage);
|
||||
|
||||
/**
|
||||
* @param conditions as created by {@link RolloutGroupConditionBuilder}.
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate conditions(RolloutGroupConditions conditions);
|
||||
|
||||
/**
|
||||
* @param confirmationRequired if confirmation is required for this rollout group (considered
|
||||
* with confirmation flow active)
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate confirmationRequired(boolean confirmationRequired);
|
||||
|
||||
/**
|
||||
* @return peek on current state of {@link RolloutGroup} in the builder
|
||||
*/
|
||||
RolloutGroup build();
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
|
||||
/**
|
||||
* Builder to update an existing {@link Rollout} entry. Defines all fields that
|
||||
* can be updated.
|
||||
*/
|
||||
public interface RolloutUpdate {
|
||||
|
||||
/**
|
||||
* Set name of the {@link Rollout}
|
||||
*
|
||||
* @param name for {@link Rollout#getName()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutUpdate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
|
||||
|
||||
/**
|
||||
* Set description of the {@link Rollout}
|
||||
*
|
||||
* @param description for {@link Rollout#getDescription()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutUpdate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
|
||||
}
|
||||
@@ -10,10 +10,16 @@
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
|
||||
/**
|
||||
* Update operations to be executed by the target.
|
||||
@@ -338,4 +344,17 @@ public interface Action extends TenantAwareBaseEntity {
|
||||
DOWNLOAD_ONLY
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
class ActionStatusCreate {
|
||||
|
||||
private long actionId;
|
||||
|
||||
@NotNull
|
||||
private Status status;
|
||||
private Integer code;
|
||||
private Collection<@ValidString String> messages;
|
||||
|
||||
private Long occurredAt;
|
||||
}
|
||||
}
|
||||
@@ -94,4 +94,4 @@ public class RolloutGroupConditionBuilder {
|
||||
errorAction(RolloutGroupErrorAction.PAUSE, "");
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user