resources

package
v0.0.0-...-cef23b5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToPricedResource

func ConvertToPricedResource[T pricing.PricingProfileITF](t tools.DataType,
	selectedInstance *int, selectedPartnership *int, selectedBuyingStrategy *int, selectedStrategy *int,
	selectedBookingModeIndex *int, abs ResourceInterface, request *tools.APIRequest) (pricing.PricedItemITF, error)

func EmitAEBehaviorReport

func EmitAEBehaviorReport(consumerPeerID string, violations []AEViolation)

EmitAEBehaviorReport emits a PEER_BEHAVIOR_EVENT(BehaviorFraud) for each unique AE violation. Call this before rejecting the execution.

func FiltersFromFlatMap

func FiltersFromFlatMap(flatMap map[string]interface{}, target interface{}) *dbs.Filters

func InitNative

func InitNative()

func VerifyAuthAction

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

Types

type AEViolation

type AEViolation struct {
	AEID       string
	ResourceID string
	Type       AEViolationType
	Message    string
}

AEViolation describes a single constraint that was not satisfied.

type AEViolationType

type AEViolationType string
const (
	AEViolationRevoked          AEViolationType = "ae_revoked"
	AEViolationExpired          AEViolationType = "ae_expired"
	AEViolationNotYetValid      AEViolationType = "ae_not_yet_valid"
	AEViolationPeerNotAllowed   AEViolationType = "ae_peer_not_allowed"
	AEViolationWorkflowNotAllow AEViolationType = "ae_workflow_not_allowed"
	AEViolationCouplingRequired AEViolationType = "ae_coupling_required"
	AEViolationCouplingForbid   AEViolationType = "ae_coupling_forbidden"
)

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"`
}

func (*AbstractInstanciatedResource[T]) AddInstances

func (abs *AbstractInstanciatedResource[T]) AddInstances(instance ResourceInstanceITF)

func (*AbstractInstanciatedResource[T]) GetSelectedInstance

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

func (*AbstractInstanciatedResource[T]) SetAllowedInstances

func (abs *AbstractInstanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest, instanceID ...string) []ResourceInstanceITF

func (*AbstractInstanciatedResource[T]) VerifyAuth

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

type AbstractResource

type AbstractResource struct {
	utils.AbstractObject                                                   // AbstractObject contains the basic fields of an object (id, name)
	PurchaseID           string                                            `json:"purchase_id,omitempty"`                                          // is_buy precise if a resource is buy or not
	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"` // 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"`
	AllowedBookingModes  map[booking.BookingMode]*pricing.PricingVariation `bson:"allowed_booking_modes" json:"allowed_booking_modes"`

	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"`

	// License is the usage licence of the resource (SPDX identifier or free-text).
	// Displayed prominently in the catalog detail view.
	License string `json:"license,omitempty" bson:"license,omitempty"`

	// ExploitationAuthorizations (AEs) are coupling and peer-usage constraints
	// issued by the resource owner.  Stored embedded in the resource document,
	// NOT in a separate collection.
	// Visibility-filtered per requesting peer before any response is sent.
	ExploitationAuthorizations []ExploitationAuthorization `json:"exploitation_authorizations,omitempty" bson:"exploitation_authorizations,omitempty"`
}

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

func (*AbstractResource) CanUpdate

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

func (*AbstractResource) ClearEnv

func (ri *AbstractResource) ClearEnv() utils.DBObject

func (*AbstractResource) Extend

func (ri *AbstractResource) Extend(typ ...string) map[string][]tools.DataType

func (*AbstractResource) FilterExploitationAuthorizations

func (r *AbstractResource) FilterExploitationAuthorizations(peerID string, isAdmin bool)

FilterExploitationAuthorizations removes AEs that are not visible to peerID. Must be called before serializing the resource for a consumer peer. The resource owner (CreatorID) always sees all AEs unfiltered.

func (*AbstractResource) FilterPeer

func (abs *AbstractResource) FilterPeer(peerID string) *dbs.Filters

func (*AbstractResource) GetBookingModes

func (r *AbstractResource) GetBookingModes() map[booking.BookingMode]*pricing.PricingVariation

func (*AbstractResource) GetEnv

func (abs *AbstractResource) GetEnv() []models.Param

func (*AbstractResource) GetExploitationAuthorizations

func (r *AbstractResource) GetExploitationAuthorizations() []ExploitationAuthorization

GetExploitationAuthorizations returns all AEs attached to this resource. Used by oc-schedulerd's CheckWorkflowAE via structural interface assertion.

func (*AbstractResource) GetInputs

