objects

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

This file contains all objects that are common to all Netbox objects.

Index

Constants

View Source
const (
	DisplayWeightDefault = 100
	SearchWeightDefault  = 1000
)
View Source
const (
	AssignedObjectTypeVMInterface     = "virtualization.vminterface"
	AssignedObjectTypeDeviceInterface = "dcim.interface"
)
View Source
const (
	AdminContactRoleName = "Admin"
)

Default role name for admins of vms.

View Source
const (
	// Default vlan group for all objects, that are not party of any other vlan group.
	DefaultVlanGroupName = "Default netbox-ssot vlan group"
)
View Source
const (
	MaxDescriptionLength = 200
)

Variables

View Source
var (
	SiteStatusActive          = SiteStatus{Choice{Value: "active", Label: "Active"}}
	SiteStatusOffline         = SiteStatus{Choice{Value: "offline", Label: "Offline"}}
	SiteStatusPlanned         = SiteStatus{Choice{Value: "planned", Label: "Planned"}}
	SiteStatusStaged          = SiteStatus{Choice{Value: "staged", Label: "Staged"}}
	SiteStatusFailed          = SiteStatus{Choice{Value: "failed", Label: "Failed"}}
	SiteStatusInventory       = SiteStatus{Choice{Value: "inventory", Label: "Inventory"}}
	SiteStatusDecommissioning = SiteStatus{Choice{Value: "decommissioning", Label: "Decommissioning"}}
)
View Source
var (
	FrontToRear = DeviceAirFlowType{Choice{Value: "front-to-rear", Label: "Front to rear"}}
	RearToFront = DeviceAirFlowType{Choice{Value: "rear-to-front", Label: "Rear to front"}}
	LeftToRight = DeviceAirFlowType{Choice{Value: "left-to-right", Label: "Left to right"}}
	RightToLeft = DeviceAirFlowType{Choice{Value: "right-to-left", Label: "Right to left"}}
	SideToRear  = DeviceAirFlowType{Choice{Value: "side-to-rear", Label: "Side to rear"}}
	Passive     = DeviceAirFlowType{Choice{Value: "passive", Label: "Passive"}}
	Mixed       = DeviceAirFlowType{Choice{Value: "mixed", Label: "Mixed"}}
)
View Source
var (
	DeviceStatusOffline         = DeviceStatus{Choice{Value: "offline", Label: "Offline"}}
	DeviceStatusActive          = DeviceStatus{Choice{Value: "active", Label: "Active"}}
	DeviceStatusPlanned         = DeviceStatus{Choice{Value: "planned", Label: "Planned"}}
	DeviceStatusStaged          = DeviceStatus{Choice{Value: "staged", Label: "Staged"}}
	DeviceStatusFailed          = DeviceStatus{Choice{Value: "failed", Label: "Failed"}}
	DeviceStatusInventory       = DeviceStatus{Choice{Value: "inventory", Label: "Inventory"}}
	DeviceStatusDecommissioning = DeviceStatus{Choice{Value: "decommissioning", Label: "Decommissioning"}}
)
View Source
var (
	// Netbox's Virtual interface types.
	VirtualInterfaceType = InterfaceType{Choice{Value: "virtual", Label: "Virtual"}}
	BridgeInterfaceType  = InterfaceType{Choice{Value: "bridge", Label: "Bridge"}}
	LAGInterfaceType     = InterfaceType{Choice{Value: "lag", Label: "Link Aggregation Group (LAG)"}}

	// Netbox's Ethernet (Fixed) interface types.
	BASEFXInterfaceType       = InterfaceType{Choice{Value: "100base-fx", Label: "100BASE-FX (10/100ME FIBER)"}}
	BASELFXInterfaceType      = InterfaceType{Choice{Value: "100base-lfx", Label: "100BASE-LFX (10/100ME FIBER)"}}
	BASETXInterfaceType       = InterfaceType{Choice{Value: "100base-tx", Label: "100BASE-TX (10/100ME)"}}
	BASET1InterfaceType       = InterfaceType{Choice{Value: "100base-t1", Label: "100BASE-T1 (10/100ME Single Pair)"}}
	GE1FixedInterfaceType     = InterfaceType{Choice{Value: "1000base-t", Label: "1000BASE-T (1GE)"}}
	GE1GBICInterfaceType      = InterfaceType{Choice{Value: "1000base-x-gbic", Label: "GBIC (1GE)"}}
	GE1SFPInterfaceType       = InterfaceType{Choice{Value: "1000base-x-sfp", Label: "SFP (1GE)"}}
	GE2FixedInterfaceType     = InterfaceType{Choice{Value: "2.5gbase-t", Label: "2.5GBASE-T (2.5GE)"}}
	GE5FixedInterfaceType     = InterfaceType{Choice{Value: "5gbase-t", Label: "5GBASE-T (5GE)"}}
	GE10FixedInterfaceType    = InterfaceType{Choice{Value: "10gbase-t", Label: "10GBASE-T (10GE)"}}
	GE10CX4InterfaceType      = InterfaceType{Choice{Value: "10gbase-cx4", Label: "10GBASE-CX4 (10GE)"}}
	GE10SFPPInterfaceType     = InterfaceType{Choice{Value: "10gbase-x-sfpp", Label: "SFP+ (10GE)"}}
	GE10XFPInterfaceType      = InterfaceType{Choice{Value: "10gbase-x-xfp", Label: "XFP (10GE)"}}
	GE10XENPAKInterfaceType   = InterfaceType{Choice{Value: "10gbase-x-xenpak", Label: "XENPAK (10GE)"}}
	GE10X2InterfaceType       = InterfaceType{Choice{Value: "10gbase-x-x2", Label: "X2 (10GE)"}}
	GE25SFP28InterfaceType    = InterfaceType{Choice{Value: "25gbase-x-sfp28", Label: "SFP28 (25GE)"}}
	GE50SFP56InterfaceType    = InterfaceType{Choice{Value: "50gbase-x-sfp56", Label: "SFP56 (50GE)"}}
	GE40QSFPPlusInterfaceType = InterfaceType{Choice{Value: "40gbase-x-qsfpp", Label: "QSFP+ (40GE)"}}
	GE50QSFP28InterfaceType   = InterfaceType{Choice{Value: "50gbase-x-sfp28", Label: "QSFP28 (50GE)"}}
	GE100CFPInterfaceType     = InterfaceType{Choice{Value: "100gbase-x-cfp", Label: "CFP (100GE)"}}
	GE100CFP2InterfaceType    = InterfaceType{Choice{Value: "100gbase-x-cfp2", Label: "CFP2 (100GE)"}}
	GE100CFP4InterfaceType    = InterfaceType{Choice{Value: "100gbase-x-cfp4", Label: "CFP4 (100GE)"}}
	GE100CXPInterfaceType     = InterfaceType{Choice{Value: "100gbase-x-cxp", Label: "CXP (100GE)"}}
	GE100CPAKInterfaceType    = InterfaceType{Choice{Value: "100gbase-x-cpak", Label: "Cisco CPAK (100GE)"}}
	GE100DSFPInterfaceType    = InterfaceType{Choice{Value: "100gbase-x-dsfp", Label: "DSFP (100GE)"}}
	GE100SFPDDInterfaceType   = InterfaceType{Choice{Value: "100gbase-x-sfpdd", Label: "SFP-DD (100GE)"}}
	GE100QSFP28InterfaceType  = InterfaceType{Choice{Value: "100gbase-x-qsfp28", Label: "QSFP28 (100GE)"}}
	GE100QSFPDDInterfaceType  = InterfaceType{Choice{Value: "100gbase-x-qsfpdd", Label: "QSFP-DD (100GE)"}}
	GE200CFP2InterfaceType    = InterfaceType{Choice{Value: "200gbase-x-cfp2", Label: "CFP2 (200GE)"}}
	GE200QSFP56InterfaceType  = InterfaceType{Choice{Value: "200gbase-x-qsfp56", Label: "QSFP56 (200GE)"}}
	GE200QSFPDDInterfaceType  = InterfaceType{Choice{Value: "200gbase-x-qsfpdd", Label: "QSFP-DD (200GE)"}}
	GE400CFP2InterfaceType    = InterfaceType{Choice{Value: "400gbase-x-cfp2", Label: "CFP2 (400GE)"}}
	GE400QSFP112InterfaceType = InterfaceType{Choice{Value: "400gbase-x-qsfp112", Label: "QSFP112 (400GE)"}}
	GE400QSFPDDInterfaceType  = InterfaceType{Choice{Value: "400gbase-x-qsfpdd", Label: "QSFP-DD (400GE)"}}
	GE400OSFPInterfaceType    = InterfaceType{Choice{Value: "400gbase-x-osfp", Label: "OSFP (400GE)"}}
	GE400OSFPRHSInterfaceType = InterfaceType{Choice{Value: "400gbase-x-osfp-rhs", Label: "OSFP-RHS (400GE)"}}
	GE400CDFPInterfaceType    = InterfaceType{Choice{Value: "400gbase-x-cdfp", Label: "CDFP (400GE)"}}
	GE400CFP8InterfaceType    = InterfaceType{Choice{Value: "400gbase-x-cfp8", Label: "CPF8 (400GE)"}}
	GE800QSFPDDInterfaceType  = InterfaceType{Choice{Value: "800gbase-x-qsfpdd", Label: "QSFP-DD (800GE)"}}
	GE800OSFPInterfaceType    = InterfaceType{Choice{Value: "800gbase-x-osfp", Label: "OSFP (800GE)"}}

	// Netbox's Wireless interface types.
	IEEE80211AInterfaceType  = InterfaceType{Choice{Value: "ieee802.11a", Label: "IEEE 802.11a"}}
	IEEE80211GInterfaceType  = InterfaceType{Choice{Value: "ieee802.11g", Label: "IEEE 802.11b/g"}}
	IEEE80211NInterfaceType  = InterfaceType{Choice{Value: "ieee802.11n", Label: "IEEE 802.11n"}}
	IEEE80211ACInterfaceType = InterfaceType{Choice{Value: "ieee802.11ac", Label: "IEEE 802.11ac"}}
	IEEE80211ADInterfaceType = InterfaceType{Choice{Value: "ieee802.11ad", Label: "IEEE 802.11ad"}}
	IEEE80211AXInterfaceType = InterfaceType{Choice{Value: "ieee802.11ax", Label: "IEEE 802.11ax"}}

	// Netbox's PON interface types.
	GPONInterfaceType     = InterfaceType{Choice{Value: "gpon", Label: "GPON (2.5 Gbps / 1.25 Gps)"}}
	XGPONInterfaceType    = InterfaceType{Choice{Value: "xg-pon", Label: "XG-PON (10 Gbps / 2.5 Gbps)"}}
	XGSPONInterfaceType   = InterfaceType{Choice{Value: "xgs-pon", Label: "XGS-PON (10 Gbps)"}}
	NGPON2InterfaceType   = InterfaceType{Choice{Value: "ng-pon2", Label: "NG-PON2 (TWDM-PON) (4x10 Gbps)"}}
	EPONInterfaceType     = InterfaceType{Choice{Value: "epon", Label: "EPON (1 Gbps)"}}
	TenGEPONInterfaceType = InterfaceType{Choice{Value: "10g-epon", Label: "10G-EPON (10 Gbps)"}}

	// Netbox's Cellular interface types.
	GSMInterfaceType  = InterfaceType{Choice{Value: "gsm", Label: "GSM"}}
	CDMAInterfaceType = InterfaceType{Choice{Value: "cdma", Label: "CDMA"}}
	LTEInterfaceType  = InterfaceType{Choice{Value: "lte", Label: "LTE"}}

	// Netbox's Fiber channel interface types.
	GFC1SFPInterfaceType      = InterfaceType{Choice{Value: "1gfc-sfp", Label: "SFP (1GFC)"}}
	GFC2SFPInterfaceType      = InterfaceType{Choice{Value: "2gfc-sfp", Label: "SFP (2GFC)"}}
	GFC4SFPInterfaceType      = InterfaceType{Choice{Value: "4gfc-sfp", Label: "SFP (4GFC)"}}
	GFC8SFPPInterfaceType     = InterfaceType{Choice{Value: "8gfc-sfpp", Label: "SFP+ (8GFC)"}}
	GFC16SFPPInterfaceType    = InterfaceType{Choice{Value: "16gfc-sfpp", Label: "SFP+ (16GFC)"}}
	GFC32SFP28InterfaceType   = InterfaceType{Choice{Value: "32gfc-sfp28", Label: "SFP28 (32GFC)"}}
	GFC64QSFPPInterfaceType   = InterfaceType{Choice{Value: "64gfc-qsfpp", Label: "QSFP (64GFC)"}}
	GFC128QSFP28InterfaceType = InterfaceType{Choice{Value: "128gfc-qsfp28", Label: "QSFP28 (128GFC)"}}

	// Other type used for interfaces that do not suffice the above types.
	OtherInterfaceType = InterfaceType{Choice{Value: "other", Label: "Other"}}
)

