mirror of
https://github.com/netbox-community/netbox.git
synced 2026-02-05 14:56:24 -06:00
Add GraphQL for tenancy
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import graphene
|
||||
|
||||
from netbox.graphql.fields import ObjectField, ObjectListField
|
||||
from .types import *
|
||||
|
||||
|
||||
class TenancyQuery(graphene.ObjectType):
|
||||
tenant = ObjectField(TenantType)
|
||||
tenants = ObjectListField(TenantType)
|
||||
|
||||
tenant_group = ObjectField(TenantGroupType)
|
||||
tenant_groups = ObjectListField(TenantGroupType)
|
||||
@@ -0,0 +1,23 @@
|
||||
from tenancy import filtersets, models
|
||||
from netbox.graphql.types import ObjectType, TaggedObjectType
|
||||
|
||||
__all__ = (
|
||||
'TenantType',
|
||||
'TenantGroupType',
|
||||
)
|
||||
|
||||
|
||||
class TenantType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Tenant
|
||||
fields = '__all__'
|
||||
filterset_class = filtersets.TenantFilterSet
|
||||
|
||||
|
||||
class TenantGroupType(TaggedObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.TenantGroup
|
||||
fields = '__all__'
|
||||
filterset_class = filtersets.TenantGroupFilterSet
|
||||
Reference in New Issue
Block a user