package resource_model import ( "encoding/json" "cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/tools" ) type WebResource struct { Protocol string `bson:"protocol,omitempty" json:"protocol,omitempty"` // Protocol is the protocol of the URL Path string `bson:"path,omitempty" json:"path,omitempty"` // Path is the path of the URL } type Model struct { Type string `json:"type,omitempty" bson:"type,omitempty"` // Type is the type of the model ReadOnly bool `json:"readonly,omitempty" bson:"readonly,omitempty"` // ReadOnly is the readonly of the model } /* * ResourceModel is a struct that represents a resource model * it defines the resource metadata and specificity * Warning: This struct is not user available, it is only used by the system */ type ResourceModel struct { utils.AbstractObject ResourceType string `json:"resource_type,omitempty" bson:"resource_type,omitempty" validate:"required"` VarRefs map[string]string `json:"var_refs,omitempty" bson:"var_refs,omitempty"` // VarRefs is the variable references of the model Model map[string]map[string]Model `json:"model,omitempty" bson:"model,omitempty"` } func (d *ResourceModel) StoreDraftDefault() { d.Name = d.ResourceType + " Resource Model" d.IsDraft = false } func (abs *ResourceModel) VerifyAuth(request *tools.APIRequest) bool { return true } func (d *ResourceModel) GetAccessor(request *tools.APIRequest) utils.Accessor { return &ResourceModelMongoAccessor{ utils.AbstractAccessor{ Type: tools.RESOURCE_MODEL, Request: request, }, } } func (dma *ResourceModel) Deserialize(j map[string]interface{}, obj utils.DBObject) utils.DBObject { b, err := json.Marshal(j) if err != nil { return nil } json.Unmarshal(b, obj) return obj } func (dma *ResourceModel) Serialize(obj utils.DBObject) map[string]interface{} { var m map[string]interface{} b, err := json.Marshal(obj) if err != nil { return nil } json.Unmarshal(b, &m) return m }