Predefined types: https://github.com/netbox-community/netbox/blob/ec245b968f50bdbafaadd5d6b885832d858fa167/netbox/dcim/choices.py#L800

View Source
var (
	InterfaceModeAccess    = InterfaceMode{Choice{Value: "access", Label: "Access"}}
	InterfaceModeTagged    = InterfaceMode{Choice{Value: "tagged", Label: "Tagged"}}
	InterfaceModeTaggedAll = InterfaceMode{Choice{Value: "tagged-all", Label: "Tagged (All)"}}
)
View Source
var (
	DuplexHalf = InterfaceDuplex{Choice{Value: "half", Label: "Half"}}
	DuplexFull = InterfaceDuplex{Choice{Value: "full", Label: "Full"}}
	DuplexAuto = InterfaceDuplex{Choice{Value: "auto", Label: "Auto"}}
)

https://github.com/netbox-community/netbox/blob/1b9e6bed55d4ee53f60bcd6540bce953ddbf4167/netbox/dcim/choices.py#L1155

View Source
var (
	VDCStatusActive  = VDCStatus{Choice{Value: "active", Label: "Active"}}
	VDCStatusPlanned = VDCStatus{Choice{Value: "planned", Label: "Planned"}}
	VDCStatusOffline = VDCStatus{Choice{Value: "offline", Label: "Offline"}}
)
View Source
var (
	CustomFieldTypeText     = CustomFieldType{Choice{Value: "text", Label: "Text"}}
	CustomFieldTypeLongText = CustomFieldType{Choice{Value: "longtext", Label: "Text (long)"}}
	CustomFieldTypeInteger  = CustomFieldType{Choice{Value: "integer", Label: "Integer"}}
	CustomFieldTypeDecimal  = CustomFieldType{Choice{Value: "decimal", Label: "Decimal"}}
	CustomFieldTypeBoolean  = CustomFieldType{Choice{Value: "boolean", Label: "Boolean (true/false)"}}
	CustomFieldTypeDate     = CustomFieldType{Choice{Value: "date", Label: "Date"}}
)

