oc-lib/models/utils/interfaces.go
2024-11-28 11:05:54 +01:00

46 lines
1.5 KiB
Go

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
Deserialize(j map[string]interface{}, obj DBObject) DBObject
Serialize(obj DBObject) map[string]interface{}
}
// DBObject is an interface that defines the basic methods for a DBObject
type DBObject interface {
GenerateID()
GetID() string
GetName() string
UpToDate()
VerifyAuth(PeerID string, groups []string) bool
Deserialize(j map[string]interface{}, obj DBObject) DBObject
Serialize(obj DBObject) map[string]interface{}
GetAccessor(peerID string, groups []string, caller *tools.HTTPCaller) Accessor
}
// Accessor is an interface that defines the basic methods for an Accessor
type Accessor interface {
Init(t tools.DataType, peerID string, groups []string, caller *tools.HTTPCaller)
GetType() string
GetPeerID() string
GetGroups() []string
GetLogger() *zerolog.Logger
GetCaller() *tools.HTTPCaller
Search(filters *dbs.Filters, search string) ([]ShallowDBObject, int, error)
LoadAll() ([]ShallowDBObject, int, error)
LoadOne(id string) (DBObject, int, error)
DeleteOne(id string) (DBObject, int, error)
CopyOne(data DBObject) (DBObject, int, error)
StoreOne(data DBObject) (DBObject, int, error)
UpdateOne(set DBObject, id string) (DBObject, int, error)
}