private void deleteDatasetVersion(RestRequest restRequest) throws RestServiceException {
      long startDeleteDatasetVersionTime = System.currentTimeMillis();
      String accountName = null;
      String containerName = null;
      String datasetName = null;
      String version = null;
      try {
        Dataset dataset = (Dataset) restRequest.getArgs().get(InternalKeys.TARGET_DATASET);
        accountName = dataset.getAccountName();
        containerName = dataset.getContainerName();
        datasetName = dataset.getDatasetName();
        version = (String) restRequest.getArgs().get(TARGET_DATASET_VERSION);
        if (restRequest.getArgs().get(DATASET_DELETE_ENABLED) != null) {
          accountService.deleteDatasetVersionForDatasetDelete(accountName, containerName, datasetName, version);
        } else {
          accountService.deleteDatasetVersion(accountName, containerName, datasetName, version);
        }
        LOGGER.debug(
            "Successfully deleteDataset version for accountName: " + accountName + " containerName: " + containerName
                + " datasetName: " + datasetName + " version: " + version);
        metrics.deleteDatasetVersionProcessingTimeInMs.update(
            System.currentTimeMillis() - startDeleteDatasetVersionTime);
        // If version is null, use the latest version + 1 from DatasetVersionRecord to construct named blob path.
      } catch (AccountServiceException ex) {
        LOGGER.error(
            "Failed to delete dataset version for accountName: " + accountName + " containerName: " + containerName
                + " datasetName: " + datasetName + " version: " + version, ex);
        throw new RestServiceException(ex.getMessage(),
            RestServiceErrorCode.getRestServiceErrorCode(ex.getErrorCode()));
      }
    }
Support delete dataset version.
@param restRequest restRequest {@link RestRequest} representing the request.
@throws RestServiceException
ambry-frontend/src/main/java/com/github/ambry/frontend/DeleteBlobHandler.java