NbValue

class nbforager.NbValue(data: Dict[str, Any], strict: bool = False, **kwargs)

Dictionary parser for extracting values from a Netbox object using a chain of keys.

Netbox object may have None instead of a dictionary when a related object is absent, requiring constant data type checks. NbParser ensures the desired value is returned with the correct data type, even if the data is missing.

Raises NbParserError if strict=True and some keys are missing.

Initialize NbParser.

Parameters:
  • data (dict) – Netbox object.

  • strict (bool) – True - if data is invalid raise NbParserError, False - if data is invalid return empty data with proper type.

  • version (str) – Netbox version. Designed for compatibility with different versions.

a_terminations() list

dcim/cables.a_terminations.

a_terminations_object_cable() List[int]

dcim/cables.a_terminations.0.object.cable.

a_terminations_object_circuit_cid() List[str]

dcim/cables.a_terminations.0.object.circuit.cid.

a_terminations_object_circuit_id() List[int]

dcim/cables.a_terminations.0.object.circuit.id.

a_terminations_object_id() List[int]

dcim/cables.a_terminations.0.object.id.

a_terminations_object_term_side() List[str]

dcim/cables.a_terminations.0.object.term_side.

a_terminations_object_type() List[str]

dcim/cables/a_terminations/0/object_type.

address() str

ipam/ip-addresses.address.

asn() int

ipam/asns.asn.

assigned_device_name() str

ipam/ip-addresses.assigned_object.device.name.

b_terminations() list

dcim/cables.b_terminations.

b_terminations_object_cable() List[int]

dcim/cables.b_terminations.0.object.cable.

b_terminations_object_circuit_cid() List[str]

dcim/cables.b_terminations.0.object.circuit.cid.

b_terminations_object_circuit_id() List[int]

dcim/cables.b_terminations.0.object.circuit.id.

b_terminations_object_id() List[int]

dcim/cables.b_terminations.0.object.id.

b_terminations_object_term_side() List[str]

dcim/cables.b_terminations.0.object.term_side.

b_terminations_object_type() List[str]

dcim/cables/b_terminations/0/object_type.

cable_display() str

circuits/circuit-terminations.cable.display.

cable_end() str

circuits/circuit-terminations.cable_end.

cable_id() int

circuits/circuit-terminations.cable.id.

cable_label() str

circuits/circuit-terminations.cable.label.

cid() str

ipam/circuits.circuits.cid.

circuit_cid() str

circuits/circuit-terminations.circuit.cid.

circuit_count() int

ipam/circuits.circuit-types.circuit_count.

circuit_id() int

circuits/circuit-terminations.circuit.id.

cluster_id() int

virtualization/virtual-machines.cluster.id.

cluster_name() str

virtualization/virtual-machines.cluster.name.

color() str

circuits/circuit-types.color.

comments() str

dcim/devices.comments.

connected_endpoints() list

dcim/interfaces.connected_endpoints.

connected_endpoints_id() List[int]

dcim/interfaces/connected_endpoints/0/id.

connected_endpoints_name() List[str]

dcim/interfaces/connected_endpoints/0/name.

connected_endpoints_reachable() bool

dcim/interfaces.connected_endpoints_reachable.

connected_endpoints_type() str

dcim/interfaces.connected_endpoints_type.

created() str

dcim/devices.created.

custom_fields() dict

circuits/circuit-terminations.custom_fields.

description() str

dcim/devices.description.

device_id() int

dcim/console-ports.device.id.

device_name() str

dcim/console-ports.device.name.

device_role_id() int

dcim/devices.device_role.id.

Provide compatibility for Netbox >= v4.2 and Netbox < v4.2.

Returns:

Role ID.

Raises:
  • NbParserError – if strict=True and object has no value.

  • NbVersionError – If the key is deprecated for specific app/model.

device_role_name() str

dcim/devices.device_role.name.

Provide compatibility for Netbox >= v4.2 and Netbox < v4.2.

Returns:

Role name.

Raises:
  • NbParserError – if strict=True and object has no value.

  • NbVersionError – If the key is deprecated for specific app/model.

device_role_slug() str

dcim/devices.device_role.slug.

Provide compatibility for Netbox >= v4.2 and Netbox < v4.2.

Returns:

Role slug.

Raises:
  • NbParserError – if strict=True and object has no value.

  • NbVersionError – If the key is deprecated for specific app/model.

device_type_id() int

dcim/devices.device_type.id.

