11from typing import Annotated , List , Optional
2- import logging
2+
33from circuits .graphql .types import CircuitType , ProviderType
44from dcim .graphql .types import LocationType , SiteType
55from netbox .graphql .types import NetBoxObjectType
66from strawberry import auto , lazy , field
77from strawberry_django import type as strawberry_django_type
88import strawberry
99
10-
1110from cesnet_service_path_plugin .models import (
1211 Segment ,
1312 SegmentCircuitMapping ,
2423)
2524
2625
27- logger = logging .getLogger (__name__ )
28-
29-
3026# Custom scalar types for path geometry data
3127@strawberry .type
3228class PathBounds :
@@ -74,8 +70,6 @@ def has_type_specific_data(self) -> bool:
7470 """Whether this segment has type-specific data"""
7571 if hasattr (self , "has_type_specific_data" ):
7672 return self .has_type_specific_data ()
77- logger .warning ("Segment has no type-specific data" )
78- logger .debug (f"Type-specific data: { self .type_specific_data } " )
7973 return bool (self .type_specific_data )
8074
8175 @field
@@ -92,22 +86,6 @@ def segment_type_display(self) -> Optional[str]:
9286 return self .get_segment_type_display ()
9387 return None
9488
95- @field
96- def type_specific_schema (self ) -> Optional [strawberry .scalars .JSON ]:
97- """Schema for the segment's type"""
98- from cesnet_service_path_plugin .models .segment_types import SEGMENT_TYPE_SCHEMAS
99-
100- if self .segment_type :
101- return SEGMENT_TYPE_SCHEMAS .get (self .segment_type , {})
102- return None
103-
104- @field
105- def has_type_specific_data (self ) -> bool :
106- """Whether this segment has type-specific data"""
107- if hasattr (self , "has_type_specific_data" ):
108- return self .has_type_specific_data ()
109- return bool (self .type_specific_data )
110-
11189 @field
11290 def path_geometry_geojson (self ) -> Optional [strawberry .scalars .JSON ]:
11391 """Path geometry as GeoJSON Feature"""
@@ -155,20 +133,6 @@ def path_bounds(self) -> Optional[PathBounds]:
155133 return PathBounds (xmin = bounds [0 ], ymin = bounds [1 ], xmax = bounds [2 ], ymax = bounds [3 ])
156134 return None
157135
158- @field
159- def path_segment_count (self ) -> int :
160- """Number of path segments in the MultiLineString"""
161- if hasattr (self , "get_path_segment_count" ):
162- return self .get_path_segment_count ()
163- return 0
164-
165- @field
166- def path_total_points (self ) -> int :
167- """Total number of coordinate points across all segments"""
168- if hasattr (self , "get_total_points" ):
169- return self .get_total_points ()
170- return 0
171-
172136
173137@strawberry_django_type (SegmentCircuitMapping , filters = SegmentCircuitMappingFilter )
174138class SegmentCircuitMappingType (NetBoxObjectType ):
0 commit comments