Predefined netbox's types for CustomFields https://github.com/netbox-community/netbox/blob/35be4f05ef376e28d9af4d7245ba10cc286bb62a/netbox/extras/choices.py#L10

View Source
var (
	CustomFieldUIVisibleAlways = CustomFieldUIVisible{Choice{Value: "always", Label: "Always"}}
	CustomFieldUIVisibleIfSet  = CustomFieldUIVisible{Choice{Value: "if-set", Label: "If set"}}
	CustomFieldUIVisibleHidden = CustomFieldUIVisible{Choice{Value: "hidden", Label: "Hidden"}}
)
View Source
var (
	CustomFieldUIEditableYes    = CustomFieldUIEditable{Choice{Value: "yes", Label: "Yes"}}
	CustomFieldUIEditableNo     = CustomFieldUIEditable{Choice{Value: "no", Label: "No"}}
	CustomFieldUIEditableHidden = CustomFieldUIEditable{Choice{Value: "hidden", Label: "Hidden"}}
)
View Source
var (
	IPAddressStatusActive   = IPAddressStatus{Choice{Value: "active", Label: "Active"}}
	IPAddressStatusReserved = IPAddressStatus{Choice{Value: "reserved", Label: "Reserved"}}
	IPAddressStatusDHCP     = IPAddressStatus{Choice{Value: "dhcp", Label: "DHCP"}}
	IPAddressStatusSLAAC    = IPAddressStatus{Choice{Value: "slaac", Label: "SLAAC"}}
)
View Source
var (
	IPAddressRoleLoopback  = IPAddressRole{Choice{Value: "loopback", Label: "Loopback"}}
	IPAddressRoleSecondary = IPAddressRole{Choice{Value: "secondary", Label: "Secondary"}}
	IPAddressRoleAnycast   = IPAddressRole{Choice{Value: "anycast", Label: "Anycast"}}
	IPAddressRoleVIP       = IPAddressRole{Choice{Value: "vip", Label: "VIP"}}
	IPAddressRoleVRRP      = IPAddressRole{Choice{Value: "vrrp", Label: "VRRP"}}
	IPAddressRoleHSRP      = IPAddressRole{Choice{Value: "hsrp", Label: "HSRP"}}
	IPAddressRoleGLBP      = IPAddressRole{Choice{Value: "glbp", Label: "GLBP"}}
	IPAddressRoleCARP      = IPAddressRole{Choice{Value: "carp", Label: "CARP"}}
)
View Source
var (
	VlanStatusActive     = VlanStatus{Choice{Value: "active", Label: "Active"}}
	VlanStatusReserved   = VlanStatus{Choice{Value: "reserved", Label: "Reserved"}}
	VlanStatusDeprecated = VlanStatus{Choice{Value: "deprecated", Label: "Deprecated"}}
)
View Source
var (
	PrefixStatusContainer  = PrefixStatus{Choice{Value: "container", Label: "Container"}}
	PrefixStatusActive     = PrefixStatus{Choice{Value: "active", Label: "Active"}}
	PrefixStatusReserved   = PrefixStatus{Choice{Value: "reserved", Label: "Reserved"}}
	PrefixStatusDeprecated = PrefixStatus{Choice{Value: "deprecated", Label: "Deprecated"}}
)