device_type_manufacturer_id() int

dcim/devices.device_type.manufacturer.id.

device_type_manufacturer_name() str

dcim/devices.device_type.manufacturer.name.

device_type_manufacturer_slug() str

dcim/devices.device_type.manufacturer.slug.

device_type_model() str

dcim/devices.device_type.model.

device_type_slug() str

dcim/devices.device_type.slug.

display() str

ipam/aggregates.display.

dns_name() str

ipam/ip-addresses.dns_name.

enabled() bool

dcim/interfaces.enabled.

export_targets() list

ipam/vrfs.export_targets.

export_targets_id() List[int]

ipam/vrfs/export_targets/0/id.

export_targets_name() List[str]

ipam/vrfs/export_targets/0/name.

face_value() str

dcim/devices.face.value.

family_value() int

ipam/prefixes.family.value.

group_name() str

ipam/vlans.group.name.

id_() int

ipam/prefixes.id.

import_targets() list

ipam/vrfs.import_targets.

import_targets_id() List[int]

ipam/vrfs/import_targets/0/id.

import_targets_name() List[str]

ipam/vrfs/import_targets/0/name.

is_dcim(key: str) bool

Check if model is dcim.

Returns:

True - if model is dcim, False - otherwise.

Raises:

NbParserError

  • if url is not /api/dcim/ and self.strict=True.

is_ipam(key: str) bool

Check If model is ipam.

Returns:

True - if model is ipam, False - otherwise.

Raises:

NbParserError – If url is not aggregate or prefix or address and self.strict=True.

is_pool() bool

ipam/prefixes.is_pool.

is_private() bool

ipam/rirs.is_private.

is_virtualization(key: str) bool

Check if model is virtualization.

Returns:

True - if model is virtualization, False - otherwise.

Raises:

NbParserError

  • if url is not /api/dcim/ and self.strict=True.

is_vrf() bool

Return True if data has vrf.

label() str

dcim/cables.label.

last_updated() str

dcim/devices.last_updated.

circuits/circuit-terminations.link_peers.

circuits/circuit-terminations/link_peers/0/cable.

circuits/circuit-terminations/link_peers/0/id.

circuits/circuit-terminations/link_peers/0/name.

circuits/circuit-terminations.link_peers_type.

manufacturer_id() int

dcim/device-types.manufacturer.id.

manufacturer_name() str

dcim/device-types.manufacturer.name.

manufacturer_slug() str

dcim/device-types.manufacturer.name.

mark_connected() bool

dcim/interfaces.mark_connected.

mark_utilized() bool

ipam/prefixes.mark_utilized.

model() str

dcim/device-types.model.

name() str

dcim/devices/name, dcim/vlans/name.

occupied() bool

dcim/devices._occupied.

part_number() str

dcim/device-types.part_number.

platform_id() int

dcim/devices.platform.id.

platform_name() str

dcim/devices.platform.name.

platform_slug() str

dcim/devices.platform.slug.

prefix() str

ipam/prefixes/prefix, ipam/aggregates/prefix.

Returns:

Prefix with length A.B.C.D/LEN.

Raises:

NbParserError – if strict=True and the prefix does not match the naming convention A.B.C.D/LEN.

primary_ip4_address() str

dcim/devices/primary_ip4/address.

Provide compatibility for Netbox >= v4.2 and Netbox < v4.2.

Returns:

primary_ip4 address.

Raises:
  • NbParserError – if strict=True and object has no value.

  • NbVersionError – If the key is deprecated for specific app/model.

primary_ip4_family() int

dcim/devices/primary_ip4/family.

Provide compatibility for Netbox >= v4.2 and Netbox < v4.2.

Returns:

primary_ip4 family.

Raises:
  • NbParserError – if strict=True and object has no value.

  • NbVersionError – If the key is deprecated for specific app/model.

primary_ip_address() str

dcim/devices.primary_ip.address.

Provide compatibility for Netbox >= v4.2 and Netbox < v4.2.

Returns:

primary_ip address.

Raises:
  • NbParserError – if strict=True and object has no value.

  • NbVersionError – If the key is deprecated for specific app/model.

primary_ip_family() int

dcim/devices.primary_ip.family.

Provide compatibility for Netbox >= v4.2 and Netbox < v4.2.

Returns:

primary_ip family.

Raises:
  • NbParserError – if strict=True and object has no value.

  • NbVersionError – If the key is deprecated for specific app/model.

provider_id() int

