geobox 1.3.4__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. {geobox-1.3.4 → geobox-1.4.0}/PKG-INFO +1 -1
  2. {geobox-1.3.4 → geobox-1.4.0}/geobox/api.py +120 -1
  3. {geobox-1.3.4 → geobox-1.4.0}/geobox/apikey.py +6 -3
  4. {geobox-1.3.4 → geobox-1.4.0}/geobox/enums.py +2 -0
  5. {geobox-1.3.4 → geobox-1.4.0}/geobox/file.py +3 -0
  6. geobox-1.4.0/geobox/layout.py +314 -0
  7. {geobox-1.3.4 → geobox-1.4.0}/geobox/map.py +40 -1
  8. {geobox-1.3.4 → geobox-1.4.0}/geobox/model3d.py +2 -0
  9. {geobox-1.3.4 → geobox-1.4.0}/geobox/plan.py +27 -0
  10. {geobox-1.3.4 → geobox-1.4.0}/geobox/raster.py +4 -0
  11. {geobox-1.3.4 → geobox-1.4.0}/geobox/task.py +6 -2
  12. {geobox-1.3.4 → geobox-1.4.0}/geobox/tile3d.py +20 -1
  13. {geobox-1.3.4 → geobox-1.4.0}/geobox/workflow.py +2 -2
  14. {geobox-1.3.4 → geobox-1.4.0}/geobox.egg-info/PKG-INFO +1 -1
  15. {geobox-1.3.4 → geobox-1.4.0}/geobox.egg-info/SOURCES.txt +2 -0
  16. {geobox-1.3.4 → geobox-1.4.0}/pyproject.toml +1 -1
  17. {geobox-1.3.4 → geobox-1.4.0}/tests/test_api.py +75 -0
  18. {geobox-1.3.4 → geobox-1.4.0}/tests/test_apikey.py +1 -1
  19. geobox-1.4.0/tests/test_layout.py +136 -0
  20. {geobox-1.3.4 → geobox-1.4.0}/tests/test_map.py +22 -2
  21. {geobox-1.3.4 → geobox-1.4.0}/tests/test_plan.py +12 -0
  22. {geobox-1.3.4 → geobox-1.4.0}/tests/test_raster.py +6 -1
  23. {geobox-1.3.4 → geobox-1.4.0}/tests/test_task.py +13 -2
  24. {geobox-1.3.4 → geobox-1.4.0}/tests/test_tile3d.py +15 -0
  25. {geobox-1.3.4 → geobox-1.4.0}/LICENSE +0 -0
  26. {geobox-1.3.4 → geobox-1.4.0}/README.md +0 -0
  27. {geobox-1.3.4 → geobox-1.4.0}/geobox/__init__.py +0 -0
  28. {geobox-1.3.4 → geobox-1.4.0}/geobox/attachment.py +0 -0
  29. {geobox-1.3.4 → geobox-1.4.0}/geobox/base.py +0 -0
  30. {geobox-1.3.4 → geobox-1.4.0}/geobox/basemap.py +0 -0
  31. {geobox-1.3.4 → geobox-1.4.0}/geobox/dashboard.py +0 -0
  32. {geobox-1.3.4 → geobox-1.4.0}/geobox/exception.py +0 -0
  33. {geobox-1.3.4 → geobox-1.4.0}/geobox/feature.py +0 -0
  34. {geobox-1.3.4 → geobox-1.4.0}/geobox/field.py +0 -0
  35. {geobox-1.3.4 → geobox-1.4.0}/geobox/log.py +0 -0
  36. {geobox-1.3.4 → geobox-1.4.0}/geobox/mosaic.py +0 -0
  37. {geobox-1.3.4 → geobox-1.4.0}/geobox/query.py +0 -0
  38. {geobox-1.3.4 → geobox-1.4.0}/geobox/route.py +0 -0
  39. {geobox-1.3.4 → geobox-1.4.0}/geobox/scene.py +0 -0
  40. {geobox-1.3.4 → geobox-1.4.0}/geobox/settings.py +0 -0
  41. {geobox-1.3.4 → geobox-1.4.0}/geobox/tileset.py +0 -0
  42. {geobox-1.3.4 → geobox-1.4.0}/geobox/usage.py +0 -0
  43. {geobox-1.3.4 → geobox-1.4.0}/geobox/user.py +0 -0
  44. {geobox-1.3.4 → geobox-1.4.0}/geobox/utils.py +0 -0
  45. {geobox-1.3.4 → geobox-1.4.0}/geobox/vectorlayer.py +0 -0
  46. {geobox-1.3.4 → geobox-1.4.0}/geobox/version.py +0 -0
  47. {geobox-1.3.4 → geobox-1.4.0}/geobox/view.py +0 -0
  48. {geobox-1.3.4 → geobox-1.4.0}/geobox.egg-info/dependency_links.txt +0 -0
  49. {geobox-1.3.4 → geobox-1.4.0}/geobox.egg-info/requires.txt +0 -0
  50. {geobox-1.3.4 → geobox-1.4.0}/geobox.egg-info/top_level.txt +0 -0
  51. {geobox-1.3.4 → geobox-1.4.0}/setup.cfg +0 -0
  52. {geobox-1.3.4 → geobox-1.4.0}/tests/test_attachment.py +0 -0
  53. {geobox-1.3.4 → geobox-1.4.0}/tests/test_basemap.py +0 -0
  54. {geobox-1.3.4 → geobox-1.4.0}/tests/test_dashboard.py +0 -0
  55. {geobox-1.3.4 → geobox-1.4.0}/tests/test_feature.py +0 -0
  56. {geobox-1.3.4 → geobox-1.4.0}/tests/test_field.py +0 -0
  57. {geobox-1.3.4 → geobox-1.4.0}/tests/test_file.py +0 -0
  58. {geobox-1.3.4 → geobox-1.4.0}/tests/test_log.py +0 -0
  59. {geobox-1.3.4 → geobox-1.4.0}/tests/test_model3d.py +0 -0
  60. {geobox-1.3.4 → geobox-1.4.0}/tests/test_mosaic.py +0 -0
  61. {geobox-1.3.4 → geobox-1.4.0}/tests/test_query.py +0 -0
  62. {geobox-1.3.4 → geobox-1.4.0}/tests/test_route.py +0 -0
  63. {geobox-1.3.4 → geobox-1.4.0}/tests/test_scene.py +0 -0
  64. {geobox-1.3.4 → geobox-1.4.0}/tests/test_settings.py +0 -0
  65. {geobox-1.3.4 → geobox-1.4.0}/tests/test_tileset.py +0 -0
  66. {geobox-1.3.4 → geobox-1.4.0}/tests/test_usage.py +0 -0
  67. {geobox-1.3.4 → geobox-1.4.0}/tests/test_user.py +0 -0
  68. {geobox-1.3.4 → geobox-1.4.0}/tests/test_vectorlayer.py +0 -0
  69. {geobox-1.3.4 → geobox-1.4.0}/tests/test_version.py +0 -0
  70. {geobox-1.3.4 → geobox-1.4.0}/tests/test_view.py +0 -0
  71. {geobox-1.3.4 → geobox-1.4.0}/tests/test_workflow.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geobox
