mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 00:36:11 -06:00
10595 add contacts to graphql
This commit is contained in:
parent
ac1cf30321
commit
a9be663df2
@ -1,6 +1,8 @@
|
|||||||
|
import graphene
|
||||||
|
|
||||||
from circuits import filtersets, models
|
from circuits import filtersets, models
|
||||||
from dcim.graphql.mixins import CabledObjectMixin
|
from dcim.graphql.mixins import CabledObjectMixin
|
||||||
from extras.graphql.mixins import CustomFieldsMixin, TagsMixin
|
from extras.graphql.mixins import CustomFieldsMixin, TagsMixin, ContactsMixin
|
||||||
from netbox.graphql.types import ObjectType, OrganizationalObjectType, NetBoxObjectType
|
from netbox.graphql.types import ObjectType, OrganizationalObjectType, NetBoxObjectType
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -20,8 +22,7 @@ class CircuitTerminationType(CustomFieldsMixin, TagsMixin, CabledObjectMixin, Ob
|
|||||||
filterset_class = filtersets.CircuitTerminationFilterSet
|
filterset_class = filtersets.CircuitTerminationFilterSet
|
||||||
|
|
||||||
|
|
||||||
class CircuitType(NetBoxObjectType):
|
class CircuitType(NetBoxObjectType, ContactsMixin):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Circuit
|
model = models.Circuit
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
@ -44,7 +45,7 @@ class ProviderType(NetBoxObjectType):
|
|||||||
filterset_class = filtersets.ProviderFilterSet
|
filterset_class = filtersets.ProviderFilterSet
|
||||||
|
|
||||||
|
|
||||||
class ProviderNetworkType(NetBoxObjectType):
|
class ProviderNetworkType(NetBoxObjectType, ContactsMixin):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.ProviderNetwork
|
model = models.ProviderNetwork
|
||||||
|
@ -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
|
||||||
@ -161,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
|
||||||
@ -295,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
|
||||||
@ -303,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
|
||||||
@ -390,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
|
||||||
@ -420,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
|
||||||
@ -469,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
|
||||||
@ -477,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:
|
||||||
@ -486,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
|
||||||
|
@ -59,3 +59,10 @@ class TagsMixin:
|
|||||||
|
|
||||||
def resolve_tags(self, info):
|
def resolve_tags(self, info):
|
||||||
return self.tags.all()
|
return self.tags.all()
|
||||||
|
|
||||||
|
|
||||||
|
class ContactsMixin:
|
||||||
|
contacts = graphene.List('tenancy.graphql.types.ContactAssignmentType')
|
||||||
|
|
||||||
|
def resolve_contacts(self, info):
|
||||||
|
return list(self.contacts.all())
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import graphene
|
import graphene
|
||||||
|
|
||||||
from graphene_django import DjangoObjectType
|
from graphene_django import DjangoObjectType
|
||||||
|
from extras.graphql.mixins import ContactsMixin
|
||||||
from ipam import filtersets, models
|
from ipam import filtersets, models
|
||||||
from netbox.graphql.scalars import BigInt
|
from netbox.graphql.scalars import BigInt
|
||||||
from netbox.graphql.types import BaseObjectType, OrganizationalObjectType, NetBoxObjectType
|
from netbox.graphql.types import BaseObjectType, OrganizationalObjectType, NetBoxObjectType
|
||||||
@ -159,7 +160,7 @@ class VRFType(NetBoxObjectType):
|
|||||||
filterset_class = filtersets.VRFFilterSet
|
filterset_class = filtersets.VRFFilterSet
|
||||||
|
|
||||||
|
|
||||||
class L2VPNType(NetBoxObjectType):
|
class L2VPNType(ContactsMixin, NetBoxObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.L2VPN
|
model = models.L2VPN
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
Loading…
Reference in New Issue
Block a user