https://github.com/netbox-community/netbox/blob/b408beaed52cb9fc5f7e197a7e00479af3714564/netbox/ipam/choices.py#L21

View Source
var (
	ContactAssignmentPriorityPrimary   = ContactAssignmentPriority{Choice{Value: "primary", Label: "Primary"}}
	ContactAssignmentPrioritySecondary = ContactAssignmentPriority{Choice{Value: "secondary", Label: "Secondary"}}
	ContactAssignmentPriorityTertiary  = ContactAssignmentPriority{Choice{Value: "tertiary", Label: "Tertiary"}}
	ContactAssignmentPriorityInactive  = ContactAssignmentPriority{Choice{Value: "inactive", Label: "Inactive"}}
)

https://github.com/netbox-community/netbox/blob/487f1ccfde26ef3c1f8a28089826acc0cd6fadb2/netbox/tenancy/choices.py#L10

View Source
var (
	ClusterStatusActive  = ClusterStatus{Choice{Value: "active", Label: "Active"}}
	ClusterStatusOffline = ClusterStatus{Choice{Value: "offline", Label: "Offline"}}
)
View Source
var (
	VMStatusActive  = VMStatus{Choice{Value: "active", Label: "Active"}}
	VMStatusOffline = VMStatus{Choice{Value: "offline", Label: "Offline"}}
)
View Source
var (
	VMInterfaceModeAccess    = VMInterfaceMode{Choice{Value: "access", Label: "Access"}}
	VMInterfaceModeTagged    = VMInterfaceMode{Choice{Value: "tagged", Label: "Tagged"}}
	VMInterfaceModeTaggedAll = VMInterfaceMode{Choice{Value: "tagged-all", Label: "Tagged All"}}
)
View Source
var (
	FilterLogicLoose = FilterLogic{Choice{Value: "loose", Label: "Loose"}}
)

Maps interface speed (Kbps) to interface type.

View Source
var ManufacturerMap = map[string]string{
	"^AMD$":               "AMD",
	".*Broadcom.*":        "Broadcom",
	".*Cisco.*":           "Cisco",
	".*Dell.*":            "Dell",
	"FTS Corp":            "Fujitsu",
	".*Fujitsu.*":         "Fujitsu",
	".*HiSilicon.*":       "HiSilicon",
	"^HP$":                "HPE",
	"^HPE$":               "HPE",
	".*Huawei.*":          "Huawei",
	".*Hynix.*":           "Hynix",
	".*Inspur.*":          "Inspur",
	".*Intel.*":           "Intel",
	"LEN":                 "Lenovo",
	".*Lenovo.*":          "Lenovo",
	".*Micron.*":          "Micron",
	".*Nvidea.*":          "Nvidia",
	".*Samsung.*":         "Samsung",
	".*Supermicro.*":      "Supermicro",
	".*Toshiba.*":         "Toshiba",
	"^WD$":                "Western Digital",
	".*Western Digital.*": "Western Digital",
}

Functions

This section is empty.

Types

type AssignedObjectType

type AssignedObjectType string

type Choice

type Choice struct {
	Value string `json:"value,omitempty"`
	Label string `json:"label,omitempty"`
}

Choice represents a choice in a Netbox's choice field. This struct is used as an embedded struct in other structs that represent Choice fields.

func (Choice) String

func (c Choice) String() string

type Cluster

type Cluster struct {
	NetboxObject
	// Name is the name of the cluster. This field is required.
	Name string `json:"name,omitempty"`
	// Type is the type of the cluster. This field is required.
	// e.g. oVirt,VMware...
	Type *ClusterType `json:"type,omitempty"`
	// ClusterGroup is the cluster group to which this cluster belongs.
	Group *ClusterGroup `json:"group,omitempty"`
	// Site is the site to which this cluster belongs.
	Site *Site `json:"site,omitempty"`
	// Status is the operational status of the cluster. This field is required.
	Status ClusterStatus `json:"status,omitempty"`
	// TenantGroup is the tenant group to which this cluster belongs.
	TenantGroup *TenantGroup `json:"tenant_group,omitempty"`
	// Tenant is the tenant to which this cluster belongs.
	Tenant *Tenant `json:"tenant,omitempty"`
}

func (Cluster) String

func (c Cluster) String() string

type ClusterGroup

type ClusterGroup struct {
	NetboxObject
	// Name is the name of the cluster group. This field is required.
	Name string `json:"name,omitempty"`
	// Slug is the slugified version of the cluster group name. This field is read-only.
	Slug string `json:"slug,omitempty"`
}

type ClusterStatus

type ClusterStatus struct {
	Choice
}

type ClusterType

type ClusterType struct {
	NetboxObject
	// Name is the name of the cluster type. This field is required.
	Name string `json:"name,omitempty"`
	// Slug is the slugified version of the cluster type name. This field is read-only.
	Slug string `json:"slug,omitempty"`
}

func (ClusterType) String

func (ct ClusterType) String() string

type Contact

type Contact struct {
	NetboxObject
	// Name is the name of the Contact. This field is required.
	Name string `json:"name,omitempty"`
	// Title is the title of the Contact.]
	Title string `json:"title,omitempty"`
	// Phone is the phone number of the contact.
	Phone string `json:"phone,omitempty"`
	// Email is the email of the contact.
	Email string `json:"email,omitempty"`
	// Address is the address of the contact.
	Address string `json:"address,omitempty"`
	// Link is the web link of the contact.
	Link string `json:"link,omitempty"`
	// Comments for the contact.
	Comments string `json:"comments,omitempty"`
}

func (Contact) String

func (c Contact) String() string

type ContactAssignment

type ContactAssignment struct {
	NetboxObject
	// Content type (e.g. virtualization.virtualmachine). This field is necessary
	ObjectType ObjectType `json:"object_type,omitempty"`
	// ID of the dependent object. This field is necessary
	ObjectID int `json:"object_id,omitempty"`
	// Contact for this assignment. This field is necessary
	Contact *Contact `json:"contact,omitempty"`
	// Role of the Contact assignment. This field is necessary
	Role *ContactRole `json:"role,omitempty"`
	// Priority of the Contact Assignment
	Priority *ContactAssignmentPriority `json:"priority,omitempty"`
}