3
- Version: 1.3.4
3
+ Version: 1.4.0
4
4
  Summary: SDK for Geobox's APIs
5
5
  Author-email: Hamid Heydari <heydari.h62@gmail.com>
6
6
  License: MIT
@@ -20,6 +20,7 @@ from .map import Map
20
20
  from .user import User, UserRole, UserStatus, Session
21
21
  from .query import Query
22
22
  from .workflow import Workflow
23
+ from .layout import Layout
23
24
  from .version import VectorLayerVersion
24
25
  from .tile3d import Tile3d
25
26
  from .settings import SystemSettings
@@ -1535,7 +1536,7 @@ class GeoboxClient:
1535
1536
  Example:
1536
1537
  >>> from geobox import GeoboxClient
1537
1538
  >>> client = GeoboxClient()
1538
- >>> workflows = client.get_workflow(q="name LIKE '%My workflow%'")
1539
+ >>> workflows = client.get_workflows(q="name LIKE '%My workflow%'")
1539
1540
  """
1540
1541
  return Workflow.get_workflows(self, **kwargs)
1541
1542
 
@@ -1681,6 +1682,105 @@ class GeoboxClient:
1681
1682
  return VectorLayerVersion.get_version_by_name(self, name, user_id)
1682
1683
 
1683
1684
 
1685
+ def get_layouts(self, **kwargs) -> Union[List['Layout'], int]:
1686
+ """
1687
+ Get list of layouts with optional filtering and pagination.
1688
+
1689
+ Keyword Args:
1690
+ q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
1691
+ search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
1692
+ search_fields (str): comma separated list of fields for searching.
1693
+ order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
1694
+ return_count (bool): Whether to return total count. default is False.
1695
+ skip (int): Number of items to skip. default is 0.
1696
+ limit (int): Number of items to return. default is 10.
1697
+ user_id (int): Specific user. privileges required.
1698
+ shared (bool): Whether to return shared layouts. default is False.
1699
+
1700
+ Returns:
1701
+ List[Layout] | int: A list of layout instances or the total number of layouts.
1702
+
1703
+ Example:
1704
+ >>> from geobox import GeoboxClient
1705
+ >>> client = GeoboxClient()
1706
+ >>> layouts = client.get_layouts(q="name LIKE '%My layout%'")
1707
+ """
1708
+ return Layout.get_layouts(self, **kwargs)
1709
+
1710
+
1711
+ def create_layout(self,
1712
+ name: str,
1713
+ display_name: str = None,
1714
+ description: str = None,
1715
+ settings: Dict = {},
1716
+ thumbnail: str = None,
1717
+ user_id: int = None) -> 'Layout':
1718
+ """
1719
+ Create a new layout.
1720
+
1721
+ Args:
1722
+ name (str): The name of the layout.
1723
+ display_name (str): The display name of the layout.
1724
+ description (str): The description of the layout.
1725
+ settings (Dict): The settings of the layout.
1726
+ thumbnail (str): The thumbnail of the layout.
1727
+ user_id (int): Specific user. privileges layout.
1728
+
1729
+ Returns:
1730
+ Layout: The newly created layout instance.
1731
+
1732
+ Raises:
1733
+ ValidationError: If the layout data is invalid.
1734
+
1735
+ Example:
1736
+ >>> from geobox import GeoboxClient
1737
+ >>> client = GeoboxClient()
1738
+ >>> layout = client.create_layout(name="my_layout")
1739
+ """
1740
+ return Layout.create_layout(self, name, display_name, description, settings, thumbnail, user_id)
1741
+
1742
+
1743
+ def get_layout(self, uuid: str, user_id: int = None) -> 'Layout':
1744
+ """
1745
+ Get a layout by its UUID.
1746
+
1747
+ Args:
1748
+ uuid (str): The UUID of the layout to get.
1749
+ user_id (int): Specific user. privileges required.
1750
+
1751
+ Returns:
1752
+ Layout: The layout object.
1753
+
1754
+ Raises:
1755
+ NotFoundError: If the layout with the specified UUID is not found.
1756
+
1757
+ Example:
1758
+ >>> from geobox import GeoboxClient
1759
+ >>> client = GeoboxClient()
1760
+ >>> layout = client.get_layout(uuid="12345678-1234-5678-1234-567812345678")
1761
+ """
1762
+ return Layout.get_layout(self, uuid, user_id)
1763
+
1764
+
1765
+ def get_layout_by_name(self, name: str, user_id: int = None) -> Union['Layout', None]:
1766
+ """
1767
+ Get a layout by name
1768
+
1769
+ Args:
1770
+ name (str): the name of the layout to get
1771
+ user_id (int, optional): specific user. privileges required.
1772
+
1773
+ Returns:
1774
+ Layout | None: returns the layout if a layout matches the given name, else None
1775
+
1776
+ Example:
1777
+ >>> from geobox import GeoboxClient
1778
+ >>> client = GeoboxClient()
1779
+ >>> layout = client.get_layout_by_name(name='test')
1780
+ """
1781
+ return Layout.get_layout_by_name(self, name, user_id)
1782
+
1783
+
1684
1784
  def get_3dtiles(self, **kwargs) -> Union[List['Tile3d'], int]:
1685
1785
  """
1686
1786
  Get list of 3D Tiles with optional filtering and pagination.
@@ -2016,6 +2116,25 @@ class GeoboxClient:
2016
2116
  return Plan.get_plan(self, plan_id)
2017
2117
 
2018
2118
 
2119
+ def get_plan_by_name(self, name: str) -> Union['Plan', None]:
2120
+ """
2121
+ Get a plan by name
2122
+
2123
+ Args:
2124
+ api (GeoboxClient): The GeoboxClient instance for making requests.
2125
+ name (str): the name of the plan to get
2126
+
2127
+ Returns:
2128
+ Plan | None: returns the plan if a plan matches the given name, else None
2129
+
2130
+ Example:
2131
+ >>> from geobox import GeoboxClient
2132
+ >>> client = GeoboxClient()
2133
+ >>> plan = client.get_plan_by_name(name='test')
2134
+ """
2135
+ return Plan.get_plan_by_name(self, name)
2136
+
2137
+
2019
2138
  def get_dashboards(self, **kwargs) -> Union[List['Dashboard'], int]:
2020
2139
  """
2021
2140
  Get list of Dashboards
@@ -176,11 +176,14 @@ class ApiKey(Base):
176
176
  >>> apikey = ApiKey.get_apikey(client, key_id=1)
177
177
  >>> apikey.update(name="updated_name")
178
178
  """
