| 37 | } |
| 38 | |
| 39 | func (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 | |
| 65 | func (s *Server) ListNamespaces(ctx context.Context, in *api.ListNamespacesRequest) ( |
| 66 | *api.ListNamespacesResponse, error) { |