2024-07-18 11:51:12 +02:00
|
|
|
package utils
|
|
|
|
|
2024-08-12 16:11:25 +02:00
|
|
|
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-12 16:11:25 +02:00
|
|
|
)
|
2024-08-01 09:13:10 +02:00
|
|
|
|
2024-08-30 14:50:48 +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
|
|
|
}
|
|
|
|
|
2024-08-30 14:50:48 +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-12-04 11:33:08 +01:00
|
|
|
VerifyAuth(username string, PeerID string, groups []string) bool
|
2024-11-28 11:05:54 +01:00
|
|
|
Deserialize(j map[string]interface{}, obj DBObject) DBObject
|
|
|
|
Serialize(obj DBObject) map[string]interface{}
|
2024-12-04 11:33:08 +01:00
|
|
|
GetAccessor(username string, peerID string, groups []string, caller *tools.HTTPCaller) Accessor
|
2024-07-18 11:51:12 +02:00
|
|
|
}
|
|
|
|
|
2024-08-30 14:50:48 +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 16:49:41 +01:00
|
|
|
GetType() tools.DataType
|
2024-12-04 11:33:08 +01:00
|
|
|
GetUser() string
|
2024-11-28 11:05:54 +01:00
|
|
|
GetPeerID() string
|
|
|
|
GetGroups() []string
|
|
|
|
GetLogger() *zerolog.Logger
|
2024-08-12 16:11:25 +02:00
|
|
|
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
|
|
|
}
|