light modification

This commit is contained in:
mr
2025-01-20 13:26:30 +01:00
parent b85ca8674b
commit 8e4ebbf622
7 changed files with 30 additions and 5 deletions

View File

@@ -26,6 +26,10 @@ func (d *ComputeResource) GetAccessor(request *tools.APIRequest) utils.Accessor
return NewAccessor[*ComputeResource](tools.COMPUTE_RESOURCE, request, func() utils.DBObject { return &ComputeResource{} })
}
func (r *ComputeResource) GetType() string {
return tools.COMPUTE_RESOURCE.String()
}
func (abs *ComputeResource) ConvertToPricedResource(
t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF {
if t != tools.COMPUTE_RESOURCE {

View File

@@ -32,6 +32,10 @@ func (d *DataResource) GetAccessor(request *tools.APIRequest) utils.Accessor {
return NewAccessor[*DataResource](tools.DATA_RESOURCE, request, func() utils.DBObject { return &DataResource{} }) // Create a new instance of the accessor
}
func (r *DataResource) GetType() string {
return tools.DATA_RESOURCE.String()
}
func (abs *DataResource) ConvertToPricedResource(
t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF {
if t != tools.DATA_RESOURCE {

View File

@@ -35,6 +35,10 @@ type ProcessingResource struct {
Container *models.Container `json:"container,omitempty" bson:"container,omitempty"` // Container is the container
}
func (r *ProcessingResource) GetType() string {
return tools.PROCESSING_RESOURCE.String()
}
type PricedProcessingResource struct {
PricedResource
IsService bool

View File

@@ -33,6 +33,10 @@ type AbstractResource struct {
SelectedInstanceIndex *int `json:"selected_instance_index,omitempty" bson:"selected_instance_index,omitempty"` // SelectedInstance is the selected instance
}
func (r *AbstractResource) GetType() string {
return r.Type
}
func (r *AbstractResource) StoreDraftDefault() {
r.IsDraft = true
}
@@ -81,6 +85,7 @@ func (abs *AbstractIntanciatedResource[T]) SetAllowedInstances(request *tools.AP
}
func (d *AbstractIntanciatedResource[T]) Trim() {
d.AbstractResource.AbstractObject.Type = d.GetType()
if ok, _ := (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: d.CreatorID}}).IsMySelf(); !ok {
for _, instance := range d.Instances {
instance.ClearPeerGroups()

View File

@@ -24,6 +24,10 @@ func (d *StorageResource) GetAccessor(request *tools.APIRequest) utils.Accessor
return NewAccessor[*StorageResource](tools.STORAGE_RESOURCE, request, func() utils.DBObject { return &StorageResource{} }) // Create a new instance of the accessor
}
func (r *StorageResource) GetType() string {
return tools.STORAGE_RESOURCE.String()
}
func (abs *StorageResource) ConvertToPricedResource(
t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF {
if t != tools.STORAGE_RESOURCE {

View File

@@ -19,6 +19,10 @@ func (d *WorkflowResource) GetAccessor(request *tools.APIRequest) utils.Accessor
return NewAccessor[*ComputeResource](tools.WORKFLOW_RESOURCE, request, func() utils.DBObject { return &WorkflowResource{} })
}
func (r *WorkflowResource) GetType() string {
return tools.WORKFLOW_RESOURCE.String()
}
func (d *WorkflowResource) Trim() {
/* EMPTY */
}