Skip to content
Snippets Groups Projects
Commit 89547763 authored by Smitha Manjunath's avatar Smitha Manjunath
Browse files

add delete api

parent 10f89783
No related branches found
No related tags found
2 merge requests!346Merge branch 'aws-integration' into 'master',!273Delete api
......@@ -21,6 +21,7 @@ import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collectors;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import lombok.extern.java.Log;
import org.opengroup.osdu.core.common.model.http.AppException;
......@@ -28,6 +29,7 @@ import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.indexer.RecordInfo;
import org.opengroup.osdu.core.common.model.search.RecordChangedMessages;
import org.opengroup.osdu.core.common.model.search.SearchServiceRole;
import org.opengroup.osdu.core.common.model.storage.validation.ValidKind;
import org.opengroup.osdu.indexer.SwaggerDoc;
import org.opengroup.osdu.indexer.logging.AuditLogger;
import org.opengroup.osdu.indexer.service.IndexerService;
......@@ -37,6 +39,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.annotation.RequestScope;
import springfox.documentation.annotations.ApiIgnore;
......@@ -89,4 +92,19 @@ public class CleanupIndiciesApi {
throw new AppException(HttpStatus.BAD_REQUEST.value(), "Unknown error", "An unknown error has occurred.", e);
}
}
public ResponseEntity deleteIndex(@RequestParam("kind") @NotBlank @ValidKind String kind) {
try {
String index = elasticIndexNameResolver.getIndexNameFromKind(kind);
boolean responseStatus = indicesService.deleteIndex(index);
if (responseStatus) {
return new ResponseEntity(HttpStatus.OK);
}
} catch (AppException e) {
throw e;
} catch (Exception e) {
throw new AppException(HttpStatus.BAD_REQUEST.value(), "Unknown error", "An unknown error has occurred.", e);
}
return new ResponseEntity(HttpStatus.BAD_REQUEST);
}
}
......@@ -56,6 +56,7 @@ import org.opengroup.osdu.core.common.model.indexer.RecordIndexerPayload;
import org.opengroup.osdu.core.common.model.indexer.RecordInfo;
import org.opengroup.osdu.core.common.model.indexer.RecordStatus;
import org.opengroup.osdu.core.common.model.indexer.Records;
import org.opengroup.osdu.core.common.model.search.IndexInfo;
import org.opengroup.osdu.core.common.model.search.RecordChangedMessages;
import org.opengroup.osdu.core.common.model.search.RecordMetaAttribute;
import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment