summaryrefslogtreecommitdiffstats
path: root/api4/elasticsearch.go
diff options
context:
space:
mode:
Diffstat (limited to 'api4/elasticsearch.go')
-rw-r--r--api4/elasticsearch.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/api4/elasticsearch.go b/api4/elasticsearch.go
index 9eafec48b..c8af8089b 100644
--- a/api4/elasticsearch.go
+++ b/api4/elasticsearch.go
@@ -16,6 +16,7 @@ func InitElasticsearch() {
l4g.Debug(utils.T("api.elasticsearch.init.debug"))
BaseRoutes.Elasticsearch.Handle("/test", ApiSessionRequired(testElasticsearch)).Methods("POST")
+ BaseRoutes.Elasticsearch.Handle("/purge_indexes", ApiSessionRequired(purgeElasticsearchIndexes)).Methods("POST")
}
func testElasticsearch(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -36,3 +37,17 @@ func testElasticsearch(c *Context, w http.ResponseWriter, r *http.Request) {
ReturnStatusOK(w)
}
+
+func purgeElasticsearchIndexes(c *Context, w http.ResponseWriter, r *http.Request) {
+ if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
+ c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
+ return
+ }
+
+ if err := app.PurgeElasticsearchIndexes(); err != nil {
+ c.Err = err
+ return
+ }
+
+ ReturnStatusOK(w)
+}