PLT-6595: API to purge Elasticsearch indexes. (#6971)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
97f34e483b
Коммит
fe368a7456
@@ -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)
|
||||
}
|
||||
|
||||
@@ -17,3 +17,14 @@ func TestElasticsearchTest(t *testing.T) {
|
||||
_, resp = th.SystemAdminClient.TestElasticsearch()
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestElasticsearchPurgeIndexes(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
|
||||
_, resp := th.Client.PurgeElasticsearchIndexes()
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
_, resp = th.SystemAdminClient.PurgeElasticsearchIndexes()
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user