1010from enum import auto
1111from io import StringIO
1212from typing import Any , Generic , Literal , TypeVar , cast
13- from uuid import UUID
1413
1514import geoengine_openapi_client
1615from strenum import LowercaseStrEnum
@@ -183,7 +182,7 @@ def parse_listing(response: geoengine_openapi_client.CollectionItem) -> Listing:
183182 layer_id_response = cast (geoengine_openapi_client .ProviderLayerId , inner .id )
184183 return LayerListing (
185184 listing_id = LayerId (layer_id_response .layer_id ),
186- provider_id = LayerProviderId (UUID ( layer_id_response .provider_id ) ),
185+ provider_id = LayerProviderId (layer_id_response .provider_id ),
187186 name = inner .name ,
188187 description = inner .description ,
189188 )
@@ -192,7 +191,7 @@ def parse_listing(response: geoengine_openapi_client.CollectionItem) -> Listing:
192191 collection_id_response = cast (geoengine_openapi_client .ProviderLayerCollectionId , inner .id )
193192 return LayerCollectionListing (
194193 listing_id = LayerCollectionId (collection_id_response .collection_id ),
195- provider_id = LayerProviderId (UUID ( collection_id_response .provider_id ) ),
194+ provider_id = LayerProviderId (collection_id_response .provider_id ),
196195 name = inner .name ,
197196 description = inner .description ,
198197 )
@@ -210,7 +209,7 @@ def parse_listing(response: geoengine_openapi_client.CollectionItem) -> Listing:
210209 name = response .name ,
211210 description = response .description ,
212211 collection_id = LayerCollectionId (response .id .collection_id ),
213- provider_id = LayerProviderId (UUID ( response .id .provider_id ) ),
212+ provider_id = LayerProviderId (response .id .provider_id ),
214213 items = items ,
215214 )
216215
@@ -291,7 +290,8 @@ def add_layer(
291290 self ,
292291 name : str ,
293292 description : str ,
294- workflow : dict [str , Any ] | WorkflowBuilderOperator , # TODO: improve type
293+ # TODO: improve type
294+ workflow : dict [str , Any ] | WorkflowBuilderOperator ,
295295 symbology : Symbology | None ,
296296 timeout : int = 60 ,
297297 ) -> LayerId :
@@ -318,7 +318,8 @@ def add_layer_with_permissions(
318318 self ,
319319 name : str ,
320320 description : str ,
321- workflow : dict [str , Any ] | WorkflowBuilderOperator , # TODO: improve type
321+ # TODO: improve type
322+ workflow : dict [str , Any ] | WorkflowBuilderOperator ,
322323 symbology : Symbology | None ,
323324 permission_tuples : list [tuple [RoleId , Permission ]] | None = None ,
324325 timeout : int = 60 ,
@@ -397,7 +398,8 @@ def add_existing_collection(
397398 collection_id = existing_collection .listing_id
398399 elif isinstance (existing_collection , LayerCollection ):
399400 collection_id = existing_collection .collection_id
400- elif isinstance (existing_collection , str ): # TODO: check for LayerId in Python 3.11+
401+ # TODO: check for LayerId in Python 3.11+
402+ elif isinstance (existing_collection , str ):
401403 collection_id = existing_collection
402404 else :
403405 raise InputException ("Invalid collection type" )
@@ -446,7 +448,7 @@ def search(
446448 with geoengine_openapi_client .ApiClient (session .configuration ) as api_client :
447449 layers_api = geoengine_openapi_client .LayersApi (api_client )
448450 layer_collection_response = layers_api .search_handler (
449- provider = str ( self .provider_id ) ,
451+ provider = self .provider_id ,
450452 collection = str (self .collection_id ),
451453 search_string = search_string ,
452454 search_type = geoengine_openapi_client .SearchType (search_type ),
@@ -464,7 +466,7 @@ def search(
464466 listings .append (
465467 LayerCollectionListing (
466468 listing_id = LayerCollectionId (inner .id .collection_id ),
467- provider_id = LayerProviderId (UUID ( inner .id .provider_id ) ),
469+ provider_id = LayerProviderId (inner .id .provider_id ),
468470 name = inner .name ,
469471 description = inner .description ,
470472 )
@@ -473,7 +475,7 @@ def search(
473475 listings .append (
474476 LayerListing (
475477 listing_id = LayerId (inner .id .layer_id ),
476- provider_id = LayerProviderId (UUID ( inner .id .provider_id ) ),
478+ provider_id = LayerProviderId (inner .id .provider_id ),
477479 name = inner .name ,
478480 description = inner .description ,
479481 )
@@ -529,7 +531,8 @@ def get_or_create_unique_collection(
529531 if isinstance (res , Layer ):
530532 raise TypeError (f"Found a Layer not a Layer collection for { collection_name } " )
531533
532- return cast (LayerCollection , existing_collections [0 ].load ()) # we know that it is a collection since check that
534+ # we know that it is a collection since check that
535+ return cast (LayerCollection , existing_collections [0 ].load ())
533536
534537 def __eq__ (self , other ):
535538 """Tests if two layer listings are identical"""
@@ -594,7 +597,7 @@ def from_response(cls, response: geoengine_openapi_client.Layer) -> Layer:
594597 name = response .name ,
595598 description = response .description ,
596599 layer_id = LayerId (response .id .layer_id ),
597- provider_id = LayerProviderId (UUID ( response .id .provider_id ) ),
600+ provider_id = LayerProviderId (response .id .provider_id ),
598601 workflow = response .workflow .to_dict (),
599602 symbology = symbology ,
600603 properties = cast (list [Any ], response .properties ),
@@ -656,7 +659,7 @@ def save_as_dataset(self, timeout: int = 60) -> Task:
656659
657660 with geoengine_openapi_client .ApiClient (session .configuration ) as api_client :
658661 layers_api = geoengine_openapi_client .LayersApi (api_client )
659- response = layers_api .layer_to_dataset (str ( self .provider_id ) , str (self .layer_id ), _request_timeout = timeout )
662+ response = layers_api .layer_to_dataset (self .provider_id , str (self .layer_id ), _request_timeout = timeout )
660663
661664 return Task (TaskId .from_response (response ))
662665
@@ -684,7 +687,7 @@ def as_workflow_id(self, timeout: int = 60) -> WorkflowId:
684687 with geoengine_openapi_client .ApiClient (session .configuration ) as api_client :
685688 layers_api = geoengine_openapi_client .LayersApi (api_client )
686689 response = layers_api .layer_to_workflow_id_handler (
687- str ( self .provider_id ) , self .layer_id , _request_timeout = timeout
690+ self .provider_id , self .layer_id , _request_timeout = timeout
688691 )
689692
690693 return WorkflowId .from_response (response )
@@ -721,11 +724,12 @@ def layer_collection(
721724 page = layers_api .list_root_collections_handler (offset , page_limit , _request_timeout = timeout )
722725 else :
723726 page = layers_api .list_collection_handler (
724- str ( layer_provider_id ) , layer_collection_id , offset , page_limit , _request_timeout = timeout
727+ layer_provider_id , layer_collection_id , offset , page_limit , _request_timeout = timeout
725728 )
726729
727730 if len (page .items ) < page_limit :
728- if len (pages ) == 0 or len (page .items ) > 0 : # we need at least one page before breaking
731+ # we need at least one page before breaking
732+ if len (pages ) == 0 or len (page .items ) > 0 :
729733 pages .append (page )
730734 break
731735
@@ -744,7 +748,7 @@ def layer(layer_id: LayerId, layer_provider_id: LayerProviderId = LAYER_DB_PROVI
744748
745749 with geoengine_openapi_client .ApiClient (session .configuration ) as api_client :
746750 layers_api = geoengine_openapi_client .LayersApi (api_client )
747- response = layers_api .layer_handler (str ( layer_provider_id ) , str (layer_id ), _request_timeout = timeout )
751+ response = layers_api .layer_handler (layer_provider_id , str (layer_id ), _request_timeout = timeout )
748752
749753 return Layer .from_response (response )
750754
@@ -799,7 +803,7 @@ def _add_layer_collection_to_collection(
799803 _request_timeout = timeout ,
800804 )
801805
802- return LayerCollectionId (response .id )
806+ return LayerCollectionId (str ( response .id ) )
803807
804808
805809def _add_existing_layer_collection_to_collection (
@@ -843,7 +847,7 @@ def _add_layer_to_collection(
843847 _request_timeout = timeout ,
844848 )
845849
846- return LayerId (response .id )
850+ return LayerId (str ( response .id ) )
847851
848852
849853def _add_existing_layer_to_collection (layer_id : LayerId , collection_id : LayerCollectionId , timeout : int = 60 ) -> None :
0 commit comments