-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement refresh endpoint (as an admin endpoint) (#522)
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
onyxia-api/src/main/java/fr/insee/onyxia/api/controller/api/admin/AdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package fr.insee.onyxia.api.controller.api.admin; | ||
|
||
import fr.insee.onyxia.api.dao.universe.*; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.annotation.PostConstruct; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "Admin", description = "Restricted API endpoints") | ||
@RequestMapping("/admin") | ||
@RestController | ||
@SecurityRequirement(name = "auth") | ||
@ConditionalOnExpression("'${admin.enabled}' == 'true'") | ||
public class AdminController { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(AdminController.class); | ||
private final CatalogRefresher catalogRefresher; | ||
|
||
@PostConstruct | ||
private void postConstruct() { | ||
LOGGER.warn( | ||
""" | ||
ADMIN MODE IS ENABLED, DON'T USE THIS IN PRODUCTION | ||
"""); | ||
} | ||
|
||
@Autowired | ||
public AdminController(CatalogRefresher catalogRefresher) { | ||
this.catalogRefresher = catalogRefresher; | ||
} | ||
|
||
@GetMapping("/refreshCatalogs") | ||
public void refreshCatalogs() { | ||
catalogRefresher.run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters