Deprecate PUT target tag multi-assignment (#2468)
* Deprecate PUT /rest/v1/targettags/{targetTagId}/assigned -> use new POST method with same endpoint and params
* Remove deprecated DS tag mulit-assigned PUT method /rest/v1/distributionsettags/{distributionsetTagId}/assigned -> use already existing POST method with same endpoint and params
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -391,17 +391,6 @@ public interface MgmtDistributionSetTagRestApi {
|
||||
@PathVariable("distributionsetTagId") Long distributionsetTagId,
|
||||
@RequestBody List<Long> distributionsetIds);
|
||||
|
||||
/**
|
||||
* @deprecated since 0.8.0, use {@link #assignDistributionSet(Long, Long)} (POST) instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "0.8.0")
|
||||
@PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING,
|
||||
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE },
|
||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<Void> assignDistributionSetsPut(
|
||||
@PathVariable("distributionsetTagId") Long distributionsetTagId,
|
||||
@RequestBody List<Long> distributionsetIds);
|
||||
|
||||
/**
|
||||
* Handles the DELETE request to unassign one distribution set from the given tag id.
|
||||
*
|
||||
|
||||
@@ -322,14 +322,26 @@ public interface MgmtTargetTagRestApi {
|
||||
@ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " +
|
||||
"and the client has to wait another second.")
|
||||
})
|
||||
@PutMapping(
|
||||
@PostMapping(
|
||||
value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING,
|
||||
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<Void> assignTargets(
|
||||
@PathVariable("targetTagId") Long targetTagId,
|
||||
@RequestParam(value = "onNotFoundPolicy", required = false, defaultValue = "FAIL") OnNotFoundPolicy onNotFoundPolicy,
|
||||
@Schema(description = "List of controller ids to be assigned", example = "[\"controllerId1\", \"controllerId2\"]")
|
||||
@RequestBody List<String> controllerIds);
|
||||
@RequestBody List<String> controllerIds,
|
||||
@RequestParam(value = "onNotFoundPolicy", required = false, defaultValue = "FAIL") OnNotFoundPolicy onNotFoundPolicy);
|
||||
|
||||
/**
|
||||
* @deprecated since 0.9.0, use {@link #assignTargets(Long, List, OnNotFoundPolicy)} (POST) instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "0.9.0")
|
||||
@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> assignTargetsPut(
|
||||
@PathVariable("targetTagId") Long targetTagId,
|
||||
@RequestBody List<String> controllerIds,
|
||||
@RequestParam(value = "onNotFoundPolicy", required = false, defaultValue = "FAIL") OnNotFoundPolicy onNotFoundPolicy);
|
||||
|
||||
/**
|
||||
* Handles the DELETE request to unassign one target from the given tag id.
|
||||
|
||||
@@ -29,8 +29,6 @@ import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
@@ -150,13 +148,6 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger("DEPRECATED_USAGE");
|
||||
@Override
|
||||
public ResponseEntity<Void> assignDistributionSetsPut(final Long distributionsetTagId, final List<Long> distributionsetIds) {
|
||||
LOGGER.debug("[DEPRECATED] Deprecated usage of assignDistributionSetsPut. Use assignDistributionSets (POST) instead.");
|
||||
return assignDistributionSets(distributionsetTagId, distributionsetIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@AuditLog(entity = "DistributionSetTag", type = AuditLog.Type.UPDATE, description = "Unassign Distribution Set From Tag")
|
||||
public ResponseEntity<Void> unassignDistributionSet(final Long distributionsetTagId, final Long distributionsetId) {
|
||||
|
||||
@@ -34,6 +34,8 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.utils.TenantConfigHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -146,7 +148,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> assignTargets(
|
||||
final Long targetTagId, final OnNotFoundPolicy onNotFoundPolicy, final List<String> controllerIds) {
|
||||
final Long targetTagId, final List<String> controllerIds, final OnNotFoundPolicy onNotFoundPolicy) {
|
||||
log.debug("Assign {} targets for target tag {}", controllerIds.size(), targetTagId);
|
||||
if (onNotFoundPolicy == OnNotFoundPolicy.FAIL) {
|
||||
this.targetManagement.assignTag(controllerIds, targetTagId);
|
||||
@@ -161,6 +163,13 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger("DEPRECATED_USAGE");
|
||||
@Override
|
||||
public ResponseEntity<Void> assignTargetsPut(final Long targetTagId, final List<String> controllerIds, final OnNotFoundPolicy onNotFoundPolicy) {
|
||||
LOGGER.debug("[DEPRECATED] Deprecated usage of assignTargetsPut. Use assignTargetsPut (POST) instead.");
|
||||
return assignTargets(targetTagId, controllerIds, onNotFoundPolicy);
|
||||
}
|
||||
|
||||
@Override
|
||||
@AuditLog(entity = "TargetTag", type = AuditLog.Type.UPDATE, description = "Unassign Target From Target Tag")
|
||||
public ResponseEntity<Void> unassignTarget(final Long targetTagId, final String controllerId) {
|
||||
|
||||
@@ -429,7 +429,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
|
||||
withMissing.addAll(missing);
|
||||
|
||||
mvc.perform(
|
||||
put(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
.content(JsonBuilder.toArray(withMissing))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
|
||||
@@ -314,7 +314,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
final Target assigned0 = targets.get(0);
|
||||
final Target assigned1 = targets.get(1);
|
||||
|
||||
mvc.perform(put(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
.content(JsonBuilder.toArray(Arrays.asList(assigned0.getControllerId(), assigned1.getControllerId())))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
@@ -347,7 +347,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
final List<String> withMissing = new ArrayList<>(targets);
|
||||
withMissing.addAll(missing);
|
||||
|
||||
mvc.perform(put(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
.content(JsonBuilder.toArray(withMissing))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
@@ -387,7 +387,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
final List<String> withMissing = new ArrayList<>(targets);
|
||||
withMissing.addAll(missing);
|
||||
|
||||
mvc.perform(put(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
.param("onNotFoundPolicy", MgmtTargetTagRestApi.OnNotFoundPolicy.ON_WHAT_FOUND_AND_FAIL.name())
|
||||
.content(JsonBuilder.toArray(withMissing))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
@@ -429,7 +429,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
final List<String> withMissing = new ArrayList<>(targets);
|
||||
withMissing.addAll(missing);
|
||||
|
||||
mvc.perform(put(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
.param("onNotFoundPolicy", MgmtTargetTagRestApi.OnNotFoundPolicy.ON_WHAT_FOUND_AND_SUCCESS.name())
|
||||
.content(JsonBuilder.toArray(withMissing))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
|
||||
Reference in New Issue
Block a user