mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-26 18:38:38 -06:00
Add parent_prefixes to graphql IPAddressType
This commit is contained in:
parent
bf286df670
commit
006c22a54f
@ -138,6 +138,17 @@ class IPAddressType(NetBoxObjectType, ContactsMixin, BaseIPAddressFamilyType):
|
|||||||
Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')],
|
Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')],
|
||||||
], strawberry.union("IPAddressAssignmentType")] | None:
|
], strawberry.union("IPAddressAssignmentType")] | None:
|
||||||
return self.assigned_object
|
return self.assigned_object
|
||||||
|
|
||||||
|
@strawberry_django.field
|
||||||
|
def parent_prefixes(self) -> List[Annotated["PrefixType", strawberry.lazy('ipam.graphql.types')]]:
|
||||||
|
"""
|
||||||
|
Return all prefixes containing this IP address.
|
||||||
|
"""
|
||||||
|
from ipam.models import Prefix
|
||||||
|
return Prefix.objects.filter(
|
||||||
|
vrf=self.vrf,
|
||||||
|
prefix__net_contains_or_equals=str(self.address.ip)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
|
Loading…
Reference in New Issue
Block a user