sync

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package sync implements the core synchronization logic between Apple Business Manager and Snipe-IT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogFormatter added in v1.6.0

func SetLogFormatter(formatter logrus.Formatter)

SetLogFormatter sets the logger formatter.

func SetLogLevel

func SetLogLevel(level logrus.Level)

SetLogLevel sets the logger level.

func SetLogOutput added in v1.6.0

func SetLogOutput(output io.Writer)

SetLogOutput sets the logger output.

Types

type ABMCache added in v1.0.0

type ABMCache struct {
	Devices   []abmclient.Device
	AppleCare map[string]*abmclient.CoverageResult // device ID -> coverage
}

ABMCache holds cached ABM device and AppleCare data loaded from the cache directory.

type Engine

type Engine struct {
	ShowProgress bool // show progress bars during download
	// contains filtered or unexported fields
}

Engine performs the sync between ABM and Snipe-IT.

func NewDownloadEngine added in v1.0.0

func NewDownloadEngine(abmClient *abmclient.Client, cfg *config.Config) *Engine

NewDownloadEngine creates a lightweight engine for downloading ABM data without needing a Snipe-IT client.

func NewEngine

func NewEngine(abmClient *abmclient.Client, snipeClient *snipe.Client, cfg *config.Config) *Engine

NewEngine creates a new sync engine.

func (*Engine) CacheDir added in v1.0.0

func (e *Engine) CacheDir() string

CacheDir returns the configured cache directory, defaulting to ".cache".

func (*Engine) FetchAndSaveAppleCare added in v1.3.3

func (e *Engine) FetchAndSaveAppleCare(ctx context.Context, devices []abmclient.Device) error

FetchAndSaveAppleCare fetches AppleCare coverage for the given device list and writes applecare.json. If devices is nil, it loads devices from cache.

func (*Engine) FetchAndSaveCache added in v1.0.0

func (e *Engine) FetchAndSaveCache(ctx context.Context) error

FetchAndSaveCache fetches all devices and AppleCare coverage from ABM and writes them to the cache directory as individual JSON files. Each section is saved immediately after fetching so that partial data is preserved if a later stage fails or is interrupted.

func (*Engine) FetchAndSaveDevices added in v1.3.3

func (e *Engine) FetchAndSaveDevices(ctx context.Context) ([]abmclient.Device, error)

FetchAndSaveDevices fetches devices from ABM, applies configured filters, writes devices.json, and returns the device list for further use.

func (*Engine) LoadCache added in v1.0.0

func (e *Engine) LoadCache() error

LoadCache reads ABM cache from individual JSON files in the cache directory.

func (*Engine) Run

func (e *Engine) Run(ctx context.Context) (*Stats, error)

Run executes the full sync process.

func (*Engine) RunSingle

func (e *Engine) RunSingle(ctx context.Context, serial string) (*Stats, error)

RunSingle syncs a single device identified by serial number.

type Stats

type Stats struct {
	Total    int
	Created  int
	Updated  int
	Skipped  int
	Errors   int
	ModelNew int
}

Stats tracks sync operation counts.

Jump to

Keyboard shortcuts

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