mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-12 03:05:14 +00:00
More admin data delete endpoints (#361)
This commit is contained in:
@@ -6,9 +6,12 @@ import (
|
||||
|
||||
"github.com/micro/micro/v3/service"
|
||||
"github.com/micro/micro/v3/service/errors"
|
||||
"github.com/micro/micro/v3/service/logger"
|
||||
"github.com/micro/services/location/domain"
|
||||
loc "github.com/micro/services/location/proto"
|
||||
"github.com/micro/services/location/subscriber"
|
||||
pauth "github.com/micro/services/pkg/auth"
|
||||
adminpb "github.com/micro/services/pkg/service/proto"
|
||||
)
|
||||
|
||||
type Location struct{}
|
||||
@@ -70,3 +73,21 @@ func (l *Location) Search(ctx context.Context, req *loc.SearchRequest, rsp *loc.
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *Location) DeleteData(ctx context.Context, request *adminpb.DeleteDataRequest, response *adminpb.DeleteDataResponse) error {
|
||||
method := "admin.DeleteData"
|
||||
_, err := pauth.VerifyMicroAdmin(ctx, method)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(request.TenantId) == 0 {
|
||||
return errors.BadRequest(method, "Missing tenant ID")
|
||||
}
|
||||
|
||||
if err := domain.DeleteIndex(request.TenantId); err != nil {
|
||||
return err
|
||||
}
|
||||
logger.Infof("Deleted index for %s", request.TenantId)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user