func (ContactAssignment) String

func (ca ContactAssignment) String() string

type ContactAssignmentPriority

type ContactAssignmentPriority struct {
	Choice
}

type ContactGroup

type ContactGroup struct {
	NetboxObject
	// Name is the name of the ContactGroup. This field is required.
	Name string `json:"name,omitempty"`
	// Slug is the slug for the ContactGroup. This field is required.
	Slug string `json:"slug,omitempty"`
	// Parent contact group.
	Parent *ContactGroup `json:"parent,omitempty"`
}

type ContactRole

type ContactRole struct {
	NetboxObject
	// Name is the name of the role. This field is required.
	Name string `json:"name,omitempty"`
	// Slug is the slug of the role. This field is required.
	Slug string `json:"slug,omitempty"`
}

Contacts can be organized by functional roles. For example, we might create roles for administrative, emergency, operational contacts.

func (ContactRole) String

func (cr ContactRole) String() string

type CustomField

type CustomField struct {
	ID int `json:"id,omitempty"`
	// Name of the custom field (e.g. host_cpu_cores). This field is required.
	Name string `json:"name,omitempty"`
	// Label represents name of the field as displayed to users (e.g. Physical CPU cores). If not provided, the name will be used instead.
	Label string `json:"label,omitempty"`
	// Type is the type of the custom field. Valid choices are: text, integer, boolean, date, url, select, multiselect. This field is required.
	Type CustomFieldType `json:"type,omitempty"`
	// Type of the related object (for object/multi-object fields only) (e.g. objects.device). This field is required.
	ObjectTypes []ObjectType `json:"object_types,omitempty"`
	// Description is a description of the field. This field is optional.
	Description string `json:"description,omitempty"`
	// Weighting for search. Lower values are considered more important. Default (1000).
	SearchWeight int `json:"search_weight,omitempty"`
	// Filter logic. This field is required. (Default loose).
	FilterLogic FilterLogic `json:"filter_logic,omitempty"`
	// UI visible. This field is required. (Default read-write).
	CustomFieldUIVisible *CustomFieldUIVisible `json:"ui_visible,omitempty"`
	// UI editable. This field is required. (Default read-write).
	CustomFieldUIEditable *CustomFieldUIEditable `json:"ui_editable,omitempty"`
	// Display Weight. Fields with higher weights appear lower in a form (default is 100).
	DisplayWeight int `json:"weight,omitempty"`
	// Default value for the field (must be a JSON value). Encapsulate strings with double quotes (e.g. "Foo").
	Default interface{} `json:"default"`
	// If this field is required or not.
	Required bool `json:"required"`
}

func (CustomField) String

func (cf CustomField) String() string

type CustomFieldType

type CustomFieldType struct {
	Choice
}

CustomFieldTypes are predefined netbox's types for CustomFields.

type CustomFieldUIEditable

type CustomFieldUIEditable struct {
	Choice
}

type CustomFieldUIVisible

type CustomFieldUIVisible struct {
	Choice
}

type Device

type Device struct {
	NetboxObject

	// Device
	// Name is the name of the device.
	Name string `json:"name,omitempty"`
	// DeviceRole is the functional role of the device. This field is required.
	DeviceRole *DeviceRole `json:"role,omitempty"`

	// Hardware
	// DeviceType is the type of device. This field is required.
	DeviceType *DeviceType `json:"device_type,omitempty"`
	// Airflow is the airflow pattern of the device.
	Airflow *DeviceAirFlowType `json:"airflow,omitempty"`
	// Status is the status of the device.
	SerialNumber string `json:"serial,omitempty"`
	// AssetTag is an unique tag for identifying the device.
	AssetTag string `json:"asset_tag,omitempty"`

	// Location
	// Site is the site to which the device belongs. This field is required.
	Site *Site `json:"site,omitempty"`
	// Location is the location of the device.
	Location *Location `json:"location,omitempty"`

	// Management
	// Status of the device (e.g. active, offline, planned, etc.). This field is required.
	Status *DeviceStatus `json:"status,omitempty"`
	// Platform of the device (e.g. Cisco IOS, Dell OS9, etc.).
	Platform *Platform `json:"platform,omitempty"`

	// PrimaryIPv4 is the primary IPv4 address assigned to the server.
	PrimaryIPv4 *IPAddress `json:"primary_ip4,omitempty"`
	// PrimaryIPv6 is the primary IPv6 address assigned to the server.
	PrimaryIPv6 *IPAddress `json:"primary_ip6,omitempty"`

	// Virtualization
	// Cluster is the cluster to which the device belongs. (e.g. VMWare server belonging to a specific cluster).
	Cluster *Cluster `json:"cluster,omitempty"`

	// Tenancy
	// Tenant group
	Tenant *Tenant `json:"tenant,omitempty"`

	// The priority of the device in the virtual chassis
	// Priority
	// Additional comments.
	Comments string `json:"comments,omitempty"`
}

Device can be any piece of physical hardware, such as a server, router, or switch.

func (Device) String

func (d Device) String() string

type DeviceRole

type DeviceRole struct {
	NetboxObject
	// Name is the name of the device role. This field is required.
	Name string `json:"name,omitempty"`
	// URL-friendly unique shorthand. This field is required.
	Slug string `json:"slug,omitempty"`
	// Color of the device role. This field is required.
	Color constants.Color `json:"color,omitempty"`
	// VMRole is whether this device role is used to represent virtual machines.
	VMRole bool `json:"vm_role,omitempty"`
}

DeviceRole represents the functional role of a device. For example, a device may play the role of a router, a switch, a firewall, etc.

func (DeviceRole) String

func (dr DeviceRole) String() string

type DeviceStatus

type DeviceStatus struct {
	Choice
}

type DeviceType