func (abs *AbstractResource) GetInputs() []models.Param

func (*AbstractResource) GetOutputs

func (abs *AbstractResource) GetOutputs() []models.Param

func (*AbstractResource) GetType

func (r *AbstractResource) GetType() string

func (*AbstractResource) StoreDraftDefault

func (r *AbstractResource) StoreDraftDefault()

func (*AbstractResource) VerifyBuy

func (abs *AbstractResource) VerifyBuy()

type BookingConfiguration

type BookingConfiguration struct {
	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"`
	Mode                     booking.BookingMode `json:"mode,omitempty" bson:"mode,omitempty"`
}

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, selectedInstance *int, selectedPartnership *int, selectedBuyingStrategy *int, selectedStrategy *int, selectedBookingModeIndex *int, request *tools.APIRequest) (pricing.PricedItemITF, error)

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"`
	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"`
	GPUs               map[string]*models.GPU `bson:"gpus,omitempty" json:"gpus,omitempty"`
	Nodes              []*live.ComputeNode    `json:"nodes,omitempty" bson:"nodes,omitempty"`
	// AvailableStorages lists storage capabilities activatable on this compute unit (e.g. Minio, local volumes).
	// These are shallow StorageResource entries — not independent catalog items — but carry full pricing structure.
	AvailableStorages []*StorageResource `json:"available_storages,omitempty" bson:"available_storages,omitempty"`
}

func (*ComputeResourceInstance) IsPeerless

func (ri *ComputeResourceInstance) IsPeerless() bool

IsPeerless is always false for compute instances: a compute resource is infrastructure owned by a peer and can never be declared peerless.

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) GetPriceHT

func (p *ComputeResourcePricingProfile) GetPriceHT(amountOfData float64, explicitDuration float64, start time.Time, end time.Time, variation []*pricing.PricingVariation, 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 CouplingConstraint

type CouplingConstraint struct {
	// RequiredResourceIDs — ALL of these resource UUIDs must appear in the
	// workflow alongside the protected resource.
	RequiredResourceIDs []string `json:"required_resource_ids,omitempty" bson:"required_resource_ids,omitempty"`
	// ForbiddenResourceIDs — NONE of these resource UUIDs may appear in the
	// workflow alongside the protected resource.
	ForbiddenResourceIDs []string `json:"forbidden_resource_ids,omitempty" bson:"forbidden_resource_ids,omitempty"`
}

CouplingConstraint defines which resources must or must not co-exist in the same workflow when the protected resource is included.

type DataInstance

type DataInstance struct {
	ResourceInstance[*DataResourcePartnership]
	Access *ResourceAccess `json:"access,omitempty" bson:"access,omitempty"`
}

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, selectedInstance *int, selectedPartnership *int, selectedBuyingStrategy *int, selectedStrategy *int, selectedBookingModeIndex *int, request *tools.APIRequest) (pricing.PricedItemITF, error)

func (*DataResource) GetAccessor

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

func (*DataResource) GetType

func (r *DataResource) GetType() string

func (*DataResource) StoreDraftDefault

func (ri *DataResource) StoreDraftDefault()

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) IsBooked

func (p *DataResourcePricingProfile) IsBooked() bool

func (*DataResourcePricingProfile) IsPurchasable

func (p *DataResourcePricingProfile) IsPurchasable() bool

type DataResourcePricingStrategy

