55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package resources
|
|
|
|
// 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 ToString(r ResourceType) string {
|
|
return str[r]
|
|
}
|
|
|
|
type Resource interface {
|
|
GetType() ResourceType
|
|
}
|
|
|
|
type AbstractResource struct {
|
|
Uuid string `json:"uuid" required:"true" bson:"uuid"`
|
|
Name string `json:"name" required:"true" bson:"name"`
|
|
ShortDescription string `json:"short_description" required:"true" bson:"short_description"`
|
|
Description string `json:"description,omitempty" bson:"description"`
|
|
Logo string `json:"logo" required:"true" bson:"logo"`
|
|
Owner string `json:"owner" required:"true" bson:"owner"`
|
|
OwnerLogo string `json:"owner_logo" required:"true" bson:"owner_logo"`
|
|
SourceUrl string `json:"source_url" required:"true" bson:"source_url"`
|
|
}
|
|
|
|
func (r *AbstractResource) GetID() string {
|
|
return r.Uuid
|
|
}
|
|
|
|
func (r *AbstractResource) GetName() string {
|
|
return r.Name
|
|
}
|