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/usage.py CHANGED
@@ -1,26 +1,26 @@
1
- from urllib.parse import urlencode, urljoin
2
- from typing import Optional, Dict, List, Union, TYPE_CHECKING
1
+ from urllib.parse import urlencode
2
+ from typing import Dict, List, Union, TYPE_CHECKING
3
3
  from datetime import datetime
4
4
 
5
5
  from .base import AsyncBase
6
- from .user import User
7
- from .apikey import ApiKey
6
+ from .user import AsyncUser
7
+ from .apikey import AsyncApiKey
8
8
  from ..utils import clean_data
9
9
  from ..enums import UsageScale, UsageParam
10
10
 
11
11
  if TYPE_CHECKING:
12
12
  from . import AsyncGeoboxClient
13
- from ..api import GeoboxClient as SyncGeoboxClient
14
- from ..usage import Usage as SyncUsage
13
+ from ..api import GeoboxClient
14
+ from ..usage import Usage
15
15
 
16
16
 
17
- class Usage(AsyncBase):
17
+ class AsyncUsage(AsyncBase):
18
18
 
19
19
  BASE_ENDPOINT = 'usage/'
20
20
 
21
21
  def __init__(self,
22
- api: 'AsyncGeoboxClient',
23
- user: 'User'):
22
+ api: 'AsyncGeoboxClient',
23
+ user: 'AsyncUser'):
24
24
  """
25
25
  Constructs the necessary attributes for the Usage object.
26
26
 
@@ -39,25 +39,25 @@ class Usage(AsyncBase):
39
39
  Returns:
40
40
  str: A string representation of the Usage object.
41
41
  """
42
- return f"Usage(user={self.user})"
42
+ return f"AsyncUsage(user={self.user})"
43
43
 
44
44
 
45
45
  @classmethod
46
46
  async def get_api_usage(cls,
47
- api: 'AsyncGeoboxClient',
48
- resource: Union['User', 'ApiKey'],
49
- scale: 'UsageScale',
50
- param: 'UsageParam',
51
- from_date: 'datetime' = None,
52
- to_date: 'datetime' = None,
53
- days_before_now: int = None,
54
- limit: int = None) -> List:
47
+ api: 'AsyncGeoboxClient',
48
+ resource: Union['AsyncUser', 'AsyncApiKey'],
49
+ scale: 'UsageScale',
50
+ param: 'UsageParam',
51
+ from_date: 'datetime' = None,
52
+ to_date: 'datetime' = None,
53
+ days_before_now: int = None,
54
+ limit: int = None) -> List:
55
55
  """
56
56
  [async] Get the api usage of a user
57
57
 
58
58
  Args:
59
59
  api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
60
- resource (User | ApiKey): User or ApiKey object.
60
+ resource (AsyncUser | AsyncApiKey): User or ApiKey object.
61
61
  scale (UsageScale): the scale of the report.
62
62
  param (UsageParam): traffic or calls.
63
63
  from_date (datetime, optional): datetime object in this format: "%Y-%m-%dT%H:%M:%S".
@@ -74,10 +74,10 @@ class Usage(AsyncBase):
74
74
 
75
75
  Example:
76
76
  >>> from geobox.aio import AsyncGeoboxClient
77
- >>> from geobox.aio.usage import Usage
77
+ >>> from geobox.aio.usage import AsyncUsage
78
78
  >>> async with AsyncGeoboxClient() as client:
79
79
  >>> user = await client.get_user() # gets current user
80
- >>> usage = await Usage.get_api_usage(client,
80
+ >>> usage = await AsyncUsage.get_api_usage(client,
81
81
  ... resource=user,
82
82
  ... scale=UsageScale.Day,
83
83
  ... param=UsageParam.Calls,
@@ -92,21 +92,22 @@ class Usage(AsyncBase):
92
92
  raise ValueError("one of days_before_now or from_date/to_date parameters must have value")
93
93
 
94
94
  params = {}
95
- if isinstance(resource, User):
95
+ if isinstance(resource, AsyncUser):
96
96
  params['eid'] = resource.user_id
97
- elif isinstance(resource, ApiKey):
97
+ elif isinstance(resource, AsyncApiKey):
98
98
  params['eid'] = resource.key
99
99
  else:
100
- raise ValueError("resource must be a 'user' or 'apikey' object")
101
-
102
- params = clean_data({**params,
103
- 'scale': scale.value if scale else None,
104
- 'param': param.value if param else None,
105
- 'from_date': from_date.strftime("%Y-%m-%dT%H:%M:%S.%f") if from_date else None,
106
- 'to_date': to_date.strftime("%Y-%m-%dT%H:%M:%S.%f") if to_date else None,
107
- 'days_before_now': days_before_now,
108
- 'limit': limit
109
- })
100
+ raise ValueError("resource must be a 'AsyncUser' or 'AsyncApikey' object")
101
+
102
+ params = clean_data({
103
+ **params,
104
+ 'scale': scale.value if scale else None,
105
+ 'param': param.value if param else None,
106
+ 'from_date': from_date.strftime("%Y-%m-%dT%H:%M:%S.%f") if from_date else None,
107
+ 'to_date': to_date.strftime("%Y-%m-%dT%H:%M:%S.%f") if to_date else None,
108
+ 'days_before_now': days_before_now,
109
+ 'limit': limit
110
+ })
110
111
  query_strings = urlencode(params)
111
112
  endpoint = f"{cls.BASE_ENDPOINT}api?{query_strings}"
112
113
 
@@ -115,11 +116,11 @@ class Usage(AsyncBase):
115
116
 
116
117
  @classmethod
117
118
  async def get_process_usage(cls,
118
- api: 'AsyncGeoboxClient',
119
- user_id: int = None,
120
- from_date: datetime = None,
121
- to_date: datetime = None,
122
- days_before_now: int = None) -> float:
119
+ api: 'AsyncGeoboxClient',
120
+ user_id: int = None,
121
+ from_date: datetime = None,
122
+ to_date: datetime = None,
123
+ days_before_now: int = None) -> float:
123
124
  """
