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"
|
2024-08-12 16:11:25 +02:00
|
|
|
"cloud.o-forge.io/core/oc-lib/tools"
|
2024-07-25 09:28:55 +02:00
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Workspace struct {
|
|
|
|
utils.AbstractObject
|
2024-07-26 10:36:23 +02:00
|
|
|
resources.ResourceSet
|
2024-08-02 11:04:18 +02:00
|
|
|
IsContextual bool `json:"is_contextual" bson:"is_contextual" default:"false"`
|
|
|
|
Active bool `json:"active" bson:"active" default:"false"`
|
2024-08-12 12:03:58 +02:00
|
|
|
Shared bool `json:"shared" bson:"shared" default:"false"`
|
2024-07-25 09:28:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ao *Workspace) GetID() string {
|
|
|
|
return ao.UUID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Workspace) GenerateID() {
|
2024-08-13 09:49:42 +02:00
|
|
|
if r.UUID == "" {
|
|
|
|
r.UUID = uuid.New().String()
|
|
|
|
}
|
2024-07-25 09:28:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Workspace) GetName() string {
|
|
|
|
return d.Name
|
|
|
|
}
|
|
|
|
|
2024-08-12 16:11:25 +02:00
|
|
|
func (d *Workspace) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
2024-07-31 10:07:55 +02:00
|
|
|
data := New()
|
2024-08-12 16:11:25 +02:00
|
|
|
data.Init(utils.WORKSPACE, caller)
|
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
|
|
|
|
}
|