mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
9856 virtualization, vpn, wireless schema
This commit is contained in:
@ -10,9 +10,9 @@ from ipam.graphql.schema import IPAMQuery
|
|||||||
from netbox.registry import registry
|
from netbox.registry import registry
|
||||||
from tenancy.graphql.schema import TenancyQuery
|
from tenancy.graphql.schema import TenancyQuery
|
||||||
from users.graphql.schema import UsersQuery
|
from users.graphql.schema import UsersQuery
|
||||||
# from virtualization.graphql.schema import VirtualizationQuery
|
from virtualization.graphql.schema import VirtualizationQuery
|
||||||
# from vpn.graphql.schema import VPNQuery
|
from vpn.graphql.schema import VPNQuery
|
||||||
# from wireless.graphql.schema import WirelessQuery
|
from wireless.graphql.schema import WirelessQuery
|
||||||
|
|
||||||
|
|
||||||
@strawberry.type
|
@strawberry.type
|
||||||
@ -24,9 +24,9 @@ class Query(
|
|||||||
ExtrasQuery,
|
ExtrasQuery,
|
||||||
IPAMQuery,
|
IPAMQuery,
|
||||||
TenancyQuery,
|
TenancyQuery,
|
||||||
# VirtualizationQuery,
|
VirtualizationQuery,
|
||||||
# VPNQuery,
|
VPNQuery,
|
||||||
# WirelessQuery,
|
WirelessQuery,
|
||||||
*registry['plugins']['graphql_schemas'], # Append plugin schemas
|
*registry['plugins']['graphql_schemas'], # Append plugin schemas
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
import strawberry
|
||||||
|
import strawberry_django
|
||||||
|
from strawberry import auto
|
||||||
|
from virtualization import models, filtersets
|
||||||
|
from netbox.graphql import filters
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = (
|
||||||
|
'ClusterFilter',
|
||||||
|
'ClusterGroupFilter',
|
||||||
|
'ClusterTypeFilter',
|
||||||
|
'VirtualMachineFilter',
|
||||||
|
'VMInterfaceFilter',
|
||||||
|
'VirtualDiskFilter',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.Cluster, lookups=True)
|
||||||
|
class ClusterFilter(filtersets.ClusterFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.ClusterGroup, lookups=True)
|
||||||
|
class ClusterGroupFilter(filtersets.ClusterGroupFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.ClusterType, lookups=True)
|
||||||
|
class ClusterTypeFilter(filtersets.ClusterTypeFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.VirtualMachine, lookups=True)
|
||||||
|
class VirtualMachineFilter(filtersets.VirtualMachineFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.VMInterface, lookups=True)
|
||||||
|
class VMInterfaceFilter(filtersets.VMInterfaceFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.VirtualDisk, lookups=True)
|
||||||
|
class VirtualDiskFilter(filtersets.VirtualDiskFilterSet):
|
||||||
|
id: auto
|
||||||
|
@ -1,44 +1,27 @@
|
|||||||
import graphene
|
from typing import List
|
||||||
|
import strawberry
|
||||||
|
import strawberry_django
|
||||||
|
|
||||||
from netbox.graphql.fields import ObjectField, ObjectListField
|
|
||||||
from .types import *
|
|
||||||
from utilities.graphql_optimizer import gql_query_optimizer
|
|
||||||
from virtualization import models
|
from virtualization import models
|
||||||
|
from .types import *
|
||||||
|
|
||||||
|
|
||||||
class VirtualizationQuery(graphene.ObjectType):
|
@strawberry.type
|
||||||
cluster = ObjectField(ClusterType)
|
class VirtualizationQuery:
|
||||||
cluster_list = ObjectListField(ClusterType)
|
cluster: ClusterType = strawberry_django.field()
|
||||||
|
cluster_list: List[ClusterType] = strawberry_django.field()
|
||||||
|
|
||||||
def resolve_cluster_list(root, info, **kwargs):
|
cluster_group: ClusterGroupType = strawberry_django.field()
|
||||||
return gql_query_optimizer(models.Cluster.objects.all(), info)
|
cluster_group_list: List[ClusterGroupType] = strawberry_django.field()
|
||||||
|
|
||||||
cluster_group = ObjectField(ClusterGroupType)
|
cluster_type: ClusterTypeType = strawberry_django.field()
|
||||||
cluster_group_list = ObjectListField(ClusterGroupType)
|
cluster_type_list: List[ClusterTypeType] = strawberry_django.field()
|
||||||
|
|
||||||
def resolve_cluster_group_list(root, info, **kwargs):
|
virtual_machine: VirtualMachineType = strawberry_django.field()
|
||||||
return gql_query_optimizer(models.ClusterGroup.objects.all(), info)
|
virtual_machine_list: List[VirtualMachineType] = strawberry_django.field()
|
||||||
|
|
||||||
cluster_type = ObjectField(ClusterTypeType)
|
vm_interface: VMInterfaceType = strawberry_django.field()
|
||||||
cluster_type_list = ObjectListField(ClusterTypeType)
|
vm_interface_list: List[VMInterfaceType] = strawberry_django.field()
|
||||||
|
|
||||||
def resolve_cluster_type_list(root, info, **kwargs):
|
virtual_disk: VirtualDiskType = strawberry_django.field()
|
||||||
return gql_query_optimizer(models.ClusterType.objects.all(), info)
|
virtual_disk_list: List[VirtualDiskType] = strawberry_django.field()
|
||||||
|
|
||||||
virtual_machine = ObjectField(VirtualMachineType)
|
|
||||||
virtual_machine_list = ObjectListField(VirtualMachineType)
|
|
||||||
|
|
||||||
def resolve_virtual_machine_list(root, info, **kwargs):
|
|
||||||
return gql_query_optimizer(models.VirtualMachine.objects.all(), info)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
virtual_disk = ObjectField(VirtualDiskType)
|
|
||||||
virtual_disk_list = ObjectListField(VirtualDiskType)
|
|
||||||
|
|
||||||
def resolve_virtual_disk_list(root, info, **kwargs):
|
|
||||||
return gql_query_optimizer(models.VirtualDisk.objects.all(), info)
|
|
||||||
|
@ -47,7 +47,8 @@ class ClusterTypeType(OrganizationalObjectType):
|
|||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
models.VirtualMachine,
|
models.VirtualMachine,
|
||||||
fields='__all__',
|
# fields='__all__',
|
||||||
|
exclude=('_name', 'interface_count', 'virtual_disk_count',), # bug - temp
|
||||||
filters=VirtualMachineFilter
|
filters=VirtualMachineFilter
|
||||||
)
|
)
|
||||||
class VirtualMachineType(ConfigContextMixin, NetBoxObjectType):
|
class VirtualMachineType(ConfigContextMixin, NetBoxObjectType):
|
||||||
@ -56,7 +57,8 @@ class VirtualMachineType(ConfigContextMixin, NetBoxObjectType):
|
|||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
models.VMInterface,
|
models.VMInterface,
|
||||||
fields='__all__',
|
# fields='__all__',
|
||||||
|
exclude=('mac_address', '_name',), # bug - temp
|
||||||
filters=VMInterfaceFilter
|
filters=VMInterfaceFilter
|
||||||
)
|
)
|
||||||
class VMInterfaceType(IPAddressesMixin, ComponentObjectType):
|
class VMInterfaceType(IPAddressesMixin, ComponentObjectType):
|
||||||
@ -67,7 +69,8 @@ class VMInterfaceType(IPAddressesMixin, ComponentObjectType):
|
|||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
models.VirtualDisk,
|
models.VirtualDisk,
|
||||||
fields='__all__',
|
# fields='__all__',
|
||||||
|
exclude=('_name',), # bug - temp
|
||||||
filters=VirtualDiskFilter
|
filters=VirtualDiskFilter
|
||||||
)
|
)
|
||||||
class VirtualDiskType(ComponentObjectType):
|
class VirtualDiskType(ComponentObjectType):
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
import strawberry
|
||||||
|
import strawberry_django
|
||||||
|
from strawberry import auto
|
||||||
|
from vpn import models, filtersets
|
||||||
|
from netbox.graphql import filters
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = (
|
||||||
|
'TunnelGroupFilter',
|
||||||
|
'TunnelTerminationFilter',
|
||||||
|
'TunnelFilter',
|
||||||
|
'IKEProposalFilter',
|
||||||
|
'IKEPolicyFilter',
|
||||||
|
'IPSecProposalFilter',
|
||||||
|
'IPSecPolicyFilter',
|
||||||
|
'IPSecProfileFilter',
|
||||||
|
'L2VPNFilter',
|
||||||
|
'L2VPNTerminationFilter',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.TunnelGroup, lookups=True)
|
||||||
|
class TunnelGroupFilter(filtersets.TunnelGroupFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.TunnelTermination, lookups=True)
|
||||||
|
class TunnelTerminationFilter(filtersets.TunnelTerminationFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.Tunnel, lookups=True)
|
||||||
|
class TunnelFilter(filtersets.TunnelFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.IKEProposal, lookups=True)
|
||||||
|
class IKEProposalFilter(filtersets.IKEProposalFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.IKEPolicy, lookups=True)
|
||||||
|
class IKEPolicyFilter(filtersets.IKEPolicyFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.IPSecProposal, lookups=True)
|
||||||
|
class IPSecProposalFilter(filtersets.IPSecProposalFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.IPSecPolicy, lookups=True)
|
||||||
|
class IPSecPolicyFilter(filtersets.IPSecPolicyFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.IPSecProfile, lookups=True)
|
||||||
|
class IPSecProfileFilter(filtersets.IPSecProfileFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.L2VPN, lookups=True)
|
||||||
|
class L2VPNFilter(filtersets.L2VPNFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.L2VPNTermination, lookups=True)
|
||||||
|
class L2VPNTerminationFilter(filtersets.L2VPNTerminationFilterSet):
|
||||||
|
id: auto
|
||||||
|
@ -1,69 +1,39 @@
|
|||||||
import graphene
|
from typing import List
|
||||||
|
import strawberry
|
||||||
|
import strawberry_django
|
||||||
|
|
||||||
from netbox.graphql.fields import ObjectField, ObjectListField
|
|
||||||
from utilities.graphql_optimizer import gql_query_optimizer
|
|
||||||
from vpn import models
|
from vpn import models
|
||||||
from .types import *
|
from .types import *
|
||||||
|
|
||||||
|
|
||||||
class VPNQuery(graphene.ObjectType):
|
@strawberry.type
|
||||||
|
class VPNQuery:
|
||||||
|
ike_policy: IKEPolicyType = strawberry_django.field()
|
||||||
|
ike_policy_list: List[IKEPolicyType] = strawberry_django.field()
|
||||||
|
|
||||||
ike_policy = ObjectField(IKEPolicyType)
|
ike_proposal: IKEProposalType = strawberry_django.field()
|
||||||
ike_policy_list = ObjectListField(IKEPolicyType)
|
ike_proposal_list: List[IKEProposalType] = strawberry_django.field()
|
||||||
|
|
||||||
def resolve_ike_policy_list(root, info, **kwargs):
|
ipsec_policy: IPSecPolicyType = strawberry_django.field()
|
||||||
return gql_query_optimizer(models.IKEPolicy.objects.all(), info)
|
ipsec_policy_list: List[IPSecPolicyType] = strawberry_django.field()
|
||||||
|
|
||||||
ike_proposal = ObjectField(IKEProposalType)
|
ipsec_profile: IPSecProfileType = strawberry_django.field()
|
||||||
ike_proposal_list = ObjectListField(IKEProposalType)
|
ipsec_profile_list: List[IPSecProfileType] = strawberry_django.field()
|
||||||
|
|
||||||
def resolve_ike_proposal_list(root, info, **kwargs):
|
ipsec_proposal: IPSecProposalType = strawberry_django.field()
|
||||||
return gql_query_optimizer(models.IKEProposal.objects.all(), info)
|
ipsec_proposal_list: List[IPSecProposalType] = strawberry_django.field()
|
||||||
|
|
||||||
ipsec_policy = ObjectField(IPSecPolicyType)
|
l2vpn: L2VPNType = strawberry_django.field()
|
||||||
ipsec_policy_list = ObjectListField(IPSecPolicyType)
|
l2vpn_list: List[L2VPNType] = strawberry_django.field()
|
||||||
|
|
||||||
def resolve_ipsec_policy_list(root, info, **kwargs):
|
l2vpn_termination: L2VPNTerminationType = strawberry_django.field()
|
||||||
return gql_query_optimizer(models.IPSecPolicy.objects.all(), info)
|
l2vpn_termination_list: List[L2VPNTerminationType] = strawberry_django.field()
|
||||||
|
|
||||||
ipsec_profile = ObjectField(IPSecProfileType)
|
tunnel: TunnelType = strawberry_django.field()
|
||||||
ipsec_profile_list = ObjectListField(IPSecProfileType)
|
tunnel_list: List[TunnelType] = strawberry_django.field()
|
||||||
|
|
||||||
def resolve_ipsec_profile_list(root, info, **kwargs):
|
tunnel_group: TunnelGroupType = strawberry_django.field()
|
||||||
return gql_query_optimizer(models.IPSecProfile.objects.all(), info)
|
tunnel_group_list: List[TunnelGroupType] = strawberry_django.field()
|
||||||
|
|
||||||
ipsec_proposal = ObjectField(IPSecProposalType)
|
tunnel_termination: TunnelTerminationType = strawberry_django.field()
|
||||||
ipsec_proposal_list = ObjectListField(IPSecProposalType)
|
tunnel_termination_list: List[TunnelTerminationType] = strawberry_django.field()
|
||||||
|
|
||||||
def resolve_ipsec_proposal_list(root, info, **kwargs):
|
|
||||||
return gql_query_optimizer(models.IPSecProposal.objects.all(), info)
|
|
||||||
|
|
||||||
l2vpn = ObjectField(L2VPNType)
|
|
||||||
l2vpn_list = ObjectListField(L2VPNType)
|
|
||||||
|
|
||||||
def resolve_l2vpn_list(root, info, **kwargs):
|
|
||||||
return gql_query_optimizer(models.L2VPN.objects.all(), info)
|
|
||||||
|
|
||||||
l2vpn_termination = ObjectField(L2VPNTerminationType)
|
|
||||||
l2vpn_termination_list = ObjectListField(L2VPNTerminationType)
|
|
||||||
|
|
||||||
def resolve_l2vpn_termination_list(root, info, **kwargs):
|
|
||||||
return gql_query_optimizer(models.L2VPNTermination.objects.all(), info)
|
|
||||||
|
|
||||||
tunnel = ObjectField(TunnelType)
|
|
||||||
tunnel_list = ObjectListField(TunnelType)
|
|
||||||
|
|
||||||
def resolve_tunnel_list(root, info, **kwargs):
|
|
||||||
return gql_query_optimizer(models.Tunnel.objects.all(), info)
|
|
||||||
|
|
||||||
tunnel_group = ObjectField(TunnelGroupType)
|
|
||||||
tunnel_group_list = ObjectListField(TunnelGroupType)
|
|
||||||
|
|
||||||
def resolve_tunnel_group_list(root, info, **kwargs):
|
|
||||||
return gql_query_optimizer(models.TunnelGroup.objects.all(), info)
|
|
||||||
|
|
||||||
tunnel_termination = ObjectField(TunnelTerminationType)
|
|
||||||
tunnel_termination_list = ObjectListField(TunnelTerminationType)
|
|
||||||
|
|
||||||
def resolve_tunnel_termination_list(root, info, **kwargs):
|
|
||||||
return gql_query_optimizer(models.TunnelTermination.objects.all(), info)
|
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
import strawberry
|
||||||
|
import strawberry_django
|
||||||
|
from strawberry import auto
|
||||||
|
from wireless import models, filtersets
|
||||||
|
from netbox.graphql import filters
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = (
|
||||||
|
'WirelessLANGroupFilter',
|
||||||
|
'WirelessLANFilter',
|
||||||
|
'WirelessLinkFilter',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.WirelessLANGroup, lookups=True)
|
||||||
|
class WirelessLANGroupFilter(filtersets.WirelessLANGroupFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.WirelessLAN, lookups=True)
|
||||||
|
class WirelessLANFilter(filtersets.WirelessLANFilterSet):
|
||||||
|
id: auto
|
||||||
|
|
||||||
|
|
||||||
|
@strawberry_django.filter(models.WirelessLink, lookups=True)
|
||||||
|
class WirelessLinkFilter(filtersets.WirelessLinkFilterSet):
|
||||||
|
id: auto
|
||||||
|
@ -1,26 +1,18 @@
|
|||||||
import graphene
|
from typing import List
|
||||||
|
import strawberry
|
||||||
|
import strawberry_django
|
||||||
|
|
||||||
from netbox.graphql.fields import ObjectField, ObjectListField
|
|
||||||
from .types import *
|
|
||||||
from utilities.graphql_optimizer import gql_query_optimizer
|
|
||||||
from wireless import models
|
from wireless import models
|
||||||
|
from .types import *
|
||||||
|
|
||||||
|
|
||||||
class WirelessQuery(graphene.ObjectType):
|
@strawberry.type
|
||||||
wireless_lan = ObjectField(WirelessLANType)
|
class WirelessQuery:
|
||||||
wireless_lan_list = ObjectListField(WirelessLANType)
|
wireless_lan: WirelessLANType = strawberry_django.field()
|
||||||
|
wireless_lan_list: List[WirelessLANType] = strawberry_django.field()
|
||||||
|
|
||||||
def resolve_wireless_lan_list(root, info, **kwargs):
|
wireless_lan_group: WirelessLANGroupType = strawberry_django.field()
|
||||||
return gql_query_optimizer(models.WirelessLAN.objects.all(), info)
|
wireless_lan_group_list: List[WirelessLANGroupType] = strawberry_django.field()
|
||||||
|
|
||||||
wireless_lan_group = ObjectField(WirelessLANGroupType)
|
wireless_link: WirelessLinkType = strawberry_django.field()
|
||||||
wireless_lan_group_list = ObjectListField(WirelessLANGroupType)
|
wireless_link_list: List[WirelessLinkType] = strawberry_django.field()
|
||||||
|
|
||||||
def resolve_wireless_lan_group_list(root, info, **kwargs):
|
|
||||||
return gql_query_optimizer(models.WirelessLANGroup.objects.all(), info)
|
|
||||||
|
|
||||||
wireless_link = ObjectField(WirelessLinkType)
|
|
||||||
wireless_link_list = ObjectListField(WirelessLinkType)
|
|
||||||
|
|
||||||
def resolve_wireless_link_list(root, info, **kwargs):
|
|
||||||
return gql_query_optimizer(models.WirelessLink.objects.all(), info)
|
|
||||||
|
@ -14,7 +14,8 @@ __all__ = (
|
|||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
models.WirelessLANGroup,
|
models.WirelessLANGroup,
|
||||||
fields='__all__',
|
# fields='__all__',
|
||||||
|
exclude=('parent',), # bug - temp
|
||||||
filters=WirelessLANGroupFilter
|
filters=WirelessLANGroupFilter
|
||||||
)
|
)
|
||||||
class WirelessLANGroupType(OrganizationalObjectType):
|
class WirelessLANGroupType(OrganizationalObjectType):
|
||||||
|
Reference in New Issue
Block a user