added the function to load one ressource for each ressource type
This commit is contained in:
parent
3ddbf1a967
commit
cc3091d401
@ -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
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user