mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Expose BaseObjectType and NetBoxObjectType for plugins
This commit is contained in:
@ -26,8 +26,26 @@ class MyQuery(graphene.ObjectType):
|
||||
schema = MyQuery
|
||||
```
|
||||
|
||||
## GraphQL Objects
|
||||
|
||||
NetBox provides two object type classes for use by plugins.
|
||||
|
||||
::: netbox.graphql.types.BaseObjectType
|
||||
selection:
|
||||
members: false
|
||||
rendering:
|
||||
show_source: false
|
||||
|
||||
::: netbox.graphql.types.NetBoxObjectType
|
||||
selection:
|
||||
members: false
|
||||
rendering:
|
||||
show_source: false
|
||||
|
||||
## GraphQL Fields
|
||||
|
||||
NetBox provides two field classes for use by plugins.
|
||||
|
||||
::: netbox.graphql.fields.ObjectField
|
||||
selection:
|
||||
members: false
|
||||
|
@ -1,5 +1,5 @@
|
||||
from circuits import filtersets, models
|
||||
from netbox.graphql.types import ObjectType, OrganizationalObjectType, PrimaryObjectType
|
||||
from netbox.graphql.types import ObjectType, OrganizationalObjectType, NetBoxObjectType
|
||||
|
||||
__all__ = (
|
||||
'CircuitTerminationType',
|
||||
@ -18,7 +18,7 @@ class CircuitTerminationType(ObjectType):
|
||||
filterset_class = filtersets.CircuitTerminationFilterSet
|
||||
|
||||
|
||||
class CircuitType(PrimaryObjectType):
|
||||
class CircuitType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Circuit
|
||||
@ -34,7 +34,7 @@ class CircuitTypeType(OrganizationalObjectType):
|
||||
filterset_class = filtersets.CircuitTypeFilterSet
|
||||
|
||||
|
||||
class ProviderType(PrimaryObjectType):
|
||||
class ProviderType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Provider
|
||||
@ -42,7 +42,7 @@ class ProviderType(PrimaryObjectType):
|
||||
filterset_class = filtersets.ProviderFilterSet
|
||||
|
||||
|
||||
class ProviderNetworkType(PrimaryObjectType):
|
||||
class ProviderNetworkType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.ProviderNetwork
|
||||
|
@ -6,7 +6,7 @@ from extras.graphql.mixins import (
|
||||
)
|
||||
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
|
||||
from netbox.graphql.scalars import BigInt
|
||||
from netbox.graphql.types import BaseObjectType, OrganizationalObjectType, PrimaryObjectType
|
||||
from netbox.graphql.types import BaseObjectType, OrganizationalObjectType, NetBoxObjectType
|
||||
|
||||
__all__ = (
|
||||
'CableType',
|
||||
@ -85,7 +85,7 @@ class ComponentTemplateObjectType(
|
||||
# Model types
|
||||
#
|
||||
|
||||
class CableType(PrimaryObjectType):
|
||||
class CableType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Cable
|
||||
@ -143,7 +143,7 @@ class ConsoleServerPortTemplateType(ComponentTemplateObjectType):
|
||||
return self.type or None
|
||||
|
||||
|
||||
class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, PrimaryObjectType):
|
||||
class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Device
|
||||
@ -189,7 +189,7 @@ class DeviceRoleType(OrganizationalObjectType):
|
||||
filterset_class = filtersets.DeviceRoleFilterSet
|
||||
|
||||
|
||||
class DeviceTypeType(PrimaryObjectType):
|
||||
class DeviceTypeType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.DeviceType
|
||||
@ -300,7 +300,7 @@ class ModuleBayTemplateType(ComponentTemplateObjectType):
|
||||
filterset_class = filtersets.ModuleBayTemplateFilterSet
|
||||
|
||||
|
||||
class ModuleTypeType(PrimaryObjectType):
|
||||
class ModuleTypeType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.ModuleType
|
||||
@ -316,7 +316,7 @@ class PlatformType(OrganizationalObjectType):
|
||||
filterset_class = filtersets.PlatformFilterSet
|
||||
|
||||
|
||||
class PowerFeedType(PrimaryObjectType):
|
||||
class PowerFeedType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.PowerFeed
|
||||
@ -352,7 +352,7 @@ class PowerOutletTemplateType(ComponentTemplateObjectType):
|
||||
return self.type or None
|
||||
|
||||
|
||||
class PowerPanelType(PrimaryObjectType):
|
||||
class PowerPanelType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.PowerPanel
|
||||
@ -382,7 +382,7 @@ class PowerPortTemplateType(ComponentTemplateObjectType):
|
||||
return self.type or None
|
||||
|
||||
|
||||
class RackType(VLANGroupsMixin, ImageAttachmentsMixin, PrimaryObjectType):
|
||||
class RackType(VLANGroupsMixin, ImageAttachmentsMixin, NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Rack
|
||||
@ -396,7 +396,7 @@ class RackType(VLANGroupsMixin, ImageAttachmentsMixin, PrimaryObjectType):
|
||||
return self.outer_unit or None
|
||||
|
||||
|
||||
class RackReservationType(PrimaryObjectType):
|
||||
class RackReservationType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.RackReservation
|
||||
@ -436,7 +436,7 @@ class RegionType(VLANGroupsMixin, OrganizationalObjectType):
|
||||
filterset_class = filtersets.RegionFilterSet
|
||||
|
||||
|
||||
class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, PrimaryObjectType):
|
||||
class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, NetBoxObjectType):
|
||||
asn = graphene.Field(BigInt)
|
||||
|
||||
class Meta:
|
||||
@ -453,7 +453,7 @@ class SiteGroupType(VLANGroupsMixin, OrganizationalObjectType):
|
||||
filterset_class = filtersets.SiteGroupFilterSet
|
||||
|
||||
|
||||
class VirtualChassisType(PrimaryObjectType):
|
||||
class VirtualChassisType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.VirtualChassis
|
||||
|
@ -2,7 +2,7 @@ import graphene
|
||||
|
||||
from ipam import filtersets, models
|
||||
from netbox.graphql.scalars import BigInt
|
||||
from netbox.graphql.types import BaseObjectType, OrganizationalObjectType, PrimaryObjectType
|
||||
from netbox.graphql.types import BaseObjectType, OrganizationalObjectType, NetBoxObjectType
|
||||
|
||||
__all__ = (
|
||||
'ASNType',
|
||||
@ -23,7 +23,7 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
class ASNType(PrimaryObjectType):
|
||||
class ASNType(NetBoxObjectType):
|
||||
asn = graphene.Field(BigInt)
|
||||
|
||||
class Meta:
|
||||
@ -32,7 +32,7 @@ class ASNType(PrimaryObjectType):
|
||||
filterset_class = filtersets.ASNFilterSet
|
||||
|
||||
|
||||
class AggregateType(PrimaryObjectType):
|
||||
class AggregateType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Aggregate
|
||||
@ -40,7 +40,7 @@ class AggregateType(PrimaryObjectType):
|
||||
filterset_class = filtersets.AggregateFilterSet
|
||||
|
||||
|
||||
class FHRPGroupType(PrimaryObjectType):
|
||||
class FHRPGroupType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.FHRPGroup
|
||||
@ -59,7 +59,7 @@ class FHRPGroupAssignmentType(BaseObjectType):
|
||||
filterset_class = filtersets.FHRPGroupAssignmentFilterSet
|
||||
|
||||
|
||||
class IPAddressType(PrimaryObjectType):
|
||||
class IPAddressType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.IPAddress
|
||||
@ -70,7 +70,7 @@ class IPAddressType(PrimaryObjectType):
|
||||
return self.role or None
|
||||
|
||||
|
||||
class IPRangeType(PrimaryObjectType):
|
||||
class IPRangeType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.IPRange
|
||||
@ -81,7 +81,7 @@ class IPRangeType(PrimaryObjectType):
|
||||
return self.role or None
|
||||
|
||||
|
||||
class PrefixType(PrimaryObjectType):
|
||||
class PrefixType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Prefix
|
||||
@ -105,7 +105,7 @@ class RoleType(OrganizationalObjectType):
|
||||
filterset_class = filtersets.RoleFilterSet
|
||||
|
||||
|
||||
class RouteTargetType(PrimaryObjectType):
|
||||
class RouteTargetType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.RouteTarget
|
||||
@ -113,7 +113,7 @@ class RouteTargetType(PrimaryObjectType):
|
||||
filterset_class = filtersets.RouteTargetFilterSet
|
||||
|
||||
|
||||
class ServiceType(PrimaryObjectType):
|
||||
class ServiceType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Service
|
||||
@ -121,7 +121,7 @@ class ServiceType(PrimaryObjectType):
|
||||
filterset_class = filtersets.ServiceFilterSet
|
||||
|
||||
|
||||
class ServiceTemplateType(PrimaryObjectType):
|
||||
class ServiceTemplateType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.ServiceTemplate
|
||||
@ -129,7 +129,7 @@ class ServiceTemplateType(PrimaryObjectType):
|
||||
filterset_class = filtersets.ServiceTemplateFilterSet
|
||||
|
||||
|
||||
class VLANType(PrimaryObjectType):
|
||||
class VLANType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.VLAN
|
||||
@ -145,7 +145,7 @@ class VLANGroupType(OrganizationalObjectType):
|
||||
filterset_class = filtersets.VLANGroupFilterSet
|
||||
|
||||
|
||||
class VRFType(PrimaryObjectType):
|
||||
class VRFType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.VRF
|
||||
|
@ -5,8 +5,9 @@ from extras.graphql.mixins import ChangelogMixin, CustomFieldsMixin, JournalEntr
|
||||
|
||||
__all__ = (
|
||||
'BaseObjectType',
|
||||
'ObjectType',
|
||||
'OrganizationalObjectType',
|
||||
'PrimaryObjectType',
|
||||
'NetBoxObjectType',
|
||||
)
|
||||
|
||||
|
||||
@ -16,7 +17,7 @@ __all__ = (
|
||||
|
||||
class BaseObjectType(DjangoObjectType):
|
||||
"""
|
||||
Base GraphQL object type for all NetBox objects
|
||||
Base GraphQL object type for all NetBox objects. Restricts the model queryset to enforce object permissions.
|
||||
"""
|
||||
class Meta:
|
||||
abstract = True
|
||||
@ -51,7 +52,7 @@ class OrganizationalObjectType(
|
||||
abstract = True
|
||||
|
||||
|
||||
class PrimaryObjectType(
|
||||
class NetBoxObjectType(
|
||||
ChangelogMixin,
|
||||
CustomFieldsMixin,
|
||||
JournalEntriesMixin,
|
||||
@ -59,7 +60,7 @@ class PrimaryObjectType(
|
||||
BaseObjectType
|
||||
):
|
||||
"""
|
||||
Base type for primary models
|
||||
GraphQL type for most NetBox models. Includes support for custom fields, change logging, journaling, and tags.
|
||||
"""
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
@ -1,7 +1,7 @@
|
||||
import graphene
|
||||
|
||||
from tenancy import filtersets, models
|
||||
from netbox.graphql.types import BaseObjectType, OrganizationalObjectType, PrimaryObjectType
|
||||
from netbox.graphql.types import BaseObjectType, OrganizationalObjectType, NetBoxObjectType
|
||||
|
||||
__all__ = (
|
||||
'ContactAssignmentType',
|
||||
@ -24,7 +24,7 @@ class ContactAssignmentsMixin:
|
||||
# Tenants
|
||||
#
|
||||
|
||||
class TenantType(PrimaryObjectType):
|
||||
class TenantType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Tenant
|
||||
@ -44,7 +44,7 @@ class TenantGroupType(OrganizationalObjectType):
|
||||
# Contacts
|
||||
#
|
||||
|
||||
class ContactType(ContactAssignmentsMixin, PrimaryObjectType):
|
||||
class ContactType(ContactAssignmentsMixin, NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Contact
|
||||
|
@ -1,7 +1,7 @@
|
||||
from dcim.graphql.types import ComponentObjectType
|
||||
from extras.graphql.mixins import ConfigContextMixin
|
||||
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
|
||||
from netbox.graphql.types import OrganizationalObjectType, PrimaryObjectType
|
||||
from netbox.graphql.types import OrganizationalObjectType, NetBoxObjectType
|
||||
from virtualization import filtersets, models
|
||||
|
||||
__all__ = (
|
||||
@ -13,7 +13,7 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
class ClusterType(VLANGroupsMixin, PrimaryObjectType):
|
||||
class ClusterType(VLANGroupsMixin, NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Cluster
|
||||
@ -37,7 +37,7 @@ class ClusterTypeType(OrganizationalObjectType):
|
||||
filterset_class = filtersets.ClusterTypeFilterSet
|
||||
|
||||
|
||||
class VirtualMachineType(ConfigContextMixin, PrimaryObjectType):
|
||||
class VirtualMachineType(ConfigContextMixin, NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.VirtualMachine
|
||||
|
@ -1,5 +1,5 @@
|
||||
from wireless import filtersets, models
|
||||
from netbox.graphql.types import OrganizationalObjectType, PrimaryObjectType
|
||||
from netbox.graphql.types import OrganizationalObjectType, NetBoxObjectType
|
||||
|
||||
__all__ = (
|
||||
'WirelessLANType',
|
||||
@ -16,7 +16,7 @@ class WirelessLANGroupType(OrganizationalObjectType):
|
||||
filterset_class = filtersets.WirelessLANGroupFilterSet
|
||||
|
||||
|
||||
class WirelessLANType(PrimaryObjectType):
|
||||
class WirelessLANType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.WirelessLAN
|
||||
@ -30,7 +30,7 @@ class WirelessLANType(PrimaryObjectType):
|
||||
return self.auth_cipher or None
|
||||
|
||||
|
||||
class WirelessLinkType(PrimaryObjectType):
|
||||
class WirelessLinkType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.WirelessLink
|
||||
|
Reference in New Issue
Block a user