oc-lib/models/utils/interfaces.go

46 lines
1.5 KiB
Go
Raw Normal View History

2024-07-18 11:51:12 +02:00
package utils
import (
"cloud.o-forge.io/core/oc-lib/dbs"
"cloud.o-forge.io/core/oc-lib/tools"
2024-11-28 11:05:54 +01:00
"github.com/rs/zerolog"
)
2024-08-01 09:13:10 +02:00
// ShallowDBObject is an interface that defines the basic methods shallowed version of a DBObject
2024-07-23 11:22:50 +02:00
type ShallowDBObject interface {
GenerateID()
GetID() string
GetName() string
2024-11-28 11:05:54 +01:00
Deserialize(j map[string]interface{}, obj DBObject) DBObject
Serialize(obj DBObject) map[string]interface{}
2024-07-23 11:22:50 +02:00
}
// DBObject is an interface that defines the basic methods for a DBObject
2024-07-18 11:51:12 +02:00
type DBObject interface {
2024-07-19 10:54:58 +02:00
GenerateID()
2024-07-19 13:27:34 +02:00
GetID() string
2024-07-18 11:51:12 +02:00
GetName() string
2024-10-02 12:23:22 +02:00
UpToDate()
2024-11-28 11:05:54 +01:00
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
2024-07-18 11:51:12 +02:00
}
// Accessor is an interface that defines the basic methods for an Accessor
2024-07-18 11:51:12 +02:00
type Accessor interface {
2024-11-28 11:05:54 +01:00
Init(t tools.DataType, peerID string, groups []string, caller *tools.HTTPCaller)
2024-07-18 16:46:54 +02:00
GetType() string
2024-11-28 11:05:54 +01:00
GetPeerID() string
GetGroups() []string
GetLogger() *zerolog.Logger
GetCaller() *tools.HTTPCaller
2024-08-01 09:13:10 +02:00
Search(filters *dbs.Filters, search string) ([]ShallowDBObject, int, error)
2024-07-23 11:22:50 +02:00
LoadAll() ([]ShallowDBObject, int, error)
2024-07-19 11:27:58 +02:00
LoadOne(id string) (DBObject, int, error)
DeleteOne(id string) (DBObject, int, error)
2024-07-19 13:41:10 +02:00
CopyOne(data DBObject) (DBObject, int, error)
2024-07-19 11:27:58 +02:00
StoreOne(data DBObject) (DBObject, int, error)
2024-07-22 16:12:38 +02:00
UpdateOne(set DBObject, id string) (DBObject, int, error)
2024-07-18 11:51:12 +02:00
}