Kaynağa Gözat

#6732 - GraphQL support

Daniel Sheppard 4 yıl önce
ebeveyn
işleme
0ad440fea5
2 değiştirilmiş dosya ile 12 ekleme ve 0 silme
  1. 3 0
      netbox/ipam/graphql/schema.py
  2. 9 0
      netbox/ipam/graphql/types.py

+ 3 - 0
netbox/ipam/graphql/schema.py

@@ -5,6 +5,9 @@ from .types import *
 
 
 class IPAMQuery(graphene.ObjectType):
+    asn = ObjectField(ASNType)
+    asn_list = ObjectListField(ASNType)
+
     aggregate = ObjectField(AggregateType)
     aggregate_list = ObjectListField(AggregateType)
 

+ 9 - 0
netbox/ipam/graphql/types.py

@@ -2,6 +2,7 @@ from ipam import filtersets, models
 from netbox.graphql.types import OrganizationalObjectType, PrimaryObjectType
 
 __all__ = (
+    'ASNType',
     'AggregateType',
     'IPAddressType',
     'IPRangeType',
@@ -16,6 +17,14 @@ __all__ = (
 )
 
 
+class ASNType(PrimaryObjectType):
+
+    class Meta:
+        model = models.ASN
+        fields = '__all__'
+        filterset_class = filtersets.ASNFilterSet
+
+
 class AggregateType(PrimaryObjectType):
 
     class Meta: