add draft compute units

This commit is contained in:
mr
2025-06-17 14:51:41 +02:00
parent 2264d22c69
commit 1c751f7253
3 changed files with 36 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package resources
import (
"errors"
"slices"
"cloud.o-forge.io/core/oc-lib/dbs"
@@ -37,16 +38,25 @@ func (dca *ResourceMongoAccessor[T]) DeleteOne(id string) (utils.DBObject, int,
}
func (dca *ResourceMongoAccessor[T]) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
if dca.GetType() == tools.COMPUTE_RESOURCE {
return nil, 404, errors.New("can't update a non existing computing units resource not reported onto compute units catalog")
}
set.(T).Trim()
return utils.GenericUpdateOne(set, id, dca, dca.generateData())
}
func (dca *ResourceMongoAccessor[T]) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
if dca.GetType() == tools.COMPUTE_RESOURCE {
return nil, 404, errors.New("can't create a non existing computing units resource not reported onto compute units catalog")
}
data.(T).Trim()
return utils.GenericStoreOne(data, dca)
}
func (dca *ResourceMongoAccessor[T]) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
if dca.GetType() == tools.COMPUTE_RESOURCE {
return nil, 404, errors.New("can't copy/publish a non existing computing units resource not reported onto compute units catalog")
}
return dca.StoreOne(data)
}