|
@@ -13,6 +13,7 @@ from extras.graphql.mixins import (
|
|
|
)
|
|
)
|
|
|
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
|
|
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
|
|
|
|
|
|
|
|
|
|
+from netbox.graphql.scalars import BigInt
|
|
|
from netbox.graphql.types import (
|
|
from netbox.graphql.types import (
|
|
|
BaseObjectType,
|
|
BaseObjectType,
|
|
|
NetBoxObjectType,
|
|
NetBoxObjectType,
|
|
@@ -72,6 +73,7 @@ __all__ = (
|
|
|
#
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+@strawberry.type
|
|
|
class ComponentObjectType(
|
|
class ComponentObjectType(
|
|
|
ChangelogMixin,
|
|
ChangelogMixin,
|
|
|
CustomFieldsMixin,
|
|
CustomFieldsMixin,
|
|
@@ -81,8 +83,7 @@ class ComponentObjectType(
|
|
|
"""
|
|
"""
|
|
|
Base type for device/VM components
|
|
Base type for device/VM components
|
|
|
"""
|
|
"""
|
|
|
- class Meta:
|
|
|
|
|
- abstract = True
|
|
|
|
|
|
|
+ _name: str
|
|
|
|
|
|
|
|
|
|
|
|
|
class ComponentTemplateObjectType(
|
|
class ComponentTemplateObjectType(
|
|
@@ -92,8 +93,7 @@ class ComponentTemplateObjectType(
|
|
|
"""
|
|
"""
|
|
|
Base type for device/VM components
|
|
Base type for device/VM components
|
|
|
"""
|
|
"""
|
|
|
- class Meta:
|
|
|
|
|
- abstract = True
|
|
|
|
|
|
|
+ _name: str
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
#
|
|
@@ -147,7 +147,7 @@ class CableType(NetBoxObjectType):
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.ConsolePort,
|
|
models.ConsolePort,
|
|
|
# exclude=('_path',),
|
|
# exclude=('_path',),
|
|
|
- exclude=('_path', '_name',), # bug - temp
|
|
|
|
|
|
|
+ exclude=('_path',), # bug - temp
|
|
|
filters=ConsolePortFilter
|
|
filters=ConsolePortFilter
|
|
|
)
|
|
)
|
|
|
class ConsolePortType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
class ConsolePortType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
@@ -158,8 +158,7 @@ class ConsolePortType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin)
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.ConsolePortTemplate,
|
|
models.ConsolePortTemplate,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=ConsolePortTemplateFilter
|
|
filters=ConsolePortTemplateFilter
|
|
|
)
|
|
)
|
|
|
class ConsolePortTemplateType(ComponentTemplateObjectType):
|
|
class ConsolePortTemplateType(ComponentTemplateObjectType):
|
|
@@ -171,7 +170,7 @@ class ConsolePortTemplateType(ComponentTemplateObjectType):
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.ConsoleServerPort,
|
|
models.ConsoleServerPort,
|
|
|
# exclude=('_path',),
|
|
# exclude=('_path',),
|
|
|
- exclude=('_path', '_name',), # bug - temp
|
|
|
|
|
|
|
+ exclude=('_path',), # bug - temp
|
|
|
filters=ConsoleServerPortFilter
|
|
filters=ConsoleServerPortFilter
|
|
|
)
|
|
)
|
|
|
class ConsoleServerPortType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
class ConsoleServerPortType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
@@ -182,8 +181,7 @@ class ConsoleServerPortType(ComponentObjectType, CabledObjectMixin, PathEndpoint
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.ConsoleServerPortTemplate,
|
|
models.ConsoleServerPortTemplate,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=ConsoleServerPortTemplateFilter
|
|
filters=ConsoleServerPortTemplateFilter
|
|
|
)
|
|
)
|
|
|
class ConsoleServerPortTemplateType(ComponentTemplateObjectType):
|
|
class ConsoleServerPortTemplateType(ComponentTemplateObjectType):
|
|
@@ -194,15 +192,21 @@ class ConsoleServerPortTemplateType(ComponentTemplateObjectType):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.Device,
|
|
models.Device,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=(
|
|
|
|
|
- '_name', 'console_port_count', 'console_server_port_count', 'power_port_count', 'power_outlet_count',
|
|
|
|
|
- 'interface_count', 'front_port_count', 'rear_port_count', 'device_bay_count', 'module_bay_count',
|
|
|
|
|
- 'inventory_item_count'
|
|
|
|
|
- ), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=DeviceFilter
|
|
filters=DeviceFilter
|
|
|
)
|
|
)
|
|
|
class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
|
class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
|
|
|
|
+ _name: str
|
|
|
|
|
+ console_port_count: BigInt
|
|
|
|
|
+ console_server_port_count: BigInt
|
|
|
|
|
+ power_port_count: BigInt
|
|
|
|
|
+ power_outlet_count: BigInt
|
|
|
|
|
+ interface_count: BigInt
|
|
|
|
|
+ front_port_count: BigInt
|
|
|
|
|
+ rear_port_count: BigInt
|
|
|
|
|
+ device_bay_count: BigInt
|
|
|
|
|
+ module_bay_count: BigInt
|
|
|
|
|
+ inventory_item_count: BigInt
|
|
|
|
|
|
|
|
def resolve_face(self, info):
|
|
def resolve_face(self, info):
|
|
|
return self.face or None
|
|
return self.face or None
|
|
@@ -213,8 +217,7 @@ class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, ContactsMixin, NetBo
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.DeviceBay,
|
|
models.DeviceBay,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=DeviceBayFilter
|
|
filters=DeviceBayFilter
|
|
|
)
|
|
)
|
|
|
class DeviceBayType(ComponentObjectType):
|
|
class DeviceBayType(ComponentObjectType):
|
|
@@ -223,8 +226,7 @@ class DeviceBayType(ComponentObjectType):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.DeviceBayTemplate,
|
|
models.DeviceBayTemplate,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=DeviceBayTemplateFilter
|
|
filters=DeviceBayTemplateFilter
|
|
|
)
|
|
)
|
|
|
class DeviceBayTemplateType(ComponentTemplateObjectType):
|
|
class DeviceBayTemplateType(ComponentTemplateObjectType):
|
|
@@ -233,7 +235,7 @@ class DeviceBayTemplateType(ComponentTemplateObjectType):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.InventoryItemTemplate,
|
|
models.InventoryItemTemplate,
|
|
|
- exclude=('component_type', 'component_id', '_name', 'parent'),
|
|
|
|
|
|
|
+ exclude=('component_type', 'component_id', 'parent'),
|
|
|
filters=InventoryItemTemplateFilter
|
|
filters=InventoryItemTemplateFilter
|
|
|
)
|
|
)
|
|
|
class InventoryItemTemplateType(ComponentTemplateObjectType):
|
|
class InventoryItemTemplateType(ComponentTemplateObjectType):
|
|
@@ -253,16 +255,20 @@ class DeviceRoleType(OrganizationalObjectType):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.DeviceType,
|
|
models.DeviceType,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=(
|
|
|
|
|
- 'console_port_template_count', 'console_server_port_template_count', 'power_port_template_count',
|
|
|
|
|
- 'power_outlet_template_count', 'interface_template_count', 'front_port_template_count',
|
|
|
|
|
- 'rear_port_template_count', 'device_bay_template_count', 'module_bay_template_count',
|
|
|
|
|
- 'inventory_item_template_count',
|
|
|
|
|
- ), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=DeviceTypeFilter
|
|
filters=DeviceTypeFilter
|
|
|
)
|
|
)
|
|
|
class DeviceTypeType(NetBoxObjectType):
|
|
class DeviceTypeType(NetBoxObjectType):
|
|
|
|
|
+ console_port_template_count: BigInt
|
|
|
|
|
+ console_server_port_template_count: BigInt
|
|
|
|
|
+ power_port_template_count: BigInt
|
|
|
|
|
+ power_outlet_template_count: BigInt
|
|
|
|
|
+ interface_template_count: BigInt
|
|
|
|
|
+ front_port_template_count: BigInt
|
|
|
|
|
+ rear_port_template_count: BigInt
|
|
|
|
|
+ device_bay_template_count: BigInt
|
|
|
|
|
+ module_bay_template_count: BigInt
|
|
|
|
|
+ inventory_item_template_count: BigInt
|
|
|
|
|
|
|
|
def resolve_subdevice_role(self, info):
|
|
def resolve_subdevice_role(self, info):
|
|
|
return self.subdevice_role or None
|
|
return self.subdevice_role or None
|
|
@@ -277,7 +283,7 @@ class DeviceTypeType(NetBoxObjectType):
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.FrontPort,
|
|
models.FrontPort,
|
|
|
# fields='__all__',
|
|
# fields='__all__',
|
|
|
- exclude=('_name', 'color'), # bug - temp
|
|
|
|
|
|
|
+ exclude=('color',), # bug - temp
|
|
|
filters=FrontPortFilter
|
|
filters=FrontPortFilter
|
|
|
)
|
|
)
|
|
|
class FrontPortType(ComponentObjectType, CabledObjectMixin):
|
|
class FrontPortType(ComponentObjectType, CabledObjectMixin):
|
|
@@ -287,7 +293,7 @@ class FrontPortType(ComponentObjectType, CabledObjectMixin):
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.FrontPortTemplate,
|
|
models.FrontPortTemplate,
|
|
|
# fields='__all__',
|
|
# fields='__all__',
|
|
|
- exclude=('_name', 'color'), # bug - temp
|
|
|
|
|
|
|
+ exclude=('color',), # bug - temp
|
|
|
filters=FrontPortTemplateFilter
|
|
filters=FrontPortTemplateFilter
|
|
|
)
|
|
)
|
|
|
class FrontPortTemplateType(ComponentTemplateObjectType):
|
|
class FrontPortTemplateType(ComponentTemplateObjectType):
|
|
@@ -297,7 +303,7 @@ class FrontPortTemplateType(ComponentTemplateObjectType):
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.Interface,
|
|
models.Interface,
|
|
|
# fields='__all__',
|
|
# fields='__all__',
|
|
|
- exclude=('mac_address', '_name', 'wwn'), # bug - temp
|
|
|
|
|
|
|
+ exclude=('mac_address', 'wwn'), # bug - temp
|
|
|
filters=InterfaceFilter
|
|
filters=InterfaceFilter
|
|
|
)
|
|
)
|
|
|
class InterfaceType(IPAddressesMixin, ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
class InterfaceType(IPAddressesMixin, ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
@@ -320,8 +326,7 @@ class InterfaceType(IPAddressesMixin, ComponentObjectType, CabledObjectMixin, Pa
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.InterfaceTemplate,
|
|
models.InterfaceTemplate,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=InterfaceTemplateFilter
|
|
filters=InterfaceTemplateFilter
|
|
|
)
|
|
)
|
|
|
class InterfaceTemplateType(ComponentTemplateObjectType):
|
|
class InterfaceTemplateType(ComponentTemplateObjectType):
|
|
@@ -338,7 +343,7 @@ class InterfaceTemplateType(ComponentTemplateObjectType):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.InventoryItem,
|
|
models.InventoryItem,
|
|
|
- exclude=('component_type', 'component_id', '_name', 'parent'),
|
|
|
|
|
|
|
+ exclude=('component_type', 'component_id', 'parent'),
|
|
|
filters=InventoryItemFilter
|
|
filters=InventoryItemFilter
|
|
|
)
|
|
)
|
|
|
class InventoryItemType(ComponentObjectType):
|
|
class InventoryItemType(ComponentObjectType):
|
|
@@ -349,7 +354,7 @@ class InventoryItemType(ComponentObjectType):
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.InventoryItemRole,
|
|
models.InventoryItemRole,
|
|
|
# fields='__all__',
|
|
# fields='__all__',
|
|
|
- exclude=('color', '_name'), # bug - temp
|
|
|
|
|
|
|
+ exclude=('color',), # bug - temp
|
|
|
filters=InventoryItemRoleFilter
|
|
filters=InventoryItemRoleFilter
|
|
|
)
|
|
)
|
|
|
class InventoryItemRoleType(OrganizationalObjectType):
|
|
class InventoryItemRoleType(OrganizationalObjectType):
|
|
@@ -386,8 +391,7 @@ class ModuleType(ComponentObjectType):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.ModuleBay,
|
|
models.ModuleBay,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=ModuleBayFilter
|
|
filters=ModuleBayFilter
|
|
|
)
|
|
)
|
|
|
class ModuleBayType(ComponentObjectType):
|
|
class ModuleBayType(ComponentObjectType):
|
|
@@ -396,8 +400,7 @@ class ModuleBayType(ComponentObjectType):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.ModuleBayTemplate,
|
|
models.ModuleBayTemplate,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=ModuleBayTemplateFilter
|
|
filters=ModuleBayTemplateFilter
|
|
|
)
|
|
)
|
|
|
class ModuleBayTemplateType(ComponentTemplateObjectType):
|
|
class ModuleBayTemplateType(ComponentTemplateObjectType):
|
|
@@ -435,8 +438,7 @@ class PowerFeedType(NetBoxObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.PowerOutlet,
|
|
models.PowerOutlet,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=PowerOutletFilter
|
|
filters=PowerOutletFilter
|
|
|
)
|
|
)
|
|
|
class PowerOutletType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
class PowerOutletType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
@@ -450,8 +452,7 @@ class PowerOutletType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin)
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.PowerOutletTemplate,
|
|
models.PowerOutletTemplate,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=PowerOutletTemplateFilter
|
|
filters=PowerOutletTemplateFilter
|
|
|
)
|
|
)
|
|
|
class PowerOutletTemplateType(ComponentTemplateObjectType):
|
|
class PowerOutletTemplateType(ComponentTemplateObjectType):
|
|
@@ -474,7 +475,7 @@ class PowerPanelType(NetBoxObjectType, ContactsMixin):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.PowerPort,
|
|
models.PowerPort,
|
|
|
- exclude=('_path', '_name'),
|
|
|
|
|
|
|
+ exclude=('_path',),
|
|
|
filters=PowerPortFilter
|
|
filters=PowerPortFilter
|
|
|
)
|
|
)
|
|
|
class PowerPortType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
class PowerPortType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
@@ -485,8 +486,7 @@ class PowerPortType(ComponentObjectType, CabledObjectMixin, PathEndpointMixin):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.PowerPortTemplate,
|
|
models.PowerPortTemplate,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=PowerPortTemplateFilter
|
|
filters=PowerPortTemplateFilter
|
|
|
)
|
|
)
|
|
|
class PowerPortTemplateType(ComponentTemplateObjectType):
|
|
class PowerPortTemplateType(ComponentTemplateObjectType):
|
|
@@ -497,11 +497,11 @@ class PowerPortTemplateType(ComponentTemplateObjectType):
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.Rack,
|
|
models.Rack,
|
|
|
- # fields='__all__',
|
|
|
|
|
- exclude=('_name',), # bug - temp
|
|
|
|
|
|
|
+ fields='__all__',
|
|
|
filters=RackFilter
|
|
filters=RackFilter
|
|
|
)
|
|
)
|
|
|
class RackType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
|
class RackType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
|
|
|
|
+ _name: str
|
|
|
|
|
|
|
|
def resolve_type(self, info):
|
|
def resolve_type(self, info):
|
|
|
return self.type or None
|
|
return self.type or None
|
|
@@ -536,7 +536,7 @@ class RackRoleType(OrganizationalObjectType):
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.RearPort,
|
|
models.RearPort,
|
|
|
# fields='__all__',
|
|
# fields='__all__',
|
|
|
- exclude=('_name', 'color'), # bug - temp
|
|
|
|
|
|
|
+ exclude=('color', ), # bug - temp
|
|
|
filters=RearPortFilter
|
|
filters=RearPortFilter
|
|
|
)
|
|
)
|
|
|
class RearPortType(ComponentObjectType, CabledObjectMixin):
|
|
class RearPortType(ComponentObjectType, CabledObjectMixin):
|
|
@@ -546,7 +546,7 @@ class RearPortType(ComponentObjectType, CabledObjectMixin):
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.RearPortTemplate,
|
|
models.RearPortTemplate,
|
|
|
# fields='__all__',
|
|
# fields='__all__',
|
|
|
- exclude=('_name', 'color'), # bug - temp
|
|
|
|
|
|
|
+ exclude=('color', ), # bug - temp
|
|
|
filters=RearPortTemplateFilter
|
|
filters=RearPortTemplateFilter
|
|
|
)
|
|
)
|
|
|
class RearPortTemplateType(ComponentTemplateObjectType):
|
|
class RearPortTemplateType(ComponentTemplateObjectType):
|
|
@@ -566,12 +566,12 @@ class RegionType(VLANGroupsMixin, ContactsMixin, OrganizationalObjectType):
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|
|
|
models.Site,
|
|
models.Site,
|
|
|
# fields='__all__',
|
|
# fields='__all__',
|
|
|
- exclude=('_name', 'time_zone'), # bug - temp
|
|
|
|
|
|
|
+ exclude=('time_zone',), # bug - temp
|
|
|
filters=SiteFilter
|
|
filters=SiteFilter
|
|
|
)
|
|
)
|
|
|
class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
|
class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
|
|
- # asn = graphene.Field(BigInt)
|
|
|
|
|
- pass
|
|
|
|
|
|
|
+ _name: str
|
|
|
|
|
+ asn: BigInt
|
|
|
|
|
|
|
|
|
|
|
|
|
@strawberry_django.type(
|
|
@strawberry_django.type(
|