type DataResourcePricingStrategy int
const (
	PER_DOWNLOAD DataResourcePricingStrategy = iota + 7
	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 DynamicResource

type DynamicResource struct {
	AbstractResource
	Type      tools.DataType         `bson:"type,omitempty" json:"type,omitempty"`
	Filters   map[string]interface{} `bson:"filters,omitempty" json:"filters,omitempty"`
	SortRules map[string]string      `bson:"rules,omitempty" json:"rules,omitempty"`

	PeerIds     map[int]string `bson:"peer_ids,omitempty" json:"peer_ids,omitempty"`
	ResourceIds map[int]string `bson:"resource_ids,omitempty" json:"resource_ids,omitempty"`

	SelectedIndex            int  `bson:"selected_index,omitempty" json:"selected_index,omitempty"`
	SelectedPartnershipIndex *int `bson:"selected_partnership_index,omitempty" json:"selected_partnership_index,omitempty"`

	SelectedBuyingStrategy  int `bson:"selected_buying_strategy" json:"selected_buying_strategy,omitempty"`
	SelectedPricingStrategy int `bson:"selected_pricing_strategy" json:"selected_pricing_strategy,omitempty"`

	Instances              []ResourceInstanceITF `bson:"instances,omitempty" json:"instances,omitempty"`
	WatchedDynamicResource []string              `bson:"watched_dynamic_resource,omitempty" json:"watched_dynamic_resource,omitempty"`
}

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

func (*DynamicResource) AddInstances

func (d *DynamicResource) AddInstances(instance ResourceInstanceITF)

func (*DynamicResource) ConvertToPricedResource

func (abs *DynamicResource) ConvertToPricedResource(t tools.DataType, selectedInstance *int, selectedPartnership *int, selectedBuyingStrategy *int, selectedStrategy *int, selectedBookingModeIndex *int, request *tools.APIRequest) (pricing.PricedItemITF, error)

func (*DynamicResource) GetAccessor

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

func (*DynamicResource) GetSelectedInstance

func (d *DynamicResource) GetSelectedInstance(index *int) ResourceInstanceITF

func (*DynamicResource) GetType

func (r *DynamicResource) GetType() string

func (*DynamicResource) SetAllowedInstances

func (d *DynamicResource) SetAllowedInstances(request *tools.APIRequest, instance_id ...string) []ResourceInstanceITF

type EmbeddedStorageSelection

type EmbeddedStorageSelection struct {
	StorageIndex     int `json:"storage_index" bson:"storage_index"`         // index in ComputeResourceInstance.AvailableStorages
	PartnershipIndex int `json:"partnership_index" bson:"partnership_index"` // index in the storage's partnerships
	BuyingIndex      int `json:"buying_index" bson:"buying_index"`
	StrategyIndex    int `json:"strategy_index" bson:"strategy_index"`
}

EmbeddedStorageSelection records which storage capability was activated on a compute unit graph node, and which pricing options were selected for it. Key in WorkflowExecution.SelectedEmbeddedStorages is the compute graph node ID. A nil/absent entry means no storage was activated on that compute unit.

type ExploitationAuthorization

type ExploitationAuthorization struct {
	// ID is a client-assigned UUID so individual AEs can be referenced.
	ID string `json:"id" bson:"id"`
	// Name is a human-readable label shown in the catalog detail view.
	Name string `json:"name,omitempty" bson:"name,omitempty"`

	// AllowedPeerIDs restricts which consumer peers may use the resource.
	// An empty list means any peer is allowed.
	AllowedPeerIDs []string `json:"allowed_peer_ids,omitempty" bson:"allowed_peer_ids,omitempty"`

	// AllowedWorkflowIDs restricts which workflow IDs may include the resource.
	// An empty list means any workflow is allowed.
	AllowedWorkflowIDs []string `json:"allowed_workflow_ids,omitempty" bson:"allowed_workflow_ids,omitempty"`

	// Coupling describes positive (required) and negative (forbidden) coupling.
	// Nil means no coupling constraint.
	Coupling *CouplingConstraint `json:"coupling,omitempty" bson:"coupling,omitempty"`

	// ValidFrom / ValidUntil define the active window.
	ValidFrom  *time.Time `json:"valid_from,omitempty" bson:"valid_from,omitempty"`
	ValidUntil *time.Time `json:"valid_until,omitempty" bson:"valid_until,omitempty"`

	// IsRevoked allows instant revocation without deleting the AE from the resource.
	IsRevoked bool `json:"is_revoked" bson:"is_revoked"`
}

ExploitationAuthorization (AE) is embedded in a resource and restricts how the resource may be used by other consumer peers.

It is stored as part of the resource document (bson embedded), not as a separate collection. Create/update it by PATCHing the parent resource.

func (*ExploitationAuthorization) CheckAE

func (ae *ExploitationAuthorization) CheckAE(
	resourceID, workflowID, consumerPeerID string,
	workflowResourceIDs map[string]struct{},
	now time.Time,
) []AEViolation

CheckAE evaluates this AE against the execution context and returns any violations found. workflowResourceIDs is the set of all resource UUIDs in the workflow; resourceID is the UUID of the resource this AE belongs to.

func (*ExploitationAuthorization) IsVisibleTo

func (ae *ExploitationAuthorization) IsVisibleTo(peerID, creatorID string) bool

IsVisibleTo returns true when this AE should be included in the response to peerID. The resource owner (creatorID) always sees all AEs.

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"`
	NativeTool *NativeTool         `bson:"native_tools,omitempty" json:"native_tools,omitempty"`
	Service    *ServiceResource    `bson:"service,omitempty" json:"service,omitempty"`
	Dynamic    *DynamicResource    `bson:"dynamic,omitempty" json:"dynamic,omitempty"`
}

