geobox 2.1.0__py3-none-any.whl → 2.2.1__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 (70) hide show
  1. geobox/__init__.py +61 -63
  2. geobox/aio/__init__.py +61 -63
  3. geobox/aio/api.py +491 -574
  4. geobox/aio/apikey.py +263 -263
  5. geobox/aio/attachment.py +341 -339
  6. geobox/aio/base.py +261 -262
  7. geobox/aio/basemap.py +196 -196
  8. geobox/aio/dashboard.py +340 -342
  9. geobox/aio/feature.py +35 -35
  10. geobox/aio/field.py +315 -321
  11. geobox/aio/file.py +72 -72
  12. geobox/aio/layout.py +340 -341
  13. geobox/aio/log.py +23 -23
  14. geobox/aio/map.py +1033 -1034
  15. geobox/aio/model3d.py +415 -415
  16. geobox/aio/mosaic.py +696 -696
  17. geobox/aio/plan.py +314 -314
  18. geobox/aio/query.py +693 -693
  19. geobox/aio/raster.py +88 -454
  20. geobox/aio/{analysis.py → raster_analysis.py} +153 -170
  21. geobox/aio/route.py +4 -4
  22. geobox/aio/scene.py +340 -342
  23. geobox/aio/settings.py +18 -18
  24. geobox/aio/task.py +404 -402
  25. geobox/aio/tile3d.py +337 -339
  26. geobox/aio/tileset.py +102 -103
  27. geobox/aio/usage.py +52 -51
  28. geobox/aio/user.py +506 -507
  29. geobox/aio/vector_tool.py +1968 -0
  30. geobox/aio/vectorlayer.py +316 -414
  31. geobox/aio/version.py +272 -273
  32. geobox/aio/view.py +1019 -983
  33. geobox/aio/workflow.py +340 -341
  34. geobox/api.py +14 -98
  35. geobox/apikey.py +262 -262
  36. geobox/attachment.py +336 -337
  37. geobox/base.py +384 -384
  38. geobox/basemap.py +194 -194
  39. geobox/dashboard.py +339 -341
  40. geobox/enums.py +31 -1
  41. geobox/feature.py +31 -10
  42. geobox/field.py +320 -320
  43. geobox/file.py +4 -4
  44. geobox/layout.py +339 -340
  45. geobox/log.py +4 -4
  46. geobox/map.py +1031 -1032
  47. geobox/model3d.py +410 -410
  48. geobox/mosaic.py +696 -696
  49. geobox/plan.py +313 -313
  50. geobox/query.py +691 -691
  51. geobox/raster.py +5 -368
  52. geobox/{analysis.py → raster_analysis.py} +108 -128
  53. geobox/scene.py +341 -342
  54. geobox/settings.py +194 -194
  55. geobox/task.py +399 -400
  56. geobox/tile3d.py +337 -338
  57. geobox/tileset.py +4 -4
  58. geobox/usage.py +3 -3
  59. geobox/user.py +503 -503
  60. geobox/vector_tool.py +1968 -0
  61. geobox/vectorlayer.py +5 -110
  62. geobox/version.py +272 -272
  63. geobox/view.py +981 -981
  64. geobox/workflow.py +338 -339
  65. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/METADATA +15 -1
  66. geobox-2.2.1.dist-info/RECORD +72 -0
  67. geobox-2.1.0.dist-info/RECORD +0 -70
  68. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/WHEEL +0 -0
  69. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/licenses/LICENSE +0 -0
  70. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/top_level.txt +0 -0
