1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

9856 update types

This commit is contained in:
Arthur
2024-02-23 14:36:41 -08:00
parent a5445bb61a
commit 69134dbb50
5 changed files with 160 additions and 9 deletions

View File

@ -1,3 +1,5 @@
from typing import Annotated, List
import strawberry
import strawberry_django
@ -27,4 +29,7 @@ class DataFileType(BaseObjectType):
filters=DataSourceFilter
)
class DataSourceType(NetBoxObjectType):
pass
@strawberry_django.field
def datafiles(self) -> List[Annotated["DataFileType", strawberry.lazy('core.graphql.types')]]:
return self.datafiles.all()

View File

@ -40,7 +40,7 @@ from dcim.models import (
)
class InventoryItemTemplateComponentType(graphene.Union):
class InventoryItemTemplateComponentType:
class Meta:
types = (
ConsolePortTemplateType,
@ -70,7 +70,7 @@ class InventoryItemTemplateComponentType(graphene.Union):
return RearPortTemplateType
class InventoryItemComponentType(graphene.Union):
class InventoryItemComponentType:
class Meta:
types = (
ConsolePortType,
@ -100,7 +100,7 @@ class InventoryItemComponentType(graphene.Union):
return RearPortType
class ConnectedEndpointType(graphene.Union):
class ConnectedEndpointType:
class Meta:
types = (
CircuitTerminationType,

View File

@ -215,6 +215,74 @@ class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, ContactsMixin, NetBo
def resolve_airflow(self, info):
return self.airflow or None
@strawberry_django.field
def devicebays(self) -> List[Annotated["DeviceBayType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def vc_master_for(self) -> Annotated["VirtualChassisType", strawberry.lazy('dcim.graphql.types')]:
return self.vc_master_for
@strawberry_django.field
def virtual_machines(self) -> List[Annotated["VirtualMachineType", strawberry.lazy('virtualization.graphql.types')]]:
return self.virtual_machines.all()
@strawberry_django.field
def modules(self) -> List[Annotated["ModuleType", strawberry.lazy('dcim.graphql.types')]]:
return self.modules.all()
@strawberry_django.field
def parent_bay(self) -> Annotated["DeviceBayType", strawberry.lazy('dcim.graphql.types')]:
return self.parent_bay
@strawberry_django.field
def interfaces(self) -> List[Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def rearports(self) -> List[Annotated["RearPortType", strawberry.lazy('dcim.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def consoleports(self) -> List[Annotated["ConsolePortType", strawberry.lazy('dcim.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def powerports(self) -> List[Annotated["PowerPortType", strawberry.lazy('dcim.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def cabletermination_set(self) -> List[Annotated["CableTerminationType", strawberry.lazy('dcim.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def consoleserverports(self) -> List[Annotated["ConsoleServerPortType", strawberry.lazy('dcim.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def poweroutlets(self) -> List[Annotated["PowerOutletType", strawberry.lazy('dcim.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def frontports(self) -> List[Annotated["FrontPortType", strawberry.lazy('dcim.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def modulebays(self) -> List[Annotated["ModuleBayType", strawberry.lazy('dcim.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def services(self) -> List[Annotated["ServiceType", strawberry.lazy('ipam.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def inventoryitems(self) -> List[Annotated["InventoryItemType", strawberry.lazy('dcim.graphql.types')]]:
return self.clusters.all()
@strawberry_django.field
def vdcs(self) -> List[Annotated["VirtualDeviceContextType", strawberry.lazy('dcim.graphql.types')]]:
return self.vdcs.all()
@strawberry_django.type(
models.DeviceBay,
@ -250,7 +318,15 @@ class InventoryItemTemplateType(ComponentTemplateObjectType):
filters=DeviceRoleFilter
)
class DeviceRoleType(OrganizationalObjectType):
pass
color: str
@strawberry_django.field
def virtual_machines(self) -> List[Annotated["VirtualMachineType", strawberry.lazy('virtualization.graphql.types')]]:
return self.virtual_machines.all()
@strawberry_django.field
def devices(self) -> List[Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')]]:
return self.devices.all()
@strawberry_django.type(
@ -279,6 +355,50 @@ class DeviceTypeType(NetBoxObjectType):
def resolve_weight_unit(self, info):
return self.weight_unit or None
@strawberry_django.field
def frontporttemplates(self) -> List[Annotated["FrontPortTemplateType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def modulebaytemplates(self) -> List[Annotated["ModuleBayTemplateType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def instances(self) -> List[Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def poweroutlettemplates(self) -> List[Annotated["PowerOutletTemplateType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def powerporttemplates(self) -> List[Annotated["PowerPortTemplateType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def inventoryitemtemplates(self) -> List[Annotated["InventoryItemTemplateType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def rearporttemplates(self) -> List[Annotated["RearPortTemplateType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def consoleserverporttemplates(self) -> List[Annotated["ConsoleServerPortTemplateType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def interfacetemplates(self) -> List[Annotated["InterfaceTemplateType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def devicebaytemplates(self) -> List[Annotated["DeviceBayTemplateType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.field
def consoleporttemplates(self) -> List[Annotated["ConsolePortTemplateType", strawberry.lazy('dcim.graphql.types')]]:
return self.device_bays.all()
@strawberry_django.type(
models.FrontPort,

View File

@ -130,7 +130,14 @@ class CustomFieldType(ObjectType):
filters=CustomFieldChoiceSetFilter
)
class CustomFieldChoiceSetType(ObjectType):
pass
@strawberry_django.field
def choices_for(self) -> List[Annotated["CustomFieldType", strawberry.lazy('extras.graphql.types')]]:
return self.assignments.all()
@strawberry_django.field
def extra_choices(self) -> List[str]:
return self.assignments.all()
@strawberry_django.type(

View File

@ -1,3 +1,5 @@
from typing import Annotated, List
import strawberry
import strawberry_django
@ -56,7 +58,10 @@ class TenantGroupType(OrganizationalObjectType):
filters=ContactFilter
)
class ContactType(ContactAssignmentsMixin, NetBoxObjectType):
pass
@strawberry_django.field
def assignments(self) -> List[Annotated["ContactAssignmentType", strawberry.lazy('tenancy.graphql.types')]]:
return self.assignments.all()
@strawberry_django.type(
@ -65,7 +70,10 @@ class ContactType(ContactAssignmentsMixin, NetBoxObjectType):
filters=ContactRoleFilter
)
class ContactRoleType(ContactAssignmentsMixin, OrganizationalObjectType):
pass
@strawberry_django.field
def assignments(self) -> List[Annotated["ContactAssignmentType", strawberry.lazy('tenancy.graphql.types')]]:
return self.assignments.all()
@strawberry_django.type(
@ -75,7 +83,18 @@ class ContactRoleType(ContactAssignmentsMixin, OrganizationalObjectType):
filters=ContactGroupFilter
)
class ContactGroupType(OrganizationalObjectType):
pass
@strawberry_django.field
def parent(self) -> Annotated["ContactGroupType", strawberry.lazy('tenancy.graphql.types')]:
return self.parent
@strawberry_django.field
def contacts(self) -> List[ContactType]:
return self.clusters.all()
@strawberry_django.field
def children(self) -> List[Annotated["ContactGroupType", strawberry.lazy('tenancy.graphql.types')]]:
return self.children.all()
@strawberry_django.type(