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

48 lines
1.2 KiB
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"`
HostID int `json:"host_id"`
Host Host `json:"-" gorm:"foreignKey:ID;references:HostID"`
}
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"`
HostID int `json:"host_id"`
Host Host `json:"-" gorm:"foreignKey:ID;references:HostID"`
}
type Host struct {
gorm.Model `json:"-"`
ID string `json:"-" gorm:"primary_key;autoIncrement"`
Hostname string `json:"hostname" gorm:"unique"`
Cpus []CPU `json:"cpus" gorm:"foreignKey:ID"`
Memory []Memory `json:"memory" gorm:"foreignKey:ID"`
}
type AddHost struct {
Hostname string `json:"hostname"`
}
type Error struct {
Status string `json:"status"`
Error string `json:"error"`
}