pygeobox 1.0.0__py3-none-any.whl → 1.0.2__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.
- pygeobox/__init__.py +63 -63
- pygeobox/api.py +2517 -2517
- pygeobox/apikey.py +232 -232
- pygeobox/attachment.py +297 -297
- pygeobox/base.py +364 -364
- pygeobox/basemap.py +162 -162
- pygeobox/dashboard.py +316 -316
- pygeobox/enums.py +354 -354
- pygeobox/exception.py +47 -47
- pygeobox/field.py +309 -309
- pygeobox/map.py +858 -858
- pygeobox/model3d.py +334 -334
- pygeobox/mosaic.py +647 -647
- pygeobox/plan.py +260 -260
- pygeobox/query.py +668 -668
- pygeobox/raster.py +756 -756
- pygeobox/route.py +63 -63
- pygeobox/scene.py +317 -317
- pygeobox/settings.py +165 -165
- pygeobox/task.py +354 -354
- pygeobox/tile3d.py +294 -294
- pygeobox/tileset.py +585 -585
- pygeobox/user.py +423 -423
- pygeobox/utils.py +43 -43
- pygeobox/vectorlayer.py +1149 -1149
- pygeobox/version.py +248 -248
- pygeobox/view.py +859 -859
- pygeobox/workflow.py +315 -315
- {pygeobox-1.0.0.dist-info → pygeobox-1.0.2.dist-info}/METADATA +22 -31
- pygeobox-1.0.2.dist-info/RECORD +37 -0
- {pygeobox-1.0.0.dist-info → pygeobox-1.0.2.dist-info}/licenses/LICENSE +21 -21
- pygeobox-1.0.0.dist-info/RECORD +0 -37
- {pygeobox-1.0.0.dist-info → pygeobox-1.0.2.dist-info}/WHEEL +0 -0
- {pygeobox-1.0.0.dist-info → pygeobox-1.0.2.dist-info}/top_level.txt +0 -0
pygeobox/workflow.py
CHANGED
@@ -1,315 +1,315 @@
|
|
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 Workflow(Base):
|
10
|
-
|
11
|
-
BASE_ENDPOINT = 'workflows/'
|
12
|
-
|
13
|
-
def __init__(self,
|
14
|
-
api: 'GeoboxClient',
|
15
|
-
uuid: str,
|
16
|
-
data: Optional[Dict] = {}):
|
17
|
-
"""
|
18
|
-
Initialize a workflow instance.
|
19
|
-
|
20
|
-
Args:
|
21
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
22
|
-
uuid (str): The unique identifier for the workflow.
|
23
|
-
data (Dict): The data of the workflow.
|
24
|
-
"""
|
25
|
-
super().__init__(api, uuid=uuid, data=data)
|
26
|
-
|
27
|
-
|
28
|
-
@classmethod
|
29
|
-
def get_workflows(cls, api: 'GeoboxClient', **kwargs) -> Union[List['Workflow'], int]:
|
30
|
-
"""
|
31
|
-
Get list of workflows 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 workflows. default is False.
|
46
|
-
|
47
|
-
Returns:
|
48
|
-
List[Workflow] | int: A list of workflow instances or the total number of workflows.
|
49
|
-
|
50
|
-
Example:
|
51
|
-
>>> from geobox import GeoboxClient
|
52
|
-
>>> from geobox.workflow import Workflow
|
53
|
-
>>> client = GeoboxClient()
|
54
|
-
>>> workflows = Workflow.get_workflow(client, q="name LIKE '%My workflow%'")
|
55
|
-
or
|
56
|
-
>>> workflows = client.get_workflow(q="name LIKE '%My workflow%'")
|
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: Workflow(api, item['uuid'], item))
|
71
|
-
|
72
|
-
|
73
|
-
@classmethod
|
74
|
-
def create_workflow(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) -> 'Workflow':
|
82
|
-
"""
|
83
|
-
Create a new workflow.
|
84
|
-
|
85
|
-
Args:
|
86
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
87
|
-
name (str): The name of the Workflow.
|
88
|
-
display_name (str): The display name of the workflow.
|
89
|
-
description (str): The description of the workflow.
|
90
|
-
settings (Dict): The settings of the workflow.
|
91
|
-
thumbnail (str): The thumbnail of the workflow.
|
92
|
-
user_id (int): Specific user. privileges workflow.
|
93
|
-
|
94
|
-
Returns:
|
95
|
-
Workflow: The newly created workflow instance.
|
96
|
-
|
97
|
-
Raises:
|
98
|
-
ValidationError: If the workflow data is invalid.
|
99
|
-
|
100
|
-
Example:
|
101
|
-
>>> from geobox import GeoboxClient
|
102
|
-
>>> from geobox.workflow import Workflow
|
103
|
-
>>> client = GeoboxClient()
|
104
|
-
>>> workflow = Workflow.create_workflow(client, name="my_workflow")
|
105
|
-
or
|
106
|
-
>>> workflow = client.create_workflow(name="my_workflow")
|
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: Workflow(api, item['uuid'], item))
|
117
|
-
|
118
|
-
|
119
|
-
@classmethod
|
120
|
-
def get_workflow(cls, api: 'GeoboxClient', uuid: str, user_id: int = None) -> 'Workflow':
|
121
|
-
"""
|
122
|
-
Get a workflow by its UUID.
|
123
|
-
|
124
|
-
Args:
|
125
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
126
|
-
uuid (str): The UUID of the workflow to get.
|
127
|
-
user_id (int): Specific user. privileges required.
|
128
|
-
|
129
|
-
Returns:
|
130
|
-
Workflow: The workflow object.
|
131
|
-
|
132
|
-
Raises:
|
133
|
-
NotFoundError: If the workflow with the specified UUID is not found.
|
134
|
-
|
135
|
-
Example:
|
136
|
-
>>> from geobox import GeoboxClient
|
137
|
-
>>> from geobox.workflow import Workflow
|
138
|
-
>>> client = GeoboxClient()
|
139
|
-
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
140
|
-
or
|
141
|
-
>>> workflow = client.get_workflow(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: Workflow(api, item['uuid'], item))
|
148
|
-
|
149
|
-
|
150
|
-
@classmethod
|
151
|
-
def get_workflow_by_name(cls, api: 'GeoboxClient', name: str, user_id: int = None) -> Union['Workflow', None]:
|
152
|
-
"""
|
153
|
-
Get a workflow by name
|
154
|
-
|
155
|
-
Args:
|
156
|
-
api (GeoboxClient): The GeoboxClient instance for making requests.
|
157
|
-
name (str): the name of the workflow to get
|
158
|
-
user_id (int, optional): specific user. privileges required.
|
159
|
-
|
160
|
-
Returns:
|
161
|
-
Workflow | None: returns the workflow if a workflow matches the given name, else None
|
162
|
-
|
163
|
-
Example:
|
164
|
-
>>> from geobox import GeoboxClient
|
165
|
-
>>> from geobox.workflow import Workflow
|
166
|
-
>>> client = GeoboxClient()
|
167
|
-
>>> workflow = Workflow.get_workflow_by_name(client, name='test')
|
168
|
-
or
|
169
|
-
>>> workflow = client.get_workflow_by_name(name='test')
|
170
|
-
"""
|
171
|
-
workflows = cls.get_workflows(api, q=f"name = '{name}'", user_id=user_id)
|
172
|
-
if workflows and workflows[0].name == name:
|
173
|
-
return workflows[0]
|
174
|
-
else:
|
175
|
-
return None
|
176
|
-
|
177
|
-
|
178
|
-
def update(self, **kwargs) -> Dict:
|
179
|
-
"""
|
180
|
-
Update the workflow.
|
181
|
-
|
182
|
-
Keyword Args:
|
183
|
-
name (str): The name of the workflow.
|
184
|
-
display_name (str): The display name of the workflow.
|
185
|
-
description (str): The description of the workflow.
|
186
|
-
settings (Dict): The settings of the workflow.
|
187
|
-
thumbnail (str): The thumbnail of the workflow.
|
188
|
-
|
189
|
-
Returns:
|
190
|
-
Dict: The updated workflow data.
|
191
|
-
|
192
|
-
Raises:
|
193
|
-
ValidationError: If the workflow data is invalid.
|
194
|
-
|
195
|
-
Example:
|
196
|
-
>>> from geobox import GeoboxClient
|
197
|
-
>>> from geobox.workflow import Workflow
|
198
|
-
>>> client = GeoboxClient()
|
199
|
-
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
200
|
-
>>> workflow.update_workflow(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 Workflow.
|
215
|
-
|
216
|
-
Returns:
|
217
|
-
None
|
218
|
-
|
219
|
-
Example:
|
220
|
-
>>> from geobox import GeoboxClient
|
221
|
-
>>> from geobox.workflow import Workflow
|
222
|
-
>>> client = GeoboxClient()
|
223
|
-
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
224
|
-
>>> workflow.delete()
|
225
|
-
"""
|
226
|
-
super().delete(self.endpoint)
|
227
|
-
|
228
|
-
|
229
|
-
@property
|
230
|
-
def thumbnail(self) -> str:
|
231
|
-
"""
|
232
|
-
Get the thumbnail URL of the Workflow.
|
233
|
-
|
234
|
-
Returns:
|
235
|
-
str: The thumbnail of the Workflow.
|
236
|
-
|
237
|
-
Example:
|
238
|
-
>>> from geobox import GeoboxClient
|
239
|
-
>>> from geobox.workflow import Workflow
|
240
|
-
>>> client = GeoboxClient()
|
241
|
-
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
242
|
-
>>> workflow.thumbnail
|
243
|
-
'https://example.com/thumbnail.png'
|
244
|
-
"""
|
245
|
-
endpoint = f"{self.api.base_url}{self.endpoint}thumbnail.png"
|
246
|
-
return endpoint
|
247
|
-
|
248
|
-
|
249
|
-
def share(self, users: List['User']) -> None:
|
250
|
-
"""
|
251
|
-
Shares the workflow with specified users.
|
252
|
-
|
253
|
-
Args:
|
254
|
-
users (List[User]): The list of user objects to share the workflow with.
|
255
|
-
|
256
|
-
Returns:
|
257
|
-
None
|
258
|
-
|
259
|
-
Example:
|
260
|
-
>>> from geobox import GeoboxClient
|
261
|
-
>>> from geobox.workflow import Workflow
|
262
|
-
>>> client = GeoboxClient()
|
263
|
-
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
264
|
-
>>> users = client.search_users(search='John')
|
265
|
-
>>> workflow.share(users=users)
|
266
|
-
"""
|
267
|
-
super()._share(self.endpoint, users)
|
268
|
-
|
269
|
-
|
270
|
-
def unshare(self, users: List['User']) -> None:
|
271
|
-
"""
|
272
|
-
Unshares the workflow with specified users.
|
273
|
-
|
274
|
-
Args:
|
275
|
-
users (List[User]): The list of user objects to unshare the workflow with.
|
276
|
-
|
277
|
-
Returns:
|
278
|
-
None
|
279
|
-
|
280
|
-
Example:
|
281
|
-
>>> from geobox import GeoboxClient
|
282
|
-
>>> from geobox.workflow import Workflow
|
283
|
-
>>> client = GeoboxClient()
|
284
|
-
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
285
|
-
>>> users = client.search_users(search='John')
|
286
|
-
>>> workflow.unshare(users=users)
|
287
|
-
"""
|
288
|
-
super()._unshare(self.endpoint, users)
|
289
|
-
|
290
|
-
|
291
|
-
def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['User']:
|
292
|
-
"""
|
293
|
-
Retrieves the list of users the workflow is shared with.
|
294
|
-
|
295
|
-
Args:
|
296
|
-
search (str, optional): The search query.
|
297
|
-
skip (int, optional): The number of users to skip.
|
298
|
-
limit (int, optional): The maximum number of users to retrieve.
|
299
|
-
|
300
|
-
Returns:
|
301
|
-
List[User]: The list of shared users.
|
302
|
-
|
303
|
-
Example:
|
304
|
-
>>> from geobox import GeoboxClient
|
305
|
-
>>> from geobox.workflow import Workflow
|
306
|
-
>>> client = GeoboxClient()
|
307
|
-
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
308
|
-
>>> workflow.get_shared_users(search='John', skip=0, limit=10)
|
309
|
-
"""
|
310
|
-
params = {
|
311
|
-
'search': search,
|
312
|
-
'skip': skip,
|
313
|
-
'limit': limit
|
314
|
-
}
|
315
|
-
return super()._get_shared_users(self.endpoint, params)
|
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 Workflow(Base):
|
10
|
+
|
11
|
+
BASE_ENDPOINT = 'workflows/'
|
12
|
+
|
13
|
+
def __init__(self,
|
14
|
+
api: 'GeoboxClient',
|
15
|
+
uuid: str,
|
16
|
+
data: Optional[Dict] = {}):
|
17
|
+
"""
|
18
|
+
Initialize a workflow instance.
|
19
|
+
|
20
|
+
Args:
|
21
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
22
|
+
uuid (str): The unique identifier for the workflow.
|
23
|
+
data (Dict): The data of the workflow.
|
24
|
+
"""
|
25
|
+
super().__init__(api, uuid=uuid, data=data)
|
26
|
+
|
27
|
+
|
28
|
+
@classmethod
|
29
|
+
def get_workflows(cls, api: 'GeoboxClient', **kwargs) -> Union[List['Workflow'], int]:
|
30
|
+
"""
|
31
|
+
Get list of workflows 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 workflows. default is False.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
List[Workflow] | int: A list of workflow instances or the total number of workflows.
|
49
|
+
|
50
|
+
Example:
|
51
|
+
>>> from geobox import GeoboxClient
|
52
|
+
>>> from geobox.workflow import Workflow
|
53
|
+
>>> client = GeoboxClient()
|
54
|
+
>>> workflows = Workflow.get_workflow(client, q="name LIKE '%My workflow%'")
|
55
|
+
or
|
56
|
+
>>> workflows = client.get_workflow(q="name LIKE '%My workflow%'")
|
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: Workflow(api, item['uuid'], item))
|
71
|
+
|
72
|
+
|
73
|
+
@classmethod
|
74
|
+
def create_workflow(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) -> 'Workflow':
|
82
|
+
"""
|
83
|
+
Create a new workflow.
|
84
|
+
|
85
|
+
Args:
|
86
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
87
|
+
name (str): The name of the Workflow.
|
88
|
+
display_name (str): The display name of the workflow.
|
89
|
+
description (str): The description of the workflow.
|
90
|
+
settings (Dict): The settings of the workflow.
|
91
|
+
thumbnail (str): The thumbnail of the workflow.
|
92
|
+
user_id (int): Specific user. privileges workflow.
|
93
|
+
|
94
|
+
Returns:
|
95
|
+
Workflow: The newly created workflow instance.
|
96
|
+
|
97
|
+
Raises:
|
98
|
+
ValidationError: If the workflow data is invalid.
|
99
|
+
|
100
|
+
Example:
|
101
|
+
>>> from geobox import GeoboxClient
|
102
|
+
>>> from geobox.workflow import Workflow
|
103
|
+
>>> client = GeoboxClient()
|
104
|
+
>>> workflow = Workflow.create_workflow(client, name="my_workflow")
|
105
|
+
or
|
106
|
+
>>> workflow = client.create_workflow(name="my_workflow")
|
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: Workflow(api, item['uuid'], item))
|
117
|
+
|
118
|
+
|
119
|
+
@classmethod
|
120
|
+
def get_workflow(cls, api: 'GeoboxClient', uuid: str, user_id: int = None) -> 'Workflow':
|
121
|
+
"""
|
122
|
+
Get a workflow by its UUID.
|
123
|
+
|
124
|
+
Args:
|
125
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
126
|
+
uuid (str): The UUID of the workflow to get.
|
127
|
+
user_id (int): Specific user. privileges required.
|
128
|
+
|
129
|
+
Returns:
|
130
|
+
Workflow: The workflow object.
|
131
|
+
|
132
|
+
Raises:
|
133
|
+
NotFoundError: If the workflow with the specified UUID is not found.
|
134
|
+
|
135
|
+
Example:
|
136
|
+
>>> from geobox import GeoboxClient
|
137
|
+
>>> from geobox.workflow import Workflow
|
138
|
+
>>> client = GeoboxClient()
|
139
|
+
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
140
|
+
or
|
141
|
+
>>> workflow = client.get_workflow(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: Workflow(api, item['uuid'], item))
|
148
|
+
|
149
|
+
|
150
|
+
@classmethod
|
151
|
+
def get_workflow_by_name(cls, api: 'GeoboxClient', name: str, user_id: int = None) -> Union['Workflow', None]:
|
152
|
+
"""
|
153
|
+
Get a workflow by name
|
154
|
+
|
155
|
+
Args:
|
156
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
157
|
+
name (str): the name of the workflow to get
|
158
|
+
user_id (int, optional): specific user. privileges required.
|
159
|
+
|
160
|
+
Returns:
|
161
|
+
Workflow | None: returns the workflow if a workflow matches the given name, else None
|
162
|
+
|
163
|
+
Example:
|
164
|
+
>>> from geobox import GeoboxClient
|
165
|
+
>>> from geobox.workflow import Workflow
|
166
|
+
>>> client = GeoboxClient()
|
167
|
+
>>> workflow = Workflow.get_workflow_by_name(client, name='test')
|
168
|
+
or
|
169
|
+
>>> workflow = client.get_workflow_by_name(name='test')
|
170
|
+
"""
|
171
|
+
workflows = cls.get_workflows(api, q=f"name = '{name}'", user_id=user_id)
|
172
|
+
if workflows and workflows[0].name == name:
|
173
|
+
return workflows[0]
|
174
|
+
else:
|
175
|
+
return None
|
176
|
+
|
177
|
+
|
178
|
+
def update(self, **kwargs) -> Dict:
|
179
|
+
"""
|
180
|
+
Update the workflow.
|
181
|
+
|
182
|
+
Keyword Args:
|
183
|
+
name (str): The name of the workflow.
|
184
|
+
display_name (str): The display name of the workflow.
|
185
|
+
description (str): The description of the workflow.
|
186
|
+
settings (Dict): The settings of the workflow.
|
187
|
+
thumbnail (str): The thumbnail of the workflow.
|
188
|
+
|
189
|
+
Returns:
|
190
|
+
Dict: The updated workflow data.
|
191
|
+
|
192
|
+
Raises:
|
193
|
+
ValidationError: If the workflow data is invalid.
|
194
|
+
|
195
|
+
Example:
|
196
|
+
>>> from geobox import GeoboxClient
|
197
|
+
>>> from geobox.workflow import Workflow
|
198
|
+
>>> client = GeoboxClient()
|
199
|
+
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
200
|
+
>>> workflow.update_workflow(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 Workflow.
|
215
|
+
|
216
|
+
Returns:
|
217
|
+
None
|
218
|
+
|
219
|
+
Example:
|
220
|
+
>>> from geobox import GeoboxClient
|
221
|
+
>>> from geobox.workflow import Workflow
|
222
|
+
>>> client = GeoboxClient()
|
223
|
+
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
224
|
+
>>> workflow.delete()
|
225
|
+
"""
|
226
|
+
super().delete(self.endpoint)
|
227
|
+
|
228
|
+
|
229
|
+
@property
|
230
|
+
def thumbnail(self) -> str:
|
231
|
+
"""
|
232
|
+
Get the thumbnail URL of the Workflow.
|
233
|
+
|
234
|
+
Returns:
|
235
|
+
str: The thumbnail of the Workflow.
|
236
|
+
|
237
|
+
Example:
|
238
|
+
>>> from geobox import GeoboxClient
|
239
|
+
>>> from geobox.workflow import Workflow
|
240
|
+
>>> client = GeoboxClient()
|
241
|
+
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
242
|
+
>>> workflow.thumbnail
|
243
|
+
'https://example.com/thumbnail.png'
|
244
|
+
"""
|
245
|
+
endpoint = f"{self.api.base_url}{self.endpoint}thumbnail.png"
|
246
|
+
return endpoint
|
247
|
+
|
248
|
+
|
249
|
+
def share(self, users: List['User']) -> None:
|
250
|
+
"""
|
251
|
+
Shares the workflow with specified users.
|
252
|
+
|
253
|
+
Args:
|
254
|
+
users (List[User]): The list of user objects to share the workflow with.
|
255
|
+
|
256
|
+
Returns:
|
257
|
+
None
|
258
|
+
|
259
|
+
Example:
|
260
|
+
>>> from geobox import GeoboxClient
|
261
|
+
>>> from geobox.workflow import Workflow
|
262
|
+
>>> client = GeoboxClient()
|
263
|
+
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
264
|
+
>>> users = client.search_users(search='John')
|
265
|
+
>>> workflow.share(users=users)
|
266
|
+
"""
|
267
|
+
super()._share(self.endpoint, users)
|
268
|
+
|
269
|
+
|
270
|
+
def unshare(self, users: List['User']) -> None:
|
271
|
+
"""
|
272
|
+
Unshares the workflow with specified users.
|
273
|
+
|
274
|
+
Args:
|
275
|
+
users (List[User]): The list of user objects to unshare the workflow with.
|
276
|
+
|
277
|
+
Returns:
|
278
|
+
None
|
279
|
+
|
280
|
+
Example:
|
281
|
+
>>> from geobox import GeoboxClient
|
282
|
+
>>> from geobox.workflow import Workflow
|
283
|
+
>>> client = GeoboxClient()
|
284
|
+
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
285
|
+
>>> users = client.search_users(search='John')
|
286
|
+
>>> workflow.unshare(users=users)
|
287
|
+
"""
|
288
|
+
super()._unshare(self.endpoint, users)
|
289
|
+
|
290
|
+
|
291
|
+
def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['User']:
|
292
|
+
"""
|
293
|
+
Retrieves the list of users the workflow is shared with.
|
294
|
+
|
295
|
+
Args:
|
296
|
+
search (str, optional): The search query.
|
297
|
+
skip (int, optional): The number of users to skip.
|
298
|
+
limit (int, optional): The maximum number of users to retrieve.
|
299
|
+
|
300
|
+
Returns:
|
301
|
+
List[User]: The list of shared users.
|
302
|
+
|
303
|
+
Example:
|
304
|
+
>>> from geobox import GeoboxClient
|
305
|
+
>>> from geobox.workflow import Workflow
|
306
|
+
>>> client = GeoboxClient()
|
307
|
+
>>> workflow = Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
|
308
|
+
>>> workflow.get_shared_users(search='John', skip=0, limit=10)
|
309
|
+
"""
|
310
|
+
params = {
|
311
|
+
'search': search,
|
312
|
+
'skip': skip,
|
313
|
+
'limit': limit
|
314
|
+
}
|
315
|
+
return super()._get_shared_users(self.endpoint, params)
|