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

Method findWorksheet

backend/api/v1/worksheet_service.go:384–402  ·  view source on GitHub ↗
(ctx context.Context, projectID string, worksheetID string, loadFull bool)

Source from the content-addressed store, hash-verified

382}
383
384func (s *WorksheetService) findWorksheet(ctx context.Context, projectID string, worksheetID string, loadFull bool) (*store.WorkSheetMessage, error) {
385 user, ok := GetUserFromContext(ctx)
386 if !ok {
387 return nil, connect.NewError(connect.CodeInternal, errors.Errorf("user not found"))
388 }
389 worksheet, err := s.store.GetWorkSheet(ctx, &store.FindWorkSheetMessage{
390 ProjectIDs: []string{projectID},
391 ResourceID: &worksheetID,
392 LoadFull: loadFull,
393 PrincipalEmail: user.Email,
394 })
395 if err != nil {
396 return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get worksheet: %v", err))
397 }
398 if worksheet == nil {
399 return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("cannot find the worksheet"))
400 }
401 return worksheet, nil
402}
403
404// canWriteWorksheet check if the principal can write the worksheet.
405// worksheet is writable when the user has bb.worksheets.manage permission on the workspace, or.

Callers 4

GetWorksheetMethod · 0.95
UpdateWorksheetMethod · 0.95
DeleteWorksheetMethod · 0.95

Calls 3

GetUserFromContextFunction · 0.85
ErrorfMethod · 0.80
GetWorkSheetMethod · 0.80

Tested by

no test coverage detected