MCPcopy
hub / github.com/dgraph-io/dgraph / DropNamespace

Method DropNamespace

edgraph/namespace.go:39–63  ·  view source on GitHub ↗
(ctx context.Context, in *api.DropNamespaceRequest)

Source from the content-addressed store, hash-verified

37}
38
39func (s *Server) DropNamespace(ctx context.Context, in *api.DropNamespaceRequest) (
40 *api.DropNamespaceResponse, error) {
41
42 if err := AuthSuperAdmin(ctx); err != nil {
43 s := status.Convert(err)
44 return nil, status.Error(s.Code(),
45 "Non superadmin user cannot drop namespace. "+s.Message())
46 }
47
48 if in.Namespace == 0 {
49 glog.Infof("Namespace [%v] cannot be deleted", in.Namespace)
50 return nil, fmt.Errorf("namespace [%v] cannot be deleted", in.Namespace)
51 }
52
53 if err := (&Server{}).DeleteNamespace(ctx, in.Namespace); err != nil {
54 if !strings.Contains(err.Error(), "error deleting non-existing namespace") {
55 return nil, err
56 } else {
57 glog.Infof("Namespace with id [%d] does not exist, cannot be deleted", in.Namespace)
58 }
59 }
60
61 glog.Infof("Dropped namespace [%v]", in.Namespace)
62 return &api.DropNamespaceResponse{}, nil
63}
64
65func (s *Server) ListNamespaces(ctx context.Context, in *api.ListNamespacesRequest) (
66 *api.ListNamespacesResponse, error) {

Callers 2

TestNamespacesFunction · 0.80
TestDropNamespaceErrFunction · 0.80

Calls 6

AuthSuperAdminFunction · 0.85
CodeMethod · 0.80
InfofMethod · 0.80
DeleteNamespaceMethod · 0.65
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by 2

TestNamespacesFunction · 0.64
TestDropNamespaceErrFunction · 0.64