Files
oc-lib/models/utils/interfaces.go
2026-04-21 14:30:45 +02:00

64 lines
2.0 KiB
Go
Executable File

package utils
import (
"cloud.o-forge.io/core/oc-lib/dbs"
"cloud.o-forge.io/core/oc-lib/tools"
"github.com/rs/zerolog"
)
// ShallowDBObject is an interface that defines the basic methods shallowed version of a DBObject
type ShallowDBObject interface {
GenerateID()
GetID() string
GetName() string
Serialize(obj DBObject) map[string]interface{}
Deserialize(j map[string]interface{}, obj DBObject) DBObject
}
// DBObject is an interface that defines the basic methods for a DBObject
type DBObject interface {
GenerateID()
Extend(typ ...string) map[string][]tools.DataType
SetNotInCatalog(bool)
IsNotInCatalog() bool
SetID(id string)
GetID() string
GetName() string
SetName(name string)
IsDrafted() bool
CanDelete() bool
StoreDraftDefault()
GetCreatorID() string
UpToDate(user string, peer string, create bool)
CanUpdate(set DBObject) (bool, DBObject)
VerifyAuth(callName string, request *tools.APIRequest) bool
Serialize(obj DBObject) map[string]interface{}
GetAccessor(request *tools.APIRequest) Accessor
Deserialize(j map[string]interface{}, obj DBObject) DBObject
Sign()
Unsign()
GetSignature() []byte
GetObjectFilters(search string) *dbs.Filters
}
// Accessor is an interface that defines the basic methods for an Accessor
type Accessor interface {
NewObj() DBObject
GetUser() string
GetPeerID() string
GetGroups() []string
ShouldVerifyAuth() bool
GetType() tools.DataType
GetLogger() *zerolog.Logger
GetCaller() *tools.HTTPCaller
GetRequest() *tools.APIRequest
LoadOne(id string) (DBObject, int, error)
DeleteOne(id string) (DBObject, int, error)
CopyOne(data DBObject) (DBObject, int, error)
StoreOne(data DBObject) (DBObject, int, error)
LoadAll(isDraft bool, offset int64, limit int64) ([]ShallowDBObject, int, error)
UpdateOne(set map[string]interface{}, id string) (DBObject, int, error)
Search(filters *dbs.Filters, search string, isDraft bool, offset int64, limit int64) ([]ShallowDBObject, int, error)
GetExec(isDraft bool) func(DBObject) ShallowDBObject
}