(ctx context.Context, req *adminv1.GetProjectByIDRequest)
| 374 | } |
| 375 | |
| 376 | func (s *Server) GetProjectByID(ctx context.Context, req *adminv1.GetProjectByIDRequest) (*adminv1.GetProjectByIDResponse, error) { |
| 377 | observability.AddRequestAttributes(ctx, |
| 378 | attribute.String("args.project_id", req.Id), |
| 379 | ) |
| 380 | |
| 381 | proj, err := s.admin.DB.FindProject(ctx, req.Id) |
| 382 | if err != nil { |
| 383 | return nil, err |
| 384 | } |
| 385 | |
| 386 | org, err := s.admin.DB.FindOrganization(ctx, proj.OrganizationID) |
| 387 | if err != nil { |
| 388 | return nil, err |
| 389 | } |
| 390 | |
| 391 | claims := auth.GetClaims(ctx) |
| 392 | permissions := claims.ProjectPermissions(ctx, proj.OrganizationID, proj.ID) |
| 393 | if !permissions.ReadProject && !proj.Public && !claims.Superuser(ctx) { |
| 394 | return nil, status.Error(codes.PermissionDenied, "does not have permission to read project") |
| 395 | } |
| 396 | |
| 397 | return &adminv1.GetProjectByIDResponse{ |
| 398 | Project: s.projToDTO(proj, org.Name), |
| 399 | }, nil |
| 400 | } |
| 401 | |
| 402 | func (s *Server) SearchProjectNames(ctx context.Context, req *adminv1.SearchProjectNamesRequest) (*adminv1.SearchProjectNamesResponse, error) { |
| 403 | observability.AddRequestAttributes(ctx, |
nothing calls this directly
no test coverage detected