data

package
v0.0.0-...-0f704e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateDeviceID = errors.New("duplicate device")
)
View Source
var (
	ErrRecordNotFound = errors.New("record not found")
)

Functions

func ValidateBios

func ValidateBios(v *validator.Validator, bios *Bios)

func ValidateCPU

func ValidateCPU(v *validator.Validator, cpu *CPU)

func ValidateDIMM

func ValidateDIMM(v *validator.Validator, dimm *DIMM)

func ValidateDevice

func ValidateDevice(v *validator.Validator, device *Device)

func ValidateDisk

func ValidateDisk(v *validator.Validator, disks *Disk)

func ValidateFilters

func ValidateFilters(v *validator.Validator, f Filters)

func ValidateKernel

func ValidateKernel(v *validator.Validator, kernel *Kernel)

func ValidateMemory

func ValidateMemory(v *validator.Validator, memory *Memory)

func ValidateMotherboard

func ValidateMotherboard(v *validator.Validator, motherboard *Motherboard)

func ValidateNetwork

func ValidateNetwork(v *validator.Validator, network *Network)

func ValidateNetworkInterface

func ValidateNetworkInterface(v *validator.Validator, networkInterface *NetworkInterface)

func ValidateNetworkInterfaceDriver

func ValidateNetworkInterfaceDriver(v *validator.Validator, networkInterfaceDriver *NetworkInterfaceDriver)

func ValidateOEM

func ValidateOEM(v *validator.Validator, oem *OEM)

func ValidatePartition

func ValidatePartition(v *validator.Validator, partition *Partition)

func ValidateRelease

func ValidateRelease(v *validator.Validator, release *Release)

func ValidateSpecs

func ValidateSpecs(v *validator.Validator, specs *Specs)

func ValidateSwapDevice

func ValidateSwapDevice(v *validator.Validator, swapDevice *SwapDevice)

func ValidateVirtualization

func ValidateVirtualization(v *validator.Validator, virtualization *Virtualization)

func WithPreloads

func WithPreloads(db *gorm.DB) *gorm.DB

Types

type Bios

type Bios struct {
	ID      uint   `json:"-"`
	SpecsID uint   `json:"-"`
	Vendor  string `json:"vendor,omitempty"`
	Version string `json:"version,omitempty"`
	Date    string `json:"date,omitempty"`
}

func (Bios) String

func (b Bios) String() string

type CPU

type CPU struct {
	ID                    uint           `json:"-"`
	SpecsID               uint           `json:"-"`
	Name                  string         `json:"name,omitempty"`
	Architecture          string         `json:"architecture,omitempty"`
	CoreCount             int32          `json:"core_count,omitempty"`
	CPUCount              int32          `json:"cpu_count,omitempty"`
	MaxFrequencyMegahertz int32          `json:"max_frequency_megahertz,omitempty"`
	Mitigations           pq.StringArray `json:"mitigations,omitempty" gorm:"type:text[]"`
}

func (CPU) String

func (c CPU) String() string

type DIMM

type DIMM struct {
	ID            uint   `json:"-"`
	SpecsID       uint   `json:"-"`
	SizeGigabytes int32  `json:"size_gigabytes,omitempty"`
	Speed         int32  `json:"speed_mt_s,omitempty"`
	Manufacturer  string `json:"manufacturer,omitempty"`
	SerialNumber  string `json:"serial_number,omitempty"`
	Type          string `json:"type,omitempty"`
	PartNumber    string `json:"part_number,omitempty"`
	FormFactor    string `json:"form_factor,omitempty"`
	Locator       string `json:"locator,omitempty"`
	BankLocator   string `json:"bank_locator,omitempty"`
}

func (DIMM) String

func (d DIMM) String() string

type Device

type Device struct {
	ID        uuid.UUID `json:"uuid" gorm:"type:uuid"`
	UpdatedAt time.Time `json:"updated_at"`
	Specs     Specs     `json:"specs,omitempty" gorm:"constraint:OnDelete:CASCADE"`
}

func (Device) String

func (d Device) String() string

type DeviceModel

type DeviceModel struct {
	DB *gorm.DB
}

func (DeviceModel) Delete

func (m DeviceModel) Delete(uuid uuid.UUID, s SearchModel) error

func (DeviceModel) Get

func (m DeviceModel) Get(uuid uuid.UUID) (*Device, error)

func (DeviceModel) GetAll

func (m DeviceModel) GetAll(searchTerms string, filters Filters) ([]*Device, Metadata, error)

func (DeviceModel) Insert

func (m DeviceModel) Insert(device *Device, s SearchModel) error

func (DeviceModel) Update

func (m DeviceModel) Update(device *Device, s SearchModel) error

type Disk

type Disk struct {
	ID            uint        `json:"-"`
	SpecsID       uint        `json:"-"`
	Name          string      `json:"name,omitempty"`
	SizeMegabytes int32       `json:"size_megabytes,omitempty"`
	Partitions    []Partition `json:"partitions,omitempty" gorm:"constraint:OnDelete:CASCADE"`
}

func (Disk) String

func (d Disk) String() string

type Filters

type Filters struct {
	Page         int
	PageSize     int
	Sort         string
	SortSafelist []string
}

type Kernel

