Add support for efficient tagging and BIG set of targets (#1844)
Adding a method with: * optimized payload - just controller ids * no response payload - not needed for that use-case * targeting - thousands of targets tagged at once Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -12,6 +12,7 @@ package org.eclipse.hawkbit.mgmt.rest.resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedTargetRequestBody;
|
||||
@@ -177,10 +178,20 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
return ResponseEntity.ok(tagAssigmentResultRest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> assignTargetsByControllerIds(
|
||||
@PathVariable("targetTagId") Long targetTagId,
|
||||
@Schema(description = "List of controller ids to be assigned", example = "[\"controllerId1\", \"controllerId2\"]")
|
||||
@RequestBody List<String> assignedTargetControlIds) {
|
||||
log.debug("Assign {} targets for target tag {}", assignedTargetControlIds.size(), targetTagId);
|
||||
this.targetManagement.assignTag(assignedTargetControlIds, targetTagId);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<MgmtTarget>> assignTargets(@PathVariable("targetTagId") final Long targetTagId,
|
||||
@RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies) {
|
||||
log.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
||||
log.debug("Assign targets {} for target tag {}", assignedTargetRequestBodies, targetTagId);
|
||||
final List<Target> assignedTarget = this.targetManagement
|
||||
.assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTagId);
|
||||
return ResponseEntity.ok(MgmtTargetMapper.toResponse(assignedTarget, tenantConfigHelper));
|
||||
@@ -204,5 +215,4 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
return assignedTargetRequestBodies.stream().map(MgmtAssignedTargetRequestBody::getControllerId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user