62 lines
2.1 KiB
Go
62 lines
2.1 KiB
Go
package resources
|
|
|
|
import (
|
|
"cloud.o-forge.io/core/oc-lib/models/resources/resource_model"
|
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
|
"cloud.o-forge.io/core/oc-lib/tools"
|
|
)
|
|
|
|
type StorageSize int
|
|
|
|
// StorageType - Enum that defines the type of storage
|
|
const (
|
|
GB StorageSize = iota
|
|
MB
|
|
KB
|
|
)
|
|
|
|
var argoType = [...]string{
|
|
"Gi",
|
|
"Mi",
|
|
"Ki",
|
|
}
|
|
|
|
// New creates a new instance of the StorageResource struct
|
|
func (dma StorageSize) ToArgo() string {
|
|
return argoType[dma]
|
|
}
|
|
|
|
// enum of a data type
|
|
type StorageType int
|
|
|
|
const (
|
|
FILE = iota
|
|
STREAM
|
|
API
|
|
DATABASE
|
|
S3
|
|
MEMORY
|
|
HARDWARE
|
|
)
|
|
|
|
/*
|
|
* StorageResource is a struct that represents a storage resource
|
|
* it defines the resource storage
|
|
*/
|
|
type StorageResource struct {
|
|
resource_model.AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
|
resource_model.WebResource
|
|
Type StorageType `bson:"type,omitempty" json:"type,omitempty"` // Type is the type of the storage
|
|
Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"` // Acronym is the acronym of the storage
|
|
SizeType StorageSize `bson:"size_type" json:"size_type" default:"0"` // SizeType is the type of the storage size
|
|
Size uint `bson:"size,omitempty" json:"size,omitempty"` // Size is the size of the storage
|
|
Local bool `bson:"local" json:"local"` // Local is a flag that indicates if the storage is local
|
|
Encryption bool `bson:"encryption,omitempty" json:"encryption,omitempty"` // Encryption is a flag that indicates if the storage is encrypted
|
|
Redundancy string `bson:"redundancy,omitempty" json:"redundancy,omitempty"` // Redundancy is the redundancy of the storage
|
|
Throughput string `bson:"throughput,omitempty" json:"throughput,omitempty"` // Throughput is the throughput of the storage
|
|
}
|
|
|
|
func (d *StorageResource) GetAccessor(peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
|
|
return New[*StorageResource](tools.STORAGE_RESOURCE, peerID, groups, caller, func() utils.DBObject { return &StorageResource{} }) // Create a new instance of the accessor
|
|
}
|