type Kernel struct {
	ID      uint   `json:"-"`
	SpecsID uint   `json:"-"`
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

func (Kernel) String

func (k Kernel) String() string

type Memory

type Memory struct {
	ID          uint         `json:"-"`
	SpecsID     uint         `json:"-"`
	Memory      int32        `json:"memory,omitempty"`
	Swap        int32        `json:"swap,omitempty"`
	SwapDevices []SwapDevice `json:"swap_devices,omitempty" gorm:"constraint:OnDelete:CASCADE"`
}

func (Memory) String

func (m Memory) String() string

type Metadata

type Metadata struct {
	CurrentPage  int `json:"current_page,omitempty"`
	PageSize     int `json:"page_size,omitempty"`
	FirstPage    int `json:"first_page,omitempty"`
	LastPage     int `json:"last_page,omitempty"`
	TotalRecords int `json:"total_records,omitempty"`
}

Metadata contains pagination metadata.

type Models

type Models struct {
	Devices DeviceModel
	Search  SearchModel
}

List of all models

func NewModels

func NewModels(db *gorm.DB) Models

type Motherboard

type Motherboard struct {
	ID           uint   `json:"-"`
	SpecsID      uint   `json:"-"`
	Vendor       string `json:"vendor,omitempty"`
	Name         string `json:"name,omitempty"`
	SerialNumber string `json:"serial_number,omitempty"`
}

func (Motherboard) String

func (m Motherboard) String() string

type Network

type Network struct {
	ID         uint               `json:"-"`
	SpecsID    uint               `json:"-"`
	Hostname   string             `json:"hostname,omitempty"`
	Interfaces []NetworkInterface `json:"interfaces,omitempty" gorm:"constraint:OnDelete:CASCADE"`
}

func (Network) String

func (n Network) String() string

type NetworkInterface

type NetworkInterface struct {
	ID            uint                   `json:"-"`
	NetworkID     uint                   `json:"-"`
	MACAddress    string                 `json:"mac_address,omitempty"`
	Driver        NetworkInterfaceDriver `json:"driver,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	IPv4Addresses pq.StringArray         `json:"ipv4_addresses,omitempty" gorm:"type:text[]"`
	IPv6Addresses pq.StringArray         `json:"ipv6_addresses,omitempty" gorm:"type:text[]"`
}

func (NetworkInterface) String

func (n NetworkInterface) String() string

type NetworkInterfaceDriver

type NetworkInterfaceDriver struct {
	ID                 uint   `json:"-"`
	NetworkInterfaceID uint   `json:"-"`
	Name               string `json:"name,omitempty"`
	Version            string `json:"version,omitempty"`
	FirmwareVersion    string `json:"firmware_version,omitempty"`
}

func (NetworkInterfaceDriver) String

func (nid NetworkInterfaceDriver) String() string

type OEM

type OEM struct {
	ID           uint   `json:"-"`
	SpecsID      uint   `json:"-"`
	Manufacturer string `json:"manufacturer,omitempty"`
	ProductName  string `json:"product_name,omitempty"`
	SerialNumber string `json:"serial_number,omitempty"`
}

func (OEM) String

func (o OEM) String() string

type Partition

type Partition struct {
	ID                uint   `json:"-"`
	DiskID            uint   `json:"-"`
	Filesystem        string `json:"filesystem,omitempty"`
	CapacityMegabytes int32  `json:"capacity_megabytes,omitempty"`
	Source            string `json:"source,omitempty"`
	Target            string `json:"target,omitempty"`
}

func (Partition) String

func (p Partition) String() string

type Release

type Release struct {
	ID       uint   `json:"-"`
	SpecsID  uint   `json:"-"`
	Name     string `json:"name,omitempty"`
	Version  string `json:"version,omitempty"`
	Codename string `json:"codename,omitempty"`
}

func (Release) String

func (r Release) String() string
type Search struct {
	DeviceID uuid.UUID `json:"-" gorm:"type:uuid;primaryKey"`
	Data     string    `json:"-"`
}

type SearchModel

type SearchModel struct {
	DB *gorm.DB
}

func (SearchModel) Delete

func (m SearchModel) Delete(uuid uuid.UUID) error

func (SearchModel) Insert

func (m SearchModel) Insert(search *Search) error

type ServerInfo

type ServerInfo struct {
	Status     string               `json:"status,omitempty"`
	SystemInfo ServerInfoSystemInfo `json:"system_info,omitempty"`
}

type ServerInfoSystemInfo

type ServerInfoSystemInfo struct {
	Environment string `json:"environment,omitempty"`
	Version     string `json:"version,omitempty"`
}

type Specs

type Specs struct {
	ID             uint           `json:"-"`
	DeviceID       uuid.UUID      `json:"-"`
	BootTime       time.Time      `json:"boot_time,omitempty"`
	Motherboard    Motherboard    `json:"motherboard,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	CPU            CPU            `json:"cpu,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	Disks          []Disk         `json:"disks,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	Network        Network        `json:"network,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	Bios           Bios           `json:"bios,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	Memory         Memory         `json:"memory,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	Kernel         Kernel         `json:"kernel,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	Release        Release        `json:"release,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	DIMMs          []DIMM         `json:"dimms,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	Virtualization Virtualization `json:"virtualization,omitempty" gorm:"constraint:OnDelete:CASCADE"`
	OEM            OEM            `json:"oem,omitempty" gorm:"constraint:OnDelete:CASCADE"`
}

func (Specs) String

func (s Specs) String() string

type SwapDevice

type SwapDevice struct {
	ID       uint   `json:"-"`
	MemoryID uint   `json:"-"`
	Name     string `json:"name,omitempty"`
	Size     int32  `json:"size,omitempty"`
}

func (SwapDevice) String

func (s SwapDevice) String() string

type Virtualization

type Virtualization struct {
	ID      uint   `json:"-"`
	SpecsID uint   `json:"-"`
	Type    string `json:"type,omitempty"`
}

func (Virtualization) String

func (v Virtualization) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL