netmaker/controllers/legacy.go
Matthew R Kasun 876778a1cc
open api spec file (#2595)
* remove usergroup

* superadmin

* superadmin creation

* generate openapi spec file

* statticcheck

* review comments
2023-10-04 10:26:38 +04:00

35 lines
974 B
Go

package controller
import (
"net/http"
"github.com/gorilla/mux"
"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/logic"
)
func legacyHandlers(r *mux.Router) {
r.HandleFunc("/api/v1/legacy/nodes", logic.SecurityCheck(true, http.HandlerFunc(wipeLegacyNodes))).Methods(http.MethodDelete)
}
// swagger:route DELETE /api/v1/legacy/nodes nodes wipeLegacyNodes
//
// Delete all legacy nodes from DB.
//
// Schemes: https
//
// Security:
// oauth
//
// Responses:
// 200: successResponse
func wipeLegacyNodes(w http.ResponseWriter, r *http.Request) {
// Set header
w.Header().Set("Content-Type", "application/json")
if err := logic.RemoveAllLegacyNodes(); err != nil {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
logger.Log(0, "error occurred when removing legacy nodes", err.Error())
}
logger.Log(0, r.Header.Get("user"), "wiped legacy nodes")
logic.ReturnSuccessResponse(w, r, "wiped all legacy nodes")
}