Skip to content
Snippets Groups Projects
Commit 2bbf71ae authored by Mina Otgonbold's avatar Mina Otgonbold
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://community.opengroup.org/osdu/platform/system/indexer-service into cache-control-for-queryattributeapi
parents 0b56031e abb0dec4
No related branches found
No related tags found
2 merge requests!346Merge branch 'aws-integration' into 'master',!306Fix swagger for indexer service
...@@ -205,6 +205,8 @@ CC-BY-2.5 ...@@ -205,6 +205,8 @@ CC-BY-2.5
======================================================================== ========================================================================
CC0-1.0 CC0-1.0
======================================================================== ========================================================================
The following software have components provided under the terms of this license:
- reactive-streams (from http://www.reactive-streams.org/) - reactive-streams (from http://www.reactive-streams.org/)
======================================================================== ========================================================================
...@@ -221,11 +223,13 @@ The following software have components provided under the terms of this license: ...@@ -221,11 +223,13 @@ The following software have components provided under the terms of this license:
- HK2 Spring Bridge (from https://repo1.maven.org/maven2/org/glassfish/hk2/spring-bridge) - HK2 Spring Bridge (from https://repo1.maven.org/maven2/org/glassfish/hk2/spring-bridge)
- HK2 config types (from https://repo1.maven.org/maven2/org/glassfish/hk2/config-types) - HK2 config types (from https://repo1.maven.org/maven2/org/glassfish/hk2/config-types)
- HK2 configuration module (from https://repo1.maven.org/maven2/org/glassfish/hk2/hk2-config) - HK2 configuration module (from https://repo1.maven.org/maven2/org/glassfish/hk2/hk2-config)
- HK2 module of HK2 itself (from https://repo1.maven.org/maven2/org/glassfish/hk2/hk2)
- Java Architecture for XML Binding (from http://jaxb.java.net/, https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api) - Java Architecture for XML Binding (from http://jaxb.java.net/, https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api)
- JavaBeans Activation Framework - JavaBeans Activation Framework
- JavaBeans(TM) Activation Framework (from http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp) - JavaBeans(TM) Activation Framework (from http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp)
- JavaMail API (from https://repo1.maven.org/maven2/com/sun/mail/javax.mail) - JavaMail API (from https://repo1.maven.org/maven2/com/sun/mail/javax.mail)
- OSGi resource locator (from https://repo1.maven.org/maven2/org/glassfish/hk2/osgi-resource-locator) - OSGi resource locator (from https://repo1.maven.org/maven2/org/glassfish/hk2/osgi-resource-locator)
- Run Level Service (from https://repo1.maven.org/maven2/org/glassfish/hk2/hk2-runlevel)
- Servlet Specification 2.5 API (from http://jetty.mortbay.org, https://repo1.maven.org/maven2/org/mortbay/jetty/servlet-api-2.5) - Servlet Specification 2.5 API (from http://jetty.mortbay.org, https://repo1.maven.org/maven2/org/mortbay/jetty/servlet-api-2.5)
- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250) - javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250)
- tomcat-embed-core (from http://tomcat.apache.org/) - tomcat-embed-core (from http://tomcat.apache.org/)
...@@ -434,7 +438,7 @@ public-domain ...@@ -434,7 +438,7 @@ public-domain
======================================================================== ========================================================================
The following software have components provided under the terms of this license: The following software have components provided under the terms of this license:
- Bouncy Castle PKIX, CMS, EAC, TSP, PKCS, OCSP, CMP, and CRMF APIs (from http://www.bouncycastle.org/java.html, https://www.bouncycastle.org/java.html) - Bouncy Castle PKIX, CMS, EAC, TSP, PKCS, OCSP, CMP, and CRMF APIs (from http://www.bouncycastle.org/java.html, https://maven.repository.redhat.com/ga/org/bouncycastle/bcpkix-jdk15on, https://www.bouncycastle.org/java.html)
- Bouncy Castle Provider (from http://www.bouncycastle.org/java.html, https://www.bouncycastle.org/java.html) - Bouncy Castle Provider (from http://www.bouncycastle.org/java.html, https://www.bouncycastle.org/java.html)
- Guava: Google Core Libraries for Java (from http://code.google.com/p/guava-libraries, https://github.com/google/guava, https://repo1.maven.org/maven2/com/google/guava/guava) - Guava: Google Core Libraries for Java (from http://code.google.com/p/guava-libraries, https://github.com/google/guava, https://repo1.maven.org/maven2/com/google/guava/guava)
- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/)
...@@ -452,7 +456,7 @@ unknown ...@@ -452,7 +456,7 @@ unknown
======================================================================== ========================================================================
The following software have components provided under the terms of this license: The following software have components provided under the terms of this license:
- Bouncy Castle PKIX, CMS, EAC, TSP, PKCS, OCSP, CMP, and CRMF APIs (from http://www.bouncycastle.org/java.html, https://www.bouncycastle.org/java.html) - Bouncy Castle PKIX, CMS, EAC, TSP, PKCS, OCSP, CMP, and CRMF APIs (from http://www.bouncycastle.org/java.html, https://maven.repository.redhat.com/ga/org/bouncycastle/bcpkix-jdk15on, https://www.bouncycastle.org/java.html)
- Bouncy Castle Provider (from http://www.bouncycastle.org/java.html, https://www.bouncycastle.org/java.html) - Bouncy Castle Provider (from http://www.bouncycastle.org/java.html, https://www.bouncycastle.org/java.html)
- Byte Buddy (without dependencies) (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy) - Byte Buddy (without dependencies) (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy)
- Checker Qual (from https://checkerframework.org) - Checker Qual (from https://checkerframework.org)
......
...@@ -119,3 +119,5 @@ spec: ...@@ -119,3 +119,5 @@ spec:
value: "true" value: "true"
- name: azure_activedirectory_AppIdUri - name: azure_activedirectory_AppIdUri
value: "api://$(aad_client_id)" value: "api://$(aad_client_id)"
- name: SPRING_CONFIG_NAME
value: "common,application"
\ No newline at end of file
...@@ -145,6 +145,24 @@ will use the same schema and overwrite records with the same ids. Default value ...@@ -145,6 +145,24 @@ will use the same schema and overwrite records with the same ids. Default value
[Back to table of contents](#TOC) [Back to table of contents](#TOC)
## Delete API <a name="delete"></a>
Delete API is used to delete an index for a specific kind.
Only users who belong to the Entitlement groups 'users.datalake.ops' can make calls to this API.
```
DELETE /api/indexer/v2/index?kind=opendes:welldb:wellbore:1.0.0
```
<details><summary>**Curl**</summary>
```bash
curl --request DELETE \
--url '/api/indexer/v2/index?kind=opendes:welldb:wellbore:1.0.0' \
--header 'authorization: Bearer <JWT>' \
--header 'content-type: application/json' \
--header 'data-partition-id: opendes'
```
### Data Partition provision <a name="data-partition-provision"></a> ### Data Partition provision <a name="data-partition-provision"></a>
Configures Search backend for a data partition. Configures Search backend for a data partition.
......
...@@ -20,7 +20,9 @@ import com.google.gson.JsonParseException; ...@@ -20,7 +20,9 @@ import com.google.gson.JsonParseException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import lombok.extern.java.Log; import lombok.extern.java.Log;
import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.AppException;
...@@ -28,18 +30,25 @@ import org.opengroup.osdu.core.common.model.http.DpsHeaders; ...@@ -28,18 +30,25 @@ 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.indexer.RecordInfo;
import org.opengroup.osdu.core.common.model.search.RecordChangedMessages; 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.search.SearchServiceRole;
import org.opengroup.osdu.core.common.model.storage.validation.ValidKind;
import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver;
import org.opengroup.osdu.indexer.SwaggerDoc; import org.opengroup.osdu.indexer.SwaggerDoc;
import org.opengroup.osdu.indexer.logging.AuditLogger; import org.opengroup.osdu.indexer.logging.AuditLogger;
import org.opengroup.osdu.indexer.service.IndexerService; import org.opengroup.osdu.indexer.service.IndexerService;
import org.opengroup.osdu.indexer.service.IndicesServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; 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.bind.annotation.RestController;
import org.springframework.web.context.annotation.RequestScope; import org.springframework.web.context.annotation.RequestScope;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import static java.util.Collections.singletonList;
@Log @Log
@RestController @RestController
...@@ -52,6 +61,14 @@ public class CleanupIndiciesApi { ...@@ -52,6 +61,14 @@ public class CleanupIndiciesApi {
@Autowired @Autowired
private AuditLogger auditLogger; private AuditLogger auditLogger;
@Inject
private ElasticIndexNameResolver elasticIndexNameResolver;
@Inject
private IndicesServiceImpl indicesService;
private static final String ENTITLEMENT_GROUP = "users.datalake.ops";
@ApiIgnore @ApiIgnore
@PostMapping(path = "/index-cleanup", consumes = "application/json") @PostMapping(path = "/index-cleanup", consumes = "application/json")
@PreAuthorize("@authorizationFilter.hasPermission('" + SearchServiceRole.ADMIN + "')") @PreAuthorize("@authorizationFilter.hasPermission('" + SearchServiceRole.ADMIN + "')")
...@@ -89,4 +106,22 @@ public class CleanupIndiciesApi { ...@@ -89,4 +106,22 @@ public class CleanupIndiciesApi {
throw new AppException(HttpStatus.BAD_REQUEST.value(), "Unknown error", "An unknown error has occurred.", e); throw new AppException(HttpStatus.BAD_REQUEST.value(), "Unknown error", "An unknown error has occurred.", e);
} }
} }
@DeleteMapping(value = "/index", produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("@authorizationFilter.hasPermission('" + ENTITLEMENT_GROUP + "')")
public ResponseEntity deleteIndex(@RequestParam("kind") @NotBlank @ValidKind String kind) {
String index = elasticIndexNameResolver.getIndexNameFromKind(kind);
try {
boolean responseStatus = indicesService.deleteIndex(index);
if (responseStatus) {
this.auditLogger.indexDeleteSuccess(singletonList(index));
}
return new ResponseEntity(HttpStatus.OK);
} catch (AppException e) {
throw e;
} catch (Exception e) {
this.auditLogger.indexDeleteFail(singletonList(index));
throw new AppException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Unknown error", "An unknown error has occurred.", e);
}
}
} }
...@@ -59,6 +59,10 @@ public class AuditEvents { ...@@ -59,6 +59,10 @@ public class AuditEvents {
private static final String CONFIGURE_PARTITION_ACTION_ID = "IN0012"; private static final String CONFIGURE_PARTITION_ACTION_ID = "IN0012";
private static final String CONFIGURE_PARTITION_OPERATION = "Data partition cluster configuration update"; private static final String CONFIGURE_PARTITION_OPERATION = "Data partition cluster configuration update";
private static final String INDEX_DELETE_ACTION_ID = "IN0013";
private static final String INDEX_DELETE_SUCCESS = "Successfully deleted index";
private static final String INDEX_DELETE_FAILURE = "Failed deleting index";
private final String user; private final String user;
public AuditEvents(String user) { public AuditEvents(String user) {
...@@ -134,6 +138,28 @@ public class AuditEvents { ...@@ -134,6 +138,28 @@ public class AuditEvents {
.build(); .build();
} }
public AuditPayload getIndexDeleteFailEvent(List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.DELETE)
.status(AuditStatus.FAILURE)
.actionId(INDEX_DELETE_ACTION_ID)
.message(INDEX_DELETE_FAILURE)
.resources(resources)
.user(this.user)
.build();
}
public AuditPayload getIndexDeleteSuccessEvent(List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.DELETE)
.status(AuditStatus.SUCCESS)
.actionId(INDEX_DELETE_ACTION_ID)
.message(INDEX_DELETE_SUCCESS)
.resources(resources)
.user(this.user)
.build();
}
public AuditPayload getIndexPurgeRecordSuccessEvent(List<String> resources) { public AuditPayload getIndexPurgeRecordSuccessEvent(List<String> resources) {
return AuditPayload.builder() return AuditPayload.builder()
.action(AuditAction.DELETE) .action(AuditAction.DELETE)
......
...@@ -65,6 +65,14 @@ public class AuditLogger { ...@@ -65,6 +65,14 @@ public class AuditLogger {
this.writeLog(this.getAuditEvents().getIndexDeleteRecordFailEvent(resources)); this.writeLog(this.getAuditEvents().getIndexDeleteRecordFailEvent(resources));
} }
public void indexDeleteSuccess(List<String> resources) {
this.writeLog(this.getAuditEvents().getIndexDeleteSuccessEvent(resources));
}
public void indexDeleteFail(List<String> resources) {
this.writeLog(this.getAuditEvents().getIndexDeleteFailEvent(resources));
}
public void indexPurgeRecordSuccess(List<String> resources) { public void indexPurgeRecordSuccess(List<String> resources) {
this.writeLog(this.getAuditEvents().getIndexPurgeRecordSuccessEvent(resources)); this.writeLog(this.getAuditEvents().getIndexPurgeRecordSuccessEvent(resources));
} }
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<nimbus-jose-jwt.version>8.2</nimbus-jose-jwt.version> <nimbus-jose-jwt.version>8.2</nimbus-jose-jwt.version>
<indexer-core.version>0.15.0-SNAPSHOT</indexer-core.version> <indexer-core.version>0.15.0-SNAPSHOT</indexer-core.version>
<spring-security-jwt.version>1.1.1.RELEASE</spring-security-jwt.version> <spring-security-jwt.version>1.1.1.RELEASE</spring-security-jwt.version>
<osdu.corelibazure.version>0.14.0-rc2</osdu.corelibazure.version> <osdu.corelibazure.version>0.15.0-rc1</osdu.corelibazure.version>
<reactor-netty.version>0.9.12.RELEASE</reactor-netty.version> <reactor-netty.version>0.9.12.RELEASE</reactor-netty.version>
<java-jwt.version>3.8.1</java-jwt.version> <java-jwt.version>3.8.1</java-jwt.version>
<powermock.version>2.0.2</powermock.version> <powermock.version>2.0.2</powermock.version>
......
...@@ -92,6 +92,7 @@ tenantFactoryImpl.required=true ...@@ -92,6 +92,7 @@ tenantFactoryImpl.required=true
management.server.port=8081 management.server.port=8081
management.health.azure-key-vault.enabled=false management.health.azure-key-vault.enabled=false
management.health.elasticsearch.enabled=false management.health.elasticsearch.enabled=false
azure.health.endpoint.enabled=true
management.endpoints.web.exposure.include=${web_exposure_endpoints:health,info} management.endpoints.web.exposure.include=${web_exposure_endpoints:health,info}
management.metrics.enable.all=${enable_metrics:false} management.metrics.enable.all=${enable_metrics:false}
......
...@@ -56,6 +56,7 @@ import org.opengroup.osdu.core.common.model.indexer.RecordIndexerPayload; ...@@ -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.RecordInfo;
import org.opengroup.osdu.core.common.model.indexer.RecordStatus; 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.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.RecordChangedMessages;
import org.opengroup.osdu.core.common.model.search.RecordMetaAttribute; import org.opengroup.osdu.core.common.model.search.RecordMetaAttribute;
import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo; 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