mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-21 12:52:21 -06:00
Add GraphQL for virtualization
This commit is contained in:
0
netbox/virtualization/graphql/__init__.py
Normal file
0
netbox/virtualization/graphql/__init__.py
Normal file
21
netbox/virtualization/graphql/schema.py
Normal file
21
netbox/virtualization/graphql/schema.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import graphene
|
||||
|
||||
from netbox.graphql.fields import ObjectField, ObjectListField
|
||||
from .types import *
|
||||
|
||||
|
||||
class VirtualizationQuery(graphene.ObjectType):
|
||||
cluster = ObjectField(ClusterType)
|
||||
clusters = ObjectListField(ClusterType)
|
||||
|
||||
cluster_group = ObjectField(ClusterGroupType)
|
||||
cluster_groups = ObjectListField(ClusterGroupType)
|
||||
|
||||
cluster_type = ObjectField(ClusterTypeType)
|
||||
cluster_types = ObjectListField(ClusterTypeType)
|
||||
|
||||
virtual_machine = ObjectField(VirtualMachineType)
|
||||
virtual_machines = ObjectListField(VirtualMachineType)
|
||||
|
||||
vm_interface = ObjectField(VMInterfaceType)
|
||||
vm_interfaces = ObjectListField(VMInterfaceType)
|
||||
50
netbox/virtualization/graphql/types.py
Normal file
50
netbox/virtualization/graphql/types.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from virtualization import filtersets, models
|
||||
from netbox.graphql.types import ObjectType, TaggedObjectType
|
||||
|
||||
__all__ = (
|
||||
'ClusterType',
|
||||
'ClusterGroupType',
|
||||
'ClusterTypeType',
|
||||
'VirtualMachineType',
|
||||
'VMInterfaceType',
|
||||
)
|
||||
|
||||
|
||||
class ClusterType(TaggedObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.Cluster
|
||||
fields = '__all__'
|
||||
filterset_class = filtersets.ClusterFilterSet
|
||||
|
||||
|
||||
class ClusterGroupType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.ClusterGroup
|
||||
fields = '__all__'
|
||||
filterset_class = filtersets.ClusterGroupFilterSet
|
||||
|
||||
|
||||
class ClusterTypeType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.ClusterType
|
||||
fields = '__all__'
|
||||
filterset_class = filtersets.ClusterTypeFilterSet
|
||||
|
||||
|
||||
class VirtualMachineType(TaggedObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.VirtualMachine
|
||||
fields = '__all__'
|
||||
filterset_class = filtersets.VirtualMachineFilterSet
|
||||
|
||||
|
||||
class VMInterfaceType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.VMInterface
|
||||
fields = '__all__'
|
||||
filterset_class = filtersets.VMInterfaceFilterSet
|
||||
Reference in New Issue
Block a user