Improved models' structure
This commit is contained in:
parent
f0eec45836
commit
3732187678
10
data.go
10
data.go
@ -1,11 +1,12 @@
|
|||||||
package oclib
|
package oclib
|
||||||
|
|
||||||
|
|
||||||
type Data struct {
|
type Data struct {
|
||||||
AbstractResource
|
AbstractResource
|
||||||
|
|
||||||
Protocols []string `json:"protocol"` //TODO Enum type
|
Protocols []string `json:"protocol,omitempty" bson:"protocol,omitempty"` //TODO Enum type
|
||||||
DataType string `json:"datatype"`
|
DataType string `json:"datatype" required:"true" bson:"datatype"`
|
||||||
Example string `json:"example" required:"true" validate:"required" description:"base64 encoded data"`
|
Example string `json:"example" bson:"example" required:"true" validate:"required" description:"base64 encoded data"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,3 +15,6 @@ func (d *Data) GetType() ResourceType{
|
|||||||
return DATA
|
return DATA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,36 +1,34 @@
|
|||||||
package oclib
|
package oclib
|
||||||
|
|
||||||
type Datacenter struct {
|
type Datacenter struct {
|
||||||
Resource
|
AbstractResource `json:"resource" required:"true"`
|
||||||
ID string `json:"ID", required: "true"`
|
|
||||||
Name string `json:"Name", required: "true" `
|
|
||||||
|
|
||||||
Owner string `json:"owner" `
|
Owner string `json:"owner" required:"true"`
|
||||||
BookingPrice int `json:"bookingPrice" `
|
BookingPrice int `json:"booking_price" required:"true"`
|
||||||
|
|
||||||
CPU DatacenterCpuModel `json:"cpu" required:"true"`
|
CPU DatacenterCpuModel `json:"cpu,omitempty"`
|
||||||
RAM DatacenterMemoryModel `json:"ram" required:"true"`
|
RAM DatacenterMemoryModel `json:"ram,omitempty"`
|
||||||
GPU []DatacenterGpuModel `json:"gpu" required:"true"`
|
GPU []DatacenterGpuModel `json:"gpu,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DatacenterCpuModel struct {
|
type DatacenterCpuModel struct {
|
||||||
Cores uint `json:"cores" required:"true"` //TODO: validate
|
Cores uint `json:"cores,omitempty"` //TODO: validate
|
||||||
Architecture string `json:"architecture"` //TOOD: enum
|
Architecture string `json:"architecture,omitempty"` //TOOD: enum
|
||||||
Shared bool `json:"shared"`
|
Shared bool `json:"shared,omitempty"`
|
||||||
MinimumMemory uint `json:"minimum_memory"`
|
MinimumMemory uint `json:"minimum_memory,omitempty"`
|
||||||
Platform string `json:"platform"`
|
Platform string `json:"platform,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DatacenterMemoryModel struct {
|
type DatacenterMemoryModel struct {
|
||||||
Size uint `json:"size" description:"Units in MB"`
|
Size uint `json:"size,omitempty" description:"Units in MB"`
|
||||||
Ecc bool `json:"ecc"`
|
Ecc bool `json:"ecc,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DatacenterGpuModel struct {
|
type DatacenterGpuModel struct {
|
||||||
CudaCores uint `json:"cuda_cores"`
|
CudaCores uint `json:"cuda_cores,omitempty"`
|
||||||
Model string `json:"model"`
|
Model string `json:"model,omitempty"`
|
||||||
Memory uint `json:"memory" description:"Units in MB"`
|
Memory uint `json:"memory,omitempty" description:"Units in MB"`
|
||||||
TensorCores uint `json:"tensor_cores"`
|
TensorCores uint `json:"tensor_cores,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
package oclib
|
package oclib
|
||||||
|
|
||||||
type Processing struct {
|
type Processing struct {
|
||||||
Resource
|
AbstractResource `json:"resource" required:"true"`
|
||||||
Container string `json:"Container"` // We could create a specific class for container, that could check if the name exists/is available
|
Container string `json:"container,omitempty"` // We could create a specific class for container, that could check if the name exists/is available
|
||||||
Repository string `json:"Repository"` // Indicate where to find the container image => Could add a struct handling authentication to the repo
|
Repository string `json:"repository,omitempty"` // Indicate where to find the container image => Could add a struct handling authentication to the repo
|
||||||
Command string `json:"Command"`
|
Command string `json:"command,omitempty"`
|
||||||
Arguments []string `json:"Arguments"`
|
Arguments []string `json:"arguments,omitempty"`
|
||||||
Environment []map[string]string `json:"Environment"` // a key/value struct is what ressembles the most a NAME=VALUE struct
|
Environment []map[string]string `json:"environment,omitempty"` // a key/value struct is what ressembles the most a NAME=VALUE struct
|
||||||
|
|
||||||
ExecutionRequirements ExecutionRequirementsModel `json:"ExecutionRequirements"`
|
ExecutionRequirements ExecutionRequirementsModel `json:"execution_requirements,omitempty"`
|
||||||
|
|
||||||
Price uint `json:"Price"`
|
Price uint `json:"price,omitempty"`
|
||||||
License string `json:"License"`
|
License string `json:"license,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExecutionRequirementsModel struct {
|
type ExecutionRequirementsModel struct {
|
||||||
CPUs uint `json:"cpus" required:"true"`
|
CPUs uint `json:"cp_us,omitempty"`
|
||||||
GPUs uint `json:"gpus" description:"Amount of GPUs needed"`
|
GPUs uint `json:"gp_us,omitempty"`
|
||||||
RAM uint `json:"ram" required:"true" description:"Units in MB"`
|
RAM uint `json:"ram,omitempty"`
|
||||||
|
|
||||||
Parallel bool `json:"parallel"`
|
Parallel bool `json:"parallel,omitempty"`
|
||||||
ScalingModel uint `json:"scaling_model"`
|
ScalingModel uint `json:"scaling_model,omitempty"`
|
||||||
DiskIO string `json:"disk_io"`
|
DiskIO string `json:"disk_io,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Processing) GetType() ResourceType{
|
func (p *Processing) GetType() ResourceType{
|
||||||
|
20
resource.go
20
resource.go
@ -34,19 +34,20 @@ var extensions = [...]string{
|
|||||||
type Resource interface{
|
type Resource interface{
|
||||||
GetType() ResourceType
|
GetType() ResourceType
|
||||||
getOneResourceByID() Resource
|
getOneResourceByID() Resource
|
||||||
|
StoreOne() Resource
|
||||||
}
|
}
|
||||||
|
|
||||||
type AbstractResource struct {
|
type AbstractResource struct {
|
||||||
Uuid string `json:"Id" required:"true" `
|
Uuid string `json:"uuid" required:"true" bson:"uuid"`
|
||||||
Name string `json:"Name" required:"true" `
|
Name string `json:"name" required:"true" bson:"name"`
|
||||||
ShortDescription string
|
ShortDescription string `json:"short_description" required:"true" bson:"short_description"`
|
||||||
Description string
|
Description string `json:"description,omitempty" bson:"description"`
|
||||||
Logo string
|
Logo string `json:"logo" required:"true" bson:"logo"`
|
||||||
Owner string
|
Owner string `json:"owner" required:"true" bson:"owner"`
|
||||||
OwnerLogo string
|
OwnerLogo string `json:"owner_logo" required:"true" bson:"owner_logo"`
|
||||||
SourceUrl string
|
SourceUrl string `json:"source_url" required:"true" bson:"source_url"`
|
||||||
|
|
||||||
Graphic GraphicElement `json:"GraphicElement" `
|
Graphic GraphicElement `json:"graphic,omitempty" bson:"protocol"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -92,3 +93,4 @@ func (r *AbstractResource) isLinked(){
|
|||||||
// func (r *Resource) GetType() ResourceType {
|
// func (r *Resource) GetType() ResourceType {
|
||||||
// return INVALID
|
// return INVALID
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
16
storage.go
16
storage.go
@ -6,17 +6,17 @@ type URL struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Storage struct {
|
type Storage struct {
|
||||||
Resource `json:"resource" required:"true"`
|
AbstractResource `json:"resource" required:"true" bson:"resource"`
|
||||||
|
|
||||||
Capacity uint `json:"capacity" required:"true"`
|
Capacity uint `json:"capacity,omitempty"`
|
||||||
Url URL `json:"URL" ` // Will allow to select between several protocols
|
Url URL `json:"url,omitempty"` // Will allow to select between several protocols
|
||||||
|
|
||||||
Encryption bool `json:"encryption" `
|
Encryption bool `json:"encryption,omitempty"`
|
||||||
Redundancy string `json:"redundancy" `
|
Redundancy string `json:"redundancy,omitempty"`
|
||||||
Throughput string `json:"throughput" `
|
Throughput string `json:"throughput,omitempty"`
|
||||||
BookingPrice uint `json:"bookingPrice" `
|
BookingPrice uint `json:"booking_price,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Storage) GetType() ResourceType{
|
func (s *Storage) GetType() ResourceType {
|
||||||
return STORAGE
|
return STORAGE
|
||||||
}
|
}
|
||||||
|
16
workflow.go
16
workflow.go
@ -1,14 +1,14 @@
|
|||||||
package oclib
|
package oclib
|
||||||
|
|
||||||
type Workflow struct{
|
type Workflow struct {
|
||||||
Resource
|
AbstractResource `json:"abstract_resource" required:"true"`
|
||||||
Datas map[string]Data
|
Datas map[string]Data `json:"datas,omitempty"`
|
||||||
Storages map[string]Storage
|
Storages map[string]Storage `json:"storages,omitempty"`
|
||||||
Processing map[string]Processing
|
Processing map[string]Processing `json:"processing,omitempty"`
|
||||||
Datacenters map[string]Datacenter
|
Datacenters map[string]Datacenter `json:"datacenters,omitempty"`
|
||||||
Links map[string]Link
|
Links map[string]Link `json:"links,omitempty"`
|
||||||
|
|
||||||
Schedule WorkflowSchedule
|
Schedule WorkflowSchedule `json:"schedule,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Workflow) isDCLink(link Link) bool {
|
func (w *Workflow) isDCLink(link Link) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user