type NativeTool

type NativeTool struct {
	AbstractResource
	Kind   int `json:"kind" bson:"kind" validate:"required"`
	Params map[string]interface{}
}

* NativeT ools is a struct that represents Native Functionnality of OPENCLOUD

func (*NativeTool) AddInstances

func (r *NativeTool) AddInstances(instance ResourceInstanceITF)

func (*NativeTool) ClearEnv

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

func (*NativeTool) ConvertToPricedResource

func (w *NativeTool) ConvertToPricedResource(t tools.DataType, selectedInstance *int, selectedPartnership *int, selectedBuyingStrategy *int, selectedStrategy *int, selectedBookingModeIndex *int, request *tools.APIRequest) (pricing.PricedItemITF, error)

func (*NativeTool) GetAccessor

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

func (*NativeTool) GetSelectedInstance

func (r *NativeTool) GetSelectedInstance(selected *int) ResourceInstanceITF

func (*NativeTool) GetType

func (r *NativeTool) GetType() string

func (*NativeTool) SetAllowedInstances

func (w *NativeTool) SetAllowedInstances(request *tools.APIRequest, ids ...string) []ResourceInstanceITF

func (*NativeTool) SetName

func (d *NativeTool) SetName(name string)

type OriginMeta

type OriginMeta struct {
	Type     OriginType `json:"origin_type" bson:"origin_type"`
	Ref      string     `json:"origin_ref,omitempty" bson:"origin_ref,omitempty"` // e.g. "docker.io/pytorch/pytorch:2.1"
	Verified bool       `json:"origin_verified" bson:"origin_verified"`           // manually vetted by an OC admin
}

OriginMeta carries provenance information for a resource instance.

func (OriginMeta) DeclaredPeerless

func (o OriginMeta) DeclaredPeerless() bool

IsPeerless MUST NOT be used for authorization decisions. Use ResourceInstance.IsPeerless() instead, which derives the property from structural invariants rather than this self-declared field.

This method is kept only for display/logging purposes.

type OriginType

type OriginType int

OriginType qualifies where a resource instance comes from.

const (
	// OriginPeer: instance offered by a known network peer (default).
	OriginPeer OriginType = iota
	// OriginPublic: instance from a public registry (Docker Hub, HuggingFace, etc.).
	// No peer confirmation is needed; access is unrestricted.
	OriginPublic
	// OriginSelf: self-hosted instance with no third-party peer.
	OriginSelf
)

type PricedComputeResource

type PricedComputeResource struct {
	PricedResource[*ComputeResourcePricingProfile]

	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) GetPriceHT

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

func (*PricedComputeResource) GetType

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

func (*PricedComputeResource) IsBooked

func (r *PricedComputeResource) IsBooked() bool

func (*PricedComputeResource) IsPurchasable

func (r *PricedComputeResource) IsPurchasable() bool

type PricedDataResource

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

func (*PricedDataResource) GetPriceHT

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

func (*PricedDataResource) GetType

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

func (*PricedDataResource) IsBooked

func (r *PricedDataResource) IsBooked() bool

func (*PricedDataResource) IsPurchasable

func (r *PricedDataResource) IsPurchasable() bool

type PricedProcessingResource

type PricedProcessingResource struct {
	PricedResource[*ProcessingResourcePricingProfile]
}

func (*PricedProcessingResource) GetExplicitDurationInS

func (a *PricedProcessingResource) GetExplicitDurationInS() float64

func (*PricedProcessingResource) GetPriceHT

func (r *PricedProcessingResource) GetPriceHT() (float64, error)

func (*PricedProcessingResource) GetType

func (*PricedProcessingResource) IsBooked

func (r *PricedProcessingResource) IsBooked() bool

func (*PricedProcessingResource) IsPurchasable

func (r *PricedProcessingResource) IsPurchasable() bool

type PricedResource

type PricedResource[T pricing.PricingProfileITF] struct {
	Name                 string                      `json:"name,omitempty" bson:"name,omitempty"`
	InstancesRefs        map[string]string           `json:"instances_refs,omitempty" bson:"instances_refs,omitempty"`
	SelectedPricing      T                           `json:"selected_pricing,omitempty" bson:"selected_pricing,omitempty"`
	Quantity             int                         `json:"quantity,omitempty" bson:"quantity,omitempty"`
	BookingConfiguration *BookingConfiguration       `json:"booking_configuration,omitempty" bson:"booking_configuration,omitempty"`
	Variations           []*pricing.PricingVariation `json:"pricing_variations" bson:"pricing_variations"`
	CreatorID            string                      `json:"peer_id,omitempty" bson:"peer_id,omitempty"`
	ResourceID           string                      `json:"resource_id,omitempty" bson:"resource_id,omitempty"`
	InstanceID           string                      `json:"instance_id,omitempty" bson:"resource_id,omitempty"`

	ResourceType tools.DataType `json:"resource_type,omitempty" bson:"resource_type,omitempty"`
}

