You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
api/models/models.go

39 lines
954 B
Go

package models
import (
"time"
"gorm.io/gorm"
)
type CPU struct {
gorm.Model `json:"-"`
ID uint `json:"id" gorm:"primary_key"`
Time time.Time `json:"time" gorm:"autoCreateTime"`
Name string `json:"name"`
Socket int `json:"socket"`
Cores int `json:"cores"`
}
type Memory struct {
gorm.Model `json:"-"`
ID uint `json:"id" gorm:"primary_key"`
Time time.Time `json:"time" gorm:"autoCreateTime"`
Type string `json:"type"`
Total int `json:"total"`
Used int `json:"used"`
Usage float64 `json:"Usage"`
}
type Host struct {
gorm.Model `json:"-"`
ID uint `json:"id" gorm:"primary_key"`
Hostname string `json:"hostname" gorm:"unique"`
Cpus []CPU `json:"cpus" gorm:"foreignKey:ID"`
Memory []Memory `json:"memory" gorm:"foreignKey:ID"`
}
type CreateHostInput struct {
Hostname string `json:"hostname"`
}