mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-22 11:38:45 -06:00
Clone all GraphQL objects to V1 versions
This commit is contained in:
192
netbox/vpn/graphql/filters_v1.py
Normal file
192
netbox/vpn/graphql/filters_v1.py
Normal file
@@ -0,0 +1,192 @@
|
||||
from typing import Annotated, TYPE_CHECKING
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
from strawberry.scalars import ID
|
||||
from strawberry_django import FilterLookup
|
||||
|
||||
from core.graphql.filter_mixins_v1 import BaseObjectTypeFilterMixinV1, ChangeLogFilterMixinV1
|
||||
from extras.graphql.filter_mixins_v1 import CustomFieldsFilterMixinV1, TagsFilterMixinV1
|
||||
from netbox.graphql.filter_mixins_v1 import (
|
||||
NetBoxModelFilterMixinV1, OrganizationalModelFilterMixinV1, PrimaryModelFilterMixinV1
|
||||
)
|
||||
from tenancy.graphql.filter_mixins_v1 import ContactFilterMixinV1, TenancyFilterMixinV1
|
||||
from vpn import models
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.graphql.filters_v1 import ContentTypeFilterV1
|
||||
from ipam.graphql.filters_v1 import IPAddressFilterV1, RouteTargetFilterV1
|
||||
from netbox.graphql.filter_lookups import IntegerLookup
|
||||
from .enums import *
|
||||
|
||||
__all__ = (
|
||||
'TunnelGroupFilterV1',
|
||||
'TunnelTerminationFilterV1',
|
||||
'TunnelFilterV1',
|
||||
'IKEProposalFilterV1',
|
||||
'IKEPolicyFilterV1',
|
||||
'IPSecProposalFilterV1',
|
||||
'IPSecPolicyFilterV1',
|
||||
'IPSecProfileFilterV1',
|
||||
'L2VPNFilterV1',
|
||||
'L2VPNTerminationFilterV1',
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.TunnelGroup, lookups=True)
|
||||
class TunnelGroupFilterV1(OrganizationalModelFilterMixinV1):
|
||||
pass
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.TunnelTermination, lookups=True)
|
||||
class TunnelTerminationFilterV1(
|
||||
BaseObjectTypeFilterMixinV1, CustomFieldsFilterMixinV1, TagsFilterMixinV1, ChangeLogFilterMixinV1
|
||||
):
|
||||
tunnel: Annotated['TunnelFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
tunnel_id: ID | None = strawberry_django.filter_field()
|
||||
role: Annotated['TunnelTerminationRoleEnum', strawberry.lazy('vpn.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
termination_type: Annotated['TunnelTerminationTypeEnum', strawberry.lazy('vpn.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
termination_type_id: ID | None = strawberry_django.filter_field()
|
||||
termination_id: ID | None = strawberry_django.filter_field()
|
||||
outside_ip: Annotated['IPAddressFilterV1', strawberry.lazy('ipam.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
outside_ip_id: ID | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.Tunnel, lookups=True)
|
||||
class TunnelFilterV1(TenancyFilterMixinV1, PrimaryModelFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
status: Annotated['TunnelStatusEnum', strawberry.lazy('vpn.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
group: Annotated['TunnelGroupFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
group_id: ID | None = strawberry_django.filter_field()
|
||||
encapsulation: Annotated['TunnelEncapsulationEnum', strawberry.lazy('vpn.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
ipsec_profile: Annotated['IPSecProfileFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
tunnel_id: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
terminations: Annotated['TunnelTerminationFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.IKEProposal, lookups=True)
|
||||
class IKEProposalFilterV1(PrimaryModelFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
authentication_method: Annotated['AuthenticationMethodEnum', strawberry.lazy('vpn.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
encryption_algorithm: Annotated['EncryptionAlgorithmEnum', strawberry.lazy('vpn.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
authentication_algorithm: Annotated['AuthenticationAlgorithmEnum', strawberry.lazy('vpn.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
group: Annotated['DHGroupEnum', strawberry.lazy('vpn.graphql.enums')] | None = strawberry_django.filter_field()
|
||||
sa_lifetime: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
ike_policies: Annotated['IKEPolicyFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.IKEPolicy, lookups=True)
|
||||
class IKEPolicyFilterV1(PrimaryModelFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
version: Annotated['IKEVersionEnum', strawberry.lazy('vpn.graphql.enums')] | None = strawberry_django.filter_field()
|
||||
mode: Annotated['IKEModeEnum', strawberry.lazy('vpn.graphql.enums')] | None = strawberry_django.filter_field()
|
||||
proposals: Annotated['IKEProposalFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
preshared_key: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.IPSecProposal, lookups=True)
|
||||
class IPSecProposalFilterV1(PrimaryModelFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
encryption_algorithm: Annotated['EncryptionAlgorithmEnum', strawberry.lazy('vpn.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
authentication_algorithm: Annotated['AuthenticationAlgorithmEnum', strawberry.lazy('vpn.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
sa_lifetime_seconds: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
sa_lifetime_data: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
ipsec_policies: Annotated['IPSecPolicyFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.IPSecPolicy, lookups=True)
|
||||
class IPSecPolicyFilterV1(PrimaryModelFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
proposals: Annotated['IPSecProposalFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
pfs_group: Annotated['DHGroupEnum', strawberry.lazy('vpn.graphql.enums')] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.IPSecProfile, lookups=True)
|
||||
class IPSecProfileFilterV1(PrimaryModelFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
mode: Annotated['IPSecModeEnum', strawberry.lazy('vpn.graphql.enums')] | None = strawberry_django.filter_field()
|
||||
ike_policy: Annotated['IKEPolicyFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
ike_policy_id: ID | None = strawberry_django.filter_field()
|
||||
ipsec_policy: Annotated['IPSecPolicyFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
ipsec_policy_id: ID | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.L2VPN, lookups=True)
|
||||
class L2VPNFilterV1(ContactFilterMixinV1, TenancyFilterMixinV1, PrimaryModelFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
slug: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
type: Annotated['L2VPNTypeEnum', strawberry.lazy('vpn.graphql.enums')] | None = strawberry_django.filter_field()
|
||||
identifier: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
import_targets: Annotated['RouteTargetFilterV1', strawberry.lazy('ipam.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
export_targets: Annotated['RouteTargetFilterV1', strawberry.lazy('ipam.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
terminations: Annotated['L2VPNTerminationFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.L2VPNTermination, lookups=True)
|
||||
class L2VPNTerminationFilterV1(NetBoxModelFilterMixinV1):
|
||||
l2vpn: Annotated['L2VPNFilterV1', strawberry.lazy('vpn.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
l2vpn_id: ID | None = strawberry_django.filter_field()
|
||||
assigned_object_type: Annotated['ContentTypeFilterV1', strawberry.lazy('core.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
assigned_object_id: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
39
netbox/vpn/graphql/schema_v1.py
Normal file
39
netbox/vpn/graphql/schema_v1.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from typing import List
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
|
||||
from .types_v1 import *
|
||||
|
||||
|
||||
@strawberry.type(name="Query")
|
||||
class VPNQueryV1:
|
||||
ike_policy: IKEPolicyTypeV1 = strawberry_django.field()
|
||||
ike_policy_list: List[IKEPolicyTypeV1] = strawberry_django.field()
|
||||
|
||||
ike_proposal: IKEProposalTypeV1 = strawberry_django.field()
|
||||
ike_proposal_list: List[IKEProposalTypeV1] = strawberry_django.field()
|
||||
|
||||
ipsec_policy: IPSecPolicyTypeV1 = strawberry_django.field()
|
||||
ipsec_policy_list: List[IPSecPolicyTypeV1] = strawberry_django.field()
|
||||
|
||||
ipsec_profile: IPSecProfileTypeV1 = strawberry_django.field()
|
||||
ipsec_profile_list: List[IPSecProfileTypeV1] = strawberry_django.field()
|
||||
|
||||
ipsec_proposal: IPSecProposalTypeV1 = strawberry_django.field()
|
||||
ipsec_proposal_list: List[IPSecProposalTypeV1] = strawberry_django.field()
|
||||
|
||||
l2vpn: L2VPNTypeV1 = strawberry_django.field()
|
||||
l2vpn_list: List[L2VPNTypeV1] = strawberry_django.field()
|
||||
|
||||
l2vpn_termination: L2VPNTerminationTypeV1 = strawberry_django.field()
|
||||
l2vpn_termination_list: List[L2VPNTerminationTypeV1] = strawberry_django.field()
|
||||
|
||||
tunnel: TunnelTypeV1 = strawberry_django.field()
|
||||
tunnel_list: List[TunnelTypeV1] = strawberry_django.field()
|
||||
|
||||
tunnel_group: TunnelGroupTypeV1 = strawberry_django.field()
|
||||
tunnel_group_list: List[TunnelGroupTypeV1] = strawberry_django.field()
|
||||
|
||||
tunnel_termination: TunnelTerminationTypeV1 = strawberry_django.field()
|
||||
tunnel_termination_list: List[TunnelTerminationTypeV1] = strawberry_django.field()
|
||||
157
netbox/vpn/graphql/types_v1.py
Normal file
157
netbox/vpn/graphql/types_v1.py
Normal file
@@ -0,0 +1,157 @@
|
||||
from typing import Annotated, List, TYPE_CHECKING, Union
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
|
||||
from extras.graphql.mixins_v1 import ContactsMixinV1, CustomFieldsMixinV1, TagsMixinV1
|
||||
from netbox.graphql.types_v1 import ObjectTypeV1, OrganizationalObjectTypeV1, NetBoxObjectTypeV1
|
||||
from vpn import models
|
||||
from .filters_v1 import *
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dcim.graphql.types_v1 import InterfaceTypeV1
|
||||
from ipam.graphql.types_v1 import IPAddressTypeV1, RouteTargetTypeV1, VLANTypeV1
|
||||
from netbox.graphql.types_v1 import ContentTypeTypeV1
|
||||
from tenancy.graphql.types_v1 import TenantTypeV1
|
||||
from virtualization.graphql.types_v1 import VMInterfaceTypeV1
|
||||
|
||||
__all__ = (
|
||||
'IKEPolicyTypeV1',
|
||||
'IKEProposalTypeV1',
|
||||
'IPSecPolicyTypeV1',
|
||||
'IPSecProfileTypeV1',
|
||||
'IPSecProposalTypeV1',
|
||||
'L2VPNTypeV1',
|
||||
'L2VPNTerminationTypeV1',
|
||||
'TunnelGroupTypeV1',
|
||||
'TunnelTerminationTypeV1',
|
||||
'TunnelTypeV1',
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.TunnelGroup,
|
||||
fields='__all__',
|
||||
filters=TunnelGroupFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class TunnelGroupTypeV1(ContactsMixinV1, OrganizationalObjectTypeV1):
|
||||
|
||||
tunnels: List[Annotated["TunnelTypeV1", strawberry.lazy('vpn.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.TunnelTermination,
|
||||
fields='__all__',
|
||||
filters=TunnelTerminationFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class TunnelTerminationTypeV1(CustomFieldsMixinV1, TagsMixinV1, ObjectTypeV1):
|
||||
tunnel: Annotated["TunnelTypeV1", strawberry.lazy('vpn.graphql.types_v1')]
|
||||
termination_type: Annotated["ContentTypeTypeV1", strawberry.lazy('netbox.graphql.types_v1')] | None
|
||||
outside_ip: Annotated["IPAddressTypeV1", strawberry.lazy('ipam.graphql.types_v1')] | None
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.Tunnel,
|
||||
fields='__all__',
|
||||
filters=TunnelFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class TunnelTypeV1(ContactsMixinV1, NetBoxObjectTypeV1):
|
||||
group: Annotated["TunnelGroupTypeV1", strawberry.lazy('vpn.graphql.types_v1')] | None
|
||||
ipsec_profile: Annotated["IPSecProfileTypeV1", strawberry.lazy('vpn.graphql.types_v1')] | None
|
||||
tenant: Annotated["TenantTypeV1", strawberry.lazy('tenancy.graphql.types_v1')] | None
|
||||
|
||||
terminations: List[Annotated["TunnelTerminationTypeV1", strawberry.lazy('vpn.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.IKEProposal,
|
||||
fields='__all__',
|
||||
filters=IKEProposalFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class IKEProposalTypeV1(OrganizationalObjectTypeV1):
|
||||
|
||||
ike_policies: List[Annotated["IKEPolicyTypeV1", strawberry.lazy('vpn.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.IKEPolicy,
|
||||
fields='__all__',
|
||||
filters=IKEPolicyFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class IKEPolicyTypeV1(OrganizationalObjectTypeV1):
|
||||
|
||||
proposals: List[Annotated["IKEProposalTypeV1", strawberry.lazy('vpn.graphql.types_v1')]]
|
||||
ipsec_profiles: List[Annotated["IPSecProfileTypeV1", strawberry.lazy('vpn.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.IPSecProposal,
|
||||
fields='__all__',
|
||||
filters=IPSecProposalFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class IPSecProposalTypeV1(OrganizationalObjectTypeV1):
|
||||
|
||||
ipsec_policies: List[Annotated["IPSecPolicyTypeV1", strawberry.lazy('vpn.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.IPSecPolicy,
|
||||
fields='__all__',
|
||||
filters=IPSecPolicyFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class IPSecPolicyTypeV1(OrganizationalObjectTypeV1):
|
||||
|
||||
proposals: List[Annotated["IPSecProposalTypeV1", strawberry.lazy('vpn.graphql.types_v1')]]
|
||||
ipsec_profiles: List[Annotated["IPSecProfileTypeV1", strawberry.lazy('vpn.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.IPSecProfile,
|
||||
fields='__all__',
|
||||
filters=IPSecProfileFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class IPSecProfileTypeV1(OrganizationalObjectTypeV1):
|
||||
ike_policy: Annotated["IKEPolicyTypeV1", strawberry.lazy('vpn.graphql.types_v1')]
|
||||
ipsec_policy: Annotated["IPSecPolicyTypeV1", strawberry.lazy('vpn.graphql.types_v1')]
|
||||
|
||||
tunnels: List[Annotated["TunnelTypeV1", strawberry.lazy('vpn.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.L2VPN,
|
||||
fields='__all__',
|
||||
filters=L2VPNFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class L2VPNTypeV1(ContactsMixinV1, NetBoxObjectTypeV1):
|
||||
tenant: Annotated["TenantTypeV1", strawberry.lazy('tenancy.graphql.types_v1')] | None
|
||||
|
||||
export_targets: List[Annotated["RouteTargetTypeV1", strawberry.lazy('ipam.graphql.types_v1')]]
|
||||
terminations: List[Annotated["L2VPNTerminationTypeV1", strawberry.lazy('vpn.graphql.types_v1')]]
|
||||
import_targets: List[Annotated["RouteTargetTypeV1", strawberry.lazy('ipam.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.L2VPNTermination,
|
||||
exclude=['assigned_object_type', 'assigned_object_id'],
|
||||
filters=L2VPNTerminationFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class L2VPNTerminationTypeV1(NetBoxObjectTypeV1):
|
||||
l2vpn: Annotated["L2VPNTypeV1", strawberry.lazy('vpn.graphql.types_v1')]
|
||||
|
||||
@strawberry_django.field
|
||||
def assigned_object(self) -> Annotated[Union[
|
||||
Annotated["InterfaceTypeV1", strawberry.lazy('dcim.graphql.types_v1')],
|
||||
Annotated["VLANTypeV1", strawberry.lazy('ipam.graphql.types_v1')],
|
||||
Annotated["VMInterfaceTypeV1", strawberry.lazy('virtualization.graphql.types_v1')],
|
||||
], strawberry.union("L2VPNAssignmentTypeV1")]:
|
||||
return self.assigned_object
|
||||
Reference in New Issue
Block a user