179
- data = {
179
+ data = clean_data({
180
180
  "name": name,
181
181
  "user_id": user_id
182
- }
183
- return super()._update(self.endpoint, data)
182
+ })
183
+
184
+ response = self.api.put(self.endpoint, data, is_json=False)
185
+ self._update_properties(response)
186
+ return response
184
187
 
185
188
 
186
189
  def delete(self) -> None:
@@ -19,6 +19,7 @@ class PublishFileType(Enum):
19
19
  VECTOR = 'vector'
20
20
  RASTER = 'raster'
21
21
  MODEL3D = 'model3d'
22
+ Tiles3D = 'tiles3d'
22
23
 
23
24
  class FileType(Enum):
24
25
  Compressed = 'Compressed'
@@ -36,6 +37,7 @@ class FileType(Enum):
36
37
  FileGDB = 'FileGDB'
37
38
  GeoTIFF = 'GeoTIFF'
38
39
  GeoJSON = 'GeoJSON'
40
+ ThreedTiles = 'ThreedTiles'
39
41
 
40
42
  class FileFormat(Enum):
41
43
  # Spatial Data Formats
@@ -429,6 +429,9 @@ class File(Base):
429
429
  FileType(self.layers[0]['format']).value in ['GLB']):
430
430
  publish_as = PublishFileType.MODEL3D
431
431
 
432
+ elif self.file_type.value in ['ThreedTiles']:
433
+ publish_as = PublishFileType.Tiles3D
434
+
432
435
  else:
433
436
  raise ValidationError('Unknown format')
434
437
 
