correct
This commit is contained in:
parent
271cc2caa0
commit
085a8718e0
@ -17,7 +17,7 @@ import (
|
||||
* it defines the resource compute
|
||||
*/
|
||||
type ComputeResource struct {
|
||||
AbstractIntanciatedResource[*ComputeResourceInstance]
|
||||
AbstractInstanciatedResource[*ComputeResourceInstance]
|
||||
Architecture string `json:"architecture,omitempty" bson:"architecture,omitempty"` // Architecture is the architecture
|
||||
Infrastructure enum.InfrastructureType `json:"infrastructure" bson:"infrastructure" default:"-1"` // Infrastructure is the infrastructure
|
||||
}
|
||||
@ -35,7 +35,7 @@ func (abs *ComputeResource) ConvertToPricedResource(
|
||||
if t != tools.COMPUTE_RESOURCE {
|
||||
return nil
|
||||
}
|
||||
p := abs.AbstractIntanciatedResource.ConvertToPricedResource(t, request)
|
||||
p := abs.AbstractInstanciatedResource.ConvertToPricedResource(t, request)
|
||||
priced := p.(*PricedResource)
|
||||
return &PricedComputeResource{
|
||||
PricedResource: *priced,
|
||||
@ -52,6 +52,7 @@ type ComputeNode struct {
|
||||
|
||||
type ComputeResourceInstance struct {
|
||||
ResourceInstance[*ComputeResourcePartnership]
|
||||
Source string `json:"source,omitempty" bson:"source,omitempty"` // Source is the source of the resource
|
||||
SecurityLevel string `json:"security_level,omitempty" bson:"security_level,omitempty"`
|
||||
PowerSources []string `json:"power_sources,omitempty" bson:"power_sources,omitempty"`
|
||||
AnnualCO2Emissions float64 `json:"annual_co2_emissions,omitempty" bson:"co2_emissions,omitempty"`
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
* it defines the resource data
|
||||
*/
|
||||
type DataResource struct {
|
||||
AbstractIntanciatedResource[*DataInstance]
|
||||
AbstractInstanciatedResource[*DataInstance]
|
||||
Type string `bson:"type,omitempty" json:"type,omitempty"`
|
||||
Quality string `bson:"quality,omitempty" json:"quality,omitempty"`
|
||||
OpenData bool `bson:"open_data" json:"open_data" default:"false"` // Type is the type of the storage
|
||||
@ -42,7 +42,7 @@ func (abs *DataResource) ConvertToPricedResource(
|
||||
if t != tools.DATA_RESOURCE {
|
||||
return nil
|
||||
}
|
||||
p := abs.AbstractIntanciatedResource.ConvertToPricedResource(t, request)
|
||||
p := abs.AbstractInstanciatedResource.ConvertToPricedResource(t, request)
|
||||
priced := p.(*PricedResource)
|
||||
return &PricedDataResource{
|
||||
PricedResource: *priced,
|
||||
|
@ -25,7 +25,7 @@ type ProcessingUsage struct {
|
||||
* it defines the resource processing
|
||||
*/
|
||||
type ProcessingResource struct {
|
||||
AbstractIntanciatedResource[*ProcessingInstance]
|
||||
AbstractInstanciatedResource[*ProcessingInstance]
|
||||
Infrastructure enum.InfrastructureType `json:"infrastructure" bson:"infrastructure" default:"-1"` // Infrastructure is the infrastructure
|
||||
IsService bool `json:"is_service,omitempty" bson:"is_service,omitempty"` // IsService is a flag that indicates if the processing is a service
|
||||
Usage *ProcessingUsage `bson:"usage,omitempty" json:"usage,omitempty"` // Usage is the usage of the processing
|
||||
|
@ -47,12 +47,12 @@ func (r *AbstractResource) CanDelete() bool {
|
||||
return r.IsDraft // only draft bookings can be deleted
|
||||
}
|
||||
|
||||
type AbstractIntanciatedResource[T ResourceInstanceITF] struct {
|
||||
type AbstractInstanciatedResource[T ResourceInstanceITF] struct {
|
||||
AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
||||
Instances []T `json:"instances,omitempty" bson:"instances,omitempty"` // Bill is the bill of the resource // Bill is the bill of the resource
|
||||
}
|
||||
|
||||
func (abs *AbstractIntanciatedResource[T]) ConvertToPricedResource(
|
||||
func (abs *AbstractInstanciatedResource[T]) ConvertToPricedResource(
|
||||
t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF {
|
||||
instances := map[string]string{}
|
||||
profiles := []pricing.PricingProfileITF{}
|
||||
@ -71,14 +71,14 @@ func (abs *AbstractIntanciatedResource[T]) ConvertToPricedResource(
|
||||
}
|
||||
}
|
||||
|
||||
func (abs *AbstractIntanciatedResource[T]) ClearEnv() utils.DBObject {
|
||||
func (abs *AbstractInstanciatedResource[T]) ClearEnv() utils.DBObject {
|
||||
for _, instance := range abs.Instances {
|
||||
instance.ClearEnv()
|
||||
}
|
||||
return abs
|
||||
}
|
||||
|
||||
func (r *AbstractIntanciatedResource[T]) GetSelectedInstance() utils.DBObject {
|
||||
func (r *AbstractInstanciatedResource[T]) GetSelectedInstance() utils.DBObject {
|
||||
if r.SelectedInstanceIndex != nil && len(r.Instances) > *r.SelectedInstanceIndex {
|
||||
return r.Instances[*r.SelectedInstanceIndex]
|
||||
}
|
||||
@ -88,11 +88,11 @@ func (r *AbstractIntanciatedResource[T]) GetSelectedInstance() utils.DBObject {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (abs *AbstractIntanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest) {
|
||||
func (abs *AbstractInstanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest) {
|
||||
abs.Instances = verifyAuthAction[T](abs.Instances, request)
|
||||
}
|
||||
|
||||
func (d *AbstractIntanciatedResource[T]) Trim() {
|
||||
func (d *AbstractInstanciatedResource[T]) Trim() {
|
||||
d.Type = d.GetType()
|
||||
if ok, _ := (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: d.CreatorID}}).IsMySelf(); !ok {
|
||||
for _, instance := range d.Instances {
|
||||
@ -101,7 +101,7 @@ func (d *AbstractIntanciatedResource[T]) Trim() {
|
||||
}
|
||||
}
|
||||
|
||||
func (abs *AbstractIntanciatedResource[T]) VerifyAuth(request *tools.APIRequest) bool {
|
||||
func (abs *AbstractInstanciatedResource[T]) VerifyAuth(request *tools.APIRequest) bool {
|
||||
return len(verifyAuthAction[T](abs.Instances, request)) > 0 || abs.AbstractObject.VerifyAuth(request)
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,9 @@ import (
|
||||
* it defines the resource storage
|
||||
*/
|
||||
type StorageResource struct {
|
||||
AbstractIntanciatedResource[*StorageResourceInstance] // AbstractResource contains the basic fields of an object (id, name)
|
||||
StorageType enum.StorageType `bson:"storage_type" json:"storage_type" default:"-1"` // Type is the type of the storage
|
||||
Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"` // Acronym is the acronym of the storage
|
||||
AbstractInstanciatedResource[*StorageResourceInstance] // AbstractResource contains the basic fields of an object (id, name)
|
||||
StorageType enum.StorageType `bson:"storage_type" json:"storage_type" default:"-1"` // Type is the type of the storage
|
||||
Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"` // Acronym is the acronym of the storage
|
||||
}
|
||||
|
||||
func (d *StorageResource) GetAccessor(request *tools.APIRequest) utils.Accessor {
|
||||
@ -35,7 +35,7 @@ func (abs *StorageResource) ConvertToPricedResource(
|
||||
if t != tools.STORAGE_RESOURCE {
|
||||
return nil
|
||||
}
|
||||
p := abs.AbstractIntanciatedResource.ConvertToPricedResource(t, request)
|
||||
p := abs.AbstractInstanciatedResource.ConvertToPricedResource(t, request)
|
||||
priced := p.(*PricedResource)
|
||||
return &PricedStorageResource{
|
||||
PricedResource: *priced,
|
||||
|
Loading…
Reference in New Issue
Block a user