diff --git a/felt_python/__init__.py b/felt_python/__init__.py index 916e9a4..e8c6c6c 100644 --- a/felt_python/__init__.py +++ b/felt_python/__init__.py @@ -85,6 +85,7 @@ # Maps "create_map", "delete_map", + "get_map", "update_map", "move_map", "create_embed_token", @@ -115,6 +116,7 @@ "publish_layer_group", # Elements "list_elements", + "get_element_group", "list_element_groups", "upsert_elements", "delete_element", diff --git a/felt_python/elements.py b/felt_python/elements.py index cd92c68..20525ba 100644 --- a/felt_python/elements.py +++ b/felt_python/elements.py @@ -73,14 +73,14 @@ def get_element_group(map_id: str, element_group_id: str, api_token: str | None def list_elements_in_group( map_id: str, element_group_id: str, api_token: str | None = None ): - get_element_group(map_id, element_group_id, api_token) + return get_element_group(map_id, element_group_id, api_token) @deprecated(reason="Please use `upsert_elements` instead") def post_elements( map_id: str, geojson_feature_collection: dict | str, api_token: str | None = None ): - upsert_elements(map_id, geojson_feature_collection, api_token) + return upsert_elements(map_id, geojson_feature_collection, api_token) def upsert_elements( @@ -132,12 +132,12 @@ def post_element_group( json_element: dict | str, api_token: str | None = None, ): - upsert_element_groups(map_id, json_element, api_token) + return upsert_element_groups(map_id, json_element, api_token) def upsert_element_groups( map_id: str, - element_groups: list[dict[str, str]], + element_groups: list[dict], api_token: str | None = None, ): """Post multiple element groups diff --git a/felt_python/layer_groups.py b/felt_python/layer_groups.py index e96df51..8029454 100644 --- a/felt_python/layer_groups.py +++ b/felt_python/layer_groups.py @@ -103,7 +103,7 @@ def delete_layer_group( def publish_layer_group( map_id: str, layer_group_id: str, - name: str = None, + name: str | None = None, api_token: str | None = None, ): """Publish a layer group to the Felt library diff --git a/felt_python/layers.py b/felt_python/layers.py index bd52692..03958e8 100644 --- a/felt_python/layers.py +++ b/felt_python/layers.py @@ -6,8 +6,8 @@ import tempfile import typing import urllib.request +import urllib.parse import uuid -import typing from urllib.parse import urljoin @@ -43,11 +43,11 @@ def upload_file( map_id: str, file_name: str, layer_name: str, - metadata: dict[str, str] = None, - hints: list[dict[str, str]] = None, - lat: float = None, - lng: float = None, - zoom: float = None, + metadata: dict[str, str | None] | None = None, + hints: list[dict[str, str]] | None = None, + lat: float | None = None, + lng: float | None = None, + zoom: float | None = None, api_token: str | None = None, ): """Upload a file to a Felt map @@ -93,8 +93,8 @@ def upload_dataframe( map_id: str, dataframe: "pd.DataFrame", layer_name: str, - metadata: dict[str, str] = None, - hints: list[dict[str, str]] = None, + metadata: dict[str, str | None] | None = None, + hints: list[dict[str, str]] | None = None, api_token: str | None = None, ): """Upload a Pandas DataFrame to a Felt map""" @@ -115,8 +115,8 @@ def upload_geodataframe( map_id: str, geodataframe: "gpd.GeoDataFrame", layer_name: str, - metadata: dict[str, str] = None, - hints: list[dict[str, str]] = None, + metadata: dict[str, str | None] | None = None, + hints: list[dict[str, str]] | None = None, api_token: str | None = None, ): """Upload a GeoPandas GeoDataFrame to a Felt map""" @@ -159,8 +159,8 @@ def upload_url( map_id: str, layer_url: str, layer_name: str, - metadata: dict[str, str] = None, - hints: list[dict[str, str]] = None, + metadata: dict[str, str | None] | None = None, + hints: list[dict[str, str]] | None = None, api_token: str | None = None, ): """Upload a URL to a Felt map @@ -209,8 +209,8 @@ def refresh_url_layer(map_id: str, layer_id: str, api_token: str | None = None): @deprecated(reason="Please use `get_layer` instead") -def get_layer_details(map_id: str, api_token: str | None = None): - get_layer(map_id, api_token) +def get_layer_details(map_id: str, layer_id: str, api_token: str | None = None): + return get_layer(map_id, layer_id, api_token) def get_layer( @@ -331,7 +331,7 @@ def delete_layer( def publish_layer( map_id: str, layer_id: str, - name: str = None, + name: str | None = None, api_token: str | None = None, ): """Publish a layer to the Felt library @@ -362,7 +362,7 @@ def create_custom_export( map_id: str, layer_id: str, output_format: str, - filters: list = None, + filters: list | None = None, email_on_completion: bool = True, api_token: str | None = None, ): diff --git a/felt_python/maps.py b/felt_python/maps.py index 11b41ac..258392f 100644 --- a/felt_python/maps.py +++ b/felt_python/maps.py @@ -17,16 +17,16 @@ def create_map( - title: str = None, - description: str = None, - public_access: str = None, - basemap: str = None, - lat: float = None, - lon: float = None, - zoom: float = None, - layer_urls: list[str] = None, - workspace_id: str = None, - api_token: str = None, + title: str | None = None, + description: str | None = None, + public_access: str | None = None, + basemap: str | None = None, + lat: float | None = None, + lon: float | None = None, + zoom: float | None = None, + layer_urls: list[str] | None = None, + workspace_id: str | None = None, + api_token: str | None = None, ): """Create a new Felt map @@ -111,10 +111,10 @@ def get_map_details(map_id: str, api_token: str | None = None): def update_map( map_id: str, - title: str = None, - description: str = None, - public_access: str = None, - api_token: str = None, + title: str | None = None, + description: str | None = None, + public_access: str | None = None, + api_token: str | None = None, ): """Update a map's details @@ -148,7 +148,7 @@ def update_map( def move_map( - map_id: str, project_id: str = None, folder_id: str = None, api_token: str = None + map_id: str, project_id: str | None = None, folder_id: str | None = None, api_token: str | None = None ): """Move a map to a different project or folder @@ -181,7 +181,7 @@ def move_map( return json.load(response) -def create_embed_token(map_id: str, user_email: str = None, api_token: str = None): +def create_embed_token(map_id: str, user_email: str | None = None, api_token: str | None = None): """Create an embed token for a map Args: @@ -207,7 +207,7 @@ def create_embed_token(map_id: str, user_email: str = None, api_token: str = Non def add_source_layer( - map_id: str, source_layer_params: dict[str, str], api_token: str = None + map_id: str, source_layer_params: dict[str, str], api_token: str | None = None ): """Add a layer from a source to a map diff --git a/felt_python/sources.py b/felt_python/sources.py index c811153..cb20b3b 100644 --- a/felt_python/sources.py +++ b/felt_python/sources.py @@ -29,7 +29,7 @@ def list_sources(workspace_id: str | None = None, api_token: str | None = None): def create_source( name: str, connection: dict[str, str], - permissions: dict[str, str] = None, + permissions: dict[str, str] | None = None, api_token: str | None = None, ): """Create a new source diff --git a/tests/maps_test.py b/tests/maps_test.py index 8db6092..a8a728a 100644 --- a/tests/maps_test.py +++ b/tests/maps_test.py @@ -6,7 +6,7 @@ import os import sys import unittest -import time + import datetime sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -127,7 +127,7 @@ def test_map_workflow(self): print("Creating embed token...") token_data = create_embed_token( - map_id=map_id, user_email=f"test.user@example.com" + map_id=map_id, user_email="test.user@example.com" ) self.assertIsNotNone(token_data)