oc-lib/models/workspace/workspace.go

53 lines
979 B
Go
Raw Normal View History

2024-07-25 09:28:55 +02:00
package workspace
import (
"encoding/json"
2024-07-26 10:36:23 +02:00
"cloud.o-forge.io/core/oc-lib/models/resources"
2024-07-25 09:28:55 +02:00
"cloud.o-forge.io/core/oc-lib/models/utils"
"github.com/google/uuid"
)
type Workspace struct {
utils.AbstractObject
2024-07-26 10:36:23 +02:00
resources.ResourceSet
2024-07-25 09:28:55 +02:00
Active bool `json:"active" bson:"active" default:"false"`
}
func (ao *Workspace) GetID() string {
return ao.UUID
}
func (r *Workspace) GenerateID() {
r.UUID = uuid.New().String()
}
func (d *Workspace) GetName() string {
return d.Name
}
func (d *Workspace) GetAccessor() utils.Accessor {
data := &WorkspaceMongoAccessor{}
2024-07-26 08:58:59 +02:00
data.SetLogger(utils.WORKSPACE)
2024-07-25 09:28:55 +02:00
return data
}
func (dma *Workspace) Deserialize(j map[string]interface{}) utils.DBObject {
b, err := json.Marshal(j)
if err != nil {
return nil
}
json.Unmarshal(b, dma)
return dma
}
func (dma *Workspace) Serialize() map[string]interface{} {
var m map[string]interface{}
b, err := json.Marshal(dma)
if err != nil {
return nil
}
json.Unmarshal(b, &m)
return m
}