mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Add journal_entries to Graphene object types for all primary models
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
from circuits import filtersets, models
|
||||
from netbox.graphql.types import BaseObjectType, ObjectType, TaggedObjectType
|
||||
from netbox.graphql.types import BaseObjectType, ObjectType, PrimaryObjectType
|
||||
|
||||
__all__ = (
|
||||
'CircuitTerminationType',
|
||||
@ -18,7 +18,7 @@ class CircuitTerminationType(BaseObjectType):
|
||||
filterset_class = filtersets.CircuitTerminationFilterSet
|
||||
|
||||
|
||||
class CircuitType(TaggedObjectType):
|
||||
class CircuitType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Circuit
|
||||
@ -34,7 +34,7 @@ class CircuitTypeType(ObjectType):
|
||||
filterset_class = filtersets.CircuitTypeFilterSet
|
||||
|
||||
|
||||
class ProviderType(TaggedObjectType):
|
||||
class ProviderType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Provider
|
||||
@ -42,7 +42,7 @@ class ProviderType(TaggedObjectType):
|
||||
filterset_class = filtersets.ProviderFilterSet
|
||||
|
||||
|
||||
class ProviderNetworkType(TaggedObjectType):
|
||||
class ProviderNetworkType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.ProviderNetwork
|
||||
|
@ -1,7 +1,7 @@
|
||||
from dcim import filtersets, models
|
||||
from extras.graphql.mixins import ImageAttachmentsMixin
|
||||
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
|
||||
from netbox.graphql.types import BaseObjectType, ObjectType, TaggedObjectType
|
||||
from netbox.graphql.types import BaseObjectType, ObjectType, PrimaryObjectType, TaggedObjectType
|
||||
|
||||
__all__ = (
|
||||
'CableType',
|
||||
@ -40,7 +40,7 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
class CableType(TaggedObjectType):
|
||||
class CableType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Cable
|
||||
@ -98,7 +98,7 @@ class ConsoleServerPortTemplateType(BaseObjectType):
|
||||
return self.type or None
|
||||
|
||||
|
||||
class DeviceType(ImageAttachmentsMixin, TaggedObjectType):
|
||||
class DeviceType(ImageAttachmentsMixin, PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Device
|
||||
@ -133,7 +133,7 @@ class DeviceRoleType(ObjectType):
|
||||
filterset_class = filtersets.DeviceRoleFilterSet
|
||||
|
||||
|
||||
class DeviceTypeType(TaggedObjectType):
|
||||
class DeviceTypeType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.DeviceType
|
||||
@ -211,7 +211,7 @@ class PlatformType(ObjectType):
|
||||
filterset_class = filtersets.PlatformFilterSet
|
||||
|
||||
|
||||
class PowerFeedType(TaggedObjectType):
|
||||
class PowerFeedType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.PowerFeed
|
||||
@ -247,7 +247,7 @@ class PowerOutletTemplateType(BaseObjectType):
|
||||
return self.type or None
|
||||
|
||||
|
||||
class PowerPanelType(TaggedObjectType):
|
||||
class PowerPanelType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.PowerPanel
|
||||
@ -277,7 +277,7 @@ class PowerPortTemplateType(BaseObjectType):
|
||||
return self.type or None
|
||||
|
||||
|
||||
class RackType(VLANGroupsMixin, ImageAttachmentsMixin, TaggedObjectType):
|
||||
class RackType(VLANGroupsMixin, ImageAttachmentsMixin, PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Rack
|
||||
@ -291,7 +291,7 @@ class RackType(VLANGroupsMixin, ImageAttachmentsMixin, TaggedObjectType):
|
||||
return self.outer_unit or None
|
||||
|
||||
|
||||
class RackReservationType(TaggedObjectType):
|
||||
class RackReservationType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.RackReservation
|
||||
@ -331,7 +331,7 @@ class RegionType(VLANGroupsMixin, ObjectType):
|
||||
filterset_class = filtersets.RegionFilterSet
|
||||
|
||||
|
||||
class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, TaggedObjectType):
|
||||
class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Site
|
||||
@ -347,7 +347,7 @@ class SiteGroupType(VLANGroupsMixin, ObjectType):
|
||||
filterset_class = filtersets.SiteGroupFilterSet
|
||||
|
||||
|
||||
class VirtualChassisType(TaggedObjectType):
|
||||
class VirtualChassisType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.VirtualChassis
|
||||
|
@ -4,6 +4,7 @@ from graphene.types.generic import GenericScalar
|
||||
__all__ = (
|
||||
'CustomFieldsMixin',
|
||||
'ImageAttachmentsMixin',
|
||||
'JournalEntriesMixin',
|
||||
'TagsMixin',
|
||||
)
|
||||
|
||||
@ -22,6 +23,13 @@ class ImageAttachmentsMixin:
|
||||
return self.images.restrict(info.context.user, 'view')
|
||||
|
||||
|
||||
class JournalEntriesMixin:
|
||||
journal_entries = graphene.List('extras.graphql.types.JournalEntryType')
|
||||
|
||||
def resolve_journal_entries(self, info):
|
||||
return self.journal_entries.restrict(info.context.user, 'view')
|
||||
|
||||
|
||||
class TagsMixin:
|
||||
tags = graphene.List(graphene.String)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
from ipam import filtersets, models
|
||||
from netbox.graphql.types import ObjectType, TaggedObjectType
|
||||
from netbox.graphql.types import ObjectType, PrimaryObjectType
|
||||
|
||||
__all__ = (
|
||||
'AggregateType',
|
||||
@ -16,7 +16,7 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
class AggregateType(TaggedObjectType):
|
||||
class AggregateType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Aggregate
|
||||
@ -24,7 +24,7 @@ class AggregateType(TaggedObjectType):
|
||||
filterset_class = filtersets.AggregateFilterSet
|
||||
|
||||
|
||||
class IPAddressType(TaggedObjectType):
|
||||
class IPAddressType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.IPAddress
|
||||
@ -35,7 +35,7 @@ class IPAddressType(TaggedObjectType):
|
||||
return self.role or None
|
||||
|
||||
|
||||
class IPRangeType(TaggedObjectType):
|
||||
class IPRangeType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.IPRange
|
||||
@ -46,7 +46,7 @@ class IPRangeType(TaggedObjectType):
|
||||
return self.role or None
|
||||
|
||||
|
||||
class PrefixType(TaggedObjectType):
|
||||
class PrefixType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Prefix
|
||||
@ -70,7 +70,7 @@ class RoleType(ObjectType):
|
||||
filterset_class = filtersets.RoleFilterSet
|
||||
|
||||
|
||||
class RouteTargetType(TaggedObjectType):
|
||||
class RouteTargetType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.RouteTarget
|
||||
@ -78,7 +78,7 @@ class RouteTargetType(TaggedObjectType):
|
||||
filterset_class = filtersets.RouteTargetFilterSet
|
||||
|
||||
|
||||
class ServiceType(TaggedObjectType):
|
||||
class ServiceType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Service
|
||||
@ -86,7 +86,7 @@ class ServiceType(TaggedObjectType):
|
||||
filterset_class = filtersets.ServiceFilterSet
|
||||
|
||||
|
||||
class VLANType(TaggedObjectType):
|
||||
class VLANType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.VLAN
|
||||
@ -102,7 +102,7 @@ class VLANGroupType(ObjectType):
|
||||
filterset_class = filtersets.VLANGroupFilterSet
|
||||
|
||||
|
||||
class VRFType(TaggedObjectType):
|
||||
class VRFType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.VRF
|
||||
|
@ -1,7 +1,7 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from graphene_django import DjangoObjectType
|
||||
|
||||
from extras.graphql.mixins import CustomFieldsMixin, TagsMixin
|
||||
from extras.graphql.mixins import CustomFieldsMixin, JournalEntriesMixin, TagsMixin
|
||||
|
||||
__all__ = (
|
||||
'BaseObjectType',
|
||||
@ -43,6 +43,14 @@ class TaggedObjectType(CustomFieldsMixin, TagsMixin, BaseObjectType):
|
||||
abstract = True
|
||||
|
||||
|
||||
class PrimaryObjectType(CustomFieldsMixin, JournalEntriesMixin, TagsMixin, BaseObjectType):
|
||||
"""
|
||||
Extends BaseObjectType with support for custom fields, tags, and journal entries.
|
||||
"""
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
#
|
||||
# Miscellaneous types
|
||||
#
|
||||
|
@ -1,5 +1,5 @@
|
||||
from tenancy import filtersets, models
|
||||
from netbox.graphql.types import ObjectType, TaggedObjectType
|
||||
from netbox.graphql.types import ObjectType, PrimaryObjectType
|
||||
|
||||
__all__ = (
|
||||
'TenantType',
|
||||
@ -7,7 +7,7 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
class TenantType(TaggedObjectType):
|
||||
class TenantType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Tenant
|
||||
|
@ -1,6 +1,6 @@
|
||||
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
|
||||
from virtualization import filtersets, models
|
||||
from netbox.graphql.types import ObjectType, TaggedObjectType
|
||||
from netbox.graphql.types import ObjectType, PrimaryObjectType, TaggedObjectType
|
||||
|
||||
__all__ = (
|
||||
'ClusterType',
|
||||
@ -11,7 +11,7 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
class ClusterType(VLANGroupsMixin, TaggedObjectType):
|
||||
class ClusterType(VLANGroupsMixin, PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Cluster
|
||||
@ -35,7 +35,7 @@ class ClusterTypeType(ObjectType):
|
||||
filterset_class = filtersets.ClusterTypeFilterSet
|
||||
|
||||
|
||||
class VirtualMachineType(TaggedObjectType):
|
||||
class VirtualMachineType(PrimaryObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.VirtualMachine
|
||||
|
Reference in New Issue
Block a user