From 362273dedad83065ddc36b9e9c5b749dcb7c79c9 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Wed, 9 Apr 2025 09:23:27 -0400 Subject: [PATCH] first avaliable fields --- netbox/ipam/graphql/types.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/netbox/ipam/graphql/types.py b/netbox/ipam/graphql/types.py index 21caadc36..d92191991 100644 --- a/netbox/ipam/graphql/types.py +++ b/netbox/ipam/graphql/types.py @@ -222,6 +222,22 @@ class PrefixType(NetBoxObjectType, ContactsMixin, BaseIPAddressFamilyType): vrf=self.vrf ) + @strawberry_django.field + def first_available_ip_address(self) -> str: + """ + Return the first available IP address within this prefix as a string, or an empty string if none is available. + """ + first_ip = self.get_first_available_ip() + return first_ip if first_ip else "" + + @strawberry_django.field + def first_available_child_prefix(self) -> str: + """ + Return the first available child prefix within this prefix as a string, or an empty string if none is available. + """ + first_prefix = self.get_first_available_prefix() + return str(first_prefix) if first_prefix else "" + @strawberry_django.type( models.RIR,