geobox/aio/apikey.py CHANGED
@@ -1,263 +1,263 @@
1
- from typing import List, Dict, Optional, TYPE_CHECKING
2
- from urllib.parse import urljoin
3
-
4
- from .base import AsyncBase
5
- from ..utils import clean_data
6
-
7
- if TYPE_CHECKING:
8
- from . import AsyncGeoboxClient
9
- from ..api import GeoboxClient as SyncGeoboxClient
10
- from ..apikey import ApiKey as SyncApikey
11
-
12
-
13
- class ApiKey(AsyncBase):
14
-
15
- BASE_ENDPOINT = 'apikeys/'
16
-
17
- def __init__(self,
18
- api: 'AsyncGeoboxClient',
19
- key_id: int,
20
- data: Optional[Dict] = {}):
21
- """
22
- Initialize an apikey instance.
23
-
24
- Args:
25
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
26
- key_id (int): The unique identifier for the apikey.
27
- data (Dict, optional): The data of the apikey.
28
- """
29
- super().__init__(api, data=data)
30
- self.key_id = key_id
31
- self.endpoint = urljoin(self.BASE_ENDPOINT, str(self.id))
32
-
33
-
34
- def __repr__(self) -> str:
35
- """
36
- Return a string representation of the attachment.
37
-
38
- Returns:
39
- str: The string representation of the attachment.
40
- """
41
- return f'ApiKey(id={self.key_id}, name={self.name}, revoked={self.revoked})'
42
-
43
-
44
- @classmethod
45
- async def get_apikeys(cls, api: 'AsyncGeoboxClient', **kwargs) -> List['ApiKey']:
46
- """
47
- [async] Get a list of apikeys
48
-
49
- Args:
50
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
51
-
52
- Keyword Args:
53
- search (str): search term for keyword-based searching among all textual fields.
54
- 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.
55
- skip (int): Number of layers to skip. default is 0.
56
- limit (int): Maximum number of layers to return. default is 10.
57
- user_id (int): Specific user. privileges required.
58
-
59
- Example:
60
- >>> from geobox.aio import AsyncGeoboxClient
61
- >>> from geobox.aio.apikey import ApiKey
62
- >>> async with AsyncGeoboxClient() as client:
63
- >>> apikeys = await ApiKey.get_apikeys(client)
64
- or
65
- >>> apikeys = await client.get_apikeys()
66
- """
67
- params = {
68
- 'search': kwargs.get('search'),
69
- 'order_by': kwargs.get('order_by'),
70
- 'skip': kwargs.get('skip'),
71
- 'limit': kwargs.get('limit'),
72
- 'user_id': kwargs.get('user_id')
73
- }
74
- return await super()._get_list(api, cls.BASE_ENDPOINT, params, factory_func=lambda api, item: ApiKey(api, item['id'], item))
75
-
76
-
77
- @classmethod
78
- async def create_apikey(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> 'ApiKey':
79
- """
80
- [async] Create an ApiKey
81
-
82
- Args:
83
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
84
- name (str): name of the key.
85
- user_id (int, optional): Specific user. privileges required.
86
-
87
- Returns:
88
- ApiKey: the apikey object
89
-
90
- Example:
91
- >>> from geobox.aio import AsyncGeoboxClient
92
- >>> from geobox.aio.apikey import ApiKey
93
- >>> async with AsyncGeoboxClient() as client:
94
- >>> apikey = await ApiKey.create_apikey(client, name='test')
95
- or
96
- >>> apikey = await client.create_apikey(name='test')
97
- """
98
- data = clean_data({
99
- 'name': name,
100
- 'user_id': user_id
101
- })
102
- response = await api.post(cls.BASE_ENDPOINT, payload=data, is_json=False)
103
- return ApiKey(api, response['id'], response)
104
-
105
-
106
- @classmethod
107
- async def get_apikey(cls, api: 'AsyncGeoboxClient', key_id: int) -> 'ApiKey':
108
- """
109
- [async] Get an ApiKey
110
-
111
- Args:
112
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
113
- key_id (str): the id of the apikey.
114
-
115
- Returns:
116
- ApiKey: the ApiKey object
117
-
118
- Example:
119
- >>> from geobox.aio import AsyncGeoboxClient
120
- >>> from geobox.aio.apikey import ApiKey
121
- >>> async with AsyncGeoboxClient() as client:
122
- >>> apikey = await ApiKey.get_apikey(client, key_id=1)
123
- or
124
- >>> apikey = await client.get_apikey(key_id=1)
125
- """
126
- params = {
127
- 'f': 'json'
128
- }
129
- return await super()._get_detail(api=api,
130
- endpoint=cls.BASE_ENDPOINT,
131
- uuid=key_id,
132
- params=params,
133
- factory_func=lambda api, item: ApiKey(api, item['id'], item))
134
-
135
-
136
- @classmethod
137
- async def get_apikey_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> 'ApiKey':
138
- """
139
- [async] Get an ApiKey by name
140
-
141
- Args:
142
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
143
- name (str): the name of the key to get
144
- user_id (int, optional): specific user. privileges required.
145
-
146
- Returns:
147
- ApiKey | None: returns the key if a key matches the given name, else None
148
-
149
- Example:
150
- >>> from geobox.aio import AsyncGeoboxClient
151
- >>> from geobox.aio.apikey import ApiKey
152
- >>> async with AsyncGeoboxClient() as client:
153
- >>> apikey = await ApiKey.get_apikey_by_name(client, name='test')
154
- or
155
- >>> apikey = await client.get_apikey_by_name(name='test')
156
- """
157
- apikeys = await cls.get_apikeys(api, search=name, user_id=user_id)
158
- if apikeys and apikeys[0].name == name:
159
- return apikeys[0]
160
- else:
161
- return None
162
-
163
-
164
- async def update(self, name: str, user_id: int = None) -> Dict:
165
- """
166
- [async] Update an ApiKey
167
-
168
- Args:
169
- name (str): the name of the key
170
- user_id (int, optional): Specific user. privileges required.
171
-
172
- Returns:
173
- Dict: Updated ApiKey data
174
-
175
- Example:
176
- >>> from geobox.aio import AsyncGeoboxClient
177
- >>> from geobox.aio.apikey import ApiKey
178
- >>> async with AsyncGeoboxClient() as client:
179
- >>> apikey = await ApiKey.get_apikey(client, key_id=1)
180
- >>> await apikey.update(name="updated_name")
181
- """
182
- data = clean_data({
183
- "name": name,
184
- "user_id": user_id
185
- })
186
-
187
- response = await self.api.put(self.endpoint, data, is_json=False)
188
- self._update_properties(response)
189
- return response
190
-
191
-
192
- async def delete(self) -> None:
193
- """
194
- [async] Delete the ApiKey.
195
-
196
- Returns:
197
- None
198
-
199
- Example:
200
- >>> from geobox.aio import AsyncGeoboxClient
201
- >>> from geobox.aio.apikey import ApiKey
202
- >>> async with AsyncGeoboxClient() as client:
203
- >>> apikey = await ApiKey.get_apikey(client, key_id=1)
204
- >>> await apikey.delete()
205
- """
206
- await super().delete(self.endpoint)
207
- self.key_id = None
208
-
209
-
210
- async def revoke(self) -> None:
211
- """
212
- [async] Revoke an ApiKey
213
-
214
- Example:
215
- >>> from geobox.aio import AsyncGeoboxClient
216
- >>> from geobox.aio.apikey import ApiKey
217
- >>> async with AsyncGeoboxClient() as client:
218
- >>> apikey = await ApiKey.get_apikey(client, key_id=1)
219
- >>> await apikey.revoke()
220
- """
221
- endpoint = f"{self.endpoint}/revoke"
222
- await self.api.post(endpoint)
223
- self.data['revoked'] = True
224
-
225
-
226
- async def grant(self) -> None:
227
- """
228
- [async] Grant an ApiKey
229
-
230
- Example:
231
- >>> from geobox.aio import AsyncGeoboxClient
232
- >>> from geobox.aio.apikey import ApiKey
233
- >>> async with AsyncGeoboxClient() as client:
234
- >>> apikey = await ApiKey.get_apikey(client, key_id=1)
235
- >>> await apikey.grant()
236
- """
237
- endpoint = f"{self.endpoint}/grant"
238
- await self.api.post(endpoint)
239
- self.data['revoked'] = False
240
-
241
-
242
- def to_sync(self, sync_client: 'SyncGeoboxClient') -> 'SyncApikey':
243
- """
244
- Switch to sync version of the apikey instance to have access to the sync methods
245
-
246
- Args:
247
- sync_client (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
248
-
249
- Returns:
250
- geobox.apikey.Apikey: the sync instance of the apikey.
251
-
252
- Example:
253
- >>> from geobox import Geoboxclient
254
- >>> from geobox.aio import AsyncGeoboxClient
255
- >>> from geobox.aio.apikey import ApiKey
256
- >>> client = GeoboxClient()
257
- >>> async with AsyncGeoboxClient() as async_client:
258
- >>> apikey = await ApiKey.get_apikey(async_client, key_id=1)
259
- >>> sync_apikey = apikey.to_sync(client)
260
- """
261
- from ..apikey import ApiKey as SyncApiKey
262
-
263
- return SyncApiKey(api=sync_client, key_id=self.key_id, data=self.data)
1
+ from typing import List, Dict, Optional, TYPE_CHECKING
2
+ from urllib.parse import urljoin
3
+
4
+ from .base import AsyncBase
5
+ from ..utils import clean_data
6
+
7
+ if TYPE_CHECKING:
8
+ from . import AsyncGeoboxClient
9
+ from ..api import GeoboxClient
10
+ from ..apikey import ApiKey
11
+
12
+
13
+ class AsyncApiKey(AsyncBase):
14
+
15
+ BASE_ENDPOINT = 'apikeys/'
16
+
17
+ def __init__(self,
18
+ api: 'AsyncGeoboxClient',
19
+ key_id: int,
20
+ data: Optional[Dict] = {}):
21
+ """
22
+ Initialize an apikey instance.
23
+
24
+ Args:
25
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
26
+ key_id (int): The unique identifier for the apikey.
27
+ data (Dict, optional): The data of the apikey.
28
+ """
29
+ super().__init__(api, data=data)
30
+ self.key_id = key_id
31
+ self.endpoint = urljoin(self.BASE_ENDPOINT, str(self.id))
32
+
33
+
34
+ def __repr__(self) -> str:
35
+ """
36
+ Return a string representation of the attachment.
37
+
38
+ Returns:
39
+ str: The string representation of the attachment.
40
+ """
41
+ return f'AsyncApiKey(id={self.key_id}, name={self.name}, revoked={self.revoked})'
42
+
43
+
44
+ @classmethod
45
+ async def get_apikeys(cls, api: 'AsyncGeoboxClient', **kwargs) -> List['AsyncApiKey']:
46
+ """
47
+ [async] Get a list of apikeys
48
+
49
+ Args:
50
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
51
+
52
+ Keyword Args:
53
+ search (str): search term for keyword-based searching among all textual fields.
54
+ 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.
55
+ skip (int): Number of layers to skip. default is 0.
56
+ limit (int): Maximum number of layers to return. default is 10.
57
+ user_id (int): Specific user. privileges required.
58
+
59
+ Example:
60
+ >>> from geobox.aio import AsyncGeoboxClient
61
+ >>> from geobox.aio.apikey import AsyncApiKey
62
+ >>> async with AsyncGeoboxClient() as client:
63
+ >>> apikeys = await AsyncApiKey.get_apikeys(client)
64
+ or
65
+ >>> apikeys = await client.get_apikeys()
66
+ """
67
+ params = {
68
+ 'search': kwargs.get('search'),
69
+ 'order_by': kwargs.get('order_by'),
70
+ 'skip': kwargs.get('skip'),
71
+ 'limit': kwargs.get('limit'),
72
+ 'user_id': kwargs.get('user_id')
73
+ }
74
+ return await super()._get_list(api, cls.BASE_ENDPOINT, params, factory_func=lambda api, item: AsyncApiKey(api, item['id'], item))
75
+
76
+
77
+ @classmethod
78
+ async def create_apikey(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> 'AsyncApiKey':
79
+ """
80
+ [async] Create an ApiKey
81
+
82
+ Args:
83
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
84
+ name (str): name of the key.
85
+ user_id (int, optional): Specific user. privileges required.
86
+
87
+ Returns:
88
+ ApiKey: the apikey object
89
+
90
+ Example:
91
+ >>> from geobox.aio import AsyncGeoboxClient
92
+ >>> from geobox.aio.apikey import AsyncApiKey
93
+ >>> async with AsyncGeoboxClient() as client:
94
+ >>> apikey = await AsyncApiKey.create_apikey(client, name='test')
95
+ or
96
+ >>> apikey = await client.create_apikey(name='test')
97
+ """
98
+ data = clean_data({
99
+ 'name': name,
100
+ 'user_id': user_id
101
+ })
102
+ response = await api.post(cls.BASE_ENDPOINT, payload=data, is_json=False)
103
+ return AsyncApiKey(api, response['id'], response)
104
+
105
+
106
+ @classmethod
107
+ async def get_apikey(cls, api: 'AsyncGeoboxClient', key_id: int) -> 'AsyncApiKey':
108
+ """
109
+ [async] Get an ApiKey
110
+
111
+ Args:
112
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
113
+ key_id (str): the id of the apikey.
114
+
115
+ Returns:
116
+ ApiKey: the ApiKey object
117
+
118
+ Example:
119
+ >>> from geobox.aio import AsyncGeoboxClient
120
+ >>> from geobox.aio.apikey import AsyncApiKey
121
+ >>> async with AsyncGeoboxClient() as client:
122
+ >>> apikey = await AsyncApiKey.get_apikey(client, key_id=1)
123
+ or
124
+ >>> apikey = await client.get_apikey(key_id=1)
125
+ """
126
+ params = {
127
+ 'f': 'json'
128
+ }
129
+ return await super()._get_detail(api=api,
130
+ endpoint=cls.BASE_ENDPOINT,
131
+ uuid=key_id,
132
+ params=params,
133
+ factory_func=lambda api, item: AsyncApiKey(api, item['id'], item))
134
+
135
+
136
+ @classmethod
137
+ async def get_apikey_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> 'AsyncApiKey':
138
+ """
139
+ [async] Get an ApiKey by name
140
+
141
+ Args:
142
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
143
+ name (str): the name of the key to get
144
+ user_id (int, optional): specific user. privileges required.
145
+
146
+ Returns:
147
+ ApiKey | None: returns the key if a key matches the given name, else None
148
+
149
+ Example:
150
+ >>> from geobox.aio import AsyncGeoboxClient
151
+ >>> from geobox.aio.apikey import AsyncApiKey
152
+ >>> async with AsyncGeoboxClient() as client:
153
+ >>> apikey = await AsyncApiKey.get_apikey_by_name(client, name='test')
154
+ or
155
+ >>> apikey = await client.get_apikey_by_name(name='test')
156
+ """
157
+ apikeys = await cls.get_apikeys(api, search=name, user_id=user_id)
158
+ if apikeys and apikeys[0].name == name:
159
+ return apikeys[0]
160
+ else:
161
+ return None
162
+
163
+
164
+ async def update(self, name: str, user_id: int = None) -> Dict:
165
+ """
166
+ [async] Update an ApiKey
167
+
168
+ Args:
169
+ name (str): the name of the key
170
+ user_id (int, optional): Specific user. privileges required.
171
+
172
+ Returns:
173
+ Dict: Updated ApiKey data
174
+
175
+ Example:
176
+ >>> from geobox.aio import AsyncGeoboxClient
177
+ >>> from geobox.aio.apikey import AsyncApiKey
178
+ >>> async with AsyncGeoboxClient() as client:
179
+ >>> apikey = await AsyncApiKey.get_apikey(client, key_id=1)
180
+ >>> await apikey.update(name="updated_name")
181
+ """
182
+ data = clean_data({
183
+ "name": name,
184
+ "user_id": user_id
185
+ })
186
+
187
+ response = await self.api.put(self.endpoint, data, is_json=False)
188
+ self._update_properties(response)
189
+ return response
190
+
191
+
192
+ async def delete(self) -> None:
193
+ """
194
+ [async] Delete the ApiKey.
195
+
196
+ Returns:
197
+ None
198
+
199
+ Example:
200
+ >>> from geobox.aio import AsyncGeoboxClient
201
+ >>> from geobox.aio.apikey import AsyncApiKey
202
+ >>> async with AsyncGeoboxClient() as client:
203
+ >>> apikey = await AsyncApiKey.get_apikey(client, key_id=1)
204
+ >>> await apikey.delete()
205
+ """
206
+ await super()._delete(self.endpoint)
207
+ self.key_id = None
208
+
209
+
210
+ async def revoke(self) -> None:
211
+ """
212
+ [async] Revoke an ApiKey
213
+
214
+ Example:
215
+ >>> from geobox.aio import AsyncGeoboxClient
216
+ >>> from geobox.aio.apikey import AsyncApiKey
217
+ >>> async with AsyncGeoboxClient() as client:
218
+ >>> apikey = await AsyncApiKey.get_apikey(client, key_id=1)
219
+ >>> await apikey.revoke()
220
+ """
221
+ endpoint = f"{self.endpoint}/revoke"
222
+ await self.api.post(endpoint)
223
+ self.data['revoked'] = True
224
+
225
+
226
+ async def grant(self) -> None:
227
+ """
228
+ [async] Grant an ApiKey
229
+
230
+ Example:
231
+ >>> from geobox.aio import AsyncGeoboxClient
232
+ >>> from geobox.aio.apikey import AsyncApiKey
233
+ >>> async with AsyncGeoboxClient() as client:
234
+ >>> apikey = await AsyncApiKey.get_apikey(client, key_id=1)
235
+ >>> await apikey.grant()
236
+ """
237
+ endpoint = f"{self.endpoint}/grant"
238
+ await self.api.post(endpoint)
239
+ self.data['revoked'] = False
240
+
241
+
242
+ def to_sync(self, sync_client: 'GeoboxClient') -> 'ApiKey':
243
+ """
244
+ Switch to sync version of the apikey instance to have access to the sync methods
245
+
246
+ Args:
247
+ sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
248
+
249
+ Returns:
250
+ ApiKey: the sync instance of the apikey.
251
+
252
+ Example:
253
+ >>> from geobox import Geoboxclient
254
+ >>> from geobox.aio import AsyncGeoboxClient
255
+ >>> from geobox.aio.apikey import AsyncApiKey
256
+ >>> client = GeoboxClient()
257
+ >>> async with AsyncGeoboxClient() as async_client:
258
+ >>> apikey = await AsyncApiKey.get_apikey(async_client, key_id=1)
259
+ >>> sync_apikey = apikey.to_sync(client)
260
+ """
261
+ from ..apikey import ApiKey
262
+
263
+ return ApiKey(api=sync_client, key_id=self.key_id, data=self.data)