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