@@ -0,0 +1,314 @@
1
+ from typing import List, Dict, Optional, TYPE_CHECKING, Union
2
+
3
+ from .base import Base
4
+
5
+ if TYPE_CHECKING:
6
+ from . import GeoboxClient
7
+ from .user import User
8
+
9
+ class Layout(Base):
10
+
11
+ BASE_ENDPOINT = 'layouts/'
12
+
13
+ def __init__(self,
14
+ api: 'GeoboxClient',
15
+ uuid: str,
16
+ data: Optional[Dict] = {}):
17
+ """
18
+ Initialize a layout instance.
19
+
20
+ Args:
21
+ api (GeoboxClient): The GeoboxClient instance for making requests.
22
+ uuid (str): The unique identifier for the layout.
23
+ data (Dict): The data of the layout.
24
+ """
25
+ super().__init__(api, uuid=uuid, data=data)
26
+
27
+
28
+ @classmethod
29
+ def get_layouts(cls, api: 'GeoboxClient', **kwargs) -> Union[List['Layout'], int]:
30
+ """
31
+ Get list of layouts with optional filtering and pagination.
32
+
33
+ Args:
34
+ api (GeoboxClient): The GeoboxClient instance for making requests.
35
+
36
+ Keyword Args:
37
+ q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
38
+ search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
39
+ search_fields (str): comma separated list of fields for searching.
40
+ order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
41
+ return_count (bool): Whether to return total count. default is False.
42
+ skip (int): Number of items to skip. default is 0.
43
+ limit (int): Number of items to return. default is 10.
44
+ user_id (int): Specific user. privileges required.
45
+ shared (bool): Whether to return shared layouts. default is False.
46
+
47
+ Returns:
48
+ List[Layout] | int: A list of layout instances or the total number of layouts.
49
+
50
+ Example:
51
+ >>> from geobox import GeoboxClient
52
+ >>> from geobox.layout import Layout
53
+ >>> client = GeoboxClient()
54
+ >>> layouts = Layout.get_layout(client, q="name LIKE '%My layout%'")
55
+ or
56
+ >>> layouts = client.get_layout(q="name LIKE '%My layout%'")
57
+ """
58
+ params = {
59
+ 'f': 'json',
60
+ 'q': kwargs.get('q'),
61
+ 'search': kwargs.get('search'),
62
+ 'search_fields': kwargs.get('search_fields'),
63
+ 'order_by': kwargs.get('order_by'),
64
+ 'return_count': kwargs.get('return_count', False),
65
+ 'skip': kwargs.get('skip', 0),
66
+ 'limit': kwargs.get('limit', 10),
67
+ 'user_id': kwargs.get('user_id'),
68
+ 'shared': kwargs.get('shared', False)
69
+ }
70
+ return super()._get_list(api, cls.BASE_ENDPOINT, params, factory_func=lambda api, item: Layout(api, item['uuid'], item))
71
+
72
+
73
+ @classmethod
74
+ def create_layout(cls,
75
+ api: 'GeoboxClient',
76
+ name: str,
77
+ display_name: str = None,
78
+ description: str = None,
79
+ settings: Dict = {},
80
+ thumbnail: str = None,
81
+ user_id: int = None) -> 'Layout':
82
+ """
83
+ Create a new layout.
84
+
85
+ Args:
86
+ api (GeoboxClient): The GeoboxClient instance for making requests.
87
+ name (str): The name of the Layout.
88
+ display_name (str): The display name of the layout.
89
+ description (str): The description of the layout.
90
+ settings (Dict): The settings of the layout.
91
+ thumbnail (str): The thumbnail of the layout.
92
+ user_id (int): Specific user. privileges layout.
93
+
94
+ Returns:
95
+ Layout: The newly created layout instance.
96
+
97
+ Raises:
98
+ ValidationError: If the layout data is invalid.
99
+
100
+ Example:
101
+ >>> from geobox import GeoboxClient
102
+ >>> from geobox.layout import Layout
103
+ >>> client = GeoboxClient()
104
+ >>> layout = Layout.create_layout(client, name="my_layout")
105
+ or
106
+ >>> layout = client.create_layout(name="my_layout")
107
+ """
108
+ data = {
109
+ "name": name,
110
+ "display_name": display_name,
111
+ "description": description,
112
+ "settings": settings,
113
+ "thumbnail": thumbnail,
114
+ "user_id": user_id,
115
+ }
116
+ return super()._create(api, cls.BASE_ENDPOINT, data, factory_func=lambda api, item: Layout(api, item['uuid'], item))
117
+
118
+
119
+ @classmethod
120
+ def get_layout(cls, api: 'GeoboxClient', uuid: str, user_id: int = None) -> 'Layout':
121
+ """
122
+ Get a layout by its UUID.
123
+
124
+ Args:
125
+ api (GeoboxClient): The GeoboxClient instance for making requests.
126
+ uuid (str): The UUID of the layout to get.
127
+ user_id (int): Specific user. privileges required.
128
+
129
+ Returns:
130
+ Layout: The layout object.
131
+
132
+ Raises:
133
+ NotFoundError: If the layout with the specified UUID is not found.
134
+
135
+ Example:
136
+ >>> from geobox import GeoboxClient
137
+ >>> from geobox.layout import Layout
138
+ >>> client = GeoboxClient()
139
+ >>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
140
+ or
141
+ >>> layout = client.get_layout(uuid="12345678-1234-5678-1234-567812345678")
142
+ """
143
+ params = {
144
+ 'f': 'json',
145
+ 'user_id': user_id,
146
+ }
147
+ return super()._get_detail(api, cls.BASE_ENDPOINT, uuid, params, factory_func=lambda api, item: Layout(api, item['uuid'], item))
148
+
149
+
150
+ @classmethod
151
+ def get_layout_by_name(cls, api: 'GeoboxClient', name: str, user_id: int = None) -> Union['Layout', None]:
152
+ """
153
+ Get a layout by name
154
+
155
+ Args:
156
+ api (GeoboxClient): The GeoboxClient instance for making requests.
157
+ name (str): the name of the layout to get
158
+ user_id (int, optional): specific user. privileges required.
159
+
160
+ Returns:
161
+ Layout | None: returns the layout if a layout matches the given name, else None
162
+
163
+ Example:
164
+ >>> from geobox import GeoboxClient
165
+ >>> from geobox.layout import Layout
166
+ >>> client = GeoboxClient()
167
+ >>> layout = Layout.get_layout_by_name(client, name='test')
168
+ or
169
+ >>> layout = client.get_layout_by_name(name='test')
170
+ """
171
+ layouts = cls.get_layouts(api, q=f"name = '{name}'", user_id=user_id)
172
+ if layouts and layouts[0].name == name:
173
+ return layouts[0]
174
+ else:
175
+ return None
176
+
177
+
178
+ def update(self, **kwargs) -> Dict:
179
+ """
180
+ Update the layout.
181
+
182
+ Keyword Args:
183
+ name (str): The name of the layout.
184
+ display_name (str): The display name of the layout.
185
+ description (str): The description of the layout.
186
+ settings (Dict): The settings of the layout.
187
+ thumbnail (str): The thumbnail of the layout.
188
+
189
+ Returns:
190
+ Dict: The updated layout data.
191
+
192
+ Raises:
193
+ ValidationError: If the layout data is invalid.
194
+
195
+ Example:
196
+ >>> from geobox import GeoboxClient
197
+ >>> from geobox.layout import Layout
198
+ >>> client = GeoboxClient()
199
+ >>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
200
+ >>> layout.update_layout(display_name="New Display Name")
201
+ """
202
+ data = {
203
+ "name": kwargs.get('name'),
204
+ "display_name": kwargs.get('display_name'),
205
+ "description": kwargs.get('description'),
206
+ "settings": kwargs.get('settings'),
207
+ "thumbnail": kwargs.get('thumbnail')
208
+ }
209
+ return super()._update(self.endpoint, data)
210
+
211
+
212
+ def delete(self) -> None:
213
+ """
214
+ Delete the Layout.
215
+
216
+ Returns:
217
+ None
218
+
219
+ Example:
220
+ >>> from geobox import GeoboxClient
221
+ >>> from geobox.layout import Layout
222
+ >>> client = GeoboxClient()
223
+ >>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
224
+ >>> layout.delete()
225
+ """
226
+ super().delete(self.endpoint)
227
+
228
+
229
+ @property
230
+ def thumbnail(self) -> str:
231
+ """
232
+ Get the thumbnail URL of the Layout.
233
+
234
+ Returns:
235
+ str: The thumbnail of the Layout.
236
+
237
+ Example:
238
+ >>> from geobox import GeoboxClient
239
+ >>> from geobox.layout import Layout
240
+ >>> client = GeoboxClient()
241
+ >>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
242
+ >>> layout.thumbnail
243
+ 'https://example.com/thumbnail.png'
244
+ """
245
+ return super().thumbnail()
246
+
247
+
248
+ def share(self, users: List['User']) -> None:
249
+ """
250
+ Shares the layout with specified users.
251
+
252
+ Args:
253
+ users (List[User]): The list of user objects to share the layout with.
254
+
255
+ Returns:
256
+ None
257
+
258
+ Example:
259
+ >>> from geobox import GeoboxClient
260
+ >>> from geobox.layout import Layout
261
+ >>> client = GeoboxClient()
262
+ >>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
263
+ >>> users = client.search_users(search='John')
264
+ >>> layout.share(users=users)
265
+ """
266
+ super()._share(self.endpoint, users)
267
+
268
+
269
+ def unshare(self, users: List['User']) -> None:
270
+ """
271
+ Unshares the layout with specified users.
272
+
273
+ Args:
274
+ users (List[User]): The list of user objects to unshare the layout with.
275
+
276
+ Returns:
277
+ None
278
+
279
+ Example:
280
+ >>> from geobox import GeoboxClient
281
+ >>> from geobox.layout import Layout
282
+ >>> client = GeoboxClient()
283
+ >>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
284
+ >>> users = client.search_users(search='John')
285
+ >>> layout.unshare(users=users)
286
+ """
287
+ super()._unshare(self.endpoint, users)
288
+
289
+
290
+ def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['User']:
291
+ """
292
+ Retrieves the list of users the layout is shared with.
293
+
294
+ Args:
295
+ search (str, optional): The search query.
296
+ skip (int, optional): The number of users to skip.
297
+ limit (int, optional): The maximum number of users to retrieve.
298
+
299
+ Returns:
300
+ List[User]: The list of shared users.
301
+
302
+ Example:
303
+ >>> from geobox import GeoboxClient
304
+ >>> from geobox.layout import Layout
305
+ >>> client = GeoboxClient()
306
+ >>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
307
+ >>> layout.get_shared_users(search='John', skip=0, limit=10)
308
+ """
309
+ params = {
310
+ 'search': search,
311
+ 'skip': skip,
312
+ 'limit': limit
313
+ }
314
+ return super()._get_shared_users(self.endpoint, params)
@@ -859,4 +859,43 @@ class Map(Base):
859
859
  >>> map.image_tile_url()
860
860
  >>> map.image_tile_url(x=1, y=2, z=3, format='.pbf')
