Skip to content

Commit

Permalink
Adds Scan Get request
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanStonebraker committed Apr 12, 2024
1 parent 6ef8f95 commit 47edb74
Show file tree
Hide file tree
Showing 5 changed files with 1,074 additions and 872 deletions.
23 changes: 23 additions & 0 deletions api/ws/handlers/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,29 @@ func HandleScanListReq(req *protos.ScanListReq, hctx wsHelpers.HandlerContext) (
}, nil
}

func HandleScanGetReq(req *protos.ScanGetReq, hctx wsHelpers.HandlerContext) (*protos.ScanGetResp, error) {
// Check that we have an id, current user, and display settings
if len(req.Id) <= 0 {
return nil, errorwithstatus.MakeBadRequestError(errors.New("Scan ID must be specified"))
}

if hctx.SessUser.User.Id == "" {
return nil, errorwithstatus.MakeBadRequestError(errors.New("User must be logged in"))
}

// Check user has access
dbItem, owner, err := wsHelpers.GetUserObjectById[protos.ScanItem](true, req.Id, protos.ObjectType_OT_SCAN, dbCollections.ScansName, hctx)
if err != nil {
return nil, err
}

dbItem.Owner = wsHelpers.MakeOwnerSummary(owner, hctx.SessUser, hctx.Svcs.MongoDB, hctx.Svcs.TimeStamper)

return &protos.ScanGetResp{
Scan: dbItem,
}, nil
}

func HandleScanMetaLabelsAndTypesReq(req *protos.ScanMetaLabelsAndTypesReq, hctx wsHelpers.HandlerContext) (*protos.ScanMetaLabelsAndTypesResp, error) {
exprPB, err := beginDatasetFileReq(req.ScanId, hctx)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion data-formats
Loading

0 comments on commit 47edb74

Please sign in to comment.