type DeviceType struct {
	NetboxObject
	// Manufacturer is the manufacturer of the device type. This field is required.
	Manufacturer *Manufacturer `json:"manufacturer,omitempty"`
	// Model is the model of the device type. This field is required.
	Model string `json:"model,omitempty"`
	// Slug is a URL-friendly unique shorthand. This field is required.
	Slug string `json:"slug,omitempty"`
}

DeviceType represents the physical and operational characteristics of a device. For example, a device type may represent a Cisco C2960 switch running IOS 15.2.

func (DeviceType) String

func (dt DeviceType) String() string

type FilterLogic

type FilterLogic struct {
	Choice
}

type IPAddress

type IPAddress struct {
	NetboxObject
	// IPv4 or IPv6 address (with mask). This field is required.
	Address string `json:"address,omitempty"`
	// The status of this IP address.
	Status *IPAddressStatus `json:"status,omitempty"`
	// Role of the IP address.
	Role *IPAddressRole `json:"role,omitempty"`
	// Hostname or FQDN (not case-sensitive)
	DNSName string `json:"dns_name,omitempty"`
	// Tenancy
	Tenant *Tenant `json:"tenant,omitempty"`

	// AssignedObjectType is either a DeviceInterface or a VMInterface.
	AssignedObjectType AssignedObjectType `json:"assigned_object_type,omitempty"`
	// ID of the assigned object (either an ID of DeviceInterface or an ID of VMInterface).
	AssignedObjectID int `json:"assigned_object_id,omitempty"`
}

func (IPAddress) String

func (ip IPAddress) String() string

type IPAddressRole

type IPAddressRole struct {
	Choice
}

type IPAddressStatus

type IPAddressStatus struct {
	Choice
}

type IPRange

type IPRange struct {
	NetboxObject
}

type Interface

type Interface struct {
	NetboxObject
	// Device is the device to which the interface belongs. This field is required.
	Device *Device `json:"device,omitempty"`
	// Name is the name of the interface. This field is required.
	Name string `json:"name,omitempty"`
	// Status whether the interface is enabled or not.
	Status bool `json:"enabled,omitempty"`
	// Type is the type of interface. This field is required. Can only be one of the predetermined values.
	Type *InterfaceType `json:"type,omitempty"`
	// Interface speed in kbps
	Speed InterfaceSpeed `json:"speed,omitempty"`
	// Related Interfaces
	// Parent is the parent interface, if any.
	ParentInterface *Interface `json:"parent,omitempty"`
	// BridgedInterface is the bridged interface, if any.
	BridgedInterface *Interface `json:"bridge,omitempty"`
	// LAG is the LAG to which the interface belongs, if any.
	LAG *Interface `json:"lag,omitempty"`
	// MTU is the maximum transmission unit (MTU) configured for the interface.
	MTU int `json:"mtu,omitempty"`
	// MAC is the mac address of the interface
	MAC string `json:"mac_address,omitempty"`

	// Duplex is the duplex mode of the interface
	Duplex *InterfaceDuplex `json:"duplex,omitempty"`

	// 802.1Q Mode
	Mode *InterfaceMode `json:"mode,omitempty"`
	// TaggedVlans is a list of all the VLANs to which the interface is tagged.
	TaggedVlans []*Vlan `json:"tagged_vlans,omitempty"`
	// UntaggedVlan
	UntaggedVlan *Vlan `json:"untagged_vlan,omitempty"`
	// VirtualDeviceContexts
	Vdcs []*VirtualDeviceContext `json:"vdcs,omitempty"`
}

Interface represents a physical data interface within a device.

func (Interface) String

func (i Interface) String() string

type InterfaceDuplex

type InterfaceDuplex struct {
	Choice
}

type InterfaceMode

type InterfaceMode struct {
	Choice
}

type InterfaceSpeed

type InterfaceSpeed int64

Interface speed in kbps.

const (
	MBPS10      InterfaceSpeed = 10000
	MBPS100     InterfaceSpeed = 100000
	GBPS1       InterfaceSpeed = 1000000
	GBPS2       InterfaceSpeed = 2000000
	GBPS2Point5 InterfaceSpeed = 2500000
	GBPS4       InterfaceSpeed = 4000000
	GBPS5       InterfaceSpeed = 5000000
	GBPS8       InterfaceSpeed = 8000000
	GBPS10      InterfaceSpeed = 10000000
	GBPS16      InterfaceSpeed = 16000000
	GBPS25      InterfaceSpeed = 25000000
	GBPS32      InterfaceSpeed = 32000000
	GBPS40      InterfaceSpeed = 40000000
	GBPS50      InterfaceSpeed = 50000000
	GBPS64      InterfaceSpeed = 64000000
	GBPS100     InterfaceSpeed = 100000000
	GBPS128     InterfaceSpeed = 128000000
	GBPS200     InterfaceSpeed = 200000000
	GBPS400     InterfaceSpeed = 400000000
	GBPS800     InterfaceSpeed = 800000000
)

Available interface speeds: https://github.com/netbox-community/netbox/blob/ec245b968f50bdbafaadd5d6b885832d858fa167/netbox/dcim/choices.py#L1139

type InterfaceType

type InterfaceType struct {
	Choice
}

type Location

type Location struct {
	NetboxObject
	// Site is the site to which the location belongs. This field is required.
	Site *Site
	// Name is the name of the location. This field is required.
	Name string
	// URL-friendly unique shorthand. This field is required.
	Slug string
	// Status is the status of the location. This field is required.
	Status *SiteStatus
}

Location represents a physical location, such as a floor or room in a building.

type Manufacturer

type Manufacturer struct {
	NetboxObject
	// Name of the manufacturer (e.g. Cisco). This field is required.
	Name string `json:"name,omitempty"`
	// URL-friendly unique shorthand. This field is required.
	Slug string `json:"slug,omitempty"`
}

Manufacturer represents a hardware manufacturer (e.g. Cisco, HP, ...).

func (Manufacturer) String

func (m Manufacturer) String() string

type NetboxObject

type NetboxObject struct {
	// Netbox's ID of the object.
	ID int `json:"id,omitempty"`
	// List of tags assigned to this object.
	Tags []*Tag `json:"tags,omitempty"`
	// Description represents custom description of the object.
	Description string `json:"description,omitempty"`
	// Array of custom fields, in format customFieldLabel: customFieldValue
	CustomFields map[string]interface{} `json:"custom_fields,omitempty"`
}

