Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyFieldDefaults(schema []models.FieldSchema, fields map[string]any) map[string]any
- func AssertPacksHaveCLITwins(db *gorm.DB) error
- func AssertTemplatesHaveCLITwins(db *gorm.DB) error
- func AttachDevice(db *gorm.DB, parentID, deviceID uint) (*models.ConfigScope, error)
- func AttachService(db *gorm.DB, parentID, serviceRowID uint) (*models.ConfigScope, error)
- func CLIObjectChecksum(platform, payloadKind string, ctx *models.CLIContext, ...) string
- func CanonicalServiceParentID(db *gorm.DB, from *models.ConfigScope) (uint, error)
- func CatalogCLITypeFolder(db *gorm.DB, typeName string) (*models.ConfigScope, error)
- func CompileContextPattern(pattern string) (*regexp.Regexp, error)
- func ConnectionTypeDTO(ct *models.ServiceConnectionType) models.ServiceConnectionTypeDTO
- func CreateCLIFeature(db *gorm.DB, scopeID uint, feat *models.ConfigCLIFeature) (*models.ConfigCLIFeature, error)
- func CreateScope(db *gorm.DB, s *models.ConfigScope) (*models.ConfigScope, error)
- func CreateServiceFromTree(db *gorm.DB, parentID uint, dto *models.ServiceDTO) (*models.ConfigScope, error)
- func CreateServiceRecord(tx *gorm.DB, dto *models.ServiceDTO) (*models.Service, error)
- func DeleteAssignment(db *gorm.DB, id uint) error
- func DeleteCLIFeature(db *gorm.DB, id uint) error
- func DeleteScope(db *gorm.DB, id uint) error
- func DeleteTranslationCLIForType(db *gorm.DB, typeID uint, typeName string) error
- func DescendantScopes(db *gorm.DB, rootID uint) ([]models.ConfigScope, error)
- func DetachDevice(db *gorm.DB, id uint) error
- func DetachServiceByRowID(db *gorm.DB, serviceRowID uint) error
- func DropPackAndTemplateTables(db *gorm.DB) error
- func EncodeEndpointFields(vlan int, subNetboxID, termNetboxID uint) json.RawMessage
- func EndpointIdentity(ep models.ServiceEndpoint) string
- func EndpointRolesForCount(st *models.ServiceType, n int) []string
- func FieldEmpty(f models.FieldSchema, v any) bool
- func FieldUint(m map[string]any, key string) uint
- func FillEndpointDefaults(st *models.ServiceType, serviceFields, epFields map[string]any) map[string]any
- func GetCLIFeature(db *gorm.DB, id uint) (*models.ConfigCLIFeature, error)
- func GetScope(db *gorm.DB, id uint) (*models.ConfigScope, error)
- func InventoryMaps(types []models.ServiceType) map[string]string
- func IsPhysicalInterfaceType(t string) bool
- func IsSROS(platform string) bool
- func IsUniqueViolation(err error) bool
- func ListAssignments(db *gorm.DB, scopeID uint) ([]models.ConfigAssignment, error)
- func ListCLIFeatures(db *gorm.DB, scopeID uint) ([]models.ConfigCLIFeature, error)
- func ListEndpoints(db *gorm.DB, serviceID uint) ([]models.ServiceEndpoint, error)
- func ListScopes(db *gorm.DB) ([]models.ConfigScope, error)
- func ListServiceTypes(db *gorm.DB) ([]models.ServiceType, error)
- func LoadServiceType(db *gorm.DB, id uint) (*models.ServiceType, error)
- func LookupCLIObject(db *gorm.DB, typeName, platform string) (*models.ConfigScope, error)
- func LookupServiceType(db *gorm.DB, name string) (*models.ServiceType, error)
- func MergeEndpointNetboxIDs(fields json.RawMessage, subNetboxID, termNetboxID uint) json.RawMessage
- func MissingCLIObjectMessage(typeName, platform string) string
- func MoveScope(db *gorm.DB, id, parentID uint, sortOrder *int) (*models.ConfigScope, error)
- func NetboxIDsFromFields(raw json.RawMessage) (sub, term uint)
- func NormalizeFieldType(t string) string
- func NormalizePlatform(p string) string
- func RedactAssignmentSecrets(db *gorm.DB, rows []models.ConfigAssignment) error
- func RedactVariableSecrets(def *models.ConfigVariableDef)
- func RenameCatalogCLITypeFolder(db *gorm.DB, oldName, newName string) error
- func Render(db *gorm.DB, body, define string, data any) ([]string, error)
- func RenderCLIFeature(db *gorm.DB, ctx *models.CLIContext, feat *models.ConfigCLIFeature, data any) ([]string, error)
- func RenderCLIObject(db *gorm.DB, obj *models.ConfigScope, data any) ([]string, error)
- func RenderCLIObjectRemove(db *gorm.DB, obj *models.ConfigScope, data any) ([]string, error)
- func RenderCLITranslation(db *gorm.DB, obj *models.ConfigScope, data any, includeRemove bool) ([]string, error)
- func ReplaceConnectionTypes(tx *gorm.DB, typeID uint, dtos []models.ServiceConnectionTypeDTO) error
- func ReplaceEndpoints(db *gorm.DB, serviceID uint, eps []models.ServiceEndpoint) error
- func RequireCLIObject(obj *models.ConfigScope) error
- func Resolve(db *gorm.DB, interfaceID uint, varName string) (any, *models.ConfigScope, error)
- func ResolveMap(db *gorm.DB, interfaceID uint) (map[string]any, error)
- func ResolveMapForDevice(db *gorm.DB, deviceID uint) (map[string]any, error)
- func RootScope(db *gorm.DB) (*models.ConfigScope, error)
- func SDPIDFromNeighbor(neighborIP string) (int, error)
- func SecretDefaultUnchanged(raw []byte) bool
- func Seed(db *gorm.DB) error
- func ServiceTypeDTO(st *models.ServiceType) models.ServiceTypeDTO
- func ServiceTypeExists(db *gorm.DB, name string) (bool, error)
- func StartScope(db *gorm.DB, interfaceID uint) (*models.ConfigScope, error)
- func TypeCheck(def *models.ConfigVariableDef, v any) (any, error)
- func TypeCheckField(f models.FieldSchema, v any) (any, error)
- func TypeCheckRaw(def *models.ConfigVariableDef, raw json.RawMessage) (any, error)
- func TypeForNetboxKind(types []models.ServiceType, netboxType string) *models.ServiceType
- func UpdateCLIFeature(db *gorm.DB, id uint, dto *models.ConfigCLIFeatureDTO) (*models.ConfigCLIFeature, error)
- func UpdateScope(db *gorm.DB, id uint, patch *models.ConfigScopeDTO) (*models.ConfigScope, error)
- func UpsertAssignment(db *gorm.DB, defID, scopeID uint, value []byte) (*models.ConfigAssignment, error)
- func VLANFromFields(raw json.RawMessage) int
- func ValidFieldType(t string) bool
- func ValidPayloadKind(k string) bool
- func ValidScopeKind(k string) bool
- func ValidVarType(t string) bool
- func ValidateConnectionTypeID(db *gorm.DB, st *models.ServiceType, id *uint) error
- func ValidateConstraints(typ string, raw json.RawMessage) error
- func ValidateELINEShape(db *gorm.DB, eps []models.ServiceEndpoint) error
- func ValidateEndpoints(db *gorm.DB, st *models.ServiceType, eps []models.ServiceEndpoint) error
- func ValidateFieldSchema(f *models.FieldSchema, named bool) error
- func ValidateInterfacesSpec(spec models.ServiceInterfacesSpec) error
- func ValidateServiceFields(st *models.ServiceType, raw json.RawMessage) (json.RawMessage, error)
- func ValidateServiceType(st *models.ServiceType) error
- func ValidateVariableDef(def *models.ConfigVariableDef) error
- func WalkParents(db *gorm.DB, start *models.ConfigScope) ([]models.ConfigScope, error)
- func WouldCycle(db *gorm.DB, nodeID uint, newParentID uint) (bool, error)
- type AllocatedResource
- type BaselineRenderData
- type DCIMDevice
- type DCIMInterface
- type DeviceRender
- type FieldMeta
- type GenericRenderData
- type MatrixRow
- type RenderCommercial
- type RenderEndpoint
- type RenderedSource
- type ResolvedVar
- type ResourceCIDRStatus
- type ScopeTreeData
- type ScopeTreeNode
- type StatusError
Constants ¶
const ( FieldVLAN = "vlan" FieldSubinterfaceNetboxID = "subinterface_netbox_id" FieldTerminationNetboxID = "termination_netbox_id" )
Variables ¶
var ErrConnectionTypeInUse = statusErr(409, "connection type in use")
var ErrConnectionTypeNameTaken = statusErr(409, "connection type name already exists")
var ErrConnectionTypeNotFound = statusErr(404, "connection type not found")
var ErrServiceTypeNameTaken = statusErr(409, "service type name already exists")
ErrServiceTypeNameTaken is returned when renaming a type to a name that already exists.
Functions ¶
func ApplyFieldDefaults ¶ added in v1.1.1
ApplyFieldDefaults copies schema defaults into empty keys. Missing keys are created. Existing non-empty values are left unchanged.
func AssertPacksHaveCLITwins ¶ added in v1.0.5
AssertPacksHaveCLITwins errors if platform_packs still exists and any row has no kind=cli translator for the same (service_type_id, platform). MigrateDatabase must not DROP those tables until every pack was copied.
func AssertTemplatesHaveCLITwins ¶ added in v1.0.5
AssertTemplatesHaveCLITwins errors if config_templates still exists and any row has no baseline kind=cli twin (same name, parent = scope_id or global if null, platform-compatible). Translation CLI does not count.
func AttachDevice ¶
AttachDevice creates or updates a device-kind node under parentID and ensures a child interface node exists for each inventory interface.
func AttachService ¶ added in v1.0.5
AttachService places an existing typed CN/CI row in the tree and projects endpoint children. Lime rows are allowed. VL/VI/LF/LI are rejected.
func CLIObjectChecksum ¶ added in v1.0.5
func CLIObjectChecksum(platform, payloadKind string, ctx *models.CLIContext, feats []models.ConfigCLIFeature) string
CLIObjectChecksum is the canonical seed hash for a translation CLI object:
sha256(platform + "\n" + payload_kind + "\n" + canonicalJSON(context) + "\n" +
for each feature in sort_order:
name + "\nremove_at_root=" + bool + "\nadd\n" + AddCommands +
"\nupdate\n" + UpdateCommands + "\nremove\n" + RemoveCommands + "\n")
Empty UpdateCommands still contributes "\nupdate\n". canonicalJSON uses deterministic key order for pattern/enter/exit/captures; nil context is "null" so setting enter counts as an operator edit.
func CanonicalServiceParentID ¶ added in v1.0.5
CanonicalServiceParentID is the parent for a new canonical node started from from. Interface/device create uses the device's folder/site/location parent when that parent is organizational, otherwise _services.
func CatalogCLITypeFolder ¶ added in v1.1.0
CatalogCLITypeFolder ensures global/_catalog/cli/<typeName> exists.
func CompileContextPattern ¶ added in v1.0.5
CompileContextPattern turns the GUI placeholder language into an anchored RE2 regex. Tokens are whitespace-separated; `<ident>` becomes a named `\S+` capture. Empty and `global` mean the configure root (no wrap).
func ConnectionTypeDTO ¶ added in v1.1.0
func ConnectionTypeDTO(ct *models.ServiceConnectionType) models.ServiceConnectionTypeDTO
func CreateCLIFeature ¶ added in v1.0.5
func CreateCLIFeature(db *gorm.DB, scopeID uint, feat *models.ConfigCLIFeature) (*models.ConfigCLIFeature, error)
func CreateScope ¶
func CreateScope(db *gorm.DB, s *models.ConfigScope) (*models.ConfigScope, error)
func CreateServiceFromTree ¶ added in v1.0.5
func CreateServiceFromTree(db *gorm.DB, parentID uint, dto *models.ServiceDTO) (*models.ConfigScope, error)
CreateServiceFromTree creates a CN/CI inventory row and a canonical kind=service scope with zero endpoints.
func CreateServiceRecord ¶ added in v1.0.5
CreateServiceRecord inserts a services row using the same numbering and field-copy rules as ApiServiceCreate. The caller must validate category and service type first and run this inside a transaction when allocating the next <type><5-digit> id.
func DeleteTranslationCLIForType ¶ added in v1.1.0
DeleteTranslationCLIForType removes kind=cli objects for typeID (and descendants), then the empty _catalog/cli/<typeName> folder if present.
func DescendantScopes ¶
func DetachDevice ¶ added in v1.0.5
DetachDevice removes a device scope and its config descendants. kind=service children are reparented. The DCIM device row is never deleted.
func DetachServiceByRowID ¶ added in v1.0.5
DetachServiceByRowID drops the canonical node and its config descendants. Inventory rows are left in place. No-op if the service is not in the tree.
func DropPackAndTemplateTables ¶ added in v1.0.5
DropPackAndTemplateTables removes leftover platform_packs and config_templates. Call AssertPacksHaveCLITwins and AssertTemplatesHaveCLITwins first.
func EncodeEndpointFields ¶ added in v1.0.3
func EncodeEndpointFields(vlan int, subNetboxID, termNetboxID uint) json.RawMessage
EncodeEndpointFields stores vlan plus optional NetBox ids on an endpoint.
func EndpointIdentity ¶ added in v1.0.5
func EndpointIdentity(ep models.ServiceEndpoint) string
EndpointIdentity is the stable key for projection and virtual service_ref nodes. Replace-all allocates new service_endpoints.id values, so the table primary key cannot be used.
func EndpointRolesForCount ¶ added in v1.0.3
func EndpointRolesForCount(st *models.ServiceType, n int) []string
EndpointRolesForCount returns n copies of role "interface" for reverse- import. Bounded Max truncates; Max==0 absorbs the rest.
func FieldEmpty ¶ added in v1.1.0
func FieldEmpty(f models.FieldSchema, v any) bool
FieldEmpty is the fill/required empty rule: missing, JSON null, "", and service_id 0. false and [] are present values.
func FillEndpointDefaults ¶ added in v1.1.0
func FillEndpointDefaults(st *models.ServiceType, serviceFields, epFields map[string]any) map[string]any
FillEndpointDefaults copies same-name service-level values into empty interface fields, then interface-field defaults. It does not persist; stored endpoint JSON stays empty.
func GetCLIFeature ¶ added in v1.0.5
func InventoryMaps ¶ added in v1.0.3
func InventoryMaps(types []models.ServiceType) map[string]string
InventoryMaps returns sync_source → netbox_type for types that have both set. When two types share a source, the first in name order wins.
func IsPhysicalInterfaceType ¶ added in v1.0.3
func IsUniqueViolation ¶ added in v1.1.0
func ListAssignments ¶
func ListCLIFeatures ¶ added in v1.0.5
func ListEndpoints ¶
func ListScopes ¶
func ListScopes(db *gorm.DB) ([]models.ConfigScope, error)
func ListServiceTypes ¶ added in v1.0.3
func ListServiceTypes(db *gorm.DB) ([]models.ServiceType, error)
func LoadServiceType ¶ added in v1.1.0
func LookupCLIObject ¶ added in v1.0.5
LookupCLIObject returns the kind=cli translator for a service type name and platform. sros-md falls back to sros when no dedicated object exists.
func LookupServiceType ¶
LookupServiceType finds a service type by name.
func MergeEndpointNetboxIDs ¶ added in v1.1.0
func MergeEndpointNetboxIDs(fields json.RawMessage, subNetboxID, termNetboxID uint) json.RawMessage
MergeEndpointNetboxIDs copies subinterface/termination NetBox ids into existing endpoint fields without dropping other keys (vlan, bandwidth, …).
func MissingCLIObjectMessage ¶ added in v1.0.5
MissingCLIObjectMessage is the preview/push error when no translation CLI object exists for type+platform.
func MoveScope ¶ added in v1.0.5
MoveScope reparents id under parentID. sortOrder nil means last sibling.
func NetboxIDsFromFields ¶ added in v1.0.3
func NetboxIDsFromFields(raw json.RawMessage) (sub, term uint)
func NormalizeFieldType ¶ added in v1.1.0
func NormalizePlatform ¶
func RedactAssignmentSecrets ¶
func RedactAssignmentSecrets(db *gorm.DB, rows []models.ConfigAssignment) error
func RedactVariableSecrets ¶
func RedactVariableSecrets(def *models.ConfigVariableDef)
func RenameCatalogCLITypeFolder ¶ added in v1.1.0
RenameCatalogCLITypeFolder renames _catalog/cli/<oldName> to <newName>. Child CLI objects keep their service_type_id. Missing old folder is a no-op besides ensuring the new folder exists.
func Render ¶
Render executes a Jet template body (or a named block) against data. Funcs: include, join, eq/ne, sdpid, macColon/macHyphen/macCisco. No file/HTTP/shell. Missing struct fields error; missing map keys are empty.
func RenderCLIFeature ¶ added in v1.0.5
func RenderCLIFeature(db *gorm.DB, ctx *models.CLIContext, feat *models.ConfigCLIFeature, data any) ([]string, error)
RenderCLIFeature executes remove then add for one feature and applies the opt-in wrap policy. UpdateCommands is unused in v1.
func RenderCLIObject ¶ added in v1.0.5
func RenderCLIObjectRemove ¶ added in v1.0.5
RenderCLIObjectRemove renders only feature remove blobs (wrapped per policy).
func RenderCLITranslation ¶ added in v1.0.5
func RenderCLITranslation(db *gorm.DB, obj *models.ConfigScope, data any, includeRemove bool) ([]string, error)
RenderCLITranslation renders a service-translation CLI object. includeRemove is true for the first endpoint on a device (cleanup once) and false after.
func ReplaceConnectionTypes ¶ added in v1.1.0
ReplaceConnectionTypes applies DELETE omitted → UPDATE remaining → INSERT nameless DTOs so unique (service_type_id, name) cannot fire mid-replace. Remaining rows keep image/content_type. Omitted ids still referenced by services.connection_type_id return 409.
func ReplaceEndpoints ¶
func RequireCLIObject ¶ added in v1.0.5
func RequireCLIObject(obj *models.ConfigScope) error
RequireCLIObject gates push on the payload_kind column (not JSON).
func Resolve ¶
Resolve walks from the interface's start scope to root and returns the first assignment of varName on an enabled parameter child. Falls back to the def's DefaultValue. Assignments on the walked organizational scope itself are ignored.
func ResolveMap ¶
ResolveMap is ResolveAll as name → value, skipping vars that failed.
func ResolveMapForDevice ¶
ResolveMapForDevice resolves variables from the device scope (not a particular interface), filtered by the device's platform.
func RootScope ¶
func RootScope(db *gorm.DB) (*models.ConfigScope, error)
RootScope returns the global root folder.
func SDPIDFromNeighbor ¶
SDPIDFromNeighbor is the SR OS shared SDP ID (last IPv4 octet).
func SecretDefaultUnchanged ¶
SecretDefaultUnchanged reports that a write should keep the stored secret default: the client omitted it, sent JSON null, or echoed the redaction placeholder.
func Seed ¶
Seed creates the global root scope and reserved _catalog/_services folders when they are missing. It does not insert service types or translation CLI. Leftover platform_packs / config_templates rows (from before those tables were dropped) are copied onto CLI objects first so operator edits survive. Assignments on non-parameter scopes are copied onto a reserved parameters child and the originals are deleted. Typed CN/CI services without a tree node are placed under _services.
func ServiceTypeDTO ¶ added in v1.1.0
func ServiceTypeDTO(st *models.ServiceType) models.ServiceTypeDTO
func StartScope ¶
StartScope for an interface: interface node, else device node, else global.
func TypeCheck ¶
func TypeCheck(def *models.ConfigVariableDef, v any) (any, error)
TypeCheck coerces and validates v against def. Type, constraints, and (for vlan) the 1–4094 range. List entries and map keys/values are checked recursively when constraints.items / keys / values are set.
func TypeCheckField ¶ added in v1.1.0
func TypeCheckField(f models.FieldSchema, v any) (any, error)
TypeCheckField coerces and validates v against a definition field. MAC is stored as aabb.ccdd.eeff; prefixes as netip Prefix.Masked().
func TypeCheckRaw ¶
func TypeCheckRaw(def *models.ConfigVariableDef, raw json.RawMessage) (any, error)
func TypeForNetboxKind ¶ added in v1.0.3
func TypeForNetboxKind(types []models.ServiceType, netboxType string) *models.ServiceType
TypeForNetboxKind returns the first service type whose NetboxType matches.
func UpdateCLIFeature ¶ added in v1.0.5
func UpdateCLIFeature(db *gorm.DB, id uint, dto *models.ConfigCLIFeatureDTO) (*models.ConfigCLIFeature, error)
func UpdateScope ¶
func UpdateScope(db *gorm.DB, id uint, patch *models.ConfigScopeDTO) (*models.ConfigScope, error)
func UpsertAssignment ¶
func VLANFromFields ¶ added in v1.0.3
func VLANFromFields(raw json.RawMessage) int
func ValidFieldType ¶ added in v1.1.0
func ValidPayloadKind ¶ added in v1.0.5
func ValidScopeKind ¶
func ValidVarType ¶
func ValidateConnectionTypeID ¶ added in v1.1.0
ValidateConnectionTypeID checks that id belongs to st. If the definition has one or more connection types, id is required. Zero types means id must be unset.
func ValidateConstraints ¶
func ValidateConstraints(typ string, raw json.RawMessage) error
ValidateConstraints checks nested items/keys/values type names and that list/map-only fields are not set on scalar types.
func ValidateELINEShape ¶ added in v1.0.3
func ValidateELINEShape(db *gorm.DB, eps []models.ServiceEndpoint) error
ValidateELINEShape enforces physical ports and that A/B are not the same device+interface. Call after ValidateEndpoints.
func ValidateEndpoints ¶
func ValidateEndpoints(db *gorm.DB, st *models.ServiceType, eps []models.ServiceEndpoint) error
ValidateEndpoints checks endpoints against the service type's Interfaces spec and that each device/interface pair exists in inventory.
func ValidateFieldSchema ¶ added in v1.1.0
func ValidateFieldSchema(f *models.FieldSchema, named bool) error
ValidateFieldSchema checks one definition field. named is true for schema[] and interfaces.fields[]; list items are nameless.
func ValidateInterfacesSpec ¶ added in v1.1.0
func ValidateInterfacesSpec(spec models.ServiceInterfacesSpec) error
ValidateInterfacesSpec checks min/max on a homogeneous interfaces spec.
func ValidateServiceFields ¶ added in v1.1.0
func ValidateServiceFields(st *models.ServiceType, raw json.RawMessage) (json.RawMessage, error)
ValidateServiceFields type-checks service-level fields against st.Schema and returns canonical JSON (MAC/prefix). Required uses FieldEmpty.
func ValidateServiceType ¶ added in v1.1.0
func ValidateServiceType(st *models.ServiceType) error
ValidateServiceType checks schema and interfaces.fields (unique names, types, constraints) and rewrites snpa to mac.
func ValidateVariableDef ¶
func ValidateVariableDef(def *models.ConfigVariableDef) error
ValidateVariableDef checks type, constraints, and default_value.
func WalkParents ¶
func WalkParents(db *gorm.DB, start *models.ConfigScope) ([]models.ConfigScope, error)
WalkParents returns start then each ancestor up to root. A cycle is an error.
Types ¶
type AllocatedResource ¶ added in v1.1.0
type AllocatedResource struct {
ScopeID uint `json:"scope_id"`
CIDRs []ResourceCIDRStatus `json:"cidrs"`
}
AllocatedResource is the winning kind=resource node for a walk.
func AllocateResource ¶ added in v1.1.0
func AllocateResource(db *gorm.DB, interfaceID, deviceID uint, resourceName string, family int) (*AllocatedResource, error)
AllocateResource walks interface → device → ancestors → global and returns the closest enabled resource child whose name matches. Occupancy is a read-only scan; this does not write.
type BaselineRenderData ¶ added in v1.0.5
type BaselineRenderData struct {
Name string
Device DCIMDevice
Interface DCIMInterface
LocalIface string
Vars map[string]any
}
BaselineRenderData is the template context for baseline (non-service) CLI objects. Interface/LocalIface are set only when the object's parent is an interface; they are zero at device/folder level.
type DCIMDevice ¶
type DCIMDevice struct {
ID uint `json:"id"`
Name string `json:"name"`
Platform string `json:"platform"`
Site string `json:"site"`
Role string `json:"role"`
ModelName string `json:"model_name"`
Manufacturer string `json:"manufacturer"`
Status string `json:"status"`
PrimaryIPv4 string `json:"primary_ipv4"`
PrimaryIPv6 string `json:"primary_ipv6"`
}
DCIMDevice is the read-only inventory fragment templates may use.
func DCIMFromDevice ¶
func DCIMFromDevice(d *models.Device) DCIMDevice
type DCIMInterface ¶
type DCIMInterface struct {
ID uint `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Enabled bool `json:"enabled"`
Type string `json:"type"`
UntaggedVLAN int `json:"untagged_vlan"`
TaggedVLANs []int `json:"tagged_vlans"`
Addresses []string `json:"addresses"`
}
DCIMInterface is the read-only interface fragment templates may use.
func DCIMFromInterface ¶
func DCIMFromInterface(iface *models.Interface) DCIMInterface
type DeviceRender ¶
type DeviceRender struct {
DeviceID uint `json:"device_id"`
Name string `json:"name"`
Platform string `json:"platform"`
Sources []RenderedSource `json:"sources"`
}
func RenderDevice ¶
func RenderDevice(db *gorm.DB, deviceID uint) (*DeviceRender, error)
RenderDevice returns baseline CLI + terminating services for a device. It does not talk to the device.
type FieldMeta ¶ added in v1.1.0
FieldMeta is definition metadata exposed to templates (not stored values).
type GenericRenderData ¶
type GenericRenderData struct {
Name string
Description string
ServiceNumericID int
ConnectionType string
Fields map[string]any
FieldMeta map[string]FieldMeta
Vars map[string]any
Device DCIMDevice
Interface DCIMInterface
LocalIface string
Current RenderEndpoint
Interfaces []RenderEndpoint
Others []RenderEndpoint
}
GenericRenderData is the template context for service-translation CLI objects.
func GenericData ¶
func GenericDataWithSiblings ¶ added in v1.1.0
func GenericDataWithSiblings(db *gorm.DB, svc *models.Service, ep *models.ServiceEndpoint, device *models.Device, iface *models.Interface, siblings []models.ServiceEndpoint) (*GenericRenderData, error)
GenericDataWithSiblings is GenericData using siblings for .Interfaces/.Others instead of the persisted endpoint table (rebind teardown/add).
type MatrixRow ¶
type MatrixRow struct {
InterfaceID uint `json:"interface_id"`
InterfaceName string `json:"interface_name"`
DeviceID uint `json:"device_id"`
DeviceName string `json:"device_name"`
ScopeID *uint `json:"scope_id,omitempty"`
Value any `json:"value"`
SourceID *uint `json:"source_id,omitempty"`
SourceName string `json:"source_name,omitempty"`
FromDefault bool `json:"from_default"`
Error string `json:"error,omitempty"`
}
MatrixRows are interfaces under a scope subtree, with one variable resolved.
type RenderCommercial ¶ added in v1.1.0
RenderCommercial is the resolved commercial Service row for an endpoint.
type RenderEndpoint ¶ added in v1.1.0
type RenderEndpoint struct {
Device DCIMDevice
Interface DCIMInterface
LocalIface string
Fields map[string]any
Commercial *RenderCommercial
// NeighborIP is the peer device loopback when Device.ID != current device.
NeighborIP string
}
RenderEndpoint is one homogeneous UNI in the template context.
type RenderedSource ¶
type RenderedSource struct {
Source string `json:"source"`
Kind string `json:"kind"` // cli | service
Platform string `json:"platform"`
PayloadKind string `json:"payload_kind"`
Commands []string `json:"commands"`
Error string `json:"error,omitempty"`
}
RenderedSource is one CLI object or service's rendered CLI (or other payload).
func RenderService ¶
func RenderService(db *gorm.DB, serviceID uint) ([]RenderedSource, error)
RenderService renders every saved endpoint of a service (preview, no device I/O).
func RenderServiceEndpoints ¶ added in v1.0.5
func RenderServiceEndpoints(db *gorm.DB, serviceID uint, eps []models.ServiceEndpoint, fields json.RawMessage) ([]RenderedSource, error)
RenderServiceEndpoints renders the given endpoints against a saved service (preview, no device I/O). Incomplete rows (no device or interface) are skipped. fields, when non-empty, overlays Service.Fields for the render.
type ResolvedVar ¶
type ResolvedVar struct {
Name string
Value any
Source *models.ConfigScope
FromDefault bool
Secret bool
Required bool
Type string
Err error
}
ResolvedVar is one variable's winning value and the scope it came from.
func RedactSecrets ¶
func RedactSecrets(vars []ResolvedVar) []ResolvedVar
func ResolveAll ¶
func ResolveAll(db *gorm.DB, interfaceID uint) ([]ResolvedVar, error)
ResolveAll returns every variable def resolved at interfaceID. Required vars with no value are included with Err set rather than failing the batch.
type ResourceCIDRStatus ¶ added in v1.1.0
ResourceCIDRStatus is one pool prefix and whether occupancy found it in use.
type ScopeTreeData ¶
type ScopeTreeData struct {
ID uint `json:"id"`
Kind string `json:"kind"`
ParentID *uint `json:"parent_id,omitempty"`
SiteID *uint `json:"site_id,omitempty"`
DeviceID *uint `json:"device_id,omitempty"`
InterfaceID *uint `json:"interface_id,omitempty"`
ServiceID *uint `json:"service_id,omitempty"`
ServiceTypeID *uint `json:"service_type_id,omitempty"`
Platform string `json:"platform,omitempty"`
PayloadKind string `json:"payload_kind,omitempty"`
Enabled bool `json:"enabled"`
SortOrder int `json:"sort_order"`
Payload models.ConfigScopePayload `json:"payload"`
CanonicalID uint `json:"canonical_id,omitempty"`
ServiceRowID uint `json:"service_row_id,omitempty"`
ServiceLabel string `json:"service_label,omitempty"`
Role string `json:"role,omitempty"`
Disc string `json:"disc,omitempty"`
Identity string `json:"identity,omitempty"`
}
type ScopeTreeNode ¶
type ScopeTreeNode struct {
Key string `json:"key"`
Title string `json:"title"`
Type string `json:"type"`
Data ScopeTreeData `json:"data"`
Children []ScopeTreeNode `json:"children,omitempty"`
}
ScopeTreeNode is one nested scope for GET /api/config/scopes/tree.
type StatusError ¶
StatusError is an application-level failure with an HTTP-ish status so handlers don't have to string-match error text.
func AsStatusError ¶
func AsStatusError(err error) *StatusError
func (*StatusError) Error ¶
func (e *StatusError) Error() string