datastore

package
v0.0.0-...-34aea0c Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package datastore is the types and interface for the device datastore

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	ID             int64
	Created        time.Time
	Modified       time.Time
	OrganizationID string
	DeviceID       string
	ActionID       string
	Action         string
	Status         string
	Message        string
}

Action is the log of an action request

type DataStore

type DataStore interface {
	DeviceList(orgID string) ([]Device, error)
	DeviceGet(id string) (Device, error)
	DevicePing(id string, refresh time.Time) error
	DeviceCreate(Device) (int64, error)
	DeviceDelete(deviceID string) error

	DeviceSnapList(id int64) ([]DeviceSnap, error)
	DeviceSnapDelete(id int64) error
	DeviceSnapUpsert(ds DeviceSnap) error

	ActionCreate(act Action) (int64, error)
	ActionUpdate(actionID, status, message string) error
	ActionListForDevice(orgID, deviceID string) ([]Action, error)

	DeviceVersionGet(deviceID int64) (DeviceVersion, error)
	DeviceVersionUpsert(dv DeviceVersion) error
	DeviceVersionDelete(id int64) error

	GroupCreate(orgID, name string) (int64, error)
	GroupList(orgID string) ([]Group, error)
	GroupGet(orgID, name string) (Group, error)
	GroupLinkDevice(orgID, name, deviceID string) error
	GroupUnlinkDevice(orgID, name, deviceID string) error
	GroupGetDevices(orgID, name string) ([]Device, error)
	GroupGetExcludedDevices(orgID, name string) ([]Device, error)
}

DataStore is the interfaces for the data repository

type Device

type Device struct {
	ID             int64
	Created        time.Time
	LastRefresh    time.Time
	OrganisationID string
	DeviceID       string
	Brand          string
	Model          string
	SerialNumber   string
	DeviceKey      string
	StoreID        string
	Active         bool
}

Device the repository definition of a device

type DeviceSnap

type DeviceSnap struct {
	ID              uint             `gorm:"primarykey"`
	Created         time.Time        `gorm:"column:created"`
	Modified        time.Time        `gorm:"column:modified"`
	DeviceID        int64            `gorm:"column:device_id"`
	Name            string           `gorm:"column:name"`
	InstalledSize   int64            `gorm:"column:installed_size"`
	InstalledDate   time.Time        `gorm:"column:installed_date"`
	Status          string           `gorm:"column:status"`
	Channel         string           `gorm:"column:channel"`
	Confinement     string           `gorm:"column:confinement"`
	Version         string           `gorm:"column:version"`
	Revision        int              `gorm:"column:revision"`
	Devmode         bool             `gorm:"column:devmode"`
	Config          string           `gorm:"column:config"`
	ServiceStatuses []*ServiceStatus `gorm:"constraint:OnDelete:CASCADE;foreignKey:ID"`
}

DeviceSnap holds the details of snap on a device

func (DeviceSnap) TableName

func (DeviceSnap) TableName() string

TableName specifies a custom table name for legacy tables to use with gorm

type DeviceVersion

type DeviceVersion struct {
	ID            int64
	DeviceID      int64
	Version       string
	Series        string
	OSID          string
	OSVersionID   string
	OnClassic     bool
	KernelVersion string
}

DeviceVersion holds the details of the OS details on the device

type Group

type Group struct {
	ID             int64
	Created        time.Time
	Modified       time.Time
	OrganisationID string
	Name           string
}

Group is the record for grouping devices

type GroupDeviceLink struct {
	ID             int64
	Created        time.Time
	OrganisationID string
	GroupID        int64
	DeviceID       int64
}

GroupDeviceLink is the record for linking devices to groups

type ServiceStatus

type ServiceStatus struct {
	gorm.Model
	DeviceSnapID int64
	Name         string
	Daemon       string
	Enabled      bool
	Active       bool
}

ServiceStatus is the status of a service for a snap when a list of snaps or info for a single snap is retrieved

Directories

Path Synopsis
Package memory is the Datastore implementation for in-memory
Package memory is the Datastore implementation for in-memory
Package postgres is the Datastore implementation for Postgres
Package postgres is the Datastore implementation for Postgres

Jump to

Keyboard shortcuts

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