resource as resource named
This commit is contained in:
@@ -1,51 +1,21 @@
|
||||
package resources
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
)
|
||||
|
||||
// AbstractResource is the struct containing all of the attributes commons to all ressources
|
||||
|
||||
// Resource is the interface to be implemented by all classes inheriting from Resource to have the same behavior
|
||||
|
||||
//http://www.inanzzz.com/index.php/post/wqbs/a-basic-usage-of-int-and-string-enum-types-in-golang
|
||||
|
||||
type ResourceType int
|
||||
|
||||
const (
|
||||
INVALID ResourceType = iota
|
||||
DATA
|
||||
PROCESSING
|
||||
STORAGE
|
||||
DATACENTER
|
||||
WORKFLOW
|
||||
)
|
||||
|
||||
var str = [...]string{
|
||||
"invalid",
|
||||
"data",
|
||||
"processing",
|
||||
"storage",
|
||||
"datacenter",
|
||||
"workflow",
|
||||
}
|
||||
|
||||
func FromInt(i int) string {
|
||||
return str[i]
|
||||
}
|
||||
|
||||
func (d ResourceType) String() string {
|
||||
return str[d]
|
||||
}
|
||||
|
||||
// EnumIndex - Creating common behavior - give the type a EnumIndex functio
|
||||
func (d ResourceType) EnumIndex() int {
|
||||
return int(d)
|
||||
}
|
||||
|
||||
type Resource interface {
|
||||
GetType() ResourceType
|
||||
GetType() utils.DataType
|
||||
}
|
||||
|
||||
type AbstractResource struct {
|
||||
Uuid string `json:"uuid" required:"true" bson:"uuid" validate:"required"`
|
||||
Name string `json:"name" required:"true" bson:"name" validate:"required"`
|
||||
utils.AbstractObject
|
||||
ShortDescription string `json:"short_description" required:"true" bson:"short_description" validate:"required"`
|
||||
Description string `json:"description,omitempty" bson:"description"`
|
||||
Logo string `json:"logo" required:"true" bson:"logo" validate:"required"`
|
||||
@@ -55,7 +25,7 @@ type AbstractResource struct {
|
||||
}
|
||||
|
||||
func (r *AbstractResource) GetID() string {
|
||||
return r.Uuid
|
||||
return r.UUID
|
||||
}
|
||||
|
||||
func (r *AbstractResource) GetName() string {
|
||||
|
||||
Reference in New Issue
Block a user