func (*PricedResource[T]) AddQuantity

func (abs *PricedResource[T]) AddQuantity(amount int)

func (*PricedResource[T]) GetBookingMode

func (abs *PricedResource[T]) GetBookingMode() booking.BookingMode

func (*PricedResource[T]) GetCreatorID

func (abs *PricedResource[T]) GetCreatorID() string

func (*PricedResource[T]) GetExplicitDurationInS

func (abs *PricedResource[T]) GetExplicitDurationInS() float64

func (*PricedResource[T]) GetID

func (abs *PricedResource[T]) GetID() string

func (*PricedResource[T]) GetInstanceID

func (abs *PricedResource[T]) GetInstanceID() string

func (*PricedResource[T]) GetLocationEnd

func (abs *PricedResource[T]) GetLocationEnd() *time.Time

func (*PricedResource[T]) GetLocationStart

func (abs *PricedResource[T]) GetLocationStart() *time.Time

func (*PricedResource[T]) GetName

func (abs *PricedResource[T]) GetName() string

func (*PricedResource[T]) GetPriceHT

func (r *PricedResource[T]) GetPriceHT() (float64, error)

func (*PricedResource[T]) GetQuantity

func (abs *PricedResource[T]) GetQuantity() int

func (*PricedResource[T]) GetType

func (abs *PricedResource[T]) GetType() tools.DataType

func (*PricedResource[T]) IsBooked

func (abs *PricedResource[T]) IsBooked() bool

func (*PricedResource[T]) IsPurchasable

func (abs *PricedResource[T]) IsPurchasable() bool

IsPurchasable and IsBooked fall back to false when SelectedPricing is a nil interface. Concrete types (PricedComputeResource, etc.) override these and guarantee non-nil pricing.

func (*PricedResource[T]) SelectPricing

func (abs *PricedResource[T]) SelectPricing() pricing.PricingProfileITF

func (*PricedResource[T]) SetLocationEnd

func (abs *PricedResource[T]) SetLocationEnd(end time.Time)

func (*PricedResource[T]) SetLocationStart

func (abs *PricedResource[T]) SetLocationStart(start time.Time)

type PricedResourceITF

type PricedResourceITF interface {
	pricing.PricedItemITF
}

type PricedServiceResource

type PricedServiceResource struct {
	PricedResource[*ServiceResourcePricingProfile]
}

func (*PricedServiceResource) GetExplicitDurationInS

func (a *PricedServiceResource) GetExplicitDurationInS() float64

GetExplicitDurationInS returns -1 for DEPLOYMENT (unbounded uptime). For HOSTED, returns the actual call window duration.

func (*PricedServiceResource) GetPriceHT

func (r *PricedServiceResource) GetPriceHT() (float64, error)

func (*PricedServiceResource) GetType

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

func (*PricedServiceResource) IsBooked

func (r *PricedServiceResource) IsBooked() bool

func (*PricedServiceResource) IsPurchasable

func (r *PricedServiceResource) IsPurchasable() bool

type PricedStorageResource

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

func (*PricedStorageResource) GetPriceHT

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

func (*PricedStorageResource) GetType

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

func (*PricedStorageResource) IsBooked

func (r *PricedStorageResource) IsBooked() bool

func (*PricedStorageResource) IsPurchasable

func (r *PricedStorageResource) IsPurchasable() bool

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      *ResourceAccess `json:"access,omitempty" bson:"access,omitempty"` // Access is the access
	SizeGB      int             `json:"size_gb,omitempty" bson:"size_gb,omitempty"`
	ContentType string          `json:"content_type,omitempty" bson:"content_type,omitempty"`
}

type ProcessingResource

type ProcessingResource struct {
	AbstractInstanciatedResource[*ProcessingInstance]
	Infrastructure enum.InfrastructureType `json:"infrastructure" bson:"infrastructure" default:"-1"`
	Usage          *ProcessingUsage        `bson:"usage,omitempty" json:"usage,omitempty"`
	OpenSource     bool                    `json:"open_source" bson:"open_source" default:"false"`
	// IsService marks a long-running processing that acts as a persistent service.
	// Such processings do not require a Compute booking (they manage their own lifecycle).
	IsService bool   `json:"is_service" bson:"is_service" default:"false"`
	Maturity  string `json:"maturity,omitempty" bson:"maturity,omitempty"`
}

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

