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.
Files changed (139) hide show
  1. digitalhub/__init__.py +3 -8
  2. digitalhub/context/api.py +43 -6
  3. digitalhub/context/builder.py +1 -5
  4. digitalhub/context/context.py +28 -13
  5. digitalhub/entities/_base/_base/entity.py +0 -15
  6. digitalhub/entities/_base/context/entity.py +1 -4
  7. digitalhub/entities/_base/entity/builder.py +5 -5
  8. digitalhub/entities/_base/entity/entity.py +0 -8
  9. digitalhub/entities/_base/executable/entity.py +195 -87
  10. digitalhub/entities/_base/material/entity.py +11 -23
  11. digitalhub/entities/_base/material/utils.py +28 -4
  12. digitalhub/entities/_base/runtime_entity/builder.py +53 -18
  13. digitalhub/entities/_base/unversioned/entity.py +1 -1
  14. digitalhub/entities/_base/versioned/entity.py +1 -1
  15. digitalhub/entities/_commons/enums.py +1 -31
  16. digitalhub/entities/_commons/metrics.py +64 -30
  17. digitalhub/entities/_commons/utils.py +119 -30
  18. digitalhub/entities/_constructors/_resources.py +151 -0
  19. digitalhub/entities/{_base/entity/_constructors → _constructors}/name.py +18 -0
  20. digitalhub/entities/_processors/base/crud.py +381 -0
  21. digitalhub/entities/_processors/base/import_export.py +118 -0
  22. digitalhub/entities/_processors/base/processor.py +299 -0
  23. digitalhub/entities/_processors/base/special_ops.py +104 -0
  24. digitalhub/entities/_processors/context/crud.py +652 -0
  25. digitalhub/entities/_processors/context/import_export.py +242 -0
  26. digitalhub/entities/_processors/context/material.py +123 -0
  27. digitalhub/entities/_processors/context/processor.py +400 -0
  28. digitalhub/entities/_processors/context/special_ops.py +476 -0
  29. digitalhub/entities/_processors/processors.py +12 -0
  30. digitalhub/entities/_processors/utils.py +38 -102
  31. digitalhub/entities/artifact/crud.py +58 -22
  32. digitalhub/entities/artifact/utils.py +28 -13
  33. digitalhub/entities/builders.py +2 -0
  34. digitalhub/entities/dataitem/crud.py +63 -20
  35. digitalhub/entities/dataitem/table/entity.py +27 -22
  36. digitalhub/entities/dataitem/utils.py +82 -32
  37. digitalhub/entities/function/_base/entity.py +3 -6
  38. digitalhub/entities/function/crud.py +55 -24
  39. digitalhub/entities/model/_base/entity.py +62 -20
  40. digitalhub/entities/model/crud.py +59 -23
  41. digitalhub/entities/model/mlflow/utils.py +29 -20
  42. digitalhub/entities/model/utils.py +28 -13
  43. digitalhub/entities/project/_base/builder.py +0 -6
  44. digitalhub/entities/project/_base/entity.py +337 -164
  45. digitalhub/entities/project/_base/spec.py +4 -4
  46. digitalhub/entities/project/crud.py +28 -71
  47. digitalhub/entities/project/utils.py +7 -3
  48. digitalhub/entities/run/_base/builder.py +0 -4
  49. digitalhub/entities/run/_base/entity.py +70 -63
  50. digitalhub/entities/run/crud.py +79 -26
  51. digitalhub/entities/secret/_base/entity.py +1 -5
  52. digitalhub/entities/secret/crud.py +31 -28
  53. digitalhub/entities/task/_base/builder.py +0 -4
  54. digitalhub/entities/task/_base/entity.py +5 -5
  55. digitalhub/entities/task/_base/models.py +13 -16
  56. digitalhub/entities/task/crud.py +61 -29
  57. digitalhub/entities/trigger/_base/entity.py +1 -5
  58. digitalhub/entities/trigger/crud.py +89 -30
  59. digitalhub/entities/workflow/_base/entity.py +3 -8
  60. digitalhub/entities/workflow/crud.py +55 -24
  61. digitalhub/factory/entity.py +283 -0
  62. digitalhub/factory/enums.py +18 -0
  63. digitalhub/factory/registry.py +197 -0
  64. digitalhub/factory/runtime.py +44 -0
  65. digitalhub/factory/utils.py +3 -54
  66. digitalhub/runtimes/_base.py +2 -2
  67. digitalhub/stores/client/{dhcore/api_builder.py → api_builder.py} +3 -3
  68. digitalhub/stores/client/builder.py +19 -31
  69. digitalhub/stores/client/client.py +322 -0
  70. digitalhub/stores/client/configurator.py +408 -0
  71. digitalhub/stores/client/enums.py +50 -0
  72. digitalhub/stores/client/{dhcore/error_parser.py → error_parser.py} +0 -4
  73. digitalhub/stores/client/header_manager.py +61 -0
  74. digitalhub/stores/client/http_handler.py +152 -0
  75. digitalhub/stores/client/{_base/key_builder.py → key_builder.py} +14 -14
  76. digitalhub/stores/client/params_builder.py +330 -0
  77. digitalhub/stores/client/response_processor.py +102 -0
  78. digitalhub/stores/client/utils.py +35 -0
  79. digitalhub/stores/{credentials → configurator}/api.py +5 -9
  80. digitalhub/stores/configurator/configurator.py +123 -0
  81. digitalhub/stores/{credentials → configurator}/enums.py +27 -10
  82. digitalhub/stores/configurator/handler.py +213 -0
  83. digitalhub/stores/{credentials → configurator}/ini_module.py +31 -22
  84. digitalhub/stores/data/_base/store.py +0 -20
  85. digitalhub/stores/data/api.py +5 -7
  86. digitalhub/stores/data/builder.py +53 -27
  87. digitalhub/stores/data/local/store.py +0 -103
  88. digitalhub/stores/data/remote/store.py +0 -4
  89. digitalhub/stores/data/s3/configurator.py +39 -77
  90. digitalhub/stores/data/s3/store.py +57 -37
  91. digitalhub/stores/data/sql/configurator.py +66 -46
  92. digitalhub/stores/data/sql/store.py +171 -104
  93. digitalhub/stores/readers/data/factory.py +0 -8
  94. digitalhub/stores/readers/data/pandas/reader.py +9 -19
  95. digitalhub/utils/file_utils.py +0 -17
  96. digitalhub/utils/generic_utils.py +1 -14
  97. digitalhub/utils/git_utils.py +0 -8
  98. digitalhub/utils/io_utils.py +0 -12
  99. digitalhub/utils/store_utils.py +44 -0
  100. {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/METADATA +5 -4
  101. {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/RECORD +112 -113
  102. {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/WHEEL +1 -1
  103. digitalhub/entities/_commons/types.py +0 -9
  104. digitalhub/entities/_processors/base.py +0 -531
  105. digitalhub/entities/_processors/context.py +0 -1299
  106. digitalhub/entities/task/_base/utils.py +0 -22
  107. digitalhub/factory/factory.py +0 -381
  108. digitalhub/stores/client/_base/api_builder.py +0 -34
  109. digitalhub/stores/client/_base/client.py +0 -243
  110. digitalhub/stores/client/_base/params_builder.py +0 -34
  111. digitalhub/stores/client/api.py +0 -36
  112. digitalhub/stores/client/dhcore/client.py +0 -613
  113. digitalhub/stores/client/dhcore/configurator.py +0 -675
  114. digitalhub/stores/client/dhcore/enums.py +0 -34
  115. digitalhub/stores/client/dhcore/key_builder.py +0 -62
  116. digitalhub/stores/client/dhcore/models.py +0 -40
  117. digitalhub/stores/client/dhcore/params_builder.py +0 -278
  118. digitalhub/stores/client/dhcore/utils.py +0 -94
  119. digitalhub/stores/client/local/api_builder.py +0 -116
  120. digitalhub/stores/client/local/client.py +0 -573
  121. digitalhub/stores/client/local/enums.py +0 -15
  122. digitalhub/stores/client/local/key_builder.py +0 -62
  123. digitalhub/stores/client/local/params_builder.py +0 -120
  124. digitalhub/stores/credentials/__init__.py +0 -3
  125. digitalhub/stores/credentials/configurator.py +0 -210
  126. digitalhub/stores/credentials/handler.py +0 -176
  127. digitalhub/stores/credentials/store.py +0 -81
  128. digitalhub/stores/data/enums.py +0 -15
  129. digitalhub/stores/data/s3/utils.py +0 -78
  130. /digitalhub/entities/{_base/entity/_constructors → _constructors}/__init__.py +0 -0
  131. /digitalhub/entities/{_base/entity/_constructors → _constructors}/metadata.py +0 -0
  132. /digitalhub/entities/{_base/entity/_constructors → _constructors}/spec.py +0 -0
  133. /digitalhub/entities/{_base/entity/_constructors → _constructors}/status.py +0 -0
  134. /digitalhub/entities/{_base/entity/_constructors → _constructors}/uuid.py +0 -0
  135. /digitalhub/{stores/client/_base → entities/_processors/base}/__init__.py +0 -0
  136. /digitalhub/{stores/client/dhcore → entities/_processors/context}/__init__.py +0 -0
  137. /digitalhub/stores/{client/local → configurator}/__init__.py +0 -0
  138. {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/licenses/AUTHORS +0 -0
  139. {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/licenses/LICENSE +0 -0
@@ -1,22 +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
-
8
- def build_task_actions(kind_action_list: list[tuple[str, str]]) -> list[dict[str, str]]:
9
- """
10
- Build task actions.
11
-
12
- Parameters
13
- ----------
14
- kind_action_list : list[tuple[str, str]]
15
- List of kind-action couples.
16
-
17
- Returns
18
- -------
19
- list[dict[str, str]]
20
- Returns the task actions.
21
- """
22
- return [{"kind": kind, "action": action} for (kind, action) in kind_action_list]
@@ -1,381 +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.utils.exceptions import BuilderError
10
-
11
- if typing.TYPE_CHECKING:
12
- from digitalhub.entities._base.entity.builder import EntityBuilder
13
- from digitalhub.entities._base.entity.entity import Entity
14
- from digitalhub.entities._base.entity.metadata import Metadata
15
- from digitalhub.entities._base.entity.spec import Spec, SpecValidator
16
- from digitalhub.entities._base.entity.status import Status
17
- from digitalhub.entities._base.runtime_entity.builder import RuntimeEntityBuilder
18
- from digitalhub.runtimes._base import Runtime
19
- from digitalhub.runtimes.builder import RuntimeBuilder
20
-
21
-
22
- class Factory:
23
- """
24
- Factory for creating and managing entity and runtime builders.
25
-
26
- This class implements the Factory pattern to manage the creation of
27
- entities and runtimes through their respective builders. It maintains
28
- separate registries for entity and runtime builders.
29
-
30
- Many function arguments are called kind_to_build_from to avoid overwriting
31
- kind in kwargs.
32
-
33
- Attributes
34
- ----------
35
- _entity_builders : dict[str, EntityBuilder | RuntimeEntityBuilder]
36
- Registry of entity builders indexed by kind.
37
- _runtime_builders : dict[str, RuntimeBuilder]
38
- Registry of runtime builders indexed by kind.
39
-
40
- Notes
41
- -----
42
- All builder methods may raise BuilderError if the requested kind
43
- is not found in the registry.
44
- """
45
-
46
- def __init__(self):
47
- self._entity_builders: dict[str, EntityBuilder | RuntimeEntityBuilder] = {}
48
- self._runtime_builders: dict[str, RuntimeBuilder] = {}
49
-
50
- def add_entity_builder(self, name: str, builder: EntityBuilder | RuntimeEntityBuilder) -> None:
51
- """
52
- Register an entity builder.
53
-
54
- Parameters
55
- ----------
56
- name : str
57
- The unique identifier for the builder.
58
- builder : EntityBuilder or RuntimeEntityBuilder
59
- The builder instance to register.
60
-
61
- Returns
62
- -------
63
- None
64
-
65
- Raises
66
- ------
67
- BuilderError
68
- If a builder with the same name already exists.
69
- """
70
- if name in self._entity_builders:
71
- raise BuilderError(f"Builder {name} already exists.")
72
- self._entity_builders[name] = builder()
73
-
74
- def add_runtime_builder(self, name: str, builder: RuntimeBuilder) -> None:
75
- """
76
- Register a runtime builder.
77
-
78
- Parameters
79
- ----------
80
- name : str
81
- The unique identifier for the builder.
82
- builder : RuntimeBuilder
83
- The builder instance to register.
84
-
85
- Returns
86
- -------
87
- None
88
-
89
- Raises
90
- ------
91
- BuilderError
92
- If a builder with the same name already exists.
93
- """
94
- if name in self._runtime_builders:
95
- raise BuilderError(f"Builder {name} already exists.")
96
- self._runtime_builders[name] = builder()
97
-
98
- def build_entity_from_params(self, **kwargs) -> Entity:
99
- """
100
- Build an entity from parameters.
101
-
102
- Parameters
103
- ----------
104
- **kwargs
105
- Entity parameters.
106
-
107
- Returns
108
- -------
109
- Entity
110
- Entity object.
111
- """
112
- try:
113
- kind = kwargs["kind"]
114
- except KeyError:
115
- raise BuilderError("Missing 'kind' parameter.")
116
- self._raise_if_entity_builder_not_found(kind)
117
- return self._entity_builders[kind].build(**kwargs)
118
-
119
- def build_entity_from_dict(self, obj: dict) -> Entity:
120
- """
121
- Build an entity from a dictionary.
122
-
123
- Parameters
124
- ----------
125
- obj : dict
126
- Dictionary with entity data.
127
-
128
- Returns
129
- -------
130
- Entity
131
- Entity object.
132
- """
133
- try:
134
- kind = obj["kind"]
135
- except KeyError:
136
- raise BuilderError("Missing 'kind' parameter.")
137
- self._raise_if_entity_builder_not_found(kind)
138
- return self._entity_builders[kind].from_dict(obj)
139
-
140
- def build_spec(self, kind_to_build_from: str, **kwargs) -> Spec:
141
- """
142
- Build an entity spec.
143
-
144
- Parameters
145
- ----------
146
- kind_to_build_from : str
147
- Entity type.
148
- **kwargs
149
- Additional spec parameters.
150
-
151
- Returns
152
- -------
153
- Spec
154
- Spec object.
155
- """
156
- self._raise_if_entity_builder_not_found(kind_to_build_from)
157
- return self._entity_builders[kind_to_build_from].build_spec(**kwargs)
158
-
159
- def build_metadata(self, kind_to_build_from: str, **kwargs) -> Metadata:
160
- """
161
- Build an entity metadata.
162
-
163
- Parameters
164
- ----------
165
- kind_to_build_from : str
166
- Entity type.
167
- **kwargs
168
- Additional metadata parameters.
169
-
170
- Returns
171
- -------
172
- Metadata
173
- Metadata object.
174
- """
175
- self._raise_if_entity_builder_not_found(kind_to_build_from)
176
- return self._entity_builders[kind_to_build_from].build_metadata(**kwargs)
177
-
178
- def build_status(self, kind_to_build_from: str, **kwargs) -> Status:
179
- """
180
- Build an entity status.
181
-
182
- Parameters
183
- ----------
184
- kind_to_build_from : str
185
- Entity type.
186
- **kwargs
187
- Additional status parameters.
188
-
189
- Returns
190
- -------
191
- Status
192
- Status object.
193
- """
194
- self._raise_if_entity_builder_not_found(kind_to_build_from)
195
- return self._entity_builders[kind_to_build_from].build_status(**kwargs)
196
-
197
- def build_runtime(self, kind_to_build_from: str, project: str) -> Runtime:
198
- """
199
- Build a runtime.
200
-
201
- Parameters
202
- ----------
203
- kind_to_build_from : str
204
- Runtime type.
205
- project : str
206
- Project name.
207
-
208
- Returns
209
- -------
210
- Runtime
211
- Runtime object.
212
- """
213
- self._raise_if_runtime_builder_not_found(kind_to_build_from)
214
- return self._runtime_builders[kind_to_build_from].build(project=project)
215
-
216
- def get_entity_type_from_kind(self, kind: str) -> str:
217
- """
218
- Get entity type from builder.
219
-
220
- Parameters
221
- ----------
222
- kind : str
223
- Entity type.
224
-
225
- Returns
226
- -------
227
- str
228
- Entity type.
229
- """
230
- self._raise_if_entity_builder_not_found(kind)
231
- return self._entity_builders[kind].get_entity_type()
232
-
233
- def get_executable_kind(self, kind: str) -> str:
234
- """
235
- Get executable kind.
236
-
237
- Parameters
238
- ----------
239
- kind : str
240
- Kind.
241
-
242
- Returns
243
- -------
244
- str
245
- Executable kind.
246
- """
247
- self._raise_if_entity_builder_not_found(kind)
248
- return self._entity_builders[kind].get_executable_kind()
249
-
250
- def get_action_from_task_kind(self, kind: str, task_kind: str) -> str:
251
- """
252
- Get action from task.
253
-
254
- Parameters
255
- ----------
256
- kind : str
257
- Kind.
258
- task_kind : str
259
- Task kind.
260
-
261
- Returns
262
- -------
263
- str
264
- Action.
265
- """
266
- self._raise_if_entity_builder_not_found(kind)
267
- return self._entity_builders[kind].get_action_from_task_kind(task_kind)
268
-
269
- def get_task_kind_from_action(self, kind: str, action: str) -> list[str]:
270
- """
271
- Get task kinds from action.
272
-
273
- Parameters
274
- ----------
275
- kind : str
276
- Kind.
277
- action : str
278
- Action.
279
-
280
- Returns
281
- -------
282
- list of str
283
- Task kinds.
284
- """
285
- self._raise_if_entity_builder_not_found(kind)
286
- return self._entity_builders[kind].get_task_kind_from_action(action)
287
-
288
- def get_run_kind(self, kind: str) -> str:
289
- """
290
- Get run kind.
291
-
292
- Parameters
293
- ----------
294
- kind : str
295
- Kind.
296
-
297
- Returns
298
- -------
299
- str
300
- Run kind.
301
- """
302
- self._raise_if_entity_builder_not_found(kind)
303
- return self._entity_builders[kind].get_run_kind()
304
-
305
- def get_all_kinds(self, kind: str) -> list[str]:
306
- """
307
- Get all kinds.
308
-
309
- Parameters
310
- ----------
311
- kind : str
312
- Kind.
313
-
314
- Returns
315
- -------
316
- list of str
317
- All kinds.
318
- """
319
- return self._entity_builders[kind].get_all_kinds()
320
-
321
- def get_spec_validator(self, kind: str) -> SpecValidator:
322
- """
323
- Get spec validators.
324
-
325
- Parameters
326
- ----------
327
- kind : str
328
- Kind.
329
-
330
- Returns
331
- -------
332
- SpecValidator
333
- Spec validator.
334
- """
335
- self._raise_if_entity_builder_not_found(kind)
336
- return self._entity_builders[kind].get_spec_validator()
337
-
338
- def _raise_if_entity_builder_not_found(self, kind: str) -> None:
339
- """
340
- Verify entity builder existence.
341
-
342
- Parameters
343
- ----------
344
- kind : str
345
- The entity kind to verify.
346
-
347
- Returns
348
- -------
349
- None
350
-
351
- Raises
352
- ------
353
- BuilderError
354
- If no builder exists for the specified kind.
355
- """
356
- if kind not in self._entity_builders:
357
- raise BuilderError(f"Entity builder for kind '{kind}' not found.")
358
-
359
- def _raise_if_runtime_builder_not_found(self, kind: str) -> None:
360
- """
361
- Verify runtime builder existence.
362
-
363
- Parameters
364
- ----------
365
- kind : str
366
- The runtime kind to verify.
367
-
368
- Returns
369
- -------
370
- None
371
-
372
- Raises
373
- ------
374
- BuilderError
375
- If no builder exists for the specified kind.
376
- """
377
- if kind not in self._runtime_builders:
378
- raise BuilderError(f"Runtime builder for kind '{kind}' not found.")
379
-
380
-
381
- factory = Factory()
@@ -1,34 +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
- from abc import abstractmethod
8
-
9
-
10
- class ClientApiBuilder:
11
- """
12
- This class is used to build the API for the client.
13
- Depending on the client, the API is built differently.
14
- """
15
-
16
- @abstractmethod
17
- def build_api(self, category: str, operation: str, **kwargs) -> str:
18
- """
19
- Build the API for the client.
20
-
21
- Parameters
22
- ----------
23
- category : str
24
- The API category.
25
- operation : str
26
- The API operation.
27
- **kwargs : dict
28
- Additional keyword arguments.
29
-
30
- Returns
31
- -------
32
- str
33
- The formatted API endpoint.
34
- """
@@ -1,243 +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
- from abc import abstractmethod
9
- from typing import Any
10
-
11
- if typing.TYPE_CHECKING:
12
- from digitalhub.stores.client._base.api_builder import ClientApiBuilder
13
- from digitalhub.stores.client._base.key_builder import ClientKeyBuilder
14
- from digitalhub.stores.client._base.params_builder import ClientParametersBuilder
15
-
16
-
17
- class Client:
18
- """
19
- Base Client class interface.
20
-
21
- The client is an interface that handles the CRUD of an object during
22
- a session. It manages the creation, reading, updating, deleting and
23
- listing of objects and comes into two subclasses: Local and DHCore.
24
- """
25
-
26
- def __init__(self) -> None:
27
- self._api_builder: ClientApiBuilder = None
28
- self._key_builder: ClientKeyBuilder = None
29
- self._params_builder: ClientParametersBuilder = None
30
-
31
- ##############################
32
- # CRUD methods
33
- ##############################
34
-
35
- @abstractmethod
36
- def create_object(self, api: str, obj: Any, **kwargs) -> dict:
37
- """
38
- Create object method.
39
-
40
- Parameters
41
- ----------
42
- api : str
43
- The API endpoint to create the object.
44
- obj : Any
45
- The object to create.
46
- **kwargs : dict
47
- Additional keyword arguments.
48
-
49
- Returns
50
- -------
51
- dict
52
- The created object.
53
- """
54
-
55
- @abstractmethod
56
- def read_object(self, api: str, **kwargs) -> dict:
57
- """
58
- Read object method.
59
-
60
- Parameters
61
- ----------
62
- api : str
63
- The API endpoint to read the object.
64
- **kwargs : dict
65
- Additional keyword arguments.
66
-
67
- Returns
68
- -------
69
- dict
70
- The retrieved object.
71
- """
72
-
73
- @abstractmethod
74
- def update_object(self, api: str, obj: Any, **kwargs) -> dict:
75
- """
76
- Update object method.
77
-
78
- Parameters
79
- ----------
80
- api : str
81
- The API endpoint to update the object.
82
- obj : Any
83
- The object to update.
84
- **kwargs : dict
85
- Additional keyword arguments.
86
-
87
- Returns
88
- -------
89
- dict
90
- The updated object.
91
- """
92
-
93
- @abstractmethod
94
- def delete_object(self, api: str, **kwargs) -> dict:
95
- """
96
- Delete object method.
97
-
98
- Parameters
99
- ----------
100
- api : str
101
- The API endpoint to delete the object.
102
- **kwargs : dict
103
- Additional keyword arguments.
104
-
105
- Returns
106
- -------
107
- dict
108
- The deletion result.
109
- """
110
-
111
- @abstractmethod
112
- def list_objects(self, api: str, **kwargs) -> dict:
113
- """
114
- List objects method.
115
-
116
- Parameters
117
- ----------
118
- api : str
119
- The API endpoint to list objects.
120
- **kwargs : dict
121
- Additional keyword arguments.
122
-
123
- Returns
124
- -------
125
- dict
126
- The list of objects.
127
- """
128
-
129
- @abstractmethod
130
- def list_first_object(self, api: str, **kwargs) -> dict:
131
- """
132
- Read first object method.
133
-
134
- Parameters
135
- ----------
136
- api : str
137
- The API endpoint to read the first object.
138
- **kwargs : dict
139
- Additional keyword arguments.
140
-
141
- Returns
142
- -------
143
- dict
144
- The first object in the list.
145
- """
146
-
147
- @abstractmethod
148
- def search_objects(self, api: str, **kwargs) -> dict:
149
- """
150
- Search objects method.
151
-
152
- Parameters
153
- ----------
154
- api : str
155
- The API endpoint to search objects.
156
- **kwargs : dict
157
- Additional keyword arguments containing search parameters.
158
-
159
- Returns
160
- -------
161
- dict
162
- The search results.
163
- """
164
-
165
- ##############################
166
- # Build methods
167
- ##############################
168
-
169
- def build_api(self, category: str, operation: str, **kwargs) -> str:
170
- """
171
- Build the API for the client.
172
-
173
- Parameters
174
- ----------
175
- category : str
176
- API category.
177
- operation : str
178
- API operation.
179
- **kwargs : dict
180
- Additional parameters.
181
-
182
- Returns
183
- -------
184
- str
185
- API formatted.
186
- """
187
- return self._api_builder.build_api(category, operation, **kwargs)
188
-
189
- def build_key(self, category: str, *args, **kwargs) -> str:
190
- """
191
- Build the key for the client.
192
-
193
- Parameters
194
- ----------
195
- category : str
196
- Key category.
197
- *args : tuple
198
- Additional arguments.
199
- **kwargs : dict
200
- Additional parameters.
201
-
202
- Returns
203
- -------
204
- str
205
- Key formatted.
206
- """
207
- return self._key_builder.build_key(category, *args, **kwargs)
208
-
209
- def build_parameters(self, category: str, operation: str, **kwargs) -> dict:
210
- """
211
- Build the parameters for the client call.
212
-
213
- Parameters
214
- ----------
215
- category : str
216
- API category.
217
- operation : str
218
- API operation.
219
- **kwargs : dict
220
- Parameters to build.
221
-
222
- Returns
223
- -------
224
- dict
225
- Parameters formatted.
226
- """
227
- return self._params_builder.build_parameters(category, operation, **kwargs)
228
-
229
- ##############################
230
- # Interface methods
231
- ##############################
232
-
233
- @staticmethod
234
- @abstractmethod
235
- def is_local() -> bool:
236
- """
237
- Flag to check if client is local.
238
-
239
- Returns
240
- -------
241
- bool
242
- True if the client operates locally, False otherwise.
243
- """
@@ -1,34 +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
- from abc import abstractmethod
8
-
9
-
10
- class ClientParametersBuilder:
11
- """
12
- This class is used to build the parameters for the client call.
13
- Depending on the client, the parameters are built differently.
14
- """
15
-
16
- @abstractmethod
17
- def build_parameters(self, category: str, operation: str, **kwargs) -> dict:
18
- """
19
- Build the parameters for the client call.
20
-
21
- Parameters
22
- ----------
23
- category : str
24
- The API category.
25
- operation : str
26
- The API operation.
27
- **kwargs : dict
28
- Additional keyword arguments to build parameters from.
29
-
30
- Returns
31
- -------
32
- dict
33
- The formatted parameters for the client call.
34
- """