Skip to content
Snippets Groups Projects
Commit a2ee4b34 authored by Zhibin Mai's avatar Zhibin Mai
Browse files

Merge the new api to PartitionSetup endpoint

parent acdbc611
No related branches found
No related tags found
1 merge request!496Provide an endpoint to create aliases for all existing indices that do not have aliases
/*
* Copyright © Schlumberger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0 *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opengroup.osdu.indexer.api;
import org.opengroup.osdu.core.common.model.search.SearchServiceRole;
import org.opengroup.osdu.indexer.model.IndexAliasesResult;
import org.opengroup.osdu.indexer.service.IndexAliasService;
import org.springframework.http.HttpStatus;
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.RestController;
import org.springframework.web.context.annotation.RequestScope;
import javax.inject.Inject;
@RestController
@RequestScope
public class IndexProvisionApi {
@Inject
private IndexAliasService indexAliasService;
@PreAuthorize("@authorizationFilter.hasPermission('" + SearchServiceRole.ADMIN + "')")
@PostMapping(path = "/aliases")
public ResponseEntity<IndexAliasesResult> createIndexAliases() {
IndexAliasesResult result = indexAliasService.createIndexAliasesForAll();
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
......@@ -15,14 +15,14 @@
package org.opengroup.osdu.indexer.api;
import org.opengroup.osdu.indexer.logging.AuditLogger;
import org.opengroup.osdu.indexer.model.IndexAliasesResult;
import org.opengroup.osdu.indexer.service.IClusterConfigurationService;
import org.opengroup.osdu.indexer.service.IndexAliasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.annotation.RequestScope;
import java.io.IOException;
......@@ -37,6 +37,8 @@ public class PartitionSetupApi {
private static final String OPS = "users.datalake.ops";
@Autowired
private IndexAliasService indexAliasService;
@Autowired
private IClusterConfigurationService clusterConfigurationService;
@Autowired
......@@ -49,4 +51,11 @@ public class PartitionSetupApi {
this.auditLogger.getConfigurePartition(singletonList(dataPartitionId));
return new ResponseEntity<>(org.springframework.http.HttpStatus.OK);
}
@PreAuthorize("@authorizationFilter.hasPermission('" + OPS + "')")
@PostMapping(path = "/aliases")
public ResponseEntity<IndexAliasesResult> createIndexAliases() {
IndexAliasesResult result = indexAliasService.createIndexAliasesForAll();
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
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