DeleteService deletes a service account.
(ctx context.Context, req *adminv1.DeleteServiceRequest)
| 400 | |
| 401 | // DeleteService deletes a service account. |
| 402 | func (s *Server) DeleteService(ctx context.Context, req *adminv1.DeleteServiceRequest) (*adminv1.DeleteServiceResponse, error) { |
| 403 | observability.AddRequestAttributes(ctx, |
| 404 | attribute.String("args.name", req.Name), |
| 405 | attribute.String("args.organization_name", req.Org), |
| 406 | ) |
| 407 | |
| 408 | org, err := s.admin.DB.FindOrganizationByName(ctx, req.Org) |
| 409 | if err != nil { |
| 410 | return nil, err |
| 411 | } |
| 412 | |
| 413 | service, err := s.admin.DB.FindServiceByName(ctx, org.ID, req.Name) |
| 414 | if err != nil { |
| 415 | return nil, err |
| 416 | } |
| 417 | |
| 418 | claims := auth.GetClaims(ctx) |
| 419 | if !claims.OrganizationPermissions(ctx, org.ID).ManageOrg { |
| 420 | return nil, status.Error(codes.PermissionDenied, "not allowed to delete service") |
| 421 | } |
| 422 | |
| 423 | err = s.admin.DB.DeleteService(ctx, service.ID) |
| 424 | if err != nil { |
| 425 | return nil, err |
| 426 | } |
| 427 | |
| 428 | return &adminv1.DeleteServiceResponse{}, nil |
| 429 | } |
| 430 | |
| 431 | // ListServiceAuthTokens lists all auth tokens for a service account. |
| 432 | func (s *Server) ListServiceAuthTokens(ctx context.Context, req *adminv1.ListServiceAuthTokensRequest) (*adminv1.ListServiceAuthTokensResponse, error) { |
nothing calls this directly
no test coverage detected