From cc3091d401ea24514ffb129d14c72e6297eca733 Mon Sep 17 00:00:00 2001 From: pb Date: Thu, 31 Jul 2025 15:53:05 +0200 Subject: [PATCH] added the function to load one ressource for each ressource type --- entrypoint.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/entrypoint.go b/entrypoint.go index 7dc00ba..25db0cf 100644 --- a/entrypoint.go +++ b/entrypoint.go @@ -608,4 +608,54 @@ func GetConcatenatedName(peerId string, namespace string) string { n := s[0] + "-" + s[1] return peerId + "-" + n +} + +// ------------- Loading resources ---------- + +func LoadOneStorage(storageId string, user string, peerID string, groups []string) (*resources.StorageResource, error) { + + res := NewRequest(LibDataEnum(STORAGE_RESOURCE), user, peerID, groups,nil).LoadOne(storageId) + if res.Code != 200 { + l := GetLogger() + l.Error().Msg("Error while loading storage ressource " + storageId) + return nil,fmt.Errorf(res.Err) + } + + return res.ToStorageResource(), nil +} + +func LoadOneComputing(computingId string, user string, peerID string, groups []string) (*resources.ComputeResource, error) { + + res := NewRequest(LibDataEnum(COMPUTE_RESOURCE), user, peerID, groups,nil).LoadOne(computingId) + if res.Code != 200 { + l := GetLogger() + l.Error().Msg("Error while loading computing ressource " + computingId) + return nil,fmt.Errorf(res.Err) + } + + return res.ToComputeResource(), nil +} + +func LoadOneProcessing(processingId string, user string, peerID string, groups []string) (*resources.ProcessingResource, error) { + + res := NewRequest(LibDataEnum(PROCESSING_RESOURCE), user, peerID, groups,nil).LoadOne(processingId) + if res.Code != 200 { + l := GetLogger() + l.Error().Msg("Error while loading processing ressource " + processingId) + return nil,fmt.Errorf(res.Err) + } + + return res.ToProcessingResource(), nil +} + +func LoadOneData(dataId string, user string, peerID string, groups []string) (*resources.DataResource, error) { + + res := NewRequest(LibDataEnum(DATA_RESOURCE), user, peerID, groups,nil).LoadOne(dataId) + if res.Code != 200 { + l := GetLogger() + l.Error().Msg("Error while loading data ressource " + dataId) + return nil,fmt.Errorf(res.Err) + } + return res.ToDataResource(), nil + } \ No newline at end of file