geobox 1.4.1__py3-none-any.whl → 2.0.0__py3-none-any.whl

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 (66) hide show
  1. geobox/__init__.py +2 -2
  2. geobox/aio/__init__.py +63 -0
  3. geobox/aio/api.py +2640 -0
  4. geobox/aio/apikey.py +263 -0
  5. geobox/aio/attachment.py +339 -0
  6. geobox/aio/base.py +262 -0
  7. geobox/aio/basemap.py +196 -0
  8. geobox/aio/dashboard.py +342 -0
  9. geobox/aio/feature.py +527 -0
  10. geobox/aio/field.py +321 -0
  11. geobox/aio/file.py +522 -0
  12. geobox/aio/layout.py +341 -0
  13. geobox/aio/log.py +145 -0
  14. geobox/aio/map.py +1034 -0
  15. geobox/aio/model3d.py +415 -0
  16. geobox/aio/mosaic.py +696 -0
  17. geobox/aio/plan.py +315 -0
  18. geobox/aio/query.py +702 -0
  19. geobox/aio/raster.py +869 -0
  20. geobox/aio/route.py +63 -0
  21. geobox/aio/scene.py +342 -0
  22. geobox/aio/settings.py +194 -0
  23. geobox/aio/task.py +402 -0
  24. geobox/aio/tile3d.py +339 -0
  25. geobox/aio/tileset.py +672 -0
  26. geobox/aio/usage.py +243 -0
  27. geobox/aio/user.py +507 -0
  28. geobox/aio/vectorlayer.py +1363 -0
  29. geobox/aio/version.py +273 -0
  30. geobox/aio/view.py +983 -0
  31. geobox/aio/workflow.py +341 -0
  32. geobox/api.py +14 -13
  33. geobox/apikey.py +28 -1
  34. geobox/attachment.py +27 -1
  35. geobox/base.py +4 -4
  36. geobox/basemap.py +30 -1
  37. geobox/dashboard.py +27 -0
  38. geobox/feature.py +33 -13
  39. geobox/field.py +33 -21
  40. geobox/file.py +40 -46
  41. geobox/layout.py +28 -1
  42. geobox/log.py +31 -7
  43. geobox/map.py +56 -5
  44. geobox/model3d.py +98 -19
  45. geobox/mosaic.py +47 -7
  46. geobox/plan.py +29 -3
  47. geobox/query.py +41 -5
  48. geobox/raster.py +45 -13
  49. geobox/scene.py +26 -0
  50. geobox/settings.py +30 -1
  51. geobox/task.py +28 -6
  52. geobox/tile3d.py +27 -1
  53. geobox/tileset.py +26 -5
  54. geobox/usage.py +32 -1
  55. geobox/user.py +62 -6
  56. geobox/utils.py +34 -0
  57. geobox/vectorlayer.py +59 -4
  58. geobox/version.py +25 -1
  59. geobox/view.py +54 -15
  60. geobox/workflow.py +27 -1
  61. {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/METADATA +4 -1
  62. geobox-2.0.0.dist-info/RECORD +68 -0
  63. geobox-1.4.1.dist-info/RECORD +0 -38
  64. {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/WHEEL +0 -0
  65. {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/licenses/LICENSE +0 -0
  66. {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/top_level.txt +0 -0
geobox/aio/plan.py ADDED
@@ -0,0 +1,315 @@
1
+ from typing import List, Dict, Optional, TYPE_CHECKING, Union
2
+ from urllib.parse import urljoin
3
+
4
+ from .base import AsyncBase
5
+
6
+ if TYPE_CHECKING:
7
+ from . import AsyncGeoboxClient
8
+ from ..api import GeoboxClient as SyncGeoboxClient
9
+ from ..plan import Plan as SyncPlan
10
+
11
+
12
+ class Plan(AsyncBase):
13
+
14
+ BASE_ENDPOINT = 'plans/'
15
+
16
+ def __init__(self,
17
+ api: 'AsyncGeoboxClient',
18
+ plan_id: int,
19
+ data: Optional[Dict] = {}):
20
+ """
21
+ Initialize a plan instance.
22
+
23
+ Args:
24
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
25
+ plan_id (str): The id for the plan.
26
+ data (Dict, optional): The data of the plan.
27
+ """
28
+ super().__init__(api, data=data)
29
+ self.plan_id = plan_id
30
+ self.endpoint = urljoin(self.BASE_ENDPOINT, str(self.id))
31
+
32
+
33
+ @classmethod
34
+ async def get_plans(cls, api: 'AsyncGeoboxClient', **kwargs) -> Union[List['Plan'], int]:
35
+ """
36
+ [async] Get list of plans with optional filtering and pagination.
37
+
38
+ Args:
39
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
40
+
41
+ Keyword Args:
42
+ q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
43
+ 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.
44
+ search_fields (str): comma separated list of fields for searching.
45
+ 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.
46
+ return_count (bool): Whether to return total count. default is False.
47
+ skip (int): Number of items to skip. default is 0.
48
+ limit (int): Number of items to return. default is 10.
49
+ user_id (int): Specific user. privileges required.
50
+ shared (bool): Whether to return shared plans. default is False.
51
+
52
+ Returns:
53
+ List[Plan] | int: A list of plan instances or the total number of plans.
54
+
55
+ Example:
56
+ >>> from geobox.aio import AsyncGeoboxClient
57
+ >>> from geobox.aio.plan import Plan
58
+ >>> async with AsyncGeoboxClient() as client:
59
+ >>> plans = await Plan.get_plan(client, q="name LIKE '%My plan%'")
60
+ or
61
+ >>> plans = await client.get_plan(q="name LIKE '%My plan%'")
62
+ """
63
+ params = {
64
+ 'f': 'json',
65
+ 'q': kwargs.get('q'),
66
+ 'search': kwargs.get('search'),
67
+ 'search_fields': kwargs.get('search_fields'),
68
+ 'order_by': kwargs.get('order_by'),
69
+ 'return_count': kwargs.get('return_count', False),
70
+ 'skip': kwargs.get('skip', 0),
71
+ 'limit': kwargs.get('limit', 10),
72
+ 'user_id': kwargs.get('user_id'),
73
+ 'shared': kwargs.get('shared', False)
74
+ }
75
+ return await super()._get_list(api, cls.BASE_ENDPOINT, params, factory_func=lambda api, item: Plan(api, item['id'], item))
76
+
77
+
78
+ @classmethod
79
+ async def create_plan(cls,
80
+ api: 'AsyncGeoboxClient',
81
+ name: str,
82
+ plan_color: str,
83
+ storage: int,
84
+ concurrent_tasks: int,
85
+ daily_api_calls: int,
86
+ monthly_api_calls: int,
87
+ daily_traffic: int,
88
+ monthly_traffic: int,
89
+ daily_process: int,
90
+ monthly_process: int,
91
+ number_of_days: int = None,
92
+ display_name: str = None,
93
+ description: str = None) -> 'Plan':
94
+ """
95
+ [async] Create a new plan.
96
+
97
+ Args:
98
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
99
+ name (str): The name of the plan.
100
+ plan_color (str): hex value of the color. e.g. #000000.
101
+ storage (int): storage value in bytes. must be greater that 1.
102
+ concurrent_tasks (int): number of concurrent tasks. must be greater that 1.
103
+ daily_api_calls (int): number of daily api calls. must be greater that 1.
104
+ monthly_api_calls (int): number of monthly api calls. must be greater that 1.
105
+ daily_traffic (int): number of daily traffic. must be greater that 1.
106
+ monthly_traffic (int): number of monthly traffic. must be greater that 1.
107
+ daily_process (int): number of daily processes. must be greater that 1.
108
+ monthly_process (int): number of monthly processes. must be greater that 1.
109
+ number_of_days (int, optional): number of days. must be greater that 1.
110
+ display_name (str, optional): display name of the plan.
111
+ description (str, optional): description of the plan.
112
+
113
+ Returns:
114
+ Plan: The newly created plan instance.
115
+
116
+ Raises:
117
+ ValidationError: If the plan data is invalid.
118
+
119
+ Example:
120
+ >>> from geobox.aio import AsyncGeoboxClient
121
+ >>> from geobox.aio.plan import Plan
122
+ >>> async with AsyncGeoboxClient() as client:
123
+ >>> plan = await Plan.create_plan(client,
124
+ ... name="new_plan",
125
+ ... display_name=" New Plan",
126
+ ... description="new plan description",
127
+ ... plan_color="#000000",
128
+ ... storage=10,
129
+ ... concurrent_tasks=10,
130
+ ... daily_api_calls=10,
131
+ ... monthly_api_calls=10,
132
+ ... daily_traffic=10,
133
+ ... monthly_traffic=10,
134
+ ... daily_process=10,
135
+ ... monthly_process=10,
136
+ ... number_of_days=10)
137
+ or
138
+ >>> plan = await client.create_plan(name="new_plan",
139
+ ... display_name=" New Plan",
140
+ ... description="new plan description",
141
+ ... plan_color="#000000",
142
+ ... storage=10,
143
+ ... concurrent_tasks=10,
144
+ ... daily_api_calls=10,
145
+ ... monthly_api_calls=10,
146
+ ... daily_traffic=10,
147
+ ... monthly_traffic=10,
148
+ ... daily_process=10,
149
+ ... monthly_process=10,
150
+ ... number_of_days=10)
151
+ """
152
+ data = {
153
+ "name": name,
154
+ "display_name": display_name,
155
+ "description": description,
156
+ "plan_color": plan_color,
157
+ "storage": storage,
158
+ "concurrent_tasks": concurrent_tasks,
159
+ "daily_api_calls": daily_api_calls,
160
+ "monthly_api_calls": monthly_api_calls,
161
+ "daily_traffic": daily_traffic,
162
+ "monthly_traffic": monthly_traffic,
163
+ "daily_process": daily_process,
164
+ "monthly_process": monthly_process,
165
+ "number_of_days": number_of_days
166
+ }
167
+ return await super()._create(api, cls.BASE_ENDPOINT, data, factory_func=lambda api, item: Plan(api, item['id'], item))
168
+
169
+
170
+ @classmethod
171
+ async def get_plan(cls, api: 'AsyncGeoboxClient', plan_id: int) -> 'Plan':
172
+ """
173
+ [async] Get a plan by its id.
174
+
175
+ Args:
176
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
177
+ plan_id (int): The id of the plan to get.
178
+
179
+ Returns:
180
+ Plan: The plan object
181
+
182
+ Raises:
183
+ NotFoundError: If the plan with the specified id is not found.
184
+
185
+ Example:
186
+ >>> from geobox.aio import AsyncGeoboxClient
187
+ >>> from geobox.aio.plan import Plan
188
+ >>> async with AsyncGeoboxClient() as client:
189
+ >>> plan = await Plan.get_plan(client, plan_id=1)
190
+ or
191
+ >>> plan = await client.get_plan(plan_id=1)
192
+ """
193
+ params = {
194
+ 'f': 'json'
195
+ }
196
+ return await super()._get_detail(api, cls.BASE_ENDPOINT, plan_id, params, factory_func=lambda api, item: Plan(api, item['id'], item))
197
+
198
+
199
+ @classmethod
200
+ async def get_plan_by_name(cls, api: 'AsyncGeoboxClient', name: str) -> Union['Plan', None]:
201
+ """
202
+ [async] Get a plan by name
203
+
204
+ Args:
205
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
206
+ name (str): the name of the plan to get
207
+
208
+ Returns:
209
+ Plan | None: returns the plan if a plan matches the given name, else None
210
+
211
+ Example:
212
+ >>> from geobox.aio import AsyncGeoboxClient
213
+ >>> from geobox.aio.plan import Plan
214
+ >>> async with AsyncGeoboxClient() as client:
215
+ >>> plan = await Plan.get_plan_by_name(client, name='test')
216
+ or
217
+ >>> plan = await client.get_plan_by_name(name='test')
218
+ """
219
+ plans = await cls.get_plans(api, q=f"name = '{name}'")
220
+ if plans and plans[0].name == name:
221
+ return plans[0]
222
+ else:
223
+ return None
224
+
225
+
226
+ async def update(self, **kwargs) -> Dict:
227
+ """
228
+ [async] Update the plan
229
+
230
+ Keyword Args:
231
+ name (str): The name of the plan.
232
+ plan_color (str): hex value of the color. e.g. #000000.
233
+ storage (int): storage value in bytes. must be greater that 1.
234
+ concurrent_tasks (int): number of concurrent tasks. must be greater that 1.
235
+ daily_api_calls (int): number of daily api calls. must be greater that 1.
236
+ monthly_api_calls (int): number of monthly api calls. must be greater that 1.
237
+ daily_traffic (int): number of daily traffic. must be greater that 1.
238
+ monthly_traffic (int): number of monthly traffic. must be greater that 1.
239
+ daily_processes (int): number of daily processes. must be greater that 1.
240
+ monthly_processes (int): number of monthly processes. must be greater that 1.
241
+ number_of_days (int): number of days. must be greater that 1.
242
+ display_name (str): display name of the plan.
243
+ description (str): description of the plan.
244
+
245
+ Returns:
246
+ Dict: The updated plan data.
247
+
248
+ Raises:
249
+ ValidationError: If the plan data is invalid.
250
+
251
+ Example:
252
+ >>> from geobox.aio import AsyncGeoboxClient
253
+ >>> from geobox.aio.plan import Plan
254
+ >>> async with AsyncGeoboxClient() as client:
255
+ >>> plan = await Plan.get_plan(client, plan_id=1)
256
+ >>> await plan.update(display_name="New Display Name")
257
+ """
258
+ data = {
259
+ "name": kwargs.get('name'),
260
+ "display_name": kwargs.get('display_name'),
261
+ "description": kwargs.get('description'),
262
+ "plan_color": kwargs.get('plan_color'),
263
+ "storage": kwargs.get('storage'),
264
+ "concurrent_tasks": kwargs.get('concurrent_tasks'),
265
+ "daily_api_calls": kwargs.get('daily_api_calls'),
266
+ "monthly_api_calls": kwargs.get('monthly_api_calls'),
267
+ "daily_traffic": kwargs.get('daily_traffic'),
268
+ "monthly_traffic": kwargs.get('monthly_traffic'),
269
+ "daily_process": kwargs.get('daily_process'),
270
+ "monthly_process": kwargs.get('monthly_process'),
271
+ "number_of_days": kwargs.get('number_of_days')
272
+ }
273
+ return await super()._update(self.endpoint, data)
274
+
275
+
276
+ async def delete(self) -> None:
277
+ """
278
+ [async] Delete the plan.
279
+
280
+ Returns:
281
+ None
282
+
283
+ Example:
284
+ >>> from geobox.aio import AsyncGeoboxClient
285
+ >>> from geobox.aio.plan import Plan
286
+ >>> async with AsyncGeoboxClient() as client:
287
+ >>> plan = await Plan.get_plan(client, plan_id=1)
288
+ >>> await plan.delete()
289
+ """
290
+ await super().delete(self.endpoint)
291
+ self.plan_id = None
292
+
293
+
294
+ def to_sync(self, sync_client: 'SyncGeoboxClient') -> 'SyncPlan':
295
+ """
296
+ Switch to sync version of the plan instance to have access to the sync methods
297
+
298
+ Args:
299
+ sync_client (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
300
+
301
+ Returns:
302
+ geobox.plan.Plan: the sync instance of the plan.
303
+
304
+ Example:
305
+ >>> from geobox import Geoboxclient
306
+ >>> from geobox.aio import AsyncGeoboxClient
307
+ >>> from geobox.aio.plan import Plan
308
+ >>> client = GeoboxClient()
309
+ >>> async with AsyncGeoboxClient() as async_client:
310
+ >>> plan = await Plan.get_plan(async_client, plan_id=1)
311
+ >>> sync_plan = plan.to_sync(client)
312
+ """
313
+ from ..plan import Plan as SyncPlan
314
+
315
+ return SyncPlan(api=sync_client, plan_id=self.plan_id, data=self.data)