861
861
  """
862
- return f"{self.BASE_ENDPOINT}{self.endpoint}{z}/{x}/{y}{format}"
862
+ endpoint = f"{self.api.base_url}{self.endpoint}tiles/{z}/{x}/{y}{format}"
863
+
864
+ if not self.api.access_token and self.api.apikey:
865
+ endpoint = f'{endpoint}?apikey={self.api.apikey}'
866
+
867
+ return endpoint
868
+
869
+
870
+ def export_map_to_image(self, bbox: List, width: int, height: int) -> 'Task':
871
+ """
872
+ Export the map to image
873
+
874
+ Args:
875
+ bbox (List): e.g. [50.275, 35.1195, 51.4459, 36.0416]
876
+ width (int): minimum: 10, maximum: 10000
877
+ height (int): minimum: 10, maximum: 10000
878
+
879
+ Returns:
880
+ Task: the task object
881
+
882
+ Example:
883
+ >>> from geobox import GeoboxClient
884
+ >>> from geobox.map import Map
885
+ >>> client = GeoboxClient()
886
+ >>> map = Map.get_map(client, uuid="12345678-1234-5678-1234-567812345678")
887
+ >>> task = map.export_map_to_image(bbox=[50.275, 35.1195, 51.4459, 36.0416],
888
+ ... width=1024,
889
+ ... height=1024)
890
+ """
891
+ data = clean_data({
892
+ 'uuid': self.uuid,
893
+ 'bbox': bbox,
894
+ 'width': width,
895
+ 'height': height
896
+ })
897
+ query_string = urlencode(data)
898
+ endpoint = urljoin(self.endpoint, 'export/')
899
+ endpoint = f"{endpoint}?{query_string}"
900
+ response = self.api.post(endpoint)
901
+ return self.api.get_task(response['task_id'])
@@ -152,6 +152,7 @@ class Model(Base):
152
152
 
153
153
  Keyword Args:
154
154
  name (str): The new name for the model.
155
+ display_name (str): The new display name.
155
156
  description (str): The new description for the model.
156
157
  settings (Dict): The new settings for the model.
157
158
  thumbnail (str): The new thumbnail for the model.
@@ -190,6 +191,7 @@ class Model(Base):
190
191
  """
191
192
  data = {
192
193
  'name': kwargs.get('name'),
194
+ 'display_name': kwargs.get('display_name'),
193
195
  'description': kwargs.get('description'),
194
196
  'settings': kwargs.get('settings'),
195
197
  'thumbnail': kwargs.get('thumbnail')
@@ -191,6 +191,33 @@ class Plan(Base):
191
191
  'f': 'json'
192
192
  }
193
193
  return super()._get_detail(api, cls.BASE_ENDPOINT, plan_id, params, factory_func=lambda api, item: Plan(api, item['id'], item))
194
+
195
+
196
+ @classmethod
197
+ def get_plan_by_name(cls, api: 'GeoboxClient', name: str) -> Union['Plan', None]:
198
+ """
199
+ Get a plan by name
200
+
201
+ Args:
202
+ api (GeoboxClient): The GeoboxClient instance for making requests.
203
+ name (str): the name of the plan to get
204
+
205
+ Returns:
206
+ Plan | None: returns the plan if a plan matches the given name, else None
207
+
208
+ Example:
209
+ >>> from geobox import GeoboxClient
210
+ >>> from geobox.plan import Plan
211
+ >>> client = GeoboxClient()
212
+ >>> plan = Workflow.get_plan_by_name(client, name='test')
213
+ or
214
+ >>> plan = client.get_plan_by_name(name='test')
215
+ """
216
+ plans = cls.get_plans(api, q=f"name = '{name}'")
217
+ if plans and plans[0].name == name:
218
+ return plans[0]
219
+ else:
220
+ return None
194
221
 
195
222
 
196
223
  def update(self, **kwargs) -> Dict:
@@ -513,6 +513,10 @@ class Raster(Base):
513
513
  endpoint = f'{self.api.base_url}{self.endpoint}render/{z}/{x}/{y}.png'
514
514
  if query_string:
515
515
  endpoint = f'{endpoint}?{query_string}'
516
+
517
+ if not self.api.access_token and self.api.apikey:
518
+ endpoint = join_url_params(endpoint, {"apikey": self.api.apikey})
519
+
516
520
  return endpoint
517
521
 
518
522
 
@@ -11,6 +11,7 @@ if TYPE_CHECKING:
11
11
  from .raster import Raster
12
12
  from .model3d import Model
13
13
  from .file import File
14
+ from .tile3d import Tile3d
14
15
 
15
16
  class Task(Base):
16
17
  """
@@ -46,12 +47,12 @@ class Task(Base):
46
47
 
47
48
 
48
49
  @property
49
- def output_asset(self) -> Union['VectorLayer', 'Raster', 'Model', 'File', None]:
50
+ def output_asset(self) -> Union['VectorLayer', 'Raster', 'Model', 'File', 'Tile3d', None]:
50
51
  """
51
52
  output asset property
52
53
 
53
54
  Returns:
54
- VectorLayer | Raster | Model | None: if task type is publish, it returns the published layer
55
+ VectorLayer | Raster | Model | Tile3d | None: if task type is publish, it returns the published layer
55
56
 
56
57
  Example:
57
58
  >>> from geobox import GeoboxClient
@@ -71,6 +72,9 @@ class Task(Base):
71
72
 
72
73
  elif self.data.get('result', {}).get('file_uuid'):
73
74
  return self.api.get_file(uuid=self.data['result']['file_uuid'])
75
+
76
+ elif self.data.get('result', {}).get('3dtiles_uuid'):
77
+ return self.api.get_3dtile(uuid=self.data['result']['3dtiles_uuid'])
74
78
 
75
79
  else:
76
80
  return None
@@ -1,4 +1,5 @@
1
1
  from typing import List, Dict, Optional, TYPE_CHECKING, Union
2
+ from urllib.parse import urljoin
2
3
 
3
4
  from .base import Base
4
5
 
@@ -291,4 +292,22 @@ class Tile3d(Base):
291
292
  'skip': skip,
292
293
  'limit': limit
293
294
  }
294
- return super()._get_shared_users(self.endpoint, params)
295
+ return super()._get_shared_users(self.endpoint, params)
296
+
297
+
298
+ def get_tileset_json(self) -> Dict:
299
+ """
300
+ Get Tileset JSON of a 3D Tiles.
301
+
302
+ Returns:
303
+ Dict: The tileset JSON configuration.
304
+
305
+ Example:
306
+ >>> from geobox import GeoboxClient
307
+ >>> from geobox.tile3d import Tile3d
308
+ >>> client = GeoboxClient()
309
+ >>> tile = Tile3d.get_3dtile(api=client, uuid="12345678-1234-5678-1234-567812345678")
310
+ >>> tile_json = tile.get_tileset_json()
311
+ """
312
+ endpoint = urljoin(self.endpoint, 'tileset.json')
313
+ return self.api.get(endpoint)
@@ -51,9 +51,9 @@ class Workflow(Base):
51
51
  >>> from geobox import GeoboxClient
52
52
  >>> from geobox.workflow import Workflow
53
53
  >>> client = GeoboxClient()
54
- >>> workflows = Workflow.get_workflow(client, q="name LIKE '%My workflow%'")
54
+ >>> workflows = Workflow.get_workflows(client, q="name LIKE '%My workflow%'")
55
55
  or
