snipe

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Overview

Package snipe wraps the go-snipeit library with dry-run enforcement and convenience methods for the unifi2snipe sync process.

Index

Constants

This section is empty.

Variables

View Source
var ErrDryRun = fmt.Errorf("write blocked: dry-run mode is enabled")

ErrDryRun is returned when a write operation is attempted in dry-run mode.

Functions

func SetLogFormatter

func SetLogFormatter(formatter logrus.Formatter)

SetLogFormatter sets the logger formatter for the snipe package.

func SetLogLevel

func SetLogLevel(level logrus.Level)

SetLogLevel sets the logger level for the snipe package.

func SetLogOutput

func SetLogOutput(output io.Writer)

SetLogOutput sets the logger output for the snipe package.

Types

type Client

type Client struct {
	*snipeit.Client
	DryRun bool
}

Client wraps the go-snipeit client with dry-run enforcement.

func NewClient

func NewClient(baseURL, apiKey string, rateLimit bool) (*Client, error)

NewClient creates a new Snipe-IT client.

func (*Client) CheckoutToLocation

func (c *Client) CheckoutToLocation(ctx context.Context, assetID, locationID int, checkoutDate string) error

CheckoutToLocation checks out an asset to a Snipe-IT location. checkoutDate should be in "YYYY-MM-DD" format; pass "" to use today.

func (*Client) CreateAsset

func (c *Client) CreateAsset(ctx context.Context, asset snipeit.Asset) (*snipeit.Asset, error)

CreateAsset creates a new hardware asset.

func (*Client) CreateModel

func (c *Client) CreateModel(ctx context.Context, model snipeit.Model) (*snipeit.Model, error)

CreateModel creates a new asset model in Snipe-IT.

func (*Client) GetAssetBySerial

func (c *Client) GetAssetBySerial(ctx context.Context, serial string) (*snipeit.AssetsResponse, error)

GetAssetBySerial looks up an asset by serial number.

func (*Client) ListAllModels

func (c *Client) ListAllModels(ctx context.Context) ([]snipeit.Model, error)

ListAllModels returns all models from Snipe-IT, handling pagination.

func (*Client) PatchAsset

func (c *Client) PatchAsset(ctx context.Context, id int, asset snipeit.Asset) (*snipeit.Asset, error)

PatchAsset partially updates an existing hardware asset by ID.

func (*Client) SetupFields

func (c *Client) SetupFields(fieldsetID int, fields []FieldDef) (map[string]string, error)

SetupFields creates or updates custom fields in Snipe-IT and associates them with the given fieldset. Returns a map of field name -> db_column_name.

type FieldDef

type FieldDef struct {
	Name        string
	Element     string
	Format      string
	HelpText    string
	FieldValues string
}

FieldDef defines a custom field to create in Snipe-IT.

Jump to

Keyboard shortcuts

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