Struct representing attributes that are common to all objects in Netbox. We can this struct as an embedded struct in other structs that represent Netbox objects.

func (NetboxObject) String

func (n NetboxObject) String() string

type ObjectType added in v1.0.0

type ObjectType string
const (
	ObjectTypeDcimDevice                   ObjectType = "dcim.device"
	ObjectTypeDcimDeviceRole               ObjectType = "dcim.devicerole"
	ObjectTypeDcimDeviceType               ObjectType = "dcim.devicetype"
	ObjectTypeDcimInterface                ObjectType = "dcim.interface"
	ObjectTypeDcimLocation                 ObjectType = "dcim.location"
	ObjectTypeDcimManufacturer             ObjectType = "dcim.manufacturer"
	ObjectTypeDcimPlatform                 ObjectType = "dcim.platform"
	ObjectTypeDcimRegion                   ObjectType = "dcim.region"
	ObjectTypeDcimSite                     ObjectType = "dcim.site"
	ObjectTypeVirtualDeviceContext         ObjectType = "dcim.virtualdevicecontext"
	ObjectTypeIpamIPAddress                ObjectType = "ipam.ipaddress"
	ObjectTypeIpamVlanGroup                ObjectType = "ipam.vlangroup"
	ObjectTypeIpamVlan                     ObjectType = "ipam.vlan"
	ObjectTypeIpamPrefix                   ObjectType = "ipam.prefix"
	ObjectTypeTenancyTenantGroup           ObjectType = "tenancy.tenantgroup"
	ObjectTypeTenancyTenant                ObjectType = "tenancy.tenant"
	ObjectTypeTenancyContact               ObjectType = "tenancy.contact"
	ObjectTypeTenancyContactAssignment     ObjectType = "tenancy.contactassignment"
	ObjectTypeTenancyContactGroup          ObjectType = "tenancy.contactgroup"
	ObjectTypeTenancyContactRole           ObjectType = "tenancy.contactrole"
	ObjectTypeVirtualizationCluster        ObjectType = "virtualization.cluster"
	ObjectTypeVirtualizationClusterGroup   ObjectType = "virtualization.clustergroup"
	ObjectTypeVirtualizationClusterType    ObjectType = "virtualization.clustertype"
	ObjectTypeVirtualizationVirtualMachine ObjectType = "virtualization.virtualmachine"
	ObjectTypeVirtualizationVMInterface    ObjectType = "virtualization.vminterface"
)

All content types from netbox.

type Platform

type Platform struct {
	NetboxObject
	// Name of the platform. This field is required.
	Name string `json:"name,omitempty"`
	// URL-friendly unique shorthand. This field is required.
	Slug string `json:"slug,omitempty"`
	// Manufacturer is the manufacturer of the platform.
	Manufacturer *Manufacturer `json:"manufacturer,omitempty"`
}

Platform represents an operating system or other software platform which may be running on a device.

func (Platform) String

func (p Platform) String() string

type Prefix

type Prefix struct {
	NetboxObject
	// Prefix is a IPv4 or IPv6 network address (with mask). This field is required.
	Prefix string `json:"prefix,omitempty"`
	// Status of the prefix (default "active").
	Status *PrefixStatus `json:"status,omitempty"`

	// Site that this prefix belongs to.
	Site *Site `json:"site,omitempty"`
	// Vlan that this prefix belongs to.
	Vlan *Vlan `json:"vlan,omitempty"`

	// Tenant that this prefix belongs to.
	Tenant *Tenant `json:"tenant,omitempty"`

	Comments string `json:"comments,omitempty"`
}

func (Prefix) String

func (p Prefix) String() string

type PrefixStatus

type PrefixStatus struct {
	Choice
}

type Region

type Region struct {
	NetboxObject
	// Name is the name of the region. This field is required.
	Name string `json:"name,omitempty"`
	// Slug is a URL-friendly unique shorthand. This field is required.
	Slug string `json:"slug,omitempty"`
}

type Site

type Site struct {
	NetboxObject
	// Full name for the site. This field is required.
	Name string `json:"name,omitempty"`
	// URL-friendly unique shorthand. This field is required.
	Slug string `json:"slug,omitempty"`
	// Site status. This field is required.
	Status *SiteStatus `json:"status,omitempty"`
	// Tenant of the site
	Tenant *Tenant `json:"tenant,omitempty"`

	// Physical location of the building
	PhysicalAddress string `json:"physical_address,omitempty"`

	// Latitude of the site.
	Latitude float64 `json:"latitude,omitempty"`
	// Longitude of the site.
	Longitude float64 `json:"longitude,omitempty"`
}

Site ares used for functional groupings. A site usually represents a building within a region.

func (Site) String

func (s Site) String() string

type SiteStatus

type SiteStatus struct {
	Choice
}

type Tag

type Tag struct {
	ID          int             `json:"id,omitempty"`
	Name        string          `json:"name,omitempty"`
	Slug        string          `json:"slug,omitempty"`
	Color       constants.Color `json:"color,omitempty"`
	Description string          `json:"description,omitempty"`
}

func (Tag) String

func (t Tag) String() string

type Tenant

type Tenant struct {
	NetboxObject
	// Name is the name of the tenant. This field is required.
	Name string `json:"name,omitempty"`
	// Slug is the URL-friendly version of the tenant name. This field is read-only.
	Slug string `json:"slug,omitempty"`
	// Group is the tenant group to which this tenant belongs.
	Group *TenantGroup `json:"group,omitempty"`
}

func (Tenant) String added in v0.3.0

func (t Tenant) String() string

type TenantGroup

type TenantGroup struct {
	NetboxObject
	// Name is the name of the tenant group. This field is required.
	Name string `json:"name,omitempty"`
	// Slug is the URL-friendly version of the tenant group name. This field is read-only.
	Slug string `json:"slug,omitempty"`
}

type VDCStatus added in v0.4.0

type VDCStatus struct {
	Choice
}

