2024-12-12 16:25:47 +01:00
package pricing
import (
"time"
"cloud.o-forge.io/core/oc-lib/tools"
)
type PricingProfileITF interface {
GetID ( ) string
GetPrice ( quantity float64 , val float64 , start time . Time , end time . Time , request * tools . APIRequest , params ... string ) ( float64 , error )
2024-12-17 10:42:00 +01:00
IsPurchased ( ) bool
2024-12-12 16:25:47 +01:00
GetOverrideStrategyValue ( ) int
}
type RefundType int
const (
REFUND_DEAD_END RefundType = iota
REFUND_ON_ERROR
REFUND_ON_EARLY_END
)
2024-12-16 12:17:20 +01:00
type AccessPricingProfile [ T Strategy ] struct { // only use for acces such as : DATA && PROCESSING
ID string ` json:"id,omitempty" bson:"id,omitempty" ` // ID is the ID of the pricing
Pricing PricingStrategy [ T ] ` json:"price,omitempty" bson:"price,omitempty" ` // Price is the price of the resource
DefaultRefund RefundType ` json:"default_refund" bson:"default_refund" ` // DefaultRefund is the default refund type of the pricing
RefundRatio int32 ` json:"refund_ratio" bson:"refund_ratio" default:"0" ` // RefundRatio is the refund ratio if missing
2024-12-12 16:25:47 +01:00
}
2024-12-16 12:17:20 +01:00
func ( b * AccessPricingProfile [ T ] ) GetID ( ) string {
return b . ID
}
func ( b * AccessPricingProfile [ T ] ) GetOverrideStrategyValue ( ) int {
2024-12-12 16:25:47 +01:00
return - 1
}
2024-12-16 12:17:20 +01:00
type ExploitPrivilegeStrategy int
2024-12-12 16:25:47 +01:00
const (
2024-12-16 12:17:20 +01:00
BASIC ExploitPrivilegeStrategy = iota
2024-12-12 16:25:47 +01:00
GARANTED_ON_DELAY
GARANTED
)
2024-12-16 12:17:20 +01:00
func ( t ExploitPrivilegeStrategy ) String ( ) string {
2024-12-12 16:25:47 +01:00
return [ ... ] string { "BASIC" , "GARANTED_ON_DELAY" , "GARANTED" } [ t ]
}
2024-12-16 12:17:20 +01:00
type ExploitPricingProfile [ T Strategy ] struct { // only use for exploit such as : STORAGE, COMPUTE, WORKFLOW
AccessPricingProfile [ T ]
2024-12-12 16:25:47 +01:00
AdditionnalRefundTypes [ ] RefundType ` json:"refund_types" bson:"refund_types" ` // RefundTypes is the refund types of the pricing
2024-12-16 12:17:20 +01:00
PrivilegeStrategy ExploitPrivilegeStrategy ` json:"privilege_strategy,omitempty" bson:"privilege_strategy,omitempty" ` // Strategy is the strategy of the pricing
2024-12-12 16:25:47 +01:00
GarantedDelaySecond uint
Exceeding bool
ExceedingRatio int32 ` json:"exceeding_ratio" bson:"exceeding_ratio" default:"0" ` // ExceedingRatio is the exceeding ratio of the bill
}