oc-lib/models/resources/data/data.go

35 lines
851 B
Go
Raw Normal View History

2024-07-18 11:51:12 +02:00
package data
import (
2024-07-18 14:39:54 +02:00
"encoding/json"
2024-07-18 13:35:14 +02:00
resources "cloud.o-forge.io/core/oc-lib/models/resources"
"cloud.o-forge.io/core/oc-lib/models/utils"
2024-07-18 11:51:12 +02:00
)
type Data struct {
resources.AbstractResource
Protocols []string `json:"protocol,omitempty" bson:"protocol,omitempty"` //TODO Enum type
DataType string `json:"datatype" required:"true" bson:"datatype"`
Example string `json:"example" bson:"example" required:"true" validate:"required" description:"base64 encoded data"`
}
2024-07-18 14:39:54 +02:00
func (dma *Data) Deserialize(j map[string]interface{}) utils.DBObject {
b, err := json.Marshal(j)
if err != nil {
return nil
}
json.Unmarshal(b, dma)
return dma
}
2024-07-18 11:51:12 +02:00
func (d *Data) GetType() resources.ResourceType {
return resources.DATA
}
2024-07-18 15:02:39 +02:00
func (d *Data) GetAccessor() utils.Accessor {
data := &DataMongoAccessor{}
2024-07-18 16:46:54 +02:00
data.SetLogger(resources.DATA)
2024-07-18 11:51:12 +02:00
return data
}