func (*ProcessingResource) ConvertToPricedResource

func (abs *ProcessingResource) ConvertToPricedResource(t tools.DataType, selectedInstance *int, selectedPartnership *int, selectedBuyingStrategy *int, selectedStrategy *int, selectedBookingModeIndex *int, request *tools.APIRequest) (pricing.PricedItemITF, error)

func (*ProcessingResource) GetAccessor

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

func (*ProcessingResource) GetType

func (r *ProcessingResource) GetType() string

type ProcessingResourcePartnership

type ProcessingResourcePartnership struct {
	ResourcePartnerShip[*ProcessingResourcePricingProfile]
}

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) 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 ResourceAccess

type ResourceAccess struct {
	Source    *models.PathSource `json:"source,omitempty" bson:"source,omitempty"`
	Container *models.Container  `json:"container,omitempty" bson:"container,omitempty"` // Container is the container
}

func (*ResourceAccess) HasContainer

func (a *ResourceAccess) HasContainer() bool

HasContainer returns true when an explicit container image is provided.

func (*ResourceAccess) HasSource

func (a *ResourceAccess) HasSource() bool

HasSource returns true when the access is source-based (no embedded container).

type ResourceInstance

type ResourceInstance[T ResourcePartnerITF] struct {
	utils.AbstractObject
	ContentType    string                `json:"content_type,omitempty" bson:"content_type,omitempty"`
	LastUpdate     time.Time             `json:"last_update,omitempty" bson:"last_update,omitempty"`
	Origin         OriginMeta            `json:"origin,omitempty" bson:"origin,omitempty"`
	Location       live.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"`

	Partnerships []T `json:"partnerships,omitempty" bson:"partnerships,omitempty"`

	AverageDurationS       float64 `json:"average_duration_s,omitempty" bson:"average_duration_s,omitempty"`
	AverageDurationSamples int     `json:"average_duration_samples,omitempty" bson:"average_duration_samples,omitempty"`
}

func NewInstance

func NewInstance[T ResourcePartnerITF](name string) *ResourceInstance[T]

func (*ResourceInstance[T]) ClearPeerGroups

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

func (*ResourceInstance[T]) FilterInstance

func (ri *ResourceInstance[T]) FilterInstance(peerID string)

func (*ResourceInstance[T]) GetAverageDurationS

func (ri *ResourceInstance[T]) GetAverageDurationS() float64

func (*ResourceInstance[T]) GetOrigin

func (ri *ResourceInstance[T]) GetOrigin() OriginMeta

func (*ResourceInstance[T]) GetPartnerships

func (ri *ResourceInstance[T]) GetPartnerships() []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(peerID string, partnershipIndex *int, buyingIndex *int, strategyIndex *int) pricing.PricingProfileITF

func (*ResourceInstance[T]) IsPeerless

func (ri *ResourceInstance[T]) IsPeerless() bool

IsPeerless returns true when the instance has no owning peer and a non-empty registry reference. This is derived from structural invariants — NOT from the self-declared Origin.Type field — to prevent auth bypass via metadata manipulation:

CreatorID == "" ∧ len(Partnerships) == 0 ∧ Origin.Ref != ""

func (*ResourceInstance[T]) UpdateAverageDuration

func (ri *ResourceInstance[T]) UpdateAverageDuration(actualS float64)

type ResourceInstanceITF

type ResourceInstanceITF interface {
	utils.DBObject
	GetID() string
	GetName() string
	GetOrigin() OriginMeta
	IsPeerless() bool
	FilterInstance(peerID string)
	GetProfile(peerID string, partnershipIndex *int, buying *int, strategy *int) pricing.PricingProfileITF
	GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF
	GetPeerGroups() ([]ResourcePartnerITF, []map[string][]string)
	ClearPeerGroups()
	GetPartnerships() []ResourcePartnerITF
	GetAverageDurationS() float64
	UpdateAverageDuration(actualS float64)
}

func NewComputeResourceInstance

func NewComputeResourceInstance(name string, peerID string) ResourceInstanceITF

func NewDataInstance

func NewDataInstance(name string, peerID string) ResourceInstanceITF

func NewProcessingInstance

func NewProcessingInstance(name string, peerID string) ResourceInstanceITF

func NewServiceInstance

func NewServiceInstance(name string, peerID string) ResourceInstanceITF

func NewStorageResourceInstance

