Improve Target Tag REST & management API (#1880)
* added methods to unassign by multiple controller ids * deprecated toggle assigments - too complex to undestand * deprecated unassign (management) of single controller id - in favour of methods with controller ids Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -179,17 +179,21 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
}
|
||||
|
||||
@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);
|
||||
public ResponseEntity<Void> assignTargets(final Long targetTagId, final List<String> controllerIds) {
|
||||
log.debug("Assign {} targets for target tag {}", controllerIds.size(), targetTagId);
|
||||
this.targetManagement.assignTag(controllerIds, targetTagId);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<MgmtTarget>> assignTargets(@PathVariable("targetTagId") final Long targetTagId,
|
||||
public ResponseEntity<Void> unassignTargets(final Long targetTagId, final List<String> controllerIds) {
|
||||
log.debug("Unassign {} targets for target tag {}", controllerIds.size(), targetTagId);
|
||||
this.targetManagement.unassignTag(controllerIds, targetTagId);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<MgmtTarget>> assignTargetsByRequestBody(@PathVariable("targetTagId") final Long targetTagId,
|
||||
@RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies) {
|
||||
log.debug("Assign targets {} for target tag {}", assignedTargetRequestBodies, targetTagId);
|
||||
final List<Target> assignedTarget = this.targetManagement
|
||||
|
||||
@@ -304,7 +304,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
@Description("Verfies that tag assignments done through tag API command are correctly stored in the repository.")
|
||||
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2) })
|
||||
public void assignTargets() throws Exception {
|
||||
public void assignTargetsByRequestBody() throws Exception {
|
||||
final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0);
|
||||
final int targetsAssigned = 2;
|
||||
final List<Target> targets = testdataFactory.createTargets(targetsAssigned);
|
||||
|
||||
Reference in New Issue
Block a user