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:
Avgustin Marinov
2024-09-19 13:56:59 +03:00
committed by GitHub
parent 48db65a8ef
commit aed717df57
3 changed files with 55 additions and 12 deletions

View File

@@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
@@ -321,19 +322,51 @@ public interface MgmtTargetTagRestApi {
List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies);
/**
* Handles the POST request to assign targets to the given tag id.
* Handles the PUT request to assign targets to the given tag id.
*
* @param targetTagId
* the ID of the target tag to retrieve
* @param assignedTargetRequestBodies
* list of controller ids to be assigned
* @param targetTagId the ID of the target tag to retrieve
* @param assignedTargetControlIdsStream stream of controller ids to be assigned
*
* @return the list of assigned targets.
*/
@Operation(summary = "Assign target(s) to given tagId",
description = "Handles the POST request of target assignment. Already assigned target will be ignored.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully retrieved"),
@ApiResponse(responseCode = "200", description = "Successfully assigned"),
@ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionInfo.class))),
@ApiResponse(responseCode = "401", description = "The request requires user authentication."),
@ApiResponse(responseCode = "403", description = "Insufficient permissions, entity is not allowed to be " +
"changed (i.e. read-only) or data volume restriction applies."),
@ApiResponse(responseCode = "405", description = "The http request method is not allowed on the resource."),
@ApiResponse(responseCode = "406", description = "In case accept header is specified and not application/json."),
@ApiResponse(responseCode = "409", description = "E.g. in case an entity is created or modified by another " +
"user in another request at the same time. You may retry your modification request."),
@ApiResponse(responseCode = "415", description = "The request was attempt with a media-type which is not " +
"supported by the server for this resource."),
@ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " +
"and the client has to wait another second.")
})
@PutMapping(
value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING,
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE } )
ResponseEntity<Void> assignTargetsByControllerIds(
@PathVariable("targetTagId") Long targetTagId,
@Schema(description = "List of controller ids to be assigned", example = "[\"controllerId1\", \"controllerId2\"]")
@RequestBody List<String> assignedTargetControlIds);
/**
* Handles the POST request to assign targets to the given tag id.
*
* @param targetTagId the ID of the target tag to retrieve
* @param assignedTargetRequestBodies list of controller ids to be assigned
*
* @return the list of assigned targets.
*/
@Operation(summary = "Assign target(s) to given tagId and return targets",
description = "Handles the POST request of target assignment. Already assigned target will be ignored.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully assigned"),
@ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionInfo.class))),
@ApiResponse(responseCode = "401", description = "The request requires user authentication."),