func NewStorageResourceInstance(name string, peerID string) ResourceInstanceITF

type ResourceInterface

type ResourceInterface interface {
	utils.DBObject
	FilterPeer(peerID string) *dbs.Filters
	GetBookingModes() map[booking.BookingMode]*pricing.PricingVariation
	ConvertToPricedResource(t tools.DataType, a *int, selectedPartnership *int, selectedBuyingStrategy *int, selectedStrategy *int, b *int, request *tools.APIRequest) (pricing.PricedItemITF, error)
	GetType() string
	ClearEnv() utils.DBObject
	VerifyBuy()
	SetAllowedInstances(request *tools.APIRequest, instance_id ...string) []ResourceInstanceITF
	AddInstances(instance ResourceInstanceITF)
	GetSelectedInstance(index *int) ResourceInstanceITF
	StoreDraftDefault()

	GetEnv() []models.Param
	GetInputs() []models.Param
	GetOutputs() []models.Param
}

func ToResource

func ToResource(
	dt int,
	payload []byte,
) (ResourceInterface, error)

type ResourceMongoAccessor

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

func NewAccessor

func NewAccessor[T ResourceInterface](t tools.DataType, request *tools.APIRequest) *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]) GetExec

func (a *ResourceMongoAccessor[T]) GetExec(isDraft bool) func(utils.DBObject) utils.ShallowDBObject

func (*ResourceMongoAccessor[T]) GetObjectFilters

func (abs *ResourceMongoAccessor[T]) GetObjectFilters(search string) *dbs.Filters

func (*ResourceMongoAccessor[T]) LoadAll

func (wfa *ResourceMongoAccessor[T]) LoadAll(isDraft bool, offset int64, limit int64) ([]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, offset int64, limit int64) ([]utils.ShallowDBObject, int, error)

func (*ResourceMongoAccessor[T]) ShouldVerifyAuth

func (dca *ResourceMongoAccessor[T]) ShouldVerifyAuth() bool

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 map[string]interface{}, 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
	FilterPartnership(peerID string)
}

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]) FilterPartnership

func (ri *ResourcePartnerShip[T]) FilterPartnership(peerID string)

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"`
	NativeTool  []string `bson:"native,omitempty" json:"native,omitempty"`
	Services    []string `bson:"services,omitempty" json:"services,omitempty"`
	Dynamics    []string `bson:"dynamics,omitempty" json:"dynamics,omitempty"`

	// DynamicResources are stored inline — no DB collection, resolved at runtime via SetAllowedInstances.
	DynamicResources    []*DynamicResource    `bson:"-" json:"dynamic_resources,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"`
	NativeTools         []*NativeTool         `bson:"-" json:"native_tools,omitempty"`
	ServiceResources    []*ServiceResource    `bson:"-" json:"service_resources,omitempty"`
}

func (*ResourceSet) Clear

func (r *ResourceSet) Clear()

func (*ResourceSet) Fill

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

type ServiceInstance

type ServiceInstance struct {
	ResourceInstance[*ServiceResourcePartnership]
	Mode          ServiceMode            `json:"mode" bson:"mode" default:"0"`
	Access        *ServiceResourceAccess `json:"access,omitempty" bson:"access,omitempty"`
	MaxConcurrent int                    `json:"max_concurrent,omitempty" bson:"max_concurrent,omitempty"`
}

func (*ServiceInstance) IsPeerless

func (ri *ServiceInstance) IsPeerless() bool

type ServiceMode

type ServiceMode int
const (
	DEPLOYMENT ServiceMode = iota // deploy the service, pay for uptime — duration unbounded
	HOSTED                        // use an existing service, pay per call — duration per request
)

func (ServiceMode) String

func (m ServiceMode) String() string

type ServiceResource

type ServiceResource struct {
	AbstractInstanciatedResource[*ServiceInstance]
	Infrastructure enum.InfrastructureType `json:"infrastructure" bson:"infrastructure" default:"-1"`
	Usage          *ServiceUsage           `bson:"usage,omitempty" json:"usage,omitempty"`
	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"`
}

func (*ServiceResource) ConvertToPricedResource

func (abs *ServiceResource) ConvertToPricedResource(t tools.DataType, selectedInstance *int, selectedPartnership *int, selectedBuyingStrategy *int, selectedStrategy *int, selectedBookingModeIndex *int, request *tools.APIRequest) (pricing.PricedItemITF, error)

func (*ServiceResource) GetAccessor

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

func (*ServiceResource) GetType

func (r *ServiceResource) GetType() string

type ServiceResourceAccess

