2024-07-18 11:51:12 +02:00
|
|
|
package resources
|
|
|
|
|
2024-07-19 10:54:58 +02:00
|
|
|
import (
|
2024-08-01 16:50:16 +02:00
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
2024-07-26 10:36:23 +02:00
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resources/data"
|
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
|
|
|
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
2024-07-19 10:54:58 +02:00
|
|
|
)
|
|
|
|
|
2024-07-18 11:51:12 +02:00
|
|
|
// AbstractResource is the struct containing all of the attributes commons to all ressources
|
|
|
|
|
|
|
|
// Resource is the interface to be implemented by all classes inheriting from Resource to have the same behavior
|
|
|
|
|
2024-07-23 11:22:50 +02:00
|
|
|
// http://www.inanzzz.com/index.php/post/wqbs/a-basic-usage-of-int-and-string-enum-types-in-golang
|
2024-07-26 10:36:23 +02:00
|
|
|
type ResourceSet struct {
|
|
|
|
Datas []string `bson:"datas,omitempty" json:"datas,omitempty"`
|
|
|
|
Storages []string `bson:"storages,omitempty" json:"storages,omitempty"`
|
2024-07-30 12:08:13 +02:00
|
|
|
Processings []string `bson:"processings,omitempty" json:"processings,omitempty"`
|
2024-07-26 10:36:23 +02:00
|
|
|
Datacenters []string `bson:"datacenters,omitempty" json:"datacenters,omitempty"`
|
|
|
|
Workflows []string `bson:"workflows,omitempty" json:"workflows,omitempty"`
|
2024-07-25 11:46:33 +02:00
|
|
|
|
2024-07-26 10:36:23 +02:00
|
|
|
DataResources []*data.DataResource `bson:"-" json:"data_resources,omitempty"`
|
|
|
|
StorageResources []*storage.StorageResource `bson:"-" json:"storage_resources,omitempty"`
|
|
|
|
ProcessingResources []*processing.ProcessingResource `bson:"-" json:"processing_resources,omitempty"`
|
|
|
|
DatacenterResources []*datacenter.DatacenterResource `bson:"-" json:"datacenter_resources,omitempty"`
|
|
|
|
WorkflowResources []*w.WorkflowResource `bson:"-" json:"workflow_resources,omitempty"`
|
2024-07-18 11:51:12 +02:00
|
|
|
}
|
2024-07-30 12:08:13 +02:00
|
|
|
|
|
|
|
type ItemResource struct {
|
2024-07-31 16:21:19 +02:00
|
|
|
Data *data.DataResource `bson:"data,omitempty" json:"data,omitempty"`
|
|
|
|
Processing *processing.ProcessingResource `bson:"processing,omitempty" json:"processing,omitempty"`
|
|
|
|
Storage *storage.StorageResource `bson:"storage,omitempty" json:"storage,omitempty"`
|
|
|
|
Datacenter *datacenter.DatacenterResource `bson:"datacenter,omitempty" json:"datacenter,omitempty"`
|
|
|
|
Workflow *w.WorkflowResource `bson:"workflow,omitempty" json:"workflow,omitempty"`
|
2024-07-30 12:08:13 +02:00
|
|
|
}
|
2024-08-01 16:50:16 +02:00
|
|
|
|
|
|
|
func (i *ItemResource) GetAbstractRessource() *resource_model.AbstractResource {
|
|
|
|
|
|
|
|
if(i.Data != nil){
|
|
|
|
return &i.Data.AbstractResource
|
|
|
|
}
|
|
|
|
if(i.Processing != nil){
|
|
|
|
return &i.Processing.AbstractResource
|
|
|
|
}
|
|
|
|
if(i.Storage != nil){
|
|
|
|
return &i.Storage.AbstractResource
|
|
|
|
}
|
|
|
|
if(i.Datacenter != nil){
|
|
|
|
return &i.Datacenter.AbstractResource
|
|
|
|
}
|
|
|
|
if(i.Workflow != nil){
|
|
|
|
return &i.Workflow.AbstractResource
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|