Virtual Device Context status.

type VM

type VM struct {
	NetboxObject
	// Name is the name of the virtual machine. This field is required.
	Name string `json:"name,omitempty"`
	// Status is the status of the virtual machine. This field is required.
	Status *VMStatus `json:"status,omitempty"`
	// Site is the site to which this virtual machine belongs.
	Site *Site `json:"site,omitempty"`
	// Cluster is the cluster to which this virtual machine belongs.
	Cluster *Cluster `json:"cluster,omitempty"`
	// Host is a specific host that this virtual machine is hosted on.
	Host *Device `json:"device,omitempty"`

	// TenantGroup is the datacenter that this virtual machine belongs to.
	TenantGroup *TenantGroup `json:"tenant_group,omitempty"`
	// Tenant is the tenant to which this virtual machine belongs.
	Tenant *Tenant `json:"tenant,omitempty"`

	// Platform is the platform of the virtual machine.
	Platform *Platform `json:"platform,omitempty"`
	// PrimaryIPv4 is the primary IPv4 address assigned to the virtual machine.
	PrimaryIPv4 *IPAddress `json:"primary_ip4,omitempty"`
	// PrimaryIPv6 is the primary IPv6 address assigned to the virtual machine.
	PrimaryIPv6 *IPAddress `json:"primary_ip6,omitempty"`

	// VCPUs is the number of virtual CPUs allocated to the virtual machine.
	VCPUs float32 `json:"vcpus,omitempty"`
	// Memory is the amount of memory allocated to the virtual machine in MB.
	Memory int `json:"memory,omitempty"`
	// Disk is the amount of disk space allocated to the virtual machine in GB.
	Disk int `json:"disk,omitempty"`
	// Role of the virtual machine.
	Role *DeviceRole `json:"role,omitempty"`

	// Additional Comments
	Comments string `json:"comments,omitempty"`
}

VM represents a netbox's virtual machine.

func (VM) String

func (vm VM) String() string

type VMInterface

type VMInterface struct {
	NetboxObject
	// VM that this interface belongs to. This field is required.
	VM *VM `json:"virtual_machine,omitempty"`
	// Name is the name of the interface. This field is required.
	Name string `json:"name,omitempty"`
	// MAC address of the interface.
	MACAddress string `json:"mac_address,omitempty"`
	// MTU of the interface.
	MTU int `json:"mtu,omitempty"`
	// Enabled is true if interface is enabled, false otherwise.
	Enabled bool `json:"enabled,omitempty"`
	// Related parent interface of this interface.
	ParentInterface *VMInterface `json:"parent,omitempty"`
	// Related bridged interface
	BridgedInterface *VMInterface `json:"bridge,omitempty"`
	// 802.1Q VLAN Tagging Mode
	Mode *VMInterfaceMode `json:"mode,omitempty"`
	// When Mode=VMInterfaceModeTagged: TaggedVlans is a list of all the VLANs that are tagged on the interface.
	TaggedVlans []*Vlan `json:"tagged_vlans,omitempty"`
	// When mode=VMInterfaceModeAccess: UntaggedVlan is the VLAN that is untagged on the interface.
	UntaggedVlan *Vlan `json:"untagged_vlan,omitempty"`
}

func (VMInterface) String

func (vmi VMInterface) String() string

type VMInterfaceMode

type VMInterfaceMode struct {
	Choice
}

802.1Q VLAN Tagging Mode (Access, Tagged, Tagged All).

type VMStatus

type VMStatus struct {
	Choice
}

type VirtualDeviceContext added in v0.4.0

type VirtualDeviceContext struct {
	NetboxObject
	// Name of the VirtualDeviceContext. This field is required.
	Name string `json:"name,omitempty"`
	// Device that VirtualDeviceContext belongs to. This field is required.
	Device *Device `json:"device,omitempty"`
	// Status of the VirtualDeviceContext. This field is required.
	Status *VDCStatus `json:"status,omitempty"`
	// Unique identifier for VirtualDeviceContext within Single Device.
	Identifier int `json:"identifier,omitempty"`
	// Tenant for this VirtualDeviceContext.
	Tenant *Tenant `json:"tenant,omitempty"`
	// Primary IPv4 for VirtualDeviceContext.
	PrimaryIPv4 *IPAddress `json:"primary_ipv4,omitempty"`
	// Primary IPv6 for VirtualDeviceContext.
	PrimaryIPv6 *IPAddress `json:"primary_ipv6,omitempty"`
}

VirtualDeviceContext represents extra virtual context within a device.

func (VirtualDeviceContext) String added in v0.4.0

func (vdc VirtualDeviceContext) String() string

type Vlan

type Vlan struct {
	NetboxObject
	// Name of the VLAN. This field is required.
	Name string `json:"name,omitempty"`
	// VID of the VLAN. This field is required.
	Vid int `json:"vid,omitempty"`
	// VlanGroup that this vlan belongs to.
	Group *VlanGroup `json:"group,omitempty"`
	// Status of the VLAN. This field is required. Default is "active".
	Status *VlanStatus `json:"status,omitempty"`
	// Tenant that this VLAN belongs to.
	Tenant *Tenant `json:"tenant,omitempty"`
	// Site that this VLAN belongs to.
	Site *Site `json:"site,omitempty"`
	// Comments about this Vlan.
	Comments string `json:"comments,omitempty"`
}

func (Vlan) String

func (v Vlan) String() string

type VlanGroup

type VlanGroup struct {
	NetboxObject
	// Name of the VlanGroup. This field is required.
	Name string `json:"name,omitempty"`
	// Slug of the VlanGroup. This field is required.
	Slug string `json:"slug,omitempty"`
	// MinVid is the minimal VID that can be assigned in this group. This field is required (default 1).
	MinVid int `json:"min_vid,omitempty"`
	// MaxVid is the maximal VID that can be assigned in this group. This field is required (default 4094).
	MaxVid int `json:"max_vid,omitempty"`
}

func (VlanGroup) String

func (vg VlanGroup) String() string

type VlanStatus

type VlanStatus struct {
	Choice
}

Jump to

Keyboard shortcuts

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