type ServiceResourceAccess struct {
	Container       *models.Container    `json:"container,omitempty" bson:"container,omitempty"`
	Protocol        live.ServiceProtocol `json:"protocol" bson:"protocol" default:"0"`
	EndpointPattern string               `json:"endpoint_pattern,omitempty" bson:"endpoint_pattern,omitempty"`
	HealthCheckPath string               `json:"health_check_path,omitempty" bson:"health_check_path,omitempty"`
}

ServiceResourceAccess describes how to reach the service once running. Populated for HOSTED instances (endpoint already known) and as a template for DEPLOYMENT.

type ServiceResourcePartnership

type ServiceResourcePartnership struct {
	ResourcePartnerShip[*ServiceResourcePricingProfile]
}

type ServiceResourcePricingProfile

type ServiceResourcePricingProfile struct {
	Mode          ServiceMode                                                 `json:"mode" bson:"mode"`
	UptimePricing *pricing.ExploitPricingProfile[pricing.TimePricingStrategy] `json:"uptime_pricing,omitempty" bson:"uptime_pricing,omitempty"`
	AccessPricing *pricing.AccessPricingProfile[pricing.TimePricingStrategy]  `json:"access_pricing,omitempty" bson:"access_pricing,omitempty"`
}

ServiceResourcePricingProfile handles both service modes:

  • DEPLOYMENT: uptime billing via ExploitPricingProfile (pay while service is up)
  • HOSTED: per-call billing via AccessPricingProfile (pay per request)

func (*ServiceResourcePricingProfile) GetOverrideStrategyValue

func (p *ServiceResourcePricingProfile) GetOverrideStrategyValue() int

func (*ServiceResourcePricingProfile) GetPriceHT

func (p *ServiceResourcePricingProfile) GetPriceHT(quantity float64, val float64, start time.Time, end time.Time, variations []*pricing.PricingVariation, params ...string) (float64, error)

func (*ServiceResourcePricingProfile) GetPurchase

func (*ServiceResourcePricingProfile) IsBooked

func (p *ServiceResourcePricingProfile) IsBooked() bool

func (*ServiceResourcePricingProfile) IsPurchasable

func (p *ServiceResourcePricingProfile) IsPurchasable() bool

type ServiceUsage

type ServiceUsage struct {
	CPUs         map[string]*models.CPU `bson:"cpus,omitempty" json:"cpus,omitempty"`
	GPUs         map[string]*models.GPU `bson:"gpus,omitempty" json:"gpus,omitempty"`
	RAM          *models.RAM            `bson:"ram,omitempty" json:"ram,omitempty"`
	StorageGb    float64                `bson:"storage,omitempty" json:"storage,omitempty"`
	Hypothesis   string                 `bson:"hypothesis,omitempty" json:"hypothesis,omitempty"`
	ScalingModel string                 `bson:"scaling_model,omitempty" json:"scaling_model,omitempty"`
}

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, selectedInstance *int, selectedPartnership *int, selectedBuyingStrategy *int, selectedStrategy *int, selectedBookingModeIndex *int, request *tools.APIRequest) (pricing.PricedItemITF, error)

func (*StorageResource) GetAccessor

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

func (*StorageResource) GetType

func (r *StorageResource) GetType() string

func (*StorageResource) StoreDraftDefault

func (ri *StorageResource) StoreDraftDefault()

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) IsPeerless

func (ri *StorageResourceInstance) IsPeerless() bool

IsPeerless is always false for storage instances: a storage resource is infrastructure owned by a peer and can never be declared peerless.

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) 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 + 7
	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) AddInstances

func (r *WorkflowResource) AddInstances(instance ResourceInstanceITF)

func (*WorkflowResource) ClearEnv

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

func (*WorkflowResource) ConvertToPricedResource

func (w *WorkflowResource) ConvertToPricedResource(t tools.DataType, selectedInstance *int, selectedPartnership *int, selectedBuyingStrategy *int, selectedStrategy *int, selectedBookingModeIndex *int, request *tools.APIRequest) (pricing.PricedItemITF, error)

func (*WorkflowResource) GetAccessor

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

func (*WorkflowResource) GetSelectedInstance

func (r *WorkflowResource) GetSelectedInstance(selected *int) ResourceInstanceITF

func (*WorkflowResource) GetType

func (r *WorkflowResource) GetType() string

func (*WorkflowResource) SetAllowedInstances

func (w *WorkflowResource) SetAllowedInstances(request *tools.APIRequest, ids ...string) []ResourceInstanceITF

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
⌂ 换网址