Introduce target grouping (#2538)

* Introduce target grouping

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>

* minor refactor

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>

* throw validation exception instead direct returning bad request response

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>

* fix group query parameter

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>

* remove wrongly added import

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>

* add review fixes

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>

* apply latest review changes

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>

* apply latest changes after sybnc/review

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>

* fix after review

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>

---------

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
This commit is contained in:
Stanislav Trailov
2025-07-14 15:48:37 +03:00
committed by GitHub
parent e7373275bf
commit b4793fcce1
23 changed files with 888 additions and 2 deletions

View File

@@ -620,6 +620,41 @@ public interface TargetManagement {
@PreAuthorize(HAS_AUTH_UPDATE_TARGET)
Target assignType(@NotEmpty String controllerId, @NotNull Long targetTypeId);
/**
* Finds targets by group or subgroup.
* @param group - provided group/subgroup to filter for
* @param withSubgroups - whether is a subgroup or not e.g. x/y/z
* @param pageable - page parameter
* @return all matching targets to provided group/subgroup
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findTargetsByGroup(@NotEmpty String group, boolean withSubgroups, @NotNull Pageable pageable);
/**
* Finds all the distinct target groups in the scope of a tenant
*
* @return list of all distinct target groups
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<String> findGroups();
/**
* Assigns the target group of the targets matching the provided rsql filter.
*
* @param group target group parameter
* @param rsql rsql filter for {@link Target}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
void assignTargetGroupWithRsql(String group, @NotNull String rsql);
/**
* Assigns the provided group to the targets which are in the provided list of controllerIds.
*
* @param group target group parameter
* @param controllerIds list of targets
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
void assignTargetsWithGroup(String group, @NotEmpty List<String> controllerIds);
/**
* updates the {@link Target}.
*

View File

@@ -73,6 +73,12 @@ public interface TargetCreate {
*/
TargetCreate status(@NotNull TargetUpdateStatus status);
/**
* @param group for setting the group of the target
* @return updated builder instance
*/
TargetCreate group(String group);
/**
* @return peek on current state of {@link Target} in the builder
*/

View File

@@ -70,4 +70,11 @@ public interface TargetUpdate {
* @return updated builder instance
*/
TargetUpdate requestAttributes(Boolean requestAttributes);
/**
*
* @param group for {@link Target#getGroup()}
* @return updated builder instance
*/
TargetUpdate group(String group);
}

View File

@@ -124,4 +124,10 @@ public interface Target extends NamedEntity {
* {@link #getControllerAttributes()}.
*/
boolean isRequestControllerAttributes();
/**
*
* @return the group of the target
*/
String getGroup();
}