resource as resource named

This commit is contained in:
mr
2024-07-19 10:54:58 +02:00
parent 218714683b
commit 2a9a784ec1
28 changed files with 381 additions and 284 deletions

View File

@@ -7,14 +7,14 @@ import (
"cloud.o-forge.io/core/oc-lib/models/utils"
)
type Data struct {
type DataResource 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"`
}
func (dma *Data) Deserialize(j map[string]interface{}) utils.DBObject {
func (dma *DataResource) Deserialize(j map[string]interface{}) utils.DBObject {
b, err := json.Marshal(j)
if err != nil {
return nil
@@ -23,7 +23,7 @@ func (dma *Data) Deserialize(j map[string]interface{}) utils.DBObject {
return dma
}
func (dma *Data) Serialize() map[string]interface{} {
func (dma *DataResource) Serialize() map[string]interface{} {
var m map[string]interface{}
b, err := json.Marshal(dma)
if err != nil {
@@ -33,12 +33,8 @@ func (dma *Data) Serialize() map[string]interface{} {
return m
}
func (d *Data) GetType() resources.ResourceType {
return resources.DATA
}
func (d *Data) GetAccessor() utils.Accessor {
func (d *DataResource) GetAccessor() utils.Accessor {
data := &DataMongoAccessor{}
data.SetLogger(resources.DATA)
data.SetLogger(utils.DATACENTER_RESOURCE)
return data
}