MCPcopy Create free account
hub / github.com/bytebase/bytebase / GetWorksheet

Method GetWorksheet

backend/api/v1/worksheet_service.go:104–128  ·  view source on GitHub ↗

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],
)

Source from the content-addressed store, hash-verified

102
103// GetWorksheet returns the requested worksheet, cutoff the content if the content is too long and the `raw` flag in request is false.
104func (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.
131func (s *WorksheetService) SearchWorksheets(

Callers

nothing calls this directly

Calls 5

findWorksheetMethod · 0.95
canReadWorksheetMethod · 0.95
GetProjectIDWorksheetIDFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected