diff --git a/netbox/dcim/graphql/types.py b/netbox/dcim/graphql/types.py index bb64471fb..7f238b987 100644 --- a/netbox/dcim/graphql/types.py +++ b/netbox/dcim/graphql/types.py @@ -311,7 +311,7 @@ class InventoryItemTemplateType(ComponentTemplateObjectType): Annotated["PowerOutletType", strawberry.lazy('dcim.graphql.types')], Annotated["PowerPortType", strawberry.lazy('dcim.graphql.types')], Annotated["RearPortType", strawberry.lazy('dcim.graphql.types')], - ], strawberry.union("InventoryItemComponentType")]]: + ], strawberry.union("InventoryItemTemplateComponentType")]]: return self.component diff --git a/netbox/ipam/graphql/types.py b/netbox/ipam/graphql/types.py index b98e1d7a2..283dd3e30 100644 --- a/netbox/ipam/graphql/types.py +++ b/netbox/ipam/graphql/types.py @@ -234,8 +234,7 @@ class RouteTargetType(NetBoxObjectType): @strawberry_django.type( models.Service, - # fields='__all__', - exclude=('ports',), # bug - temp + fields='__all__', filters=ServiceFilter ) class ServiceType(NetBoxObjectType): @@ -248,8 +247,7 @@ class ServiceType(NetBoxObjectType): @strawberry_django.type( models.ServiceTemplate, - # fields='__all__', - exclude=('ports',), # bug - temp + fields='__all__', filters=ServiceTemplateFilter ) class ServiceTemplateType(NetBoxObjectType): @@ -262,7 +260,30 @@ class ServiceTemplateType(NetBoxObjectType): filters=VLANFilter ) class VLANType(NetBoxObjectType): - pass + + @strawberry_django.field + def interfaces_as_untagged(self) -> List[Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')]]: + return self.interfaces_as_untagged.all() + + @strawberry_django.field + def vminterfaces_as_untagged(self) -> List[Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')]]: + return self.vminterfaces_as_untagged.all() + + @strawberry_django.field + def wirelesslan_set(self) -> List[Annotated["WirelessLANType", strawberry.lazy('wireless.graphql.types')]]: + return self.wirelesslan_set.all() + + @strawberry_django.field + def prefixes(self) -> List[Annotated["PrefixType", strawberry.lazy('ipam.graphql.types')]]: + return self.prefixes.all() + + @strawberry_django.field + def interfaces_as_tagged(self) -> List[Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')]]: + return self.interfaces_as_tagged.all() + + @strawberry_django.field + def vminterfaces_as_tagged(self) -> List[Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')]]: + return self.vminterfaces_as_tagged.all() @strawberry_django.type( @@ -271,8 +292,22 @@ class VLANType(NetBoxObjectType): filters=VLANGroupFilter ) class VLANGroupType(OrganizationalObjectType): - # scope = graphene.Field('ipam.graphql.gfk_mixins.VLANGroupScopeType') - pass + + @strawberry_django.field + def vlans(self) -> List[VLANType]: + return self.vlans.all() + + @strawberry_django.field + def scope(self) -> Annotated[Union[ + Annotated["ClusterType", strawberry.lazy('virtualization.graphql.types')], + Annotated["ClusterGroupType", strawberry.lazy('virtualization.graphql.types')], + Annotated["LocationType", strawberry.lazy('dcim.graphql.types')], + Annotated["RackType", strawberry.lazy('dcim.graphql.types')], + Annotated["RegionType", strawberry.lazy('dcim.graphql.types')], + Annotated["SiteType", strawberry.lazy('dcim.graphql.types')], + Annotated["SiteGroupType", strawberry.lazy('dcim.graphql.types')], + ], strawberry.union("VLANGroupScopeType")]: + return self.scope @strawberry_django.type( @@ -281,4 +316,31 @@ class VLANGroupType(OrganizationalObjectType): filters=VRFFilter ) class VRFType(NetBoxObjectType): - pass + + @strawberry_django.field + def interfaces(self) -> List[Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')]]: + return self.interfaces.all() + + @strawberry_django.field + def ip_addresses(self) -> List[Annotated["IPAddressType", strawberry.lazy('ipam.graphql.types')]]: + return self.ip_addresses.all() + + @strawberry_django.field + def vminterfaces(self) -> List[Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')]]: + return self.vminterfaces.all() + + @strawberry_django.field + def ip_ranges(self) -> List[Annotated["IPRangeType", strawberry.lazy('ipam.graphql.types')]]: + return self.ip_ranges.all() + + @strawberry_django.field + def export_targets(self) -> List[Annotated["RouteTargetType", strawberry.lazy('ipam.graphql.types')]]: + return self.export_targets.all() + + @strawberry_django.field + def import_targets(self) -> List[Annotated["RouteTargetType", strawberry.lazy('ipam.graphql.types')]]: + return self.import_targets.all() + + @strawberry_django.field + def prefixes(self) -> List[Annotated["PrefixType", strawberry.lazy('ipam.graphql.types')]]: + return self.prefixes.all() diff --git a/netbox/virtualization/graphql/types.py b/netbox/virtualization/graphql/types.py index bfac3ef44..a263a8d9d 100644 --- a/netbox/virtualization/graphql/types.py +++ b/netbox/virtualization/graphql/types.py @@ -6,6 +6,7 @@ import strawberry_django from dcim.graphql.types import ComponentObjectType from extras.graphql.mixins import ConfigContextMixin from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin +from netbox.graphql.scalars import BigInt from netbox.graphql.types import OrganizationalObjectType, NetBoxObjectType from virtualization import models from .filters import * @@ -70,33 +71,61 @@ class ClusterTypeType(OrganizationalObjectType): @strawberry_django.type( models.VirtualMachine, - # fields='__all__', - exclude=('_name', 'interface_count', 'virtual_disk_count',), # bug - temp + fields='__all__', filters=VirtualMachineFilter ) class VirtualMachineType(ConfigContextMixin, NetBoxObjectType): _name: str + interface_count: BigInt + virtual_disk_count: BigInt + + @strawberry_django.field + def interfaces(self) -> List[Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')]]: + return self.interfaces.all() + + @strawberry_django.field + def services(self) -> List[Annotated["ServiceType", strawberry.lazy('ipam.graphql.types')]]: + return self.services.all() + + @strawberry_django.field + def virtualdisks(self) -> List[Annotated["VirtualDiskType", strawberry.lazy('virtualization.graphql.types')]]: + return self.virtualdisks.all() @strawberry_django.type( models.VMInterface, - # fields='__all__', - exclude=('mac_address', '_name',), # bug - temp + fields='__all__', filters=VMInterfaceFilter ) class VMInterfaceType(IPAddressesMixin, ComponentObjectType): + _name: str + mac_address: str - def resolve_mode(self, info): - return self.mode or None + @strawberry_django.field + def ip_addresses(self) -> List[Annotated["IPAddressType", strawberry.lazy('ipam.graphql.types')]]: + return self.ip_addresses.all() + + @strawberry_django.field + def tagged_vlans(self) -> List[Annotated["VLANType", strawberry.lazy('ipam.graphql.types')]]: + return self.tagged_vlans.all() + + @strawberry_django.field + def mac_address(self) -> List[Annotated["ClusterType", strawberry.lazy('virtualization.graphql.types')]]: + return self.mac_address.all() + + @strawberry_django.field + def bridge_interfaces(self) -> List[Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')]]: + return self.bridge_interfaces.all() + + @strawberry_django.field + def child_interfaces(self) -> List[Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')]]: + return self.child_interfaces.all() @strawberry_django.type( models.VirtualDisk, - # fields='__all__', - exclude=('_name',), # bug - temp + fields='__all__', filters=VirtualDiskFilter ) class VirtualDiskType(ComponentObjectType): - - def resolve_mode(self, info): - return self.mode or None + _name: str diff --git a/netbox/wireless/graphql/types.py b/netbox/wireless/graphql/types.py index c3204aecb..189c565ec 100644 --- a/netbox/wireless/graphql/types.py +++ b/netbox/wireless/graphql/types.py @@ -21,7 +21,18 @@ __all__ = ( filters=WirelessLANGroupFilter ) class WirelessLANGroupType(OrganizationalObjectType): - pass + + @strawberry_django.field + def parent(self) -> Annotated["WirelessLANGroupType", strawberry.lazy('wireless.graphql.types')]: + return self.parent + + @strawberry_django.field + def wireless_lans(self) -> List[Annotated["WirelessLANType", strawberry.lazy('wireless.graphql.types')]]: + return self.wireless_lans.all() + + @strawberry_django.field + def children(self) -> List[Annotated["WirelessLANGroupType", strawberry.lazy('wireless.graphql.types')]]: + return self.children.all() @strawberry_django.type(