model

package
v0.0.0-...-2b04316 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDeviceAction = errors.New("invalid device action")
	ErrMissingDeviceStatus = errors.New("missing device status")
	ErrInvalidDeviceStatus = errors.New("invalid device status")
)

Functions

This section is empty.

Types

type Device

type Device struct {
	Description string            `json:"description"`
	Identifier  string            `json:"identifier"`
	Interfaces  []Interface       `json:"interfaces" yaml:"interfaces"`
	CreatedAt   time.Time         `json:"created_at" yaml:"created_at"`
	FirstSeenAt time.Time         `json:"first_seen_at" yaml:"first_seen_at"`
	LastSeenAt  time.Time         `json:"last_seen_at" yaml:"last_seen_at"`
	Present     bool              `json:"present" yaml:"present"`
	Properties  map[string]string `json:"properties,omitempty" yaml:"properties,omitempty"`
	Status      Status            `json:"status" yaml:"status"`
	UpdatedAt   time.Time         `json:"updated_at" yaml:"updated_at"`
}

Device represents a single device that can be tracked.

type DeviceAdded

type DeviceAdded struct {
	Description string            `json:"description"`
	Identifier  string            `json:"identifier"`
	Present     bool              `json:"present"`
	Properties  map[string]string `json:"properties"`
	LastSeenAt  time.Time         `json:"last_seen_at"`
}

type DevicePresenceUpdated

type DevicePresenceUpdated struct {
	Identifier string    `json:"identifier"`
	Present    bool      `json:"present"`
	LastSeenAt time.Time `json:"last_seen_at"`
}

type DeviceRemoved

type DeviceRemoved struct {
	Identifier string `json:"identifier"`
}

type DeviceUpdated

type DeviceUpdated struct {
	Description string            `json:"description"`
	Identifier  string            `json:"identifier"`
	Present     bool              `json:"present"`
	Properties  map[string]string `json:"properties"`
	LastSeenAt  time.Time         `json:"last_seen_at"`
}

type Event

type Event struct {
	Type EventType       `json:"type"`
	Data json.RawMessage `json:"data"`
}

type EventType

type EventType uint
const (
	EventTypeUndefined EventType = iota
	EventTypeAdded
	EventTypePresenceUpdated
	EventTypeUpdated
	EventTypeRemoved
)

func (EventType) MarshalJSON

func (e EventType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (*EventType) String

func (e *EventType) String() string

func (*EventType) UnmarshalJSON

func (e *EventType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted json string to the enum value

type Interface

type Interface struct {
	Type        InterfaceType
	MACAddress  string
	IPv4Address string
}

Interface defines a physical/software interface that can be uniquely addressed

type InterfaceType

type InterfaceType uint

InterfaceType defines the type of physical/software interface

const (
	// InterfaceUnknown corresponds to an unsupported/unknown interface
	InterfaceUnknown InterfaceType = iota

	// InterfaceEthernet corresponds to an Ethernet interface
	InterfaceEthernet

	// InterfaceWifi corresponds to a WiFi interface
	InterfaceWifi

	// InterfaceBluetooth corresponds to a Bluetooth interface
	InterfaceBluetooth
)

func (InterfaceType) MarshalJSON

func (i InterfaceType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (InterfaceType) MarshalYAML

func (i InterfaceType) MarshalYAML() (interface{}, error)

MarshalYAML marshals the enum as yaml string

func (InterfaceType) String

func (i InterfaceType) String() string

func (*InterfaceType) UnmarshalJSON

func (i *InterfaceType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted json string to the enum value

func (*InterfaceType) UnmarshalYAML

func (i *InterfaceType) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals a yaml string to the enum value

type Status

type Status uint

Status represents the various states a device can be in.

const (
	// StatusUndefined is the default initialised device status.
	StatusUndefined Status = iota

	// StatusDiscovered is the initial state given to a device that was found
	// by a tracker scan operation for the first time.
	StatusDiscovered

	// StatusIgnored is the state given to a device that should not be tracked.
	StatusIgnored

	// StatusTracked is the state given to a device that should be watched.
	StatusTracked
)

func StatusOf

func StatusOf(s string) Status

func (Status) MarshalJSON

func (s Status) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (Status) MarshalYAML

func (s Status) MarshalYAML() (interface{}, error)

MarshalYAML marshals the enum as yaml string

func (Status) String

func (s Status) String() string

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted json string to the enum value

func (*Status) UnmarshalYAML

func (s *Status) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals a yaml string to the enum value

Jump to

Keyboard shortcuts

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