56
- >>> workflows = client.get_workflow(q="name LIKE '%My workflow%'")
56
+ >>> workflows = client.get_workflows(q="name LIKE '%My workflow%'")
57
57
  """
58
58
  params = {
59
59
  'f': 'json',
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geobox
3
- Version: 1.3.4
3
+ Version: 1.4.0
4
4
  Summary: SDK for Geobox's APIs
5
5
  Author-email: Hamid Heydari <heydari.h62@gmail.com>
6
6
  License: MIT
@@ -13,6 +13,7 @@ geobox/exception.py
13
13
  geobox/feature.py
14
14
  geobox/field.py
15
15
  geobox/file.py
16
+ geobox/layout.py
16
17
  geobox/log.py
17
18
  geobox/map.py
18
19
  geobox/model3d.py
@@ -46,6 +47,7 @@ tests/test_dashboard.py
46
47
  tests/test_feature.py
47
48
  tests/test_field.py
48
49
  tests/test_file.py
50
+ tests/test_layout.py
49
51
  tests/test_log.py
50
52
  tests/test_map.py
51
53
  tests/test_model3d.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "geobox"
7
- version = "1.3.4"
7
+ version = "1.4.0"
8
8
  description = "SDK for Geobox's APIs"
9
9
  authors = [
10
10
  {name = "Hamid Heydari", email = "heydari.h62@gmail.com"}
@@ -1437,6 +1437,67 @@ def test_get_version_by_name(mock_version_data):
1437
1437
  assert version.data == mock_version_data
1438
1438
 
1439
1439
 
1440
+ def test_get_layouts(mock_layout_data):
1441
+ with patch('geobox.api.GeoboxClient.get_access_token') as mock_get_token, \
1442
+ patch('geobox.api.GeoboxClient.get') as mock_get:
1443
+
1444
+ mock_get_token.return_value = 'test_token'
1445
+ mock_get.return_value = [mock_layout_data, mock_layout_data]
1446
+
1447
+ client = GeoboxClient(username='testuser', password='testpassword')
1448
+ layouts = client.get_layouts()
1449
+
1450
+ assert len(layouts) == 2
1451
+ assert isinstance(layouts[0], Layout)
1452
+ assert layouts[0].data == mock_layout_data
1453
+
1454
+
1455
+ def test_create_layout(mock_layout_data):
1456
+ with patch('geobox.api.GeoboxClient.get_access_token') as mock_get_token, \
1457
+ patch('geobox.api.GeoboxClient.post') as mock_get:
1458
+
1459
+ mock_get_token.return_value = 'test_token'
1460
+ mock_get.return_value = mock_layout_data
1461
+
1462
+ client = GeoboxClient(username='testuser', password='testpassword')
1463
+ layout = client.create_layout(name=mock_layout_data['name'],
1464
+ display_name=mock_layout_data['display_name'],
1465
+ description=mock_layout_data['description'],
1466
+ settings=mock_layout_data['settings'],
1467
+ thumbnail=mock_layout_data.get('thumbnail'))
1468
+
1469
+ assert isinstance(layout, Layout)
1470
+ assert layout.data == mock_layout_data
1471
+
1472
+
1473
+ def test_get_layout(mock_layout_data):
1474
+ with patch('geobox.api.GeoboxClient.get_access_token') as mock_get_token, \
1475
+ patch('geobox.api.GeoboxClient.get') as mock_get:
1476
+
1477
+ mock_get_token.return_value = 'test_token'
1478
+ mock_get.return_value = mock_layout_data
1479
+
1480
+ client = GeoboxClient(username='testuser', password='testpassword')
1481
+ layout = client.get_layout(uuid=mock_layout_data['uuid'])
1482
+
1483
+ assert isinstance(layout, Layout)
1484
+ assert layout.data == mock_layout_data
1485
+
1486
+
1487
+ def test_get_layout_by_name(mock_layout_data):
1488
+ with patch('geobox.api.GeoboxClient.get_access_token') as mock_get_token, \
1489
+ patch('geobox.api.GeoboxClient.get') as mock_get:
1490
+
1491
+ mock_get_token.return_value = 'test_token'
1492
+ mock_get.return_value = [mock_layout_data]
1493
+
1494
+ client = GeoboxClient(username='testuser', password='testpassword')
1495
+ layout = client.get_layout_by_name(name=mock_layout_data['name'])
1496
+
1497
+ assert isinstance(layout, Layout)
1498
+ assert layout.data == mock_layout_data
1499
+
1500
+
1440
1501
  def test_get_3dtiles(mock_tile3d_data):
1441
1502
  with patch('geobox.api.GeoboxClient.get_access_token') as mock_get_token, \
1442
1503
  patch('geobox.api.GeoboxClient.get') as mock_get:
@@ -1626,6 +1687,20 @@ def test_get_plan(mock_plan_data):
1626
1687
  assert plan.data == mock_plan_data
1627
1688
 
1628
1689
 
1690
+ def test_get_plan_by_name(mock_plan_data):
1691
+ with patch('geobox.api.GeoboxClient.get_access_token') as mock_get_token, \
1692
+ patch('geobox.api.GeoboxClient.get') as mock_get:
1693
+
1694
+ mock_get_token.return_value = 'test_token'
1695
+ mock_get.return_value = [mock_plan_data]
1696
+
1697
+ client = GeoboxClient(username='testuser', password='testpassword')
1698
+ plan = client.get_plan_by_name(name=mock_plan_data['name'])
1699
+
1700
+ assert isinstance(plan, Plan)
1701
+ assert plan.data == mock_plan_data
1702
+
1703
+
1629
1704
  def test_get_dashboards(mock_dashboard_data):
1630
1705
  with patch('geobox.api.GeoboxClient.get_access_token') as mock_get_token, \
1631
1706
  patch('geobox.api.GeoboxClient.get') as mock_get:
@@ -63,7 +63,7 @@ def test_update(api, mock_apikey_data):
63
63
 
64
64
  api.put.return_value = updated_data
65
65
  apikey.update(name='updated_name')
66
- api.put.assert_called_once_with(apikey.endpoint, {'name': 'updated_name'})
66
+ api.put.assert_called_once_with(apikey.endpoint, {'name': 'updated_name'}, is_json=False)
67
67
 
68
68
 
69
69
  def test_delete(api, mock_apikey_data):
@@ -0,0 +1,136 @@
1
+ import pytest
2
+ from unittest.mock import patch
3
+
4
+ from geobox.layout import Layout
5
+ from geobox.user import User
6
+
7
+ def test_init(api, mock_layout_data):
8
+ layout = Layout(api, mock_layout_data['uuid'], mock_layout_data)
9
+ assert layout.name == mock_layout_data['name']
10
+ assert layout.uuid == mock_layout_data['uuid']
11
+ assert layout.data == mock_layout_data
12
+ assert layout.endpoint == f'{Layout.BASE_ENDPOINT}{layout.uuid}/'
13
+
14
+
15
+ def test_get_layouts(api, mock_layout_data):
16
+ api.get.return_value = [mock_layout_data, mock_layout_data]
17
+ layouts = Layout.get_layouts(api)
18
+ api.get.assert_called_once_with(f'{Layout.BASE_ENDPOINT}?f=json&return_count=False&skip=0&limit=10&shared=False')
19
+ assert len(layouts) == 2
20
+ assert type(layouts[0]) == Layout
21
+ assert layouts[0].data == mock_layout_data
22
+
23
+
24
+ def test_create_layout(api, mock_layout_data):
25
+ api.post.return_value = mock_layout_data
26
+ layout = Layout.create_layout(api,
27
+ name=mock_layout_data['name'],
28
+ display_name=mock_layout_data['display_name'],
29
+ description=mock_layout_data['description'],
30
+ settings=mock_layout_data['settings'],
31
+ thumbnail=mock_layout_data.get('thumbnail'))
32
+ api.post.assert_called_once_with(Layout.BASE_ENDPOINT, {'name': 'test', 'settings': {}})
33
+ assert type(layout) == Layout
34
+ assert layout.uuid == mock_layout_data['uuid']
35
+ assert layout.data == mock_layout_data
36
+
37
+
38
+ def test_get_layout(api, mock_layout_data):
39
+ api.get.return_value = mock_layout_data
40
+ layout = Layout.get_layout(api, uuid=mock_layout_data['uuid'])
41
+ api.get.assert_called_once_with(f"{Layout.BASE_ENDPOINT}{mock_layout_data['uuid']}/?f=json")
42
+ assert type(layout) == Layout
43
+ assert layout.uuid == mock_layout_data['uuid']
44
+ assert layout.data == mock_layout_data
45
+
46
+
47
+ def test_get_layout_by_name(api, mock_layout_data):
48
+ api.get.return_value = [mock_layout_data]
49
+ layout = Layout.get_layout_by_name(api, name=mock_layout_data['name'])
50
+ api.get.assert_called_once_with(f"{Layout.BASE_ENDPOINT}?f=json&q=name+%3D+%27test%27&return_count=False&skip=0&limit=10&shared=False")
51
+ assert type(layout) == Layout
52
+ assert layout.uuid == mock_layout_data['uuid']
53
+ assert layout.data == mock_layout_data
54
+ # not found
55
+ layout = Layout.get_layout_by_name(api, name='not_found')
56
+ assert layout == None
57
+
58
+
59
+ def test_update(api, mock_layout_data):
60
+ layout = Layout(api, mock_layout_data['uuid'], mock_layout_data)
61
+ updated_data = {**mock_layout_data,
62
+ 'settings': {'settings': 'value'},
63
+ 'thumbnail': 'thumbnail-url'}
64
+
65
+ api.put.return_value = updated_data
66
+ layout.update(settings={'settings': 'value'}, thumbnail='thumbnail-url')
67
+ api.put.assert_called_once_with(layout.endpoint, {'settings': {'settings': 'value'}, 'thumbnail': 'thumbnail-url'})
68
+
69
+
70
+ def test_delete(api, mock_layout_data):
71
+ layout = Layout(api, mock_layout_data['uuid'], mock_layout_data)
72
+ endpoint = layout.endpoint
73
+ layout.delete()
74
+ api.delete.assert_called_once_with(endpoint)
75
+ assert layout.uuid is None
76
+ assert layout.endpoint is None
77
+
78
+
79
+ def test_thumbnail(api, mock_layout_data):
80
+ layout = Layout(api, mock_layout_data['uuid'], mock_layout_data)
81
+ thumbnail_url = layout.thumbnail
82
+ assert thumbnail_url == f"{api.base_url}{layout.endpoint}thumbnail.png"
83
+
84
+
85
+ def test_share(api, mock_layout_data, mock_user_data):
86
+ """Test file sharing."""
87
+ with patch.object(api, 'post'):
88
+ layout = Layout(api, uuid=mock_layout_data['uuid'], data=mock_layout_data)
89
+ users = [
90
+ User(api, user_id=mock_user_data['1']['id'], data=mock_user_data['1']),
91
+ User(api, user_id=mock_user_data['2']['id'], data=mock_user_data['2'])
92
+ ]
93
+ layout.share(users=users)
94
+ api.post.assert_called_once_with(
95
+ f'{layout.endpoint}share/',
96
+ {'user_ids': [1, 2]}, is_json=False
97
+ )
98
+
99
+
100
+ def test_unshare(api, mock_layout_data, mock_user_data):
101
+ """Test file unsharing."""
102
+ with patch.object(api, 'post'):
103
+ layout = Layout(api, uuid=mock_layout_data['uuid'], data=mock_layout_data)
104
+ users = [
105
+ User(api, user_id=mock_user_data['1']['id'], data=mock_user_data['1']),
106
+ User(api, user_id=mock_user_data['2']['id'], data=mock_user_data['2'])
107
+ ]
108
+ layout.unshare(users=users)
109
+
110
+ # Verify the API call
111
+ api.post.assert_called_once_with(
112
+ f'{layout.endpoint}unshare/',
113
+ {'user_ids': [1, 2]}, is_json=False
114
+ )
115
+
116
+
117
+ def test_get_shared_users(api, mock_layout_data, mock_user_data):
118
+ """Test getting shared users."""
119
+ mock_response = [
120
+ mock_user_data['1'],
121
+ mock_user_data['2']
122
+ ]
123
+
124
+ with patch.object(api, 'get', return_value=mock_response):
125
+ layout = Layout(api, uuid=mock_layout_data['uuid'], data=mock_layout_data)
126
+ result = layout.get_shared_users(search='user', limit=2)
127
+
128
+ api.get.assert_called_once_with(
129
+ f'{layout.endpoint}shared-with-users/?search=user&skip=0&limit=2'
130
+ )
131
+
132
+ assert len(result) == 2
133
+ assert result[0].first_name == 'test 1'
134
+ assert result[0].last_name == 'test 1'
135
+ assert result[1].first_name == 'test 2'
136
+ assert result[1].last_name == 'test 2'
@@ -552,5 +552,25 @@ def test_add_model_with_existing_models(api, mock_map_data, mock_model_data, moc
552
552
  def test_image_tile_url(api, mock_map_data):
553
553
  map = Map(api, uuid=mock_map_data['uuid'], data=mock_map_data)
554
554
 
555
- assert map.image_tile_url() == f"{map.BASE_ENDPOINT}{map.endpoint}"+"{z}/{x}/{y}.png"
556
- assert map.image_tile_url(x=1, y=2, z=3, format='.pbf') == f"{map.BASE_ENDPOINT}{map.endpoint}3/1/2.pbf"
555
+ assert map.image_tile_url() == f"{map.api.base_url}{map.endpoint}tiles/"+"{z}/{x}/{y}.png"
556
+ assert map.image_tile_url(x=1, y=2, z=3, format='.pbf') == f"{map.api.base_url}{map.endpoint}tiles/3/1/2.pbf"
557
+
558
+ # apikey
559
+ api.access_token = ''
560
+ api.apikey = 'apikey@1234'
561
+
562
+ assert map.image_tile_url() == f"{map.api.base_url}{map.endpoint}tiles/"+"{z}/{x}/{y}.png?apikey=apikey@1234"
563
+
564
+
565
+ def test_export_map_to_image(api, mock_map_data, mock_success_task_data):
566
+ map = Map(api, uuid=mock_map_data['uuid'], data=mock_map_data)
567
+
568
+ api.post.return_value = {
569
+ 'task_id': mock_success_task_data['uuid']
570
+ }
571
+ api.get_task.return_value = Task(api, mock_success_task_data['uuid'], mock_success_task_data)
572
+
573
+ task = map.export_map_to_image(bbox=[50.275, 35.1195, 51.4459, 36.0416], width=100, height=100)
574
+
575
+ api.post.assert_called_once_with('maps/da9a505b-7b51-4042-a3ba-c821e4f2cd34/export/?uuid=da9a505b-7b51-4042-a3ba-c821e4f2cd34&bbox=%5B50.275%2C+35.1195%2C+51.4459%2C+36.0416%5D&width=100&height=100')
576
+ assert type(task) == Task
@@ -52,6 +52,18 @@ def test_get_plan(api, mock_plan_data):
52
52
  assert plan.data == mock_plan_data
53
53
 
54
54
 
55
+ def test_get_plan_by_name(api, mock_plan_data):
56
+ api.get.return_value = [mock_plan_data]
57
+ plan = Plan.get_plan_by_name(api, name=mock_plan_data['name'])
58
+ api.get.assert_called_once_with(f"{Plan.BASE_ENDPOINT}?f=json&q=name+%3D+%27test%27&return_count=False&skip=0&limit=10&shared=False")
59
+ assert type(plan) == Plan
60
+ assert plan.plan_id == mock_plan_data['id']
61
+ assert plan.data == mock_plan_data
62
+ # not found
63
+ plan = Plan.get_plan_by_name(api, name='not_found')
64
+ assert plan == None
65
+
66
+
55
67
  def test_update(api, mock_plan_data):
56
68
  plan = Plan(api, mock_plan_data['id'], mock_plan_data)
57
69
  updated_data = {**mock_plan_data,
@@ -249,7 +249,12 @@ def test_get_render_png_url(api, mock_raster_data):
249
249
  raster = Raster(api, uuid=mock_raster_data['uuid'], data=mock_raster_data)
250
250
  url = raster.get_render_png_url(x=10, y=20, z=1, indexes=1)
251
251
  assert url == f"{raster.api.base_url}{raster.endpoint}render/1/10/20.png?indexes=1"
252
-
252
+ # apikey
253
+ api.access_token = ''
254
+ api.apikey = 'apikey_1234'
255
+ url = raster.get_render_png_url(x=10, y=20, z=1, indexes=1)
256
+ assert url == f"{raster.api.base_url}{raster.endpoint}render/1/10/20.png?indexes=1&apikey=apikey_1234"
257
+
253
258
 
254
259
  def test_get_tile_png_url(api, mock_raster_data):
255
260
  """Test getting tile PNG URL."""
@@ -10,6 +10,7 @@ from geobox.enums import LayerType, TaskStatus
10
10
  from geobox.vectorlayer import VectorLayer
11
11
  from geobox.raster import Raster
12
12
  from geobox.model3d import Model
13
+ from geobox.tile3d import Tile3d
13
14
 
14
15
 
15
16
  def test_init(api, mock_success_task_data):
@@ -26,7 +27,7 @@ def test_repr(api, mock_success_task_data):
26
27
  assert repr(task) == f"Task(uuid={task.uuid}, name={mock_success_task_data['name']})"
27
28
 
28
29
 
29
- def test_output_asset_property(api, mock_publish_task_data, mock_vector_data, mock_raster_data, mock_model_data, mock_file_data):
30
+ def test_output_asset_property(api, mock_publish_task_data, mock_vector_data, mock_raster_data, mock_model_data, mock_file_data, mock_tile3d_data):
30
31
  # raster layer
31
32
  task = Task(api, uuid=mock_publish_task_data['uuid'], data=mock_publish_task_data)
32
33
  api.get_raster.return_value = Raster(api, mock_raster_data['uuid'], data=mock_raster_data)
@@ -66,9 +67,19 @@ def test_output_asset_property(api, mock_publish_task_data, mock_vector_data, mo
66
67
  assert task.output_asset.uuid == expected_layer.uuid
67
68
  assert task.output_asset.data == expected_layer.data
68
69
  assert type(task.output_asset) == File
70
+ # tile3d
71
+ mock_publish_task_data['result']['3dtiles_uuid'] = mock_publish_task_data['result']['file_uuid']
72
+ del mock_publish_task_data['result']['file_uuid']
73
+ task = Task(api, uuid=mock_publish_task_data['uuid'], data=mock_publish_task_data)
74
+ api.get_3dtile.return_value = Tile3d(api, mock_tile3d_data['uuid'], data=mock_tile3d_data)
75
+ expected_layer = Tile3d(api, mock_tile3d_data['uuid'], data=mock_tile3d_data)
76
+ assert task.output_asset.name == expected_layer.name
77
+ assert task.output_asset.uuid == expected_layer.uuid
78
+ assert task.output_asset.data == expected_layer.data
79
+ assert type(task.output_asset) == Tile3d
69
80
  #None
70
81
  mock_publish_task_data['name'] = 'import'
71
- del mock_publish_task_data['result']['file_uuid']
82
+ del mock_publish_task_data['result']['3dtiles_uuid']
72
83
  task = Task(api, uuid=mock_publish_task_data['uuid'], data=mock_publish_task_data)
73
84
  assert task.output_asset == None
74
85
 
@@ -128,3 +128,18 @@ def test_get_shared_users(api, mock_tile3d_data, mock_user_data):
128
128
  assert result[0].last_name == 'test 1'
129
129
  assert result[1].first_name == 'test 2'
130
130
  assert result[1].last_name == 'test 2'
131
+
132
+
133
+ def test_get_tileset_json(api, mock_tile3d_data):
134
+ mock_response = {
135
+ 'key': 'value'
136
+ }
137
+ with patch.object(api, 'get', return_value=mock_response):
138
+ tile3d = Tile3d(api, uuid=mock_tile3d_data['uuid'], data=mock_tile3d_data)
139
+ result = tile3d.get_tileset_json()
140
+
141
+ assert result == mock_response
142
+
143
+ api.get.assert_called_once_with('3dtiles/fa1e14c3-bb36-4541-a7c3-d0a7f70d8852/tileset.json')
144
+
145
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes