56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package workspace
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
|
"cloud.o-forge.io/core/oc-lib/tools"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Workspace struct {
|
|
utils.AbstractObject
|
|
resources.ResourceSet
|
|
IsContextual bool `json:"is_contextual" bson:"is_contextual" default:"false"`
|
|
Active bool `json:"active" bson:"active" default:"false"`
|
|
Shared bool `json:"shared" bson:"shared" 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(caller *tools.HTTPCaller) utils.Accessor {
|
|
data := New()
|
|
data.Init(utils.WORKSPACE, caller)
|
|
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
|
|
}
|