|
@@ -2,7 +2,7 @@ import graphene
|
|
|
|
|
|
|
|
from dcim import filtersets, models
|
|
from dcim import filtersets, models
|
|
|
from extras.graphql.mixins import (
|
|
from extras.graphql.mixins import (
|
|
|
- ChangelogMixin, ConfigContextMixin, CustomFieldsMixin, ImageAttachmentsMixin, TagsMixin,
|
|
|
|
|
|
|
+ ChangelogMixin, ConfigContextMixin, ContactsMixin, CustomFieldsMixin, ImageAttachmentsMixin, TagsMixin,
|
|
|
)
|
|
)
|
|
|
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
|
|
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
|
|
|
from netbox.graphql.scalars import BigInt
|
|
from netbox.graphql.scalars import BigInt
|
|
@@ -87,6 +87,8 @@ class ComponentTemplateObjectType(
|
|
|
#
|
|
#
|
|
|
|
|
|
|
|
class CableType(NetBoxObjectType):
|
|
class CableType(NetBoxObjectType):
|
|
|
|
|
+ a_terminations = graphene.List('dcim.graphql.gfk_mixins.CableTerminationTerminationType')
|
|
|
|
|
+ b_terminations = graphene.List('dcim.graphql.gfk_mixins.CableTerminationTerminationType')
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.Cable
|
|
model = models.Cable
|
|
@@ -99,12 +101,19 @@ class CableType(NetBoxObjectType):
|
|
|
def resolve_length_unit(self, info):
|
|
def resolve_length_unit(self, info):
|
|
|
return self.length_unit or None
|
|
return self.length_unit or None
|
|
|
|
|
|
|
|
|
|
+ def resolve_a_terminations(self, info):
|
|
|
|
|
+ return self.a_terminations
|
|
|
|
|
+
|
|
|
|
|
+ def resolve_b_terminations(self, info):
|
|
|
|
|
+ return self.b_terminations
|
|
|
|
|
+
|
|
|
|
|
|
|
|
class CableTerminationType(NetBoxObjectType):
|
|
class CableTerminationType(NetBoxObjectType):
|
|
|
|
|
+ termination = graphene.Field('dcim.graphql.gfk_mixins.CableTerminationTerminationType')
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.CableTermination
|
|
model = models.CableTermination
|
|
|
- fields = '__all__'
|
|
|
|
|
|
|
+ exclude = ('termination_type', 'termination_id')
|
|
|
filterset_class = filtersets.CableTerminationFilterSet
|
|
filterset_class = filtersets.CableTerminationFilterSet
|
|
|
|
|
|
|
|
|
|
|
|
@@ -152,7 +161,7 @@ class ConsoleServerPortTemplateType(ComponentTemplateObjectType):
|
|
|
return self.type or None
|
|
return self.type or None
|
|
|
|
|
|
|
|
|
|
|
|
|
-class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, NetBoxObjectType):
|
|
|
|
|
|
|
+class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.Device
|
|
model = models.Device
|
|
@@ -183,10 +192,11 @@ class DeviceBayTemplateType(ComponentTemplateObjectType):
|
|
|
|
|
|
|
|
|
|
|
|
|
class InventoryItemTemplateType(ComponentTemplateObjectType):
|
|
class InventoryItemTemplateType(ComponentTemplateObjectType):
|
|
|
|
|
+ component = graphene.Field('dcim.graphql.gfk_mixins.InventoryItemTemplateComponentType')
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.InventoryItemTemplate
|
|
model = models.InventoryItemTemplate
|
|
|
- fields = '__all__'
|
|
|
|
|
|
|
+ exclude = ('component_type', 'component_id')
|
|
|
filterset_class = filtersets.InventoryItemTemplateFilterSet
|
|
filterset_class = filtersets.InventoryItemTemplateFilterSet
|
|
|
|
|
|
|
|
|
|
|
|
@@ -269,10 +279,11 @@ class InterfaceTemplateType(ComponentTemplateObjectType):
|
|
|
|
|
|
|
|
|
|
|
|
|
class InventoryItemType(ComponentObjectType):
|
|
class InventoryItemType(ComponentObjectType):
|
|
|
|
|
+ component = graphene.Field('dcim.graphql.gfk_mixins.InventoryItemComponentType')
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.InventoryItem
|
|
model = models.InventoryItem
|
|
|
- fields = '__all__'
|
|
|
|
|
|
|
+ exclude = ('component_type', 'component_id')
|
|
|
filterset_class = filtersets.InventoryItemFilterSet
|
|
filterset_class = filtersets.InventoryItemFilterSet
|
|
|
|
|
|
|
|
|
|
|
|
@@ -284,7 +295,7 @@ class InventoryItemRoleType(OrganizationalObjectType):
|
|
|
filterset_class = filtersets.InventoryItemRoleFilterSet
|
|
filterset_class = filtersets.InventoryItemRoleFilterSet
|
|
|
|
|
|
|
|
|
|
|
|
|
-class LocationType(VLANGroupsMixin, ImageAttachmentsMixin, OrganizationalObjectType):
|
|
|
|
|
|
|
+class LocationType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, OrganizationalObjectType):
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.Location
|
|
model = models.Location
|
|
@@ -292,7 +303,7 @@ class LocationType(VLANGroupsMixin, ImageAttachmentsMixin, OrganizationalObjectT
|
|
|
filterset_class = filtersets.LocationFilterSet
|
|
filterset_class = filtersets.LocationFilterSet
|
|
|
|
|
|
|
|
|
|
|
|
|
-class ManufacturerType(OrganizationalObjectType):
|
|
|
|
|
|
|
+class ManufacturerType(OrganizationalObjectType, ContactsMixin):
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.Manufacturer
|
|
model = models.Manufacturer
|
|
@@ -379,7 +390,7 @@ class PowerOutletTemplateType(ComponentTemplateObjectType):
|
|
|
return self.type or None
|
|
return self.type or None
|
|
|
|
|
|
|
|
|
|
|
|
|
-class PowerPanelType(NetBoxObjectType):
|
|
|
|
|
|
|
+class PowerPanelType(NetBoxObjectType, ContactsMixin):
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.PowerPanel
|
|
model = models.PowerPanel
|
|
@@ -409,7 +420,7 @@ class PowerPortTemplateType(ComponentTemplateObjectType):
|
|
|
return self.type or None
|
|
return self.type or None
|
|
|
|
|
|
|
|
|
|
|
|
|
-class RackType(VLANGroupsMixin, ImageAttachmentsMixin, NetBoxObjectType):
|
|
|
|
|
|
|
+class RackType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.Rack
|
|
model = models.Rack
|
|
@@ -458,7 +469,7 @@ class RearPortTemplateType(ComponentTemplateObjectType):
|
|
|
filterset_class = filtersets.RearPortTemplateFilterSet
|
|
filterset_class = filtersets.RearPortTemplateFilterSet
|
|
|
|
|
|
|
|
|
|
|
|
|
-class RegionType(VLANGroupsMixin, OrganizationalObjectType):
|
|
|
|
|
|
|
+class RegionType(VLANGroupsMixin, ContactsMixin, OrganizationalObjectType):
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.Region
|
|
model = models.Region
|
|
@@ -466,7 +477,7 @@ class RegionType(VLANGroupsMixin, OrganizationalObjectType):
|
|
|
filterset_class = filtersets.RegionFilterSet
|
|
filterset_class = filtersets.RegionFilterSet
|
|
|
|
|
|
|
|
|
|
|
|
|
-class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, NetBoxObjectType):
|
|
|
|
|
|
|
+class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
|
|
asn = graphene.Field(BigInt)
|
|
asn = graphene.Field(BigInt)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
@@ -475,7 +486,7 @@ class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, NetBoxObjectType):
|
|
|
filterset_class = filtersets.SiteFilterSet
|
|
filterset_class = filtersets.SiteFilterSet
|
|
|
|
|
|
|
|
|
|
|
|
|
-class SiteGroupType(VLANGroupsMixin, OrganizationalObjectType):
|
|
|
|
|
|
|
+class SiteGroupType(VLANGroupsMixin, ContactsMixin, OrganizationalObjectType):
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = models.SiteGroup
|
|
model = models.SiteGroup
|