124
125
  [async] Get process usage of a user in seconds
125
126
 
@@ -138,9 +139,9 @@ class Usage(AsyncBase):
138
139
 
139
140
  Example:
140
141
  >>> from geobox.aio import AsyncGeoboxClient
141
- >>> from geobox.aio.usage import Usage
142
+ >>> from geobox.aio.usage import AsyncUsage
142
143
  >>> async with AsyncGeoboxClient() as client:
143
- >>> process_usage = await Usage.get_process_usage(client, days_before_now=5)
144
+ >>> process_usage = await AsyncUsage.get_process_usage(client, days_before_now=5)
144
145
  or
145
146
  >>> process_usage = await client.get_process_usage(days_before_now=5)
146
147
  """
@@ -172,9 +173,9 @@ class Usage(AsyncBase):
172
173
 
173
174
  Returns:
174
175
  >>> from geobox.aio import AsyncGeoboxClient
175
- >>> from geobox.aio.usage import Usage
176
+ >>> from geobox.aio.usage import AsyncUsage
176
177
  >>> async with AsyncGeoboxClient() as client:
177
- >>> usage_summary = await Usage.get_usage_summary(client)
178
+ >>> usage_summary = await AsyncUsage.get_usage_summary(client)
178
179
  or
179
180
  >>> usage_summary = await client.get_usage_summary()
180
181
  """
@@ -200,9 +201,9 @@ class Usage(AsyncBase):
200
201
 
201
202
  Example:
202
203
  >>> from geobox.aio import AsyncGeoboxClient
203
- >>> from geobox.aio.usage import Usage
204
+ >>> from geobox.aio.usage import AsyncUsage
204
205
  >>> async with AsyncGeoboxClient() as client:
205
- >>> await Usage.update_usage(client)
206
+ >>> await AsyncUsage.update_usage(client)
206
207
  or
207
208
  >>> await client.update_usage()
208
209
  """
@@ -213,31 +214,31 @@ class Usage(AsyncBase):
213
214
  return await api.post(endpoint, payload=data)
214
215
 
215
216
 
216
- def to_sync(self, sync_client: 'SyncGeoboxClient') -> 'SyncUsage':
217
+ def to_sync(self, sync_client: 'GeoboxClient') -> 'Usage':
217
218
  """
218
219
  Switch to sync version of the usage instance to have access to the sync methods
219
220
 
220
221
  Args:
221
- sync_client (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
222
+ sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
222
223
 
223
224
  Returns:
224
- geobox.usage.Usage: the sync instance of the usage.
225
+ Usage: the sync instance of the usage.
225
226
 
226
227
  Example:
227
228
  >>> from geobox import Geoboxclient
228
229
  >>> from geobox.aio import AsyncGeoboxClient
229
- >>> from geobox.aio.usage import Usage
230
+ >>> from geobox.aio.usage import AsyncUsage
230
231
  >>> client = GeoboxClient()
231
232
  >>> async with AsyncGeoboxClient() as async_client:
232
233
  >>> user = await async_client.get_user()
233
- >>> usage = await Usage.get_api_usage(async_client,
234
+ >>> usage = await AsyncUsage.get_api_usage(async_client,
234
235
  ... resource=user,
235
236
  ... scale=UsageScale.Day,
236
237
  ... param=UsageParam.Calls,
237
238
  ... days_before_now=5)
238
239
  >>> sync_usage = await usage.to_sync(client)
239
240
  """
240
- from ..usage import Usage as SyncUsage
241
+ from ..usage import Usage
241
242
 
242
243
  user = self.user.to_sync(sync_client)
243
- return SyncUsage(api=sync_client, user=user)
244
+ return Usage(api=sync_client, user=user)