oclib
This commit is contained in:
@@ -219,7 +219,6 @@ func GetExtend(obj utils.DBObject, extends map[string][]tools.DataType, cache ma
|
|||||||
}
|
}
|
||||||
for _, vv := range v {
|
for _, vv := range v {
|
||||||
if cache[vv] != nil && cache[vv][fmt.Sprintf("%v", base[k+"_id"])] != nil {
|
if cache[vv] != nil && cache[vv][fmt.Sprintf("%v", base[k+"_id"])] != nil {
|
||||||
fmt.Println("FOUND", vv, k, cache[vv][fmt.Sprintf("%v", base[k+"_id"])])
|
|
||||||
base[k] = cache[vv][fmt.Sprintf("%v", base[k+"_id"])]
|
base[k] = cache[vv][fmt.Sprintf("%v", base[k+"_id"])]
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ type ProcessingUsage struct {
|
|||||||
*/
|
*/
|
||||||
type ProcessingResource struct {
|
type ProcessingResource struct {
|
||||||
AbstractInstanciatedResource[*ProcessingInstance]
|
AbstractInstanciatedResource[*ProcessingInstance]
|
||||||
IsEvent bool `json:"is_event,omitempty" bson:"is_event,omitempty"`
|
|
||||||
Infrastructure enum.InfrastructureType `json:"infrastructure" bson:"infrastructure" default:"-1"`
|
Infrastructure enum.InfrastructureType `json:"infrastructure" bson:"infrastructure" default:"-1"`
|
||||||
Usage *ProcessingUsage `bson:"usage,omitempty" json:"usage,omitempty"`
|
Usage *ProcessingUsage `bson:"usage,omitempty" json:"usage,omitempty"`
|
||||||
OpenSource bool `json:"open_source" bson:"open_source" default:"false"`
|
OpenSource bool `json:"open_source" bson:"open_source" default:"false"`
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package purchase_resource
|
package purchase_resource
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/logs"
|
"cloud.o-forge.io/core/oc-lib/logs"
|
||||||
@@ -30,7 +29,6 @@ func NewAccessor(request *tools.APIRequest) *PurchaseResourceMongoAccessor {
|
|||||||
*/
|
*/
|
||||||
func (a *PurchaseResourceMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
func (a *PurchaseResourceMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||||
return utils.GenericLoadOne(id, a.New(), func(d utils.DBObject) (utils.DBObject, int, error) {
|
return utils.GenericLoadOne(id, a.New(), func(d utils.DBObject) (utils.DBObject, int, error) {
|
||||||
fmt.Println("FOUND PURCHASE", d)
|
|
||||||
if d.(*PurchaseResource).EndDate != nil && time.Now().UTC().After(*d.(*PurchaseResource).EndDate) {
|
if d.(*PurchaseResource).EndDate != nil && time.Now().UTC().After(*d.(*PurchaseResource).EndDate) {
|
||||||
utils.GenericDelete(d, a)
|
utils.GenericDelete(d, a)
|
||||||
return nil, 404, nil
|
return nil, 404, nil
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package resources
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||||
@@ -97,8 +98,10 @@ func (wfa *ResourceMongoAccessor[T]) LoadAll(isDraft bool, offset int64, limit i
|
|||||||
func (wfa *ResourceMongoAccessor[T]) Search(filters *dbs.Filters, search string, isDraft bool, offset int64, limit int64) ([]utils.ShallowDBObject, int, error) {
|
func (wfa *ResourceMongoAccessor[T]) Search(filters *dbs.Filters, search string, isDraft bool, offset int64, limit int64) ([]utils.ShallowDBObject, int, error) {
|
||||||
if filters == nil && search == "*" {
|
if filters == nil && search == "*" {
|
||||||
return utils.GenericLoadAll[T](func(d utils.DBObject) utils.ShallowDBObject {
|
return utils.GenericLoadAll[T](func(d utils.DBObject) utils.ShallowDBObject {
|
||||||
|
fmt.Println("Search", d)
|
||||||
d.(T).VerifyBuy()
|
d.(T).VerifyBuy()
|
||||||
d.(T).SetAllowedInstances(wfa.Request)
|
d.(T).SetAllowedInstances(wfa.Request)
|
||||||
|
fmt.Println("Search2", d)
|
||||||
return d
|
return d
|
||||||
}, isDraft, wfa, offset, limit)
|
}, isDraft, wfa, offset, limit)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (m ServiceMode) String() string {
|
|||||||
type ServiceProtocol int
|
type ServiceProtocol int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
HTTP ServiceProtocol = iota
|
HTTP ServiceProtocol = iota
|
||||||
GRPC
|
GRPC
|
||||||
WEBSOCKET
|
WEBSOCKET
|
||||||
TCP
|
TCP
|
||||||
@@ -111,7 +111,7 @@ type ServiceResourcePartnership struct {
|
|||||||
// - DEPLOYMENT: uptime billing via ExploitPricingProfile (pay while service is up)
|
// - DEPLOYMENT: uptime billing via ExploitPricingProfile (pay while service is up)
|
||||||
// - HOSTED: per-call billing via AccessPricingProfile (pay per request)
|
// - HOSTED: per-call billing via AccessPricingProfile (pay per request)
|
||||||
type ServiceResourcePricingProfile struct {
|
type ServiceResourcePricingProfile struct {
|
||||||
Mode ServiceMode `json:"mode" bson:"mode"`
|
Mode ServiceMode `json:"mode" bson:"mode"`
|
||||||
UptimePricing *pricing.ExploitPricingProfile[pricing.TimePricingStrategy] `json:"uptime_pricing,omitempty" bson:"uptime_pricing,omitempty"`
|
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"`
|
AccessPricing *pricing.AccessPricingProfile[pricing.TimePricingStrategy] `json:"access_pricing,omitempty" bson:"access_pricing,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user