resources

package
v0.0.0-...-f4b0cf5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyAuthAction

func VerifyAuthAction[T ResourceInstanceITF](baseInstance []T, request *tools.APIRequest) []T

Types

type AbstractInstanciatedResource

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 (*AbstractInstanciatedResource[T]) ClearEnv

func (abs *AbstractInstanciatedResource[T]) ClearEnv() utils.DBObject

func (*AbstractInstanciatedResource[T]) ConvertToPricedResource

func (abs *AbstractInstanciatedResource[T]) ConvertToPricedResource(t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF

func (*AbstractInstanciatedResource[T]) GetSelectedInstance

func (r *AbstractInstanciatedResource[T]) GetSelectedInstance() ResourceInstanceITF

func (*AbstractInstanciatedResource[T]) SetAllowedInstances

func (abs *AbstractInstanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest)

func (*AbstractInstanciatedResource[T]) Trim

func (d *AbstractInstanciatedResource[T]) Trim()

func (*AbstractInstanciatedResource[T]) VerifyAuth

func (abs *AbstractInstanciatedResource[T]) VerifyAuth(request *tools.APIRequest) bool

type AbstractResource

type AbstractResource struct {
	utils.AbstractObject                // AbstractObject contains the basic fields of an object (id, name)
	Type                  string        `json:"type,omitempty" bson:"type,omitempty"`                                               // Type is the type of the resource
	Description           string        `json:"description,omitempty" bson:"description,omitempty"`                                 // Description is the description of the resource
	ShortDescription      string        `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"` // ShortDescription is the short description of the resource
	Owners                []utils.Owner `json:"owners,omitempty" bson:"owners,omitempty"`                                           // Owners is the list of owners of the resource
	UsageRestrictions     string        `bson:"usage_restrictions,omitempty" json:"usage_restrictions,omitempty"`
	SelectedInstanceIndex *int          `json:"selected_instance_index,omitempty" bson:"selected_instance_index,omitempty"` // SelectedInstance is the selected instance
}

AbstractResource is the struct containing all of the attributes commons to all ressources

func (*AbstractResource) CanDelete

func (r *AbstractResource) CanDelete() bool

func (*AbstractResource) CanUpdate

func (r *AbstractResource) CanUpdate(set utils.DBObject) (bool, utils.DBObject)

func (*AbstractResource) GetSelectedInstance

func (r *AbstractResource) GetSelectedInstance() ResourceInstanceITF

func (*AbstractResource) GetType

func (r *AbstractResource) GetType() string

func (*AbstractResource) StoreDraftDefault

func (r *AbstractResource) StoreDraftDefault()

type ComputeNode

type ComputeNode struct {
	Name     string           `json:"name,omitempty" bson:"name,omitempty"`
	Quantity int64            `json:"quantity" bson:"quantity" default:"1"`
	RAM      *models.RAM      `bson:"ram,omitempty" json:"ram,omitempty"`   // RAM is the RAM
	CPUs     map[string]int64 `bson:"cpus,omitempty" json:"cpus,omitempty"` // CPUs is the list of CPUs key is model
	GPUs     map[string]int64 `bson:"gpus,omitempty" json:"gpus,omitempty"` // GPUs is the list of GPUs key is model
}

type ComputeResource

type ComputeResource struct {
	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
}

* ComputeResource is a struct that represents a compute resource * it defines the resource compute

func (*ComputeResource) ConvertToPricedResource

func (abs *ComputeResource) ConvertToPricedResource(t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF

func (*ComputeResource) GetAccessor

func (d *ComputeResource) GetAccessor(request *tools.APIRequest) utils.Accessor

func (*ComputeResource) GetType

func (r *ComputeResource) GetType() string

type ComputeResourceInstance

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"`
	CPUs               map[string]*models.CPU `bson:"cpus,omitempty" json:"cpus,omitempty"` // CPUs is the list of CPUs key is model
	GPUs               map[string]*models.GPU `bson:"gpus,omitempty" json:"gpus,omitempty"` // GPUs is the list of GPUs key is model
	Nodes              []*ComputeNode         `json:"nodes,omitempty" bson:"nodes,omitempty"`
}

type ComputeResourcePartnership

type ComputeResourcePartnership struct {
	ResourcePartnerShip[*ComputeResourcePricingProfile]
	MinGaranteedCPUsCores    map[string]float64 `json:"garanteed_cpus,omitempty" bson:"garanteed_cpus,omitempty"`
	MinGaranteedGPUsMemoryGB map[string]float64 `json:"garanteed_gpus,omitempty" bson:"garanteed_gpus,omitempty"`
	MinGaranteedRAMSize      float64            `json:"garanteed_ram,omitempty" bson:"garanteed_ram,omitempty"`

	MaxAllowedCPUsCores    map[string]float64 `json:"allowed_cpus,omitempty" bson:"allowed_cpus,omitempty"`
	MaxAllowedGPUsMemoryGB map[string]float64 `json:"allowed_gpus,omitempty" bson:"allowed_gpus,omitempty"`
	MaxAllowedRAMSize      float64            `json:"allowed_ram,omitempty" bson:"allowed_ram,omitempty"`
}

type ComputeResourcePricingProfile

type ComputeResourcePricingProfile struct {
	pricing.ExploitPricingProfile[pricing.TimePricingStrategy]
	// ExploitPricingProfile is the pricing profile of a compute it means that we exploit the resource for an amount of continuous time
	CPUsPrices map[string]float64 `json:"cpus_prices,omitempty" bson:"cpus_prices,omitempty"` // CPUsPrices is the prices of the CPUs
	GPUsPrices map[string]float64 `json:"gpus_prices,omitempty" bson:"gpus_prices,omitempty"` // GPUsPrices is the prices of the GPUs
	RAMPrice   float64            `json:"ram_price" bson:"ram_price" default:"-1"`            // RAMPrice is the price of the RAM
}

func (*ComputeResourcePricingProfile) GetOverrideStrategyValue

func (p *ComputeResourcePricingProfile) GetOverrideStrategyValue() int

func (*ComputeResourcePricingProfile) GetPrice

func (p *ComputeResourcePricingProfile) GetPrice(amountOfData float64, explicitDuration float64, start time.Time, end time.Time, params ...string) (float64, error)

NOT A PROPER QUANTITY amountOfData is the number of CPUs, GPUs or RAM dependings on the params

func (*ComputeResourcePricingProfile) GetPurchase

func (*ComputeResourcePricingProfile) IsBooked

func (p *ComputeResourcePricingProfile) IsBooked() bool

func (*ComputeResourcePricingProfile) IsPurchasable

func (p *ComputeResourcePricingProfile) IsPurchasable() bool

type DataInstance

type DataInstance struct {
	ResourceInstance[*DataResourcePartnership]
	Source string `json:"source,omitempty" bson:"source,omitempty"` // Source is the source of the data
}

func (*DataInstance) StoreDraftDefault

func (ri *DataInstance) StoreDraftDefault()

type DataResource

type DataResource struct {
	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
	Static                 bool       `bson:"static" json:"static" default:"false"`
	UpdatePeriod           *time.Time `bson:"update_period,omitempty" json:"update_period,omitempty"`
	PersonalData           bool       `bson:"personal_data,omitempty" json:"personal_data,omitempty"`
	AnonymizedPersonalData bool       `bson:"anonymized_personal_data,omitempty" json:"anonymized_personal_data,omitempty"`
	SizeGB                 float64    `json:"size,omitempty" bson:"size,omitempty"` // SizeGB is the size of the data	License              DataLicense `json:"license" bson:"license" description:"license of the data" default:"0"` // License is the license of the data
	// ? Interest               DataLicense `json:"interest" bson:"interest" description:"interest of the data" default:"0"`      // Interest is the interest of the data
	Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"` // Example is an example of the data
}

* DataResource is a struct that represents a data resource * it defines the resource data

func (*DataResource) ConvertToPricedResource

func (abs *DataResource) ConvertToPricedResource(t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF

func (*DataResource) GetAccessor

func (d *DataResource) GetAccessor(request *tools.APIRequest) utils.Accessor

func (*DataResource) GetType

func (r *DataResource) GetType() string

type DataResourcePartnership

type DataResourcePartnership struct {
	ResourcePartnerShip[*DataResourcePricingProfile]
	MaxDownloadableGbAllowed      float64 `json:"allowed_gb,omitempty" bson:"allowed_gb,omitempty"`
	PersonalDataAllowed           bool    `json:"personal_data_allowed,omitempty" bson:"personal_data_allowed,omitempty"`
	AnonymizedPersonalDataAllowed bool    `json:"anonymized_personal_data_allowed,omitempty" bson:"anonymized_personal_data_allowed,omitempty"`
}

type DataResourcePricingProfile

type DataResourcePricingProfile struct {
	pricing.AccessPricingProfile[DataResourcePricingStrategy] // AccessPricingProfile is the pricing profile of a data it means that we can access the data for an amount of time
}

func (*DataResourcePricingProfile) GetOverrideStrategyValue

func (p *DataResourcePricingProfile) GetOverrideStrategyValue() int

func (*DataResourcePricingProfile) GetPrice

func (p *DataResourcePricingProfile) GetPrice(amountOfData float64, explicitDuration float64, start time.Time, end time.Time, params ...string) (float64, error)

func (*DataResourcePricingProfile) GetPurchase

func (*DataResourcePricingProfile) IsBooked

func (p *DataResourcePricingProfile) IsBooked() bool

func (*DataResourcePricingProfile) IsPurchasable

func (p *DataResourcePricingProfile) IsPurchasable() bool

type DataResourcePricingStrategy

type DataResourcePricingStrategy int
const (
	PER_DOWNLOAD DataResourcePricingStrategy = iota + 6
	PER_TB_DOWNLOADED
	PER_GB_DOWNLOADED
	PER_MB_DOWNLOADED
	PER_KB_DOWNLOADED
)

func DataResourcePricingStrategyList

func DataResourcePricingStrategyList() []DataResourcePricingStrategy

func ToDataResourcePricingStrategy

func ToDataResourcePricingStrategy(i int) DataResourcePricingStrategy

func (DataResourcePricingStrategy) GetQuantity

func (t DataResourcePricingStrategy) GetQuantity(amountOfDataGB float64) (float64, error)

func (DataResourcePricingStrategy) GetStrategy

func (t DataResourcePricingStrategy) GetStrategy() string

func (DataResourcePricingStrategy) GetStrategyValue

func (t DataResourcePricingStrategy) GetStrategyValue() int

func (DataResourcePricingStrategy) String

type GeoPoint

type GeoPoint struct {
	Latitude  float64 `json:"latitude,omitempty" bson:"latitude,omitempty"`
	Longitude float64 `json:"longitude,omitempty" bson:"longitude,omitempty"`
}

type ItemResource

type ItemResource struct {
	Data       *DataResource       `bson:"data,omitempty" json:"data,omitempty"`
	Processing *ProcessingResource `bson:"processing,omitempty" json:"processing,omitempty"`
	Storage    *StorageResource    `bson:"storage,omitempty" json:"storage,omitempty"`
	Compute    *ComputeResource    `bson:"compute,omitempty" json:"compute,omitempty"`
	Workflow   *WorkflowResource   `bson:"workflow,omitempty" json:"workflow,omitempty"`
}

type PricedComputeResource

type PricedComputeResource struct {
	PricedResource

	CPUsLocated map[string]float64 `json:"cpus_in_use" bson:"cpus_in_use"` // CPUsInUse is the list of CPUs in use
	GPUsLocated map[string]float64 `json:"gpus_in_use" bson:"gpus_in_use"` // GPUsInUse is the list of GPUs in use
	RAMLocated  float64            `json:"ram_in_use" bson:"ram_in_use"`   // RAMInUse is the RAM in use
}

func (*PricedComputeResource) FillWithDefaultProcessingUsage

func (i *PricedComputeResource) FillWithDefaultProcessingUsage(usage *ProcessingUsage)

* FillWithDefaultProcessingUsage fills the order item with the default processing usage * it depends on the processing usage only if nothing is set, during order

func (*PricedComputeResource) GetPrice

func (r *PricedComputeResource) GetPrice() (float64, error)

func (*PricedComputeResource) GetType

func (r *PricedComputeResource) GetType() tools.DataType

type PricedDataResource

type PricedDataResource struct {
	PricedResource
	UsageStorageGB float64 `json:"storage_gb,omitempty" bson:"storage_gb,omitempty"`
}

func (*PricedDataResource) GetPrice

func (r *PricedDataResource) GetPrice() (float64, error)

func (*PricedDataResource) GetType

func (r *PricedDataResource) GetType() tools.DataType

type PricedProcessingResource

type PricedProcessingResource struct {
	PricedResource
	IsService bool
}

func (*PricedProcessingResource) GetExplicitDurationInS

func (a *PricedProcessingResource) GetExplicitDurationInS() float64

func (*PricedProcessingResource) GetType

type PricedResource

type PricedResource struct {
	Name                     string                    `json:"name,omitempty" bson:"name,omitempty"`
	InstancesRefs            map[string]string         `json:"instances_refs,omitempty" bson:"instances_refs,omitempty"`
	SelectedPricing          pricing.PricingProfileITF `json:"selected_pricing,omitempty" bson:"selected_pricing,omitempty"`
	ExplicitBookingDurationS float64                   `json:"explicit_location_duration_s,omitempty" bson:"explicit_location_duration_s,omitempty"`
	UsageStart               *time.Time                `json:"start,omitempty" bson:"start,omitempty"`
	UsageEnd                 *time.Time                `json:"end,omitempty" bson:"end,omitempty"`
	CreatorID                string                    `json:"peer_id,omitempty" bson:"peer_id,omitempty"`
	ResourceID               string                    `json:"resource_id,omitempty" bson:"resource_id,omitempty"`
	ResourceType             tools.DataType            `json:"resource_type,omitempty" bson:"resource_type,omitempty"`
}

func (*PricedResource) GetCreatorID

func (abs *PricedResource) GetCreatorID() string

func (*PricedResource) GetExplicitDurationInS

func (abs *PricedResource) GetExplicitDurationInS() float64

func (*PricedResource) GetID

func (abs *PricedResource) GetID() string

func (*PricedResource) GetLocationEnd

func (abs *PricedResource) GetLocationEnd() *time.Time

func (*PricedResource) GetLocationStart

func (abs *PricedResource) GetLocationStart() *time.Time

func (*PricedResource) GetPrice

func (r *PricedResource) GetPrice() (float64, error)

func (*PricedResource) GetType

func (abs *PricedResource) GetType() tools.DataType

func (*PricedResource) IsBooked

func (abs *PricedResource) IsBooked() bool

func (*PricedResource) IsPurchasable

func (abs *PricedResource) IsPurchasable() bool

func (*PricedResource) SelectPricing

func (abs *PricedResource) SelectPricing() pricing.PricingProfileITF

func (*PricedResource) SetLocationEnd

func (abs *PricedResource) SetLocationEnd(end time.Time)

func (*PricedResource) SetLocationStart

func (abs *PricedResource) SetLocationStart(start time.Time)

type PricedStorageResource

type PricedStorageResource struct {
	PricedResource
	UsageStorageGB float64 `json:"storage_gb,omitempty" bson:"storage_gb,omitempty"`
}

func (*PricedStorageResource) GetPrice

func (r *PricedStorageResource) GetPrice() (float64, error)

func (*PricedStorageResource) GetType

func (r *PricedStorageResource) GetType() tools.DataType

type PrivilegeStoragePricingStrategy

type PrivilegeStoragePricingStrategy int
const (
	BASIC_STORAGE PrivilegeStoragePricingStrategy = iota
	GARANTED_ON_DELAY_STORAGE
	GARANTED_STORAGE
)

func PrivilegeStoragePricingStrategyList

func PrivilegeStoragePricingStrategyList() []PrivilegeStoragePricingStrategy

func (PrivilegeStoragePricingStrategy) String

type ProcessingInstance

type ProcessingInstance struct {
	ResourceInstance[*ResourcePartnerShip[*ProcessingResourcePricingProfile]]
	Access *ProcessingResourceAccess `json:"access,omitempty" bson:"access,omitempty"` // Access is the access
}

type ProcessingResource

type ProcessingResource struct {
	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
	OpenSource     bool                    `json:"open_source" bson:"open_source" default:"false"`
	License        string                  `json:"license,omitempty" bson:"license,omitempty"`
	Maturity       string                  `json:"maturity,omitempty" bson:"maturity,omitempty"`
}

* ProcessingResource is a struct that represents a processing resource * it defines the resource processing

func (*ProcessingResource) GetAccessor

func (d *ProcessingResource) GetAccessor(request *tools.APIRequest) utils.Accessor

func (*ProcessingResource) GetType

func (r *ProcessingResource) GetType() string

type ProcessingResourceAccess

type ProcessingResourceAccess struct {
	Container *models.Container `json:"container,omitempty" bson:"container,omitempty"` // Container is the container
}

type ProcessingResourcePricingProfile

type ProcessingResourcePricingProfile struct {
	pricing.AccessPricingProfile[pricing.TimePricingStrategy] // AccessPricingProfile is the pricing profile of a data it means that we can access the data for an amount of time
}

func (*ProcessingResourcePricingProfile) GetPrice

func (p *ProcessingResourcePricingProfile) GetPrice(amountOfData float64, val float64, start time.Time, end time.Time, params ...string) (float64, error)

func (*ProcessingResourcePricingProfile) GetPurchase

func (*ProcessingResourcePricingProfile) IsBooked

func (p *ProcessingResourcePricingProfile) IsBooked() bool

func (*ProcessingResourcePricingProfile) IsPurchasable

func (p *ProcessingResourcePricingProfile) IsPurchasable() bool

type ProcessingUsage

type ProcessingUsage struct {
	CPUs map[string]*models.CPU `bson:"cpus,omitempty" json:"cpus,omitempty"` // CPUs is the list of CPUs key is model
	GPUs map[string]*models.GPU `bson:"gpus,omitempty" json:"gpus,omitempty"` // GPUs is the list of GPUs key is model
	RAM  *models.RAM            `bson:"ram,omitempty" json:"ram,omitempty"`   // RAM is the RAM

	StorageGb    float64 `bson:"storage,omitempty" json:"storage,omitempty"` // Storage is the storage
	Hypothesis   string  `bson:"hypothesis,omitempty" json:"hypothesis,omitempty"`
	ScalingModel string  `bson:"scaling_model,omitempty" json:"scaling_model,omitempty"` // ScalingModel is the scaling model
}

type ResourceInstance

type ResourceInstance[T ResourcePartnerITF] struct {
	utils.AbstractObject
	Location                 GeoPoint              `json:"location,omitempty" bson:"location,omitempty"`
	Country                  countries.CountryCode `json:"country,omitempty" bson:"country,omitempty"`
	AccessProtocol           string                `json:"access_protocol,omitempty" bson:"access_protocol,omitempty"`
	Env                      []models.Param        `json:"env,omitempty" bson:"env,omitempty"`
	Inputs                   []models.Param        `json:"inputs,omitempty" bson:"inputs,omitempty"`
	Outputs                  []models.Param        `json:"outputs,omitempty" bson:"outputs,omitempty"`
	SelectedPartnershipIndex int                   `json:"selected_partnership_index,omitempty" bson:"selected_partnership_index,omitempty"`
	SelectedBuyingStrategy   int                   `json:"selected_buying_strategy,omitempty" bson:"selected_buying_strategy,omitempty"`
	SelectedStrategy         int                   `json:"selected_strategy,omitempty" bson:"selected_strategy,omitempty"`
	Partnerships             []T                   `json:"partnerships,omitempty" bson:"partnerships,omitempty"`
}

func (*ResourceInstance[T]) ClearEnv

func (ri *ResourceInstance[T]) ClearEnv()

func (*ResourceInstance[T]) ClearPeerGroups

func (ri *ResourceInstance[T]) ClearPeerGroups()

func (*ResourceInstance[T]) GetPartnerships

func (ri *ResourceInstance[T]) GetPartnerships(peerID string, groups []string) []ResourcePartnerITF

func (*ResourceInstance[T]) GetPeerGroups

func (ri *ResourceInstance[T]) GetPeerGroups() ([]ResourcePartnerITF, []map[string][]string)

func (*ResourceInstance[T]) GetPricingsProfiles

func (ri *ResourceInstance[T]) GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF

func (*ResourceInstance[T]) GetProfile

func (ri *ResourceInstance[T]) GetProfile() pricing.PricingProfileITF

func (*ResourceInstance[T]) GetSelectedPartnership

func (ri *ResourceInstance[T]) GetSelectedPartnership(peerID string, groups []string) ResourcePartnerITF

type ResourceInstanceITF

type ResourceInstanceITF interface {
	utils.DBObject
	GetID() string
	GetName() string
	StoreDraftDefault()
	ClearEnv()
	GetProfile() pricing.PricingProfileITF
	GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF
	GetPeerGroups() ([]ResourcePartnerITF, []map[string][]string)
	ClearPeerGroups()
	GetSelectedPartnership(peerID string, groups []string) ResourcePartnerITF
	GetPartnerships(peerID string, groups []string) []ResourcePartnerITF
}

type ResourceInterface

type ResourceInterface interface {
	utils.DBObject
	Trim()
	ConvertToPricedResource(t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF
	GetType() string
	GetSelectedInstance() ResourceInstanceITF
	ClearEnv() utils.DBObject
	SetAllowedInstances(request *tools.APIRequest)
}

type ResourceMongoAccessor

type ResourceMongoAccessor[T ResourceInterface] struct {
	utils.AbstractAccessor // AbstractAccessor contains the basic fields of an accessor (model, caller)
	// contains filtered or unexported fields
}

func NewAccessor

func NewAccessor[T ResourceInterface](t tools.DataType, request *tools.APIRequest, g func() utils.DBObject) *ResourceMongoAccessor[T]

New creates a new instance of the computeMongoAccessor

func (*ResourceMongoAccessor[T]) CopyOne

func (dca *ResourceMongoAccessor[T]) CopyOne(data utils.DBObject) (utils.DBObject, int, error)

func (*ResourceMongoAccessor[T]) DeleteOne

func (dca *ResourceMongoAccessor[T]) DeleteOne(id string) (utils.DBObject, int, error)

* Nothing special here, just the basic CRUD operations

func (*ResourceMongoAccessor[T]) LoadAll

func (wfa *ResourceMongoAccessor[T]) LoadAll(isDraft bool) ([]utils.ShallowDBObject, int, error)

func (*ResourceMongoAccessor[T]) LoadOne

func (dca *ResourceMongoAccessor[T]) LoadOne(id string) (utils.DBObject, int, error)

func (*ResourceMongoAccessor[T]) Search

func (wfa *ResourceMongoAccessor[T]) Search(filters *dbs.Filters, search string, isDraft bool) ([]utils.ShallowDBObject, int, error)

func (*ResourceMongoAccessor[T]) StoreOne

func (dca *ResourceMongoAccessor[T]) StoreOne(data utils.DBObject) (utils.DBObject, int, error)

func (*ResourceMongoAccessor[T]) UpdateOne

func (dca *ResourceMongoAccessor[T]) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error)

type ResourcePartnerITF

type ResourcePartnerITF interface {
	GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF
	GetPeerGroups() map[string][]string
	ClearPeerGroups()
	GetProfile(buying int, strategy int) pricing.PricingProfileITF
}

type ResourcePartnerShip

type ResourcePartnerShip[T pricing.PricingProfileITF] struct {
	Namespace       string              `json:"namespace" bson:"namespace" default:"default-namespace"`
	PeerGroups      map[string][]string `json:"peer_groups,omitempty" bson:"peer_groups,omitempty"`
	PricingProfiles map[int]map[int]T   `json:"pricing_profiles,omitempty" bson:"pricing_profiles,omitempty"`
}

func (*ResourcePartnerShip[T]) ClearPeerGroups

func (rp *ResourcePartnerShip[T]) ClearPeerGroups()

func (*ResourcePartnerShip[T]) GetPeerGroups

func (rp *ResourcePartnerShip[T]) GetPeerGroups() map[string][]string

func (*ResourcePartnerShip[T]) GetPricingsProfiles

func (ri *ResourcePartnerShip[T]) GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF

Le pricing doit être selectionné lors d'un scheduling... le type de paiement défini le type de stratégie de paiement note : il faut rajouté - une notion de facturation Une order est l'ensemble de la commande... un booking une réservation, une purchase un acte d'achat. Une bill (facture) représente alors... l'emission d'une facture à un instant T en but d'être honorée, envoyée ... etc.

func (*ResourcePartnerShip[T]) GetProfile

func (ri *ResourcePartnerShip[T]) GetProfile(buying int, strategy int) pricing.PricingProfileITF

type ResourceSet

type ResourceSet struct {
	Datas       []string `bson:"datas,omitempty" json:"datas,omitempty"`
	Storages    []string `bson:"storages,omitempty" json:"storages,omitempty"`
	Processings []string `bson:"processings,omitempty" json:"processings,omitempty"`
	Computes    []string `bson:"computes,omitempty" json:"computes,omitempty"`
	Workflows   []string `bson:"workflows,omitempty" json:"workflows,omitempty"`

	DataResources       []*DataResource       `bson:"-" json:"data_resources,omitempty"`
	StorageResources    []*StorageResource    `bson:"-" json:"storage_resources,omitempty"`
	ProcessingResources []*ProcessingResource `bson:"-" json:"processing_resources,omitempty"`
	ComputeResources    []*ComputeResource    `bson:"-" json:"compute_resources,omitempty"`
	WorkflowResources   []*WorkflowResource   `bson:"-" json:"workflow_resources,omitempty"`
}

func (*ResourceSet) Clear

func (r *ResourceSet) Clear()

func (*ResourceSet) Fill

func (r *ResourceSet) Fill(request *tools.APIRequest)

type StorageResource

type StorageResource struct {
	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
}

* StorageResource is a struct that represents a storage resource * it defines the resource storage

func (*StorageResource) ConvertToPricedResource

func (abs *StorageResource) ConvertToPricedResource(t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF

func (*StorageResource) GetAccessor

func (d *StorageResource) GetAccessor(request *tools.APIRequest) utils.Accessor

func (*StorageResource) GetType

func (r *StorageResource) GetType() string

type StorageResourceInstance

type StorageResourceInstance struct {
	ResourceInstance[*StorageResourcePartnership]
	Source        string           `bson:"source,omitempty" json:"source,omitempty"` // Source is the source of the storage
	Path          string           `bson:"path,omitempty" json:"path,omitempty"`     // Path is the store folders in the source
	Local         bool             `bson:"local" json:"local"`
	SecurityLevel string           `bson:"security_level,omitempty" json:"security_level,omitempty"`
	SizeType      enum.StorageSize `bson:"size_type" json:"size_type" default:"0"`           // SizeType is the type of the storage size
	SizeGB        int64            `bson:"size,omitempty" json:"size,omitempty"`             // Size is the size of the storage
	Encryption    bool             `bson:"encryption,omitempty" json:"encryption,omitempty"` // Encryption is a flag that indicates if the storage is encrypted
	Redundancy    string           `bson:"redundancy,omitempty" json:"redundancy,omitempty"` // Redundancy is the redundancy of the storage
	Throughput    string           `bson:"throughput,omitempty" json:"throughput,omitempty"` // Throughput is the throughput of the storage
}

func (*StorageResourceInstance) ClearEnv

func (ri *StorageResourceInstance) ClearEnv()

func (*StorageResourceInstance) StoreDraftDefault

func (ri *StorageResourceInstance) StoreDraftDefault()

type StorageResourcePartnership

type StorageResourcePartnership struct {
	ResourcePartnerShip[*StorageResourcePricingProfile]
	MaxSizeGBAllowed     float64 `json:"allowed_gb,omitempty" bson:"allowed_gb,omitempty"`
	OnlyEncryptedAllowed bool    `json:"personal_data_allowed,omitempty" bson:"personal_data_allowed,omitempty"`
}

type StorageResourcePricingProfile

type StorageResourcePricingProfile struct {
	pricing.ExploitPricingProfile[StorageResourcePricingStrategy] // ExploitPricingProfile is the pricing profile of a storage it means that we exploit the resource for an amount of continuous time
}

func (*StorageResourcePricingProfile) GetPrice

func (p *StorageResourcePricingProfile) GetPrice(amountOfData float64, val float64, start time.Time, end time.Time, params ...string) (float64, error)

func (*StorageResourcePricingProfile) GetPurchase

func (*StorageResourcePricingProfile) IsBooked

func (p *StorageResourcePricingProfile) IsBooked() bool

func (*StorageResourcePricingProfile) IsPurchasable

func (p *StorageResourcePricingProfile) IsPurchasable() bool

type StorageResourcePricingStrategy

type StorageResourcePricingStrategy int
const (
	PER_DATA_STORED StorageResourcePricingStrategy = iota + 6
	PER_TB_STORED
	PER_GB_STORED
	PER_MB_STORED
	PER_KB_STORED
)

func StorageResourcePricingStrategyList

func StorageResourcePricingStrategyList() []StorageResourcePricingStrategy

func ToStorageResourcePricingStrategy

func ToStorageResourcePricingStrategy(i int) StorageResourcePricingStrategy

func (StorageResourcePricingStrategy) GetQuantity

func (t StorageResourcePricingStrategy) GetQuantity(amountOfDataGB float64) (float64, error)

func (StorageResourcePricingStrategy) GetStrategy

func (t StorageResourcePricingStrategy) GetStrategy() string

func (StorageResourcePricingStrategy) GetStrategyValue

func (t StorageResourcePricingStrategy) GetStrategyValue() int

func (StorageResourcePricingStrategy) String

type WorkflowResource

type WorkflowResource struct {
	AbstractResource
	WorkflowID string `bson:"workflow_id,omitempty" json:"workflow_id,omitempty"` // WorkflowID is the ID of the native workflow
}

WorkflowResource is a struct that represents a workflow resource it defines the resource workflow

func (*WorkflowResource) ClearEnv

func (d *WorkflowResource) ClearEnv() utils.DBObject

func (*WorkflowResource) ConvertToPricedResource

func (w *WorkflowResource) ConvertToPricedResource(t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF

func (*WorkflowResource) GetAccessor

func (d *WorkflowResource) GetAccessor(request *tools.APIRequest) utils.Accessor

func (*WorkflowResource) GetType

func (r *WorkflowResource) GetType() string

func (*WorkflowResource) SetAllowedInstances

func (w *WorkflowResource) SetAllowedInstances(request *tools.APIRequest)

func (*WorkflowResource) Trim

func (d *WorkflowResource) Trim()

type WorkflowResourcePricingProfile

type WorkflowResourcePricingProfile struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL