GetWorksheet returns the requested worksheet, cutoff the content if the content is too long and the `raw` flag in request is false.
( ctx context.Context, req *connect.Request[v1pb.GetWorksheetRequest], )
| 102 | |
| 103 | // GetWorksheet returns the requested worksheet, cutoff the content if the content is too long and the `raw` flag in request is false. |
| 104 | func (s *WorksheetService) GetWorksheet( |
| 105 | ctx context.Context, |
| 106 | req *connect.Request[v1pb.GetWorksheetRequest], |
| 107 | ) (*connect.Response[v1pb.Worksheet], error) { |
| 108 | projectID, worksheetID, err := common.GetProjectIDWorksheetID(req.Msg.Name) |
| 109 | if err != nil { |
| 110 | return nil, connect.NewError(connect.CodeInvalidArgument, err) |
| 111 | } |
| 112 | |
| 113 | worksheet, err := s.findWorksheet(ctx, projectID, worksheetID, true /* loadFull */) |
| 114 | if err != nil { |
| 115 | return nil, err |
| 116 | } |
| 117 | |
| 118 | ok, err := s.canReadWorksheet(ctx, worksheet) |
| 119 | if err != nil { |
| 120 | return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to check access with error: %v", err)) |
| 121 | } |
| 122 | if !ok { |
| 123 | return nil, connect.NewError(connect.CodePermissionDenied, errors.Errorf("cannot access worksheet %s", worksheet.Title)) |
| 124 | } |
| 125 | |
| 126 | v1pbWorksheet := convertToAPIWorksheetMessage(worksheet) |
| 127 | return connect.NewResponse(v1pbWorksheet), nil |
| 128 | } |
| 129 | |
| 130 | // SearchWorksheets returns a list of worksheets based on the search filters. |
| 131 | func (s *WorksheetService) SearchWorksheets( |
nothing calls this directly
no test coverage detected