Files
Sebastian Unterschütz d127a3b957
Release / release (push) Successful in 49s
feat: enhance host resolution, filtering, and cache management
- **Strategies**: Add resolver strategy input validation and parsing in setup wizard. Support comma-separated input with known strategy mapping.
- **Client**: Extend Search and SearchAll to include kind and tag filters. Add pagination for full cache refresh handling large datasets.
- **Cache**: Introduce `RecentlyUsed` and `MarkUsed`. Persist `LastUsed` timestamps for entries.
- **TUI**: Add recent hosts view, tag/kind filters, and inline editor for user/port override.
- **Tests**: Comprehensive unit tests for new features, including strategy validation, cache behavior, and client filtering.
- **Docs**: Update README with new TUI features and cache subcommands.
2026-05-23 17:06:24 +02:00

61 lines
1.6 KiB
Go

package netbox
// SearchOptions filters a Search or SearchAll query.
// Zero value means no filtering (return all kinds, no tag filter).
type SearchOptions struct {
Tag string // filter by tag slug; empty = no filter
Kind string // "device" | "vm" | "" (both)
}
// HostEntry is a unified model for both devices and virtual machines from NetBox.
type HostEntry struct {
ID int
Name string
Kind string // "device" | "vm"
PrimaryIP4 string // e.g. "10.0.1.5" (prefix length stripped)
PrimaryIP6 string
Tags []string
}
// netboxIP represents an IP address as returned by the NetBox API.
type netboxIP struct {
Address string `json:"address"` // CIDR notation, e.g. "10.0.1.5/24"
}
// netboxDevice matches the relevant fields of the NetBox /dcim/devices/ response.
type netboxDevice struct {
ID int `json:"id"`
Name string `json:"name"`
Tags []struct {
Name string `json:"name"`
} `json:"tags"`
PrimaryIP4 *netboxIP `json:"primary_ip4"`
PrimaryIP6 *netboxIP `json:"primary_ip6"`
}
// netboxVM matches the relevant fields of the NetBox /virtualization/virtual-machines/ response.
type netboxVM struct {
ID int `json:"id"`
Name string `json:"name"`
Tags []struct {
Name string `json:"name"`
} `json:"tags"`
PrimaryIP4 *netboxIP `json:"primary_ip4"`
PrimaryIP6 *netboxIP `json:"primary_ip6"`
}
type netboxListResponse[T any] struct {
Count int `json:"count"`
Results []T `json:"results"`
}
type netboxIPListResponse struct {
Count int `json:"count"`
Results []struct {
Address string `json:"address"`
Interface *struct {
Name string `json:"name"`
} `json:"assigned_object"`
} `json:"results"`
}