digitalhub 0.13.0b3__py3-none-any.whl → 0.14.9__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.
- digitalhub/__init__.py +3 -8
- digitalhub/context/api.py +43 -6
- digitalhub/context/builder.py +1 -5
- digitalhub/context/context.py +28 -13
- digitalhub/entities/_base/_base/entity.py +0 -15
- digitalhub/entities/_base/context/entity.py +1 -4
- digitalhub/entities/_base/entity/builder.py +5 -5
- digitalhub/entities/_base/entity/entity.py +0 -8
- digitalhub/entities/_base/executable/entity.py +195 -87
- digitalhub/entities/_base/material/entity.py +11 -23
- digitalhub/entities/_base/material/utils.py +28 -4
- digitalhub/entities/_base/runtime_entity/builder.py +53 -18
- digitalhub/entities/_base/unversioned/entity.py +1 -1
- digitalhub/entities/_base/versioned/entity.py +1 -1
- digitalhub/entities/_commons/enums.py +1 -31
- digitalhub/entities/_commons/metrics.py +64 -30
- digitalhub/entities/_commons/utils.py +119 -30
- digitalhub/entities/_constructors/_resources.py +151 -0
- digitalhub/entities/{_base/entity/_constructors → _constructors}/name.py +18 -0
- digitalhub/entities/_processors/base/crud.py +381 -0
- digitalhub/entities/_processors/base/import_export.py +118 -0
- digitalhub/entities/_processors/base/processor.py +299 -0
- digitalhub/entities/_processors/base/special_ops.py +104 -0
- digitalhub/entities/_processors/context/crud.py +652 -0
- digitalhub/entities/_processors/context/import_export.py +242 -0
- digitalhub/entities/_processors/context/material.py +123 -0
- digitalhub/entities/_processors/context/processor.py +400 -0
- digitalhub/entities/_processors/context/special_ops.py +476 -0
- digitalhub/entities/_processors/processors.py +12 -0
- digitalhub/entities/_processors/utils.py +38 -102
- digitalhub/entities/artifact/crud.py +58 -22
- digitalhub/entities/artifact/utils.py +28 -13
- digitalhub/entities/builders.py +2 -0
- digitalhub/entities/dataitem/crud.py +63 -20
- digitalhub/entities/dataitem/table/entity.py +27 -22
- digitalhub/entities/dataitem/utils.py +82 -32
- digitalhub/entities/function/_base/entity.py +3 -6
- digitalhub/entities/function/crud.py +55 -24
- digitalhub/entities/model/_base/entity.py +62 -20
- digitalhub/entities/model/crud.py +59 -23
- digitalhub/entities/model/mlflow/utils.py +29 -20
- digitalhub/entities/model/utils.py +28 -13
- digitalhub/entities/project/_base/builder.py +0 -6
- digitalhub/entities/project/_base/entity.py +337 -164
- digitalhub/entities/project/_base/spec.py +4 -4
- digitalhub/entities/project/crud.py +28 -71
- digitalhub/entities/project/utils.py +7 -3
- digitalhub/entities/run/_base/builder.py +0 -4
- digitalhub/entities/run/_base/entity.py +70 -63
- digitalhub/entities/run/crud.py +79 -26
- digitalhub/entities/secret/_base/entity.py +1 -5
- digitalhub/entities/secret/crud.py +31 -28
- digitalhub/entities/task/_base/builder.py +0 -4
- digitalhub/entities/task/_base/entity.py +5 -5
- digitalhub/entities/task/_base/models.py +13 -16
- digitalhub/entities/task/crud.py +61 -29
- digitalhub/entities/trigger/_base/entity.py +1 -5
- digitalhub/entities/trigger/crud.py +89 -30
- digitalhub/entities/workflow/_base/entity.py +3 -8
- digitalhub/entities/workflow/crud.py +55 -24
- digitalhub/factory/entity.py +283 -0
- digitalhub/factory/enums.py +18 -0
- digitalhub/factory/registry.py +197 -0
- digitalhub/factory/runtime.py +44 -0
- digitalhub/factory/utils.py +3 -54
- digitalhub/runtimes/_base.py +2 -2
- digitalhub/stores/client/{dhcore/api_builder.py → api_builder.py} +3 -3
- digitalhub/stores/client/builder.py +19 -31
- digitalhub/stores/client/client.py +322 -0
- digitalhub/stores/client/configurator.py +408 -0
- digitalhub/stores/client/enums.py +50 -0
- digitalhub/stores/client/{dhcore/error_parser.py → error_parser.py} +0 -4
- digitalhub/stores/client/header_manager.py +61 -0
- digitalhub/stores/client/http_handler.py +152 -0
- digitalhub/stores/client/{_base/key_builder.py → key_builder.py} +14 -14
- digitalhub/stores/client/params_builder.py +330 -0
- digitalhub/stores/client/response_processor.py +102 -0
- digitalhub/stores/client/utils.py +35 -0
- digitalhub/stores/{credentials → configurator}/api.py +5 -9
- digitalhub/stores/configurator/configurator.py +123 -0
- digitalhub/stores/{credentials → configurator}/enums.py +27 -10
- digitalhub/stores/configurator/handler.py +213 -0
- digitalhub/stores/{credentials → configurator}/ini_module.py +31 -22
- digitalhub/stores/data/_base/store.py +0 -20
- digitalhub/stores/data/api.py +5 -7
- digitalhub/stores/data/builder.py +53 -27
- digitalhub/stores/data/local/store.py +0 -103
- digitalhub/stores/data/remote/store.py +0 -4
- digitalhub/stores/data/s3/configurator.py +39 -77
- digitalhub/stores/data/s3/store.py +57 -37
- digitalhub/stores/data/sql/configurator.py +66 -46
- digitalhub/stores/data/sql/store.py +171 -104
- digitalhub/stores/readers/data/factory.py +0 -8
- digitalhub/stores/readers/data/pandas/reader.py +9 -19
- digitalhub/utils/file_utils.py +0 -17
- digitalhub/utils/generic_utils.py +1 -14
- digitalhub/utils/git_utils.py +0 -8
- digitalhub/utils/io_utils.py +0 -12
- digitalhub/utils/store_utils.py +44 -0
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/METADATA +5 -4
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/RECORD +112 -113
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/WHEEL +1 -1
- digitalhub/entities/_commons/types.py +0 -9
- digitalhub/entities/_processors/base.py +0 -531
- digitalhub/entities/_processors/context.py +0 -1299
- digitalhub/entities/task/_base/utils.py +0 -22
- digitalhub/factory/factory.py +0 -381
- digitalhub/stores/client/_base/api_builder.py +0 -34
- digitalhub/stores/client/_base/client.py +0 -243
- digitalhub/stores/client/_base/params_builder.py +0 -34
- digitalhub/stores/client/api.py +0 -36
- digitalhub/stores/client/dhcore/client.py +0 -613
- digitalhub/stores/client/dhcore/configurator.py +0 -675
- digitalhub/stores/client/dhcore/enums.py +0 -34
- digitalhub/stores/client/dhcore/key_builder.py +0 -62
- digitalhub/stores/client/dhcore/models.py +0 -40
- digitalhub/stores/client/dhcore/params_builder.py +0 -278
- digitalhub/stores/client/dhcore/utils.py +0 -94
- digitalhub/stores/client/local/api_builder.py +0 -116
- digitalhub/stores/client/local/client.py +0 -573
- digitalhub/stores/client/local/enums.py +0 -15
- digitalhub/stores/client/local/key_builder.py +0 -62
- digitalhub/stores/client/local/params_builder.py +0 -120
- digitalhub/stores/credentials/__init__.py +0 -3
- digitalhub/stores/credentials/configurator.py +0 -210
- digitalhub/stores/credentials/handler.py +0 -176
- digitalhub/stores/credentials/store.py +0 -81
- digitalhub/stores/data/enums.py +0 -15
- digitalhub/stores/data/s3/utils.py +0 -78
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/__init__.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/metadata.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/spec.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/status.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/uuid.py +0 -0
- /digitalhub/{stores/client/_base → entities/_processors/base}/__init__.py +0 -0
- /digitalhub/{stores/client/dhcore → entities/_processors/context}/__init__.py +0 -0
- /digitalhub/stores/{client/local → configurator}/__init__.py +0 -0
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,531 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
import typing
|
|
8
|
-
|
|
9
|
-
from digitalhub.context.api import delete_context
|
|
10
|
-
from digitalhub.entities._commons.enums import ApiCategories, BackendOperations
|
|
11
|
-
from digitalhub.factory.factory import factory
|
|
12
|
-
from digitalhub.stores.client.api import get_client
|
|
13
|
-
from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError, EntityNotExistsError
|
|
14
|
-
from digitalhub.utils.io_utils import read_yaml
|
|
15
|
-
|
|
16
|
-
if typing.TYPE_CHECKING:
|
|
17
|
-
from digitalhub.entities.project._base.entity import Project
|
|
18
|
-
from digitalhub.stores.client._base.client import Client
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class BaseEntityOperationsProcessor:
|
|
22
|
-
"""
|
|
23
|
-
Processor for Base Entity operations.
|
|
24
|
-
|
|
25
|
-
This object interacts with the context, check the category of the object,
|
|
26
|
-
and then calls the appropriate method to perform the requested operation.
|
|
27
|
-
Operations can be CRUD, search, list, etc.
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
##############################
|
|
31
|
-
# CRUD base entity
|
|
32
|
-
##############################
|
|
33
|
-
|
|
34
|
-
def _create_base_entity(
|
|
35
|
-
self,
|
|
36
|
-
client: Client,
|
|
37
|
-
entity_type: str,
|
|
38
|
-
entity_dict: dict,
|
|
39
|
-
**kwargs,
|
|
40
|
-
) -> dict:
|
|
41
|
-
"""
|
|
42
|
-
Create object in backend.
|
|
43
|
-
|
|
44
|
-
Parameters
|
|
45
|
-
----------
|
|
46
|
-
client : Client
|
|
47
|
-
Client instance.
|
|
48
|
-
entity_type : str
|
|
49
|
-
Entity type.
|
|
50
|
-
entity_dict : dict
|
|
51
|
-
Object instance.
|
|
52
|
-
**kwargs : dict
|
|
53
|
-
Parameters to pass to the API call.
|
|
54
|
-
|
|
55
|
-
Returns
|
|
56
|
-
-------
|
|
57
|
-
dict
|
|
58
|
-
Object instance.
|
|
59
|
-
"""
|
|
60
|
-
api = client.build_api(
|
|
61
|
-
ApiCategories.BASE.value,
|
|
62
|
-
BackendOperations.CREATE.value,
|
|
63
|
-
entity_type=entity_type,
|
|
64
|
-
)
|
|
65
|
-
return client.create_object(api, entity_dict, **kwargs)
|
|
66
|
-
|
|
67
|
-
def create_project_entity(
|
|
68
|
-
self,
|
|
69
|
-
_entity: Project | None = None,
|
|
70
|
-
**kwargs,
|
|
71
|
-
) -> Project:
|
|
72
|
-
"""
|
|
73
|
-
Create object in backend.
|
|
74
|
-
|
|
75
|
-
Parameters
|
|
76
|
-
----------
|
|
77
|
-
_entity : Project
|
|
78
|
-
Object instance.
|
|
79
|
-
**kwargs : dict
|
|
80
|
-
Parameters to pass to entity builder.
|
|
81
|
-
|
|
82
|
-
Returns
|
|
83
|
-
-------
|
|
84
|
-
Project
|
|
85
|
-
Object instance.
|
|
86
|
-
"""
|
|
87
|
-
if _entity is not None:
|
|
88
|
-
client = _entity._client
|
|
89
|
-
obj = _entity
|
|
90
|
-
else:
|
|
91
|
-
client = get_client(kwargs.get("local"))
|
|
92
|
-
obj = factory.build_entity_from_params(**kwargs)
|
|
93
|
-
ent = self._create_base_entity(client, obj.ENTITY_TYPE, obj.to_dict())
|
|
94
|
-
ent["local"] = client.is_local()
|
|
95
|
-
return factory.build_entity_from_dict(ent)
|
|
96
|
-
|
|
97
|
-
def _read_base_entity(
|
|
98
|
-
self,
|
|
99
|
-
client: Client,
|
|
100
|
-
entity_type: str,
|
|
101
|
-
entity_name: str,
|
|
102
|
-
**kwargs,
|
|
103
|
-
) -> dict:
|
|
104
|
-
"""
|
|
105
|
-
Read object from backend.
|
|
106
|
-
|
|
107
|
-
Parameters
|
|
108
|
-
----------
|
|
109
|
-
client : Client
|
|
110
|
-
Client instance.
|
|
111
|
-
entity_type : str
|
|
112
|
-
Entity type.
|
|
113
|
-
entity_name : str
|
|
114
|
-
Entity name.
|
|
115
|
-
**kwargs : dict
|
|
116
|
-
Parameters to pass to the API call.
|
|
117
|
-
|
|
118
|
-
Returns
|
|
119
|
-
-------
|
|
120
|
-
dict
|
|
121
|
-
Object instance.
|
|
122
|
-
"""
|
|
123
|
-
api = client.build_api(
|
|
124
|
-
ApiCategories.BASE.value,
|
|
125
|
-
BackendOperations.READ.value,
|
|
126
|
-
entity_type=entity_type,
|
|
127
|
-
entity_name=entity_name,
|
|
128
|
-
)
|
|
129
|
-
return client.read_object(api, **kwargs)
|
|
130
|
-
|
|
131
|
-
def read_project_entity(
|
|
132
|
-
self,
|
|
133
|
-
entity_type: str,
|
|
134
|
-
entity_name: str,
|
|
135
|
-
**kwargs,
|
|
136
|
-
) -> Project:
|
|
137
|
-
"""
|
|
138
|
-
Read object from backend.
|
|
139
|
-
|
|
140
|
-
Parameters
|
|
141
|
-
----------
|
|
142
|
-
entity_type : str
|
|
143
|
-
Entity type.
|
|
144
|
-
entity_name : str
|
|
145
|
-
Entity name.
|
|
146
|
-
**kwargs : dict
|
|
147
|
-
Parameters to pass to entity builder.
|
|
148
|
-
|
|
149
|
-
Returns
|
|
150
|
-
-------
|
|
151
|
-
Project
|
|
152
|
-
Object instance.
|
|
153
|
-
"""
|
|
154
|
-
client = get_client(kwargs.pop("local", False))
|
|
155
|
-
obj = self._read_base_entity(client, entity_type, entity_name, **kwargs)
|
|
156
|
-
obj["local"] = client.is_local()
|
|
157
|
-
return factory.build_entity_from_dict(obj)
|
|
158
|
-
|
|
159
|
-
def import_project_entity(
|
|
160
|
-
self,
|
|
161
|
-
file: str,
|
|
162
|
-
**kwargs,
|
|
163
|
-
) -> Project:
|
|
164
|
-
"""
|
|
165
|
-
Import object from a YAML file and create a new object into the backend.
|
|
166
|
-
|
|
167
|
-
Parameters
|
|
168
|
-
----------
|
|
169
|
-
file : str
|
|
170
|
-
Path to YAML file.
|
|
171
|
-
**kwargs : dict
|
|
172
|
-
Additional keyword arguments.
|
|
173
|
-
|
|
174
|
-
Returns
|
|
175
|
-
-------
|
|
176
|
-
Project
|
|
177
|
-
Object instance.
|
|
178
|
-
"""
|
|
179
|
-
client = get_client(kwargs.pop("local", False))
|
|
180
|
-
obj: dict = read_yaml(file)
|
|
181
|
-
obj["status"] = {}
|
|
182
|
-
obj["local"] = client.is_local()
|
|
183
|
-
ent: Project = factory.build_entity_from_dict(obj)
|
|
184
|
-
|
|
185
|
-
try:
|
|
186
|
-
self._create_base_entity(ent._client, ent.ENTITY_TYPE, ent.to_dict())
|
|
187
|
-
except EntityAlreadyExistsError:
|
|
188
|
-
raise EntityError(f"Entity {ent.name} already exists. If you want to update it, use load instead.")
|
|
189
|
-
|
|
190
|
-
# Import related entities
|
|
191
|
-
ent._import_entities(obj)
|
|
192
|
-
ent.refresh()
|
|
193
|
-
return ent
|
|
194
|
-
|
|
195
|
-
def load_project_entity(
|
|
196
|
-
self,
|
|
197
|
-
file: str,
|
|
198
|
-
**kwargs,
|
|
199
|
-
) -> Project:
|
|
200
|
-
"""
|
|
201
|
-
Load object from a YAML file and update an existing object into the backend.
|
|
202
|
-
|
|
203
|
-
Parameters
|
|
204
|
-
----------
|
|
205
|
-
file : str
|
|
206
|
-
Path to YAML file.
|
|
207
|
-
**kwargs : dict
|
|
208
|
-
Additional keyword arguments.
|
|
209
|
-
|
|
210
|
-
Returns
|
|
211
|
-
-------
|
|
212
|
-
Project
|
|
213
|
-
Object instance.
|
|
214
|
-
"""
|
|
215
|
-
client = get_client(kwargs.pop("local", False))
|
|
216
|
-
obj: dict = read_yaml(file)
|
|
217
|
-
obj["local"] = client.is_local()
|
|
218
|
-
ent: Project = factory.build_entity_from_dict(obj)
|
|
219
|
-
|
|
220
|
-
try:
|
|
221
|
-
self._update_base_entity(ent._client, ent.ENTITY_TYPE, ent.name, ent.to_dict())
|
|
222
|
-
except EntityNotExistsError:
|
|
223
|
-
self._create_base_entity(ent._client, ent.ENTITY_TYPE, ent.to_dict())
|
|
224
|
-
|
|
225
|
-
# Load related entities
|
|
226
|
-
ent._load_entities(obj)
|
|
227
|
-
ent.refresh()
|
|
228
|
-
return ent
|
|
229
|
-
|
|
230
|
-
def _list_base_entities(
|
|
231
|
-
self,
|
|
232
|
-
client: Client,
|
|
233
|
-
entity_type: str,
|
|
234
|
-
**kwargs,
|
|
235
|
-
) -> list[dict]:
|
|
236
|
-
"""
|
|
237
|
-
List objects from backend.
|
|
238
|
-
|
|
239
|
-
Parameters
|
|
240
|
-
----------
|
|
241
|
-
client : Client
|
|
242
|
-
Client instance.
|
|
243
|
-
entity_type : str
|
|
244
|
-
Entity type.
|
|
245
|
-
**kwargs : dict
|
|
246
|
-
Parameters to pass to the API call.
|
|
247
|
-
|
|
248
|
-
Returns
|
|
249
|
-
-------
|
|
250
|
-
list[dict]
|
|
251
|
-
List of objects.
|
|
252
|
-
"""
|
|
253
|
-
api = client.build_api(
|
|
254
|
-
ApiCategories.BASE.value,
|
|
255
|
-
BackendOperations.LIST.value,
|
|
256
|
-
entity_type=entity_type,
|
|
257
|
-
)
|
|
258
|
-
return client.list_objects(api, **kwargs)
|
|
259
|
-
|
|
260
|
-
def list_project_entities(
|
|
261
|
-
self,
|
|
262
|
-
entity_type: str,
|
|
263
|
-
**kwargs,
|
|
264
|
-
) -> list[Project]:
|
|
265
|
-
"""
|
|
266
|
-
List objects from backend.
|
|
267
|
-
|
|
268
|
-
Parameters
|
|
269
|
-
----------
|
|
270
|
-
entity_type : str
|
|
271
|
-
Entity type.
|
|
272
|
-
**kwargs : dict
|
|
273
|
-
Parameters to pass to API call.
|
|
274
|
-
|
|
275
|
-
Returns
|
|
276
|
-
-------
|
|
277
|
-
list[Project]
|
|
278
|
-
List of objects.
|
|
279
|
-
"""
|
|
280
|
-
client = get_client(kwargs.pop("local", False))
|
|
281
|
-
objs = self._list_base_entities(client, entity_type, **kwargs)
|
|
282
|
-
entities = []
|
|
283
|
-
for obj in objs:
|
|
284
|
-
obj["local"] = client.is_local()
|
|
285
|
-
ent = factory.build_entity_from_dict(obj)
|
|
286
|
-
entities.append(ent)
|
|
287
|
-
return entities
|
|
288
|
-
|
|
289
|
-
def _update_base_entity(
|
|
290
|
-
self,
|
|
291
|
-
client: Client,
|
|
292
|
-
entity_type: str,
|
|
293
|
-
entity_name: str,
|
|
294
|
-
entity_dict: dict,
|
|
295
|
-
**kwargs,
|
|
296
|
-
) -> dict:
|
|
297
|
-
"""
|
|
298
|
-
Update object method.
|
|
299
|
-
|
|
300
|
-
Parameters
|
|
301
|
-
----------
|
|
302
|
-
client : Client
|
|
303
|
-
Client instance.
|
|
304
|
-
entity_type : str
|
|
305
|
-
Entity type.
|
|
306
|
-
entity_name : str
|
|
307
|
-
Entity name.
|
|
308
|
-
entity_dict : dict
|
|
309
|
-
Object instance.
|
|
310
|
-
**kwargs : dict
|
|
311
|
-
Parameters to pass to the API call.
|
|
312
|
-
|
|
313
|
-
Returns
|
|
314
|
-
-------
|
|
315
|
-
dict
|
|
316
|
-
Object instance.
|
|
317
|
-
"""
|
|
318
|
-
api = client.build_api(
|
|
319
|
-
ApiCategories.BASE.value,
|
|
320
|
-
BackendOperations.UPDATE.value,
|
|
321
|
-
entity_type=entity_type,
|
|
322
|
-
entity_name=entity_name,
|
|
323
|
-
)
|
|
324
|
-
return client.update_object(api, entity_dict, **kwargs)
|
|
325
|
-
|
|
326
|
-
def update_project_entity(
|
|
327
|
-
self,
|
|
328
|
-
entity_type: str,
|
|
329
|
-
entity_name: str,
|
|
330
|
-
entity_dict: dict,
|
|
331
|
-
**kwargs,
|
|
332
|
-
) -> Project:
|
|
333
|
-
"""
|
|
334
|
-
Update object method.
|
|
335
|
-
|
|
336
|
-
Parameters
|
|
337
|
-
----------
|
|
338
|
-
entity_type : str
|
|
339
|
-
Entity type.
|
|
340
|
-
entity_name : str
|
|
341
|
-
Entity name.
|
|
342
|
-
entity_dict : dict
|
|
343
|
-
Object instance.
|
|
344
|
-
**kwargs : dict
|
|
345
|
-
Parameters to pass to entity builder.
|
|
346
|
-
|
|
347
|
-
Returns
|
|
348
|
-
-------
|
|
349
|
-
Project
|
|
350
|
-
Object instance.
|
|
351
|
-
"""
|
|
352
|
-
client = get_client(kwargs.pop("local", False))
|
|
353
|
-
obj = self._update_base_entity(client, entity_type, entity_name, entity_dict, **kwargs)
|
|
354
|
-
obj["local"] = client.is_local()
|
|
355
|
-
return factory.build_entity_from_dict(obj)
|
|
356
|
-
|
|
357
|
-
def _delete_base_entity(
|
|
358
|
-
self,
|
|
359
|
-
client: Client,
|
|
360
|
-
entity_type: str,
|
|
361
|
-
entity_name: str,
|
|
362
|
-
**kwargs,
|
|
363
|
-
) -> dict:
|
|
364
|
-
"""
|
|
365
|
-
Delete object method.
|
|
366
|
-
|
|
367
|
-
Parameters
|
|
368
|
-
----------
|
|
369
|
-
client : Client
|
|
370
|
-
Client instance.
|
|
371
|
-
entity_type : str
|
|
372
|
-
Entity type.
|
|
373
|
-
entity_name : str
|
|
374
|
-
Entity name.
|
|
375
|
-
**kwargs : dict
|
|
376
|
-
Parameters to pass to the API call.
|
|
377
|
-
|
|
378
|
-
Returns
|
|
379
|
-
-------
|
|
380
|
-
dict
|
|
381
|
-
Response from backend.
|
|
382
|
-
"""
|
|
383
|
-
kwargs = client.build_parameters(
|
|
384
|
-
ApiCategories.BASE.value,
|
|
385
|
-
BackendOperations.DELETE.value,
|
|
386
|
-
**kwargs,
|
|
387
|
-
)
|
|
388
|
-
api = client.build_api(
|
|
389
|
-
ApiCategories.BASE.value,
|
|
390
|
-
BackendOperations.DELETE.value,
|
|
391
|
-
entity_type=entity_type,
|
|
392
|
-
entity_name=entity_name,
|
|
393
|
-
)
|
|
394
|
-
return client.delete_object(api, **kwargs)
|
|
395
|
-
|
|
396
|
-
def delete_project_entity(
|
|
397
|
-
self,
|
|
398
|
-
entity_type: str,
|
|
399
|
-
entity_name: str,
|
|
400
|
-
**kwargs,
|
|
401
|
-
) -> dict:
|
|
402
|
-
"""
|
|
403
|
-
Delete object method.
|
|
404
|
-
|
|
405
|
-
Parameters
|
|
406
|
-
----------
|
|
407
|
-
entity_type : str
|
|
408
|
-
Entity type.
|
|
409
|
-
entity_name : str
|
|
410
|
-
Entity name.
|
|
411
|
-
**kwargs : dict
|
|
412
|
-
Parameters to pass to entity builder.
|
|
413
|
-
|
|
414
|
-
Returns
|
|
415
|
-
-------
|
|
416
|
-
dict
|
|
417
|
-
Response from backend.
|
|
418
|
-
"""
|
|
419
|
-
if kwargs.pop("clean_context", True):
|
|
420
|
-
delete_context(entity_name)
|
|
421
|
-
client = get_client(kwargs.pop("local", False))
|
|
422
|
-
return self._delete_base_entity(
|
|
423
|
-
client,
|
|
424
|
-
entity_type,
|
|
425
|
-
entity_name,
|
|
426
|
-
**kwargs,
|
|
427
|
-
)
|
|
428
|
-
|
|
429
|
-
##############################
|
|
430
|
-
# Base entity operations
|
|
431
|
-
##############################
|
|
432
|
-
|
|
433
|
-
def _build_base_entity_key(
|
|
434
|
-
self,
|
|
435
|
-
client: Client,
|
|
436
|
-
entity_id: str,
|
|
437
|
-
) -> str:
|
|
438
|
-
"""
|
|
439
|
-
Build object key.
|
|
440
|
-
|
|
441
|
-
Parameters
|
|
442
|
-
----------
|
|
443
|
-
client : Client
|
|
444
|
-
Client instance.
|
|
445
|
-
entity_id : str
|
|
446
|
-
Entity ID.
|
|
447
|
-
|
|
448
|
-
Returns
|
|
449
|
-
-------
|
|
450
|
-
str
|
|
451
|
-
Object key.
|
|
452
|
-
"""
|
|
453
|
-
return client.build_key(ApiCategories.BASE.value, entity_id)
|
|
454
|
-
|
|
455
|
-
def build_project_key(
|
|
456
|
-
self,
|
|
457
|
-
entity_id: str,
|
|
458
|
-
**kwargs,
|
|
459
|
-
) -> str:
|
|
460
|
-
"""
|
|
461
|
-
Build object key.
|
|
462
|
-
|
|
463
|
-
Parameters
|
|
464
|
-
----------
|
|
465
|
-
entity_id : str
|
|
466
|
-
Entity ID.
|
|
467
|
-
**kwargs : dict
|
|
468
|
-
Parameters to pass to entity builder.
|
|
469
|
-
|
|
470
|
-
Returns
|
|
471
|
-
-------
|
|
472
|
-
str
|
|
473
|
-
Object key.
|
|
474
|
-
"""
|
|
475
|
-
client = get_client(kwargs.pop("local", False))
|
|
476
|
-
return self._build_base_entity_key(client, entity_id)
|
|
477
|
-
|
|
478
|
-
def share_project_entity(
|
|
479
|
-
self,
|
|
480
|
-
entity_type: str,
|
|
481
|
-
entity_name: str,
|
|
482
|
-
**kwargs,
|
|
483
|
-
) -> None:
|
|
484
|
-
"""
|
|
485
|
-
Share object method.
|
|
486
|
-
|
|
487
|
-
Parameters
|
|
488
|
-
----------
|
|
489
|
-
entity_type : str
|
|
490
|
-
Entity type.
|
|
491
|
-
entity_name : str
|
|
492
|
-
Entity name.
|
|
493
|
-
**kwargs : dict
|
|
494
|
-
Parameters to pass to entity builder.
|
|
495
|
-
|
|
496
|
-
Returns
|
|
497
|
-
-------
|
|
498
|
-
None
|
|
499
|
-
"""
|
|
500
|
-
client = get_client(kwargs.pop("local", False))
|
|
501
|
-
api = client.build_api(
|
|
502
|
-
ApiCategories.BASE.value,
|
|
503
|
-
BackendOperations.SHARE.value,
|
|
504
|
-
entity_type=entity_type,
|
|
505
|
-
entity_name=entity_name,
|
|
506
|
-
)
|
|
507
|
-
|
|
508
|
-
user = kwargs.pop("user", None)
|
|
509
|
-
if unshare := kwargs.pop("unshare", False):
|
|
510
|
-
users = client.read_object(api, **kwargs)
|
|
511
|
-
for u in users:
|
|
512
|
-
if u["user"] == user:
|
|
513
|
-
kwargs["id"] = u["id"]
|
|
514
|
-
break
|
|
515
|
-
else:
|
|
516
|
-
raise ValueError(f"User '{user}' does not have access to project.")
|
|
517
|
-
|
|
518
|
-
kwargs = client.build_parameters(
|
|
519
|
-
ApiCategories.BASE.value,
|
|
520
|
-
BackendOperations.SHARE.value,
|
|
521
|
-
unshare=unshare,
|
|
522
|
-
user=user,
|
|
523
|
-
**kwargs,
|
|
524
|
-
)
|
|
525
|
-
if unshare:
|
|
526
|
-
client.delete_object(api, **kwargs)
|
|
527
|
-
return
|
|
528
|
-
client.create_object(api, obj={}, **kwargs)
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
base_processor = BaseEntityOperationsProcessor()
|