1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

39 lines
1.4 KiB
Python
Raw Normal View History

2021-06-25 15:31:43 -04:00
import graphene
from netbox.graphql.fields import ObjectField, ObjectListField
from .types import *
from utilities.graphql_optimizer import gql_query_optimizer
from virtualization import models
2021-06-25 15:31:43 -04:00
class VirtualizationQuery(graphene.ObjectType):
cluster = ObjectField(ClusterType)
cluster_list = ObjectListField(ClusterType)
2021-06-25 15:31:43 -04:00
def resolve_cluster_list(root, info, **kwargs):
return gql_query_optimizer(models.Cluster.objects.all(), info)
2021-06-25 15:31:43 -04:00
cluster_group = ObjectField(ClusterGroupType)
cluster_group_list = ObjectListField(ClusterGroupType)
2021-06-25 15:31:43 -04:00
def resolve_cluster_group_list(root, info, **kwargs):
return gql_query_optimizer(models.ClusterGroup.objects.all(), info)
2021-06-25 15:31:43 -04:00
cluster_type = ObjectField(ClusterTypeType)
cluster_type_list = ObjectListField(ClusterTypeType)
2021-06-25 15:31:43 -04:00
def resolve_cluster_type_list(root, info, **kwargs):
return gql_query_optimizer(models.ClusterType.objects.all(), info)
2021-06-25 15:31:43 -04:00
virtual_machine = ObjectField(VirtualMachineType)
virtual_machine_list = ObjectListField(VirtualMachineType)
2021-06-25 15:31:43 -04:00
def resolve_virtual_machine_list(root, info, **kwargs):
return gql_query_optimizer(models.VirtualMachine.objects.all(), info)
2021-06-25 15:31:43 -04:00
vm_interface = ObjectField(VMInterfaceType)
vm_interface_list = ObjectListField(VMInterfaceType)
def resolve_vm_interface_list(root, info, **kwargs):
return gql_query_optimizer(models.VMInterface.objects.all(), info)