devicesdb

package
v0.0.0-...-9febfc8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package devicesdb provides utilities to retrieve/update devices from db

Index

Constants

This section is empty.

Variables

View Source
var (
	// Columns
	IdColumn     = queryutils.NewColumn("id").Build()     //nolint:stylecheck
	DutIdColumn  = queryutils.NewColumn("dut_id").Build() //nolint:stylecheck
	HostColumn   = queryutils.NewColumn("host").Build()
	PortColumn   = queryutils.NewColumn("port").Build()
	TypeColumn   = queryutils.NewColumn("type").Build()
	StateColumn  = queryutils.NewColumn("state").Build()
	LabelsColumn = queryutils.NewColumn("labels").WithColumnType(
		queryutils.ColumnTypeJSONB).WithJSONFullPath(func(fields ...string) []string {
		pathComponents := []string{}
		pathComponents = append(pathComponents, fields...)
		pathComponents = append(pathComponents, "Values")
		return pathComponents
	}).Build()

	// Table
	DevicesTable = queryutils.NewTableBuilder("Devices").WithColumns(
		IdColumn,
		DutIdColumn,
		HostColumn,
		PortColumn,
		TypeColumn,
		StateColumn,
		LabelsColumn,
	).Build()
)

Functions

func CountDevices

func CountDevices(ctx context.Context, dbConn *sql.DB, filter string) (*fleetconsolerpc.CountDevicesResponse, error)

func GetBaseDimensions

func GetBaseDimensions(ctx context.Context, dbConn *sql.DB) (map[string]*fleetconsolerpc.LabelValues, error)

GetBaseDimensions gets all the base dimensions and their possible values

func GetLabels

func GetLabels(ctx context.Context, dbConn *sql.DB) (map[string]*fleetconsolerpc.LabelValues, error)

GetLabels gets all the dynamic labels and their possible values

func List

func List(ctx context.Context, dbConn *sql.DB, filter, orderby string, offset, pageSize int) ([]*fleetconsolerpc.Device, bool, error)

func ToListDevicesDevice

func ToListDevicesDevice(device *DeviceDAO) *fleetconsolerpc.Device

Types

type DeviceAddressDAO

type DeviceAddressDAO struct {
	Host string
	Port int32
}

type DeviceDAO

type DeviceDAO struct {
	Id         string //nolint:stylecheck
	DutId      string //nolint:stylecheck
	Address    *DeviceAddressDAO
	Type       string
	State      string
	DeviceSpec *DeviceSpecDAO
}

DeviceDAO represents a device as saved in AlloyDB

func FromDeviceManagerDevice

func FromDeviceManagerDevice(device *api.Device) *DeviceDAO

func (*DeviceDAO) DeviceAsDBArguments

func (device *DeviceDAO) DeviceAsDBArguments() []any

type DeviceMetricsDAO

type DeviceMetricsDAO struct {
	Total            int32
	Leased           int32
	Available        int32
	Ready            int32
	NeedManualRepair int32
	NeedRepair       int32
	RepairFailed     int32
}

type DeviceSpecDAO

type DeviceSpecDAO struct {
	Labels map[string]*LabelValuesDAO
}

type LabelValuesDAO

type LabelValuesDAO struct {
	Values []string
}

Jump to

Keyboard shortcuts

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