circuits/circuits.provider.id.

provider_name() str

circuits/circuits.provider.name.

provider_slug() str

circuits/circuits.provider.slug.

rack_id() int

dcim/devices.rack.id.

rack_name() str

dcim/devices.rack.name.

rd() str

ipam/vrfs.rd.

rir_id() int

ipam/aggregates.rir.id.

rir_name() str

ipam/aggregates.rir.name.

rir_slug() str

ipam/aggregates.rir.slug.

role_id() int

dcim/devices.role.id.

role_name() str

dcim/devices.role.name.

role_slug() str

dcim/devices.role.slug.

scope_id() int

ipam/vlan-groups.scope.id.

scope_name() str

ipam/vlan-groups.scope.name.

scope_slug() str

ipam/vlan-groups.scope.slug.

scope_type() str

ipam/vlan-groups.scope_type.

serial() str

dcim/devices.serial.

site_id() int

ipam/prefixes/site/id, dcim/devices/sites/id.

Provide compatibility for Netbox >= v4.2 and Netbox < v4.2.

Returns:

Site ID.

Raises:
  • NbParserError – if strict=True and object has no value.

  • NbVersionError – If the key is deprecated for specific app/model.

site_name() str

ipam/prefixes/site/name, dcim/devices/sites/name.

Provide compatibility for Netbox >= v4.2 and Netbox < v4.2.

Note: Different models may have different upper or lower case:
  • sites/name=”SITE1”,

  • devices/site/name=”SITE1”,

  • vlans/site/name=”site1”.

Returns:

Site name.

Raises:
  • NbParserError – if strict=True and object has no value.

  • NbVersionError – If the key is deprecated for specific app/model.

site_slug() str

ipam/prefixes/site/slug, dcim/devices/sites/slug.

Provide compatibility for Netbox >= v4.2 and Netbox < v4.2.

Returns:

Site slug.

Raises:
  • NbParserError – if strict=True and object has no value.

  • NbVersionError – If the key is deprecated for specific app/model.

slug() str

ipam/roles.slug.

status_value() str

ipam/prefixes.status.value

tag_slugs() List[str]

app/model.tags.0.slug.

Returns:

Slugs of tag.

tenant_id() int

ipam/aggregates.tenant.id.

tenant_name() str

ipam/aggregates.tenant.name.

tenant_slug() str

ipam/aggregates.tenant.name.

term_side() str

circuits/circuit-terminations.term_side.

termination_a() dict

ipam/circuits.circuits.termination_a.

termination_a_id() int

ipam/circuits.circuits.termination_a.id.

termination_a_provider_id() int

ipam/circuits.circuits.termination_a.provider.id.

termination_a_provider_name() str

ipam/circuits.circuits.termination_a.provider.name.

termination_a_site_id() int

ipam/circuits.circuits.termination_a.site.id.

termination_a_site_name() str

ipam/circuits.circuits.termination_a.site.name.

termination_a_site_slug() str

ipam/circuits.circuits.termination_a.site.slug.

termination_a_xconnect_id() str

ipam/circuits.circuits.termination_a.xconnect_id.

termination_z() dict

ipam/circuits.circuits.termination_z.

termination_z_id() int

ipam/circuits.circuits.termination_z.id.

termination_z_provider_id() int

ipam/circuits.circuits.termination_z.provider.id.

termination_z_provider_name() str

ipam/circuits.circuits.termination_z.provider.name.

termination_z_site_id() int

ipam/circuits.circuits.termination_z.site.id.

termination_z_site_name() str

ipam/circuits.circuits.termination_z.site.name.

termination_z_site_slug() str

ipam/circuits.circuits.termination_z.site.slug.

termination_z_xconnect_id() str

ipam/circuits.circuits.termination_z.xconnect_id.

type_() str

dcim/cables.type.

type_id() int

circuits/circuits.type.id.

type_name() str

circuits/circuits.type.name.

type_slug() str

circuits/circuits.type.slug.

type_value() str

dcim/console-ports.type.value.

url() str

ipam/prefixes.url.

url_ui() str

URL of object to Web UI.

vid() int

ipam/vlans.vid.

vlan_name() str

ipam/prefixes.vlan.name.

vlan_vid() int

ipam/prefixes.vlan.vid.

vrf_id() int

ipam/ip-addresses.vrf.id.

vrf_name() str

ipam/ip-addresses.vrf.name.

vrf_rd() str

ipam/ip-addresses.vrf.rd.