Przeglądaj źródła

Merge pull request #21299 from netbox-community/20172-ability-to-query-for-cabled-interfaces-via-graphql

Closes #20172: Add `cabled` filter for DCIM interfaces in GraphQL
bctiemann 2 tygodni temu
rodzic
commit
7e3b60f194
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      netbox/dcim/graphql/filters.py

+ 4 - 0
netbox/dcim/graphql/filters.py

@@ -550,6 +550,10 @@ class InterfaceFilter(
         strawberry_django.filter_field()
         strawberry_django.filter_field()
     )
     )
 
 
+    @strawberry_django.filter_field
+    def cabled(self, value: bool, prefix: str):
+        return Q(**{f'{prefix}cable__isnull': (not value)})
+
     @strawberry_django.filter_field
     @strawberry_django.filter_field
     def connected(self, queryset, value: bool, prefix: str):
     def connected(self, queryset, value: bool, prefix: str):
         if value is True:
         if value is True: