digitalhub 0.11.0b7__py3-none-any.whl → 0.13.0__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.

Potentially problematic release.


This version of digitalhub might be problematic. Click here for more details.

Files changed (272) hide show
  1. digitalhub/__init__.py +4 -1
  2. digitalhub/context/api.py +9 -5
  3. digitalhub/context/builder.py +7 -5
  4. digitalhub/context/context.py +13 -1
  5. digitalhub/entities/__init__.py +3 -0
  6. digitalhub/entities/_base/__init__.py +3 -0
  7. digitalhub/entities/_base/_base/__init__.py +3 -0
  8. digitalhub/entities/_base/_base/entity.py +4 -0
  9. digitalhub/entities/_base/context/__init__.py +3 -0
  10. digitalhub/entities/_base/context/entity.py +4 -0
  11. digitalhub/entities/_base/entity/__init__.py +3 -0
  12. digitalhub/entities/_base/entity/_constructors/__init__.py +3 -0
  13. digitalhub/entities/_base/entity/_constructors/metadata.py +4 -0
  14. digitalhub/entities/_base/entity/_constructors/name.py +4 -0
  15. digitalhub/entities/_base/entity/_constructors/spec.py +4 -0
  16. digitalhub/entities/_base/entity/_constructors/status.py +4 -0
  17. digitalhub/entities/_base/entity/_constructors/uuid.py +4 -0
  18. digitalhub/entities/_base/entity/builder.py +4 -0
  19. digitalhub/entities/_base/entity/entity.py +4 -0
  20. digitalhub/entities/_base/entity/metadata.py +4 -0
  21. digitalhub/entities/_base/entity/spec.py +4 -0
  22. digitalhub/entities/_base/entity/status.py +4 -0
  23. digitalhub/entities/_base/executable/__init__.py +3 -0
  24. digitalhub/entities/_base/executable/entity.py +109 -57
  25. digitalhub/entities/_base/material/__init__.py +3 -0
  26. digitalhub/entities/_base/material/entity.py +15 -18
  27. digitalhub/entities/_base/material/spec.py +4 -0
  28. digitalhub/entities/_base/material/status.py +4 -0
  29. digitalhub/entities/_base/material/utils.py +5 -1
  30. digitalhub/entities/_base/runtime_entity/__init__.py +3 -0
  31. digitalhub/entities/_base/runtime_entity/builder.py +4 -0
  32. digitalhub/entities/_base/unversioned/__init__.py +3 -0
  33. digitalhub/entities/_base/unversioned/builder.py +4 -0
  34. digitalhub/entities/_base/unversioned/entity.py +4 -0
  35. digitalhub/entities/_base/versioned/__init__.py +3 -0
  36. digitalhub/entities/_base/versioned/builder.py +4 -0
  37. digitalhub/entities/_base/versioned/entity.py +4 -0
  38. digitalhub/entities/_commons/__init__.py +3 -0
  39. digitalhub/entities/_commons/enums.py +4 -0
  40. digitalhub/entities/_commons/metrics.py +68 -30
  41. digitalhub/entities/_commons/utils.py +40 -9
  42. digitalhub/entities/_processors/__init__.py +3 -0
  43. digitalhub/entities/_processors/base.py +154 -79
  44. digitalhub/entities/_processors/context.py +370 -215
  45. digitalhub/entities/_processors/utils.py +78 -30
  46. digitalhub/entities/artifact/__init__.py +3 -0
  47. digitalhub/entities/artifact/_base/__init__.py +3 -0
  48. digitalhub/entities/artifact/_base/builder.py +4 -0
  49. digitalhub/entities/artifact/_base/entity.py +4 -0
  50. digitalhub/entities/artifact/_base/spec.py +4 -0
  51. digitalhub/entities/artifact/_base/status.py +4 -0
  52. digitalhub/entities/artifact/artifact/__init__.py +3 -0
  53. digitalhub/entities/artifact/artifact/builder.py +4 -0
  54. digitalhub/entities/artifact/artifact/entity.py +4 -0
  55. digitalhub/entities/artifact/artifact/spec.py +4 -0
  56. digitalhub/entities/artifact/artifact/status.py +4 -0
  57. digitalhub/entities/artifact/crud.py +8 -0
  58. digitalhub/entities/artifact/utils.py +32 -13
  59. digitalhub/entities/builders.py +4 -0
  60. digitalhub/entities/dataitem/__init__.py +3 -0
  61. digitalhub/entities/dataitem/_base/__init__.py +3 -0
  62. digitalhub/entities/dataitem/_base/builder.py +4 -0
  63. digitalhub/entities/dataitem/_base/entity.py +4 -0
  64. digitalhub/entities/dataitem/_base/spec.py +4 -0
  65. digitalhub/entities/dataitem/_base/status.py +4 -0
  66. digitalhub/entities/dataitem/crud.py +18 -2
  67. digitalhub/entities/dataitem/dataitem/__init__.py +3 -0
  68. digitalhub/entities/dataitem/dataitem/builder.py +4 -0
  69. digitalhub/entities/dataitem/dataitem/entity.py +4 -0
  70. digitalhub/entities/dataitem/dataitem/spec.py +4 -0
  71. digitalhub/entities/dataitem/dataitem/status.py +4 -0
  72. digitalhub/entities/dataitem/iceberg/__init__.py +3 -0
  73. digitalhub/entities/dataitem/iceberg/builder.py +4 -0
  74. digitalhub/entities/dataitem/iceberg/entity.py +4 -0
  75. digitalhub/entities/dataitem/iceberg/spec.py +4 -0
  76. digitalhub/entities/dataitem/iceberg/status.py +4 -0
  77. digitalhub/entities/dataitem/table/__init__.py +3 -0
  78. digitalhub/entities/dataitem/table/builder.py +4 -0
  79. digitalhub/entities/dataitem/table/entity.py +7 -3
  80. digitalhub/entities/dataitem/table/models.py +4 -0
  81. digitalhub/entities/dataitem/table/spec.py +4 -0
  82. digitalhub/entities/dataitem/table/status.py +4 -0
  83. digitalhub/entities/dataitem/table/utils.py +4 -0
  84. digitalhub/entities/dataitem/utils.py +88 -35
  85. digitalhub/entities/function/__init__.py +3 -0
  86. digitalhub/entities/function/_base/__init__.py +3 -0
  87. digitalhub/entities/function/_base/builder.py +4 -0
  88. digitalhub/entities/function/_base/entity.py +4 -0
  89. digitalhub/entities/function/_base/spec.py +4 -0
  90. digitalhub/entities/function/_base/status.py +4 -0
  91. digitalhub/entities/function/crud.py +4 -0
  92. digitalhub/entities/model/__init__.py +3 -0
  93. digitalhub/entities/model/_base/__init__.py +3 -0
  94. digitalhub/entities/model/_base/builder.py +4 -0
  95. digitalhub/entities/model/_base/entity.py +4 -0
  96. digitalhub/entities/model/_base/spec.py +4 -0
  97. digitalhub/entities/model/_base/status.py +4 -0
  98. digitalhub/entities/model/crud.py +8 -0
  99. digitalhub/entities/model/huggingface/__init__.py +3 -0
  100. digitalhub/entities/model/huggingface/builder.py +4 -0
  101. digitalhub/entities/model/huggingface/entity.py +4 -0
  102. digitalhub/entities/model/huggingface/spec.py +4 -0
  103. digitalhub/entities/model/huggingface/status.py +4 -0
  104. digitalhub/entities/model/mlflow/__init__.py +3 -0
  105. digitalhub/entities/model/mlflow/builder.py +4 -0
  106. digitalhub/entities/model/mlflow/entity.py +4 -0
  107. digitalhub/entities/model/mlflow/models.py +4 -0
  108. digitalhub/entities/model/mlflow/spec.py +4 -0
  109. digitalhub/entities/model/mlflow/status.py +4 -0
  110. digitalhub/entities/model/mlflow/utils.py +4 -0
  111. digitalhub/entities/model/model/__init__.py +3 -0
  112. digitalhub/entities/model/model/builder.py +4 -0
  113. digitalhub/entities/model/model/entity.py +4 -0
  114. digitalhub/entities/model/model/spec.py +4 -0
  115. digitalhub/entities/model/model/status.py +4 -0
  116. digitalhub/entities/model/sklearn/__init__.py +3 -0
  117. digitalhub/entities/model/sklearn/builder.py +4 -0
  118. digitalhub/entities/model/sklearn/entity.py +4 -0
  119. digitalhub/entities/model/sklearn/spec.py +4 -0
  120. digitalhub/entities/model/sklearn/status.py +4 -0
  121. digitalhub/entities/model/utils.py +32 -13
  122. digitalhub/entities/project/__init__.py +3 -0
  123. digitalhub/entities/project/_base/__init__.py +3 -0
  124. digitalhub/entities/project/_base/builder.py +4 -0
  125. digitalhub/entities/project/_base/entity.py +4 -2
  126. digitalhub/entities/project/_base/models.py +4 -0
  127. digitalhub/entities/project/_base/spec.py +4 -0
  128. digitalhub/entities/project/_base/status.py +4 -0
  129. digitalhub/entities/project/crud.py +4 -0
  130. digitalhub/entities/project/utils.py +4 -0
  131. digitalhub/entities/run/__init__.py +3 -0
  132. digitalhub/entities/run/_base/__init__.py +3 -0
  133. digitalhub/entities/run/_base/builder.py +4 -0
  134. digitalhub/entities/run/_base/entity.py +6 -2
  135. digitalhub/entities/run/_base/spec.py +4 -0
  136. digitalhub/entities/run/_base/status.py +4 -0
  137. digitalhub/entities/run/crud.py +4 -0
  138. digitalhub/entities/secret/__init__.py +3 -0
  139. digitalhub/entities/secret/_base/__init__.py +3 -0
  140. digitalhub/entities/secret/_base/builder.py +4 -0
  141. digitalhub/entities/secret/_base/entity.py +4 -0
  142. digitalhub/entities/secret/_base/spec.py +4 -0
  143. digitalhub/entities/secret/_base/status.py +4 -0
  144. digitalhub/entities/secret/crud.py +4 -0
  145. digitalhub/entities/task/__init__.py +3 -0
  146. digitalhub/entities/task/_base/__init__.py +3 -0
  147. digitalhub/entities/task/_base/builder.py +4 -0
  148. digitalhub/entities/task/_base/entity.py +4 -0
  149. digitalhub/entities/task/_base/models.py +16 -3
  150. digitalhub/entities/task/_base/spec.py +4 -0
  151. digitalhub/entities/task/_base/status.py +4 -0
  152. digitalhub/entities/task/_base/utils.py +4 -0
  153. digitalhub/entities/task/crud.py +4 -0
  154. digitalhub/entities/trigger/__init__.py +3 -0
  155. digitalhub/entities/trigger/_base/__init__.py +3 -0
  156. digitalhub/entities/trigger/_base/builder.py +4 -0
  157. digitalhub/entities/trigger/_base/entity.py +15 -0
  158. digitalhub/entities/trigger/_base/spec.py +4 -0
  159. digitalhub/entities/trigger/_base/status.py +4 -0
  160. digitalhub/entities/trigger/crud.py +4 -0
  161. digitalhub/entities/trigger/lifecycle/__init__.py +3 -0
  162. digitalhub/entities/trigger/lifecycle/builder.py +4 -0
  163. digitalhub/entities/trigger/lifecycle/entity.py +4 -0
  164. digitalhub/entities/trigger/lifecycle/spec.py +4 -0
  165. digitalhub/entities/trigger/lifecycle/status.py +4 -0
  166. digitalhub/entities/trigger/scheduler/__init__.py +3 -0
  167. digitalhub/entities/trigger/scheduler/builder.py +4 -0
  168. digitalhub/entities/trigger/scheduler/entity.py +4 -0
  169. digitalhub/entities/trigger/scheduler/spec.py +4 -0
  170. digitalhub/entities/trigger/scheduler/status.py +4 -0
  171. digitalhub/entities/workflow/__init__.py +3 -0
  172. digitalhub/entities/workflow/_base/__init__.py +3 -0
  173. digitalhub/entities/workflow/_base/builder.py +4 -0
  174. digitalhub/entities/workflow/_base/entity.py +4 -0
  175. digitalhub/entities/workflow/_base/spec.py +4 -0
  176. digitalhub/entities/workflow/_base/status.py +4 -0
  177. digitalhub/entities/workflow/crud.py +4 -0
  178. digitalhub/factory/__init__.py +3 -0
  179. digitalhub/factory/factory.py +29 -3
  180. digitalhub/factory/utils.py +15 -3
  181. digitalhub/runtimes/__init__.py +3 -0
  182. digitalhub/runtimes/_base.py +5 -1
  183. digitalhub/runtimes/builder.py +22 -1
  184. digitalhub/runtimes/enums.py +4 -0
  185. digitalhub/stores/__init__.py +3 -0
  186. digitalhub/stores/client/__init__.py +15 -0
  187. digitalhub/stores/client/_base/__init__.py +3 -0
  188. digitalhub/stores/client/_base/api_builder.py +18 -0
  189. digitalhub/stores/client/_base/client.py +97 -0
  190. digitalhub/stores/client/_base/key_builder.py +32 -0
  191. digitalhub/stores/client/_base/params_builder.py +18 -0
  192. digitalhub/stores/client/api.py +14 -5
  193. digitalhub/stores/client/builder.py +7 -1
  194. digitalhub/stores/client/dhcore/__init__.py +3 -0
  195. digitalhub/stores/client/dhcore/api_builder.py +21 -0
  196. digitalhub/stores/client/dhcore/client.py +329 -70
  197. digitalhub/stores/client/dhcore/configurator.py +489 -193
  198. digitalhub/stores/client/dhcore/enums.py +7 -0
  199. digitalhub/stores/client/dhcore/error_parser.py +39 -1
  200. digitalhub/stores/client/dhcore/key_builder.py +4 -0
  201. digitalhub/stores/client/dhcore/models.py +4 -0
  202. digitalhub/stores/client/dhcore/params_builder.py +117 -17
  203. digitalhub/stores/client/dhcore/utils.py +44 -22
  204. digitalhub/stores/client/local/__init__.py +3 -0
  205. digitalhub/stores/client/local/api_builder.py +21 -0
  206. digitalhub/stores/client/local/client.py +10 -8
  207. digitalhub/stores/client/local/enums.py +4 -0
  208. digitalhub/stores/client/local/key_builder.py +4 -0
  209. digitalhub/stores/client/local/params_builder.py +4 -0
  210. digitalhub/stores/credentials/__init__.py +3 -0
  211. digitalhub/stores/credentials/api.py +35 -0
  212. digitalhub/stores/credentials/configurator.py +210 -0
  213. digitalhub/stores/credentials/enums.py +68 -0
  214. digitalhub/stores/credentials/handler.py +176 -0
  215. digitalhub/stores/credentials/ini_module.py +164 -0
  216. digitalhub/stores/credentials/store.py +81 -0
  217. digitalhub/stores/data/__init__.py +3 -0
  218. digitalhub/stores/data/_base/__init__.py +3 -0
  219. digitalhub/stores/data/_base/store.py +31 -9
  220. digitalhub/stores/data/api.py +53 -9
  221. digitalhub/stores/data/builder.py +94 -41
  222. digitalhub/stores/data/enums.py +4 -0
  223. digitalhub/stores/data/local/__init__.py +3 -0
  224. digitalhub/stores/data/local/store.py +8 -7
  225. digitalhub/stores/data/remote/__init__.py +3 -0
  226. digitalhub/stores/data/remote/store.py +8 -7
  227. digitalhub/stores/data/s3/__init__.py +3 -0
  228. digitalhub/stores/data/s3/configurator.py +69 -80
  229. digitalhub/stores/data/s3/store.py +73 -81
  230. digitalhub/stores/data/s3/utils.py +14 -10
  231. digitalhub/stores/data/sql/__init__.py +3 -0
  232. digitalhub/stores/data/sql/configurator.py +80 -73
  233. digitalhub/stores/data/sql/store.py +195 -102
  234. digitalhub/stores/readers/__init__.py +3 -0
  235. digitalhub/stores/readers/data/__init__.py +3 -0
  236. digitalhub/stores/readers/data/_base/__init__.py +3 -0
  237. digitalhub/stores/readers/data/_base/builder.py +4 -0
  238. digitalhub/stores/readers/data/_base/reader.py +4 -0
  239. digitalhub/stores/readers/data/api.py +4 -0
  240. digitalhub/stores/readers/data/factory.py +4 -0
  241. digitalhub/stores/readers/data/pandas/__init__.py +3 -0
  242. digitalhub/stores/readers/data/pandas/builder.py +4 -0
  243. digitalhub/stores/readers/data/pandas/reader.py +4 -0
  244. digitalhub/stores/readers/query/__init__.py +3 -0
  245. digitalhub/utils/__init__.py +3 -0
  246. digitalhub/utils/enums.py +4 -0
  247. digitalhub/utils/exceptions.py +10 -0
  248. digitalhub/utils/file_utils.py +57 -30
  249. digitalhub/utils/generic_utils.py +45 -33
  250. digitalhub/utils/git_utils.py +28 -14
  251. digitalhub/utils/io_utils.py +23 -18
  252. digitalhub/utils/logger.py +4 -0
  253. digitalhub/utils/types.py +4 -0
  254. digitalhub/utils/uri_utils.py +35 -31
  255. digitalhub-0.13.0.dist-info/METADATA +301 -0
  256. digitalhub-0.13.0.dist-info/RECORD +259 -0
  257. digitalhub-0.13.0.dist-info/licenses/AUTHORS +5 -0
  258. digitalhub-0.13.0.dist-info/licenses/LICENSE +201 -0
  259. digitalhub/entities/_commons/types.py +0 -5
  260. digitalhub/stores/configurator/__init__.py +0 -0
  261. digitalhub/stores/configurator/api.py +0 -31
  262. digitalhub/stores/configurator/configurator.py +0 -198
  263. digitalhub/stores/configurator/credentials_store.py +0 -65
  264. digitalhub/stores/configurator/enums.py +0 -21
  265. digitalhub/stores/configurator/ini_module.py +0 -128
  266. digitalhub/stores/data/s3/enums.py +0 -16
  267. digitalhub/stores/data/sql/enums.py +0 -16
  268. digitalhub/stores/data/utils.py +0 -34
  269. digitalhub-0.11.0b7.dist-info/METADATA +0 -259
  270. digitalhub-0.11.0b7.dist-info/RECORD +0 -261
  271. digitalhub-0.11.0b7.dist-info/licenses/LICENSE.txt +0 -216
  272. {digitalhub-0.11.0b7.dist-info → digitalhub-0.13.0.dist-info}/WHEEL +0 -0
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  from enum import Enum
@@ -15,6 +19,7 @@ class DhcoreEnvVar(Enum):
15
19
  CLIENT_ID = "DHCORE_CLIENT_ID"
16
20
  ACCESS_TOKEN = "DHCORE_ACCESS_TOKEN"
17
21
  REFRESH_TOKEN = "DHCORE_REFRESH_TOKEN"
22
+ PERSONAL_ACCESS_TOKEN = "DHCORE_PERSONAL_ACCESS_TOKEN"
18
23
  WORKFLOW_IMAGE = "DHCORE_WORKFLOW_IMAGE"
19
24
 
20
25
 
@@ -25,3 +30,5 @@ class AuthType(Enum):
25
30
 
26
31
  BASIC = "basic"
27
32
  OAUTH2 = "oauth2"
33
+ EXCHANGE = "exchange"
34
+ ACCESS_TOKEN = "access_token_only"
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  import typing
@@ -19,19 +23,53 @@ if typing.TYPE_CHECKING:
19
23
 
20
24
 
21
25
  class ErrorParser:
26
+ """
27
+ Parser for DHCore API errors.
28
+
29
+ This class handles the parsing and translation of HTTP responses
30
+ from the DHCore backend into appropriate Python exceptions.
31
+ """
32
+
22
33
  @staticmethod
23
34
  def parse(response: Response) -> None:
24
35
  """
25
36
  Handle DHCore API errors.
26
37
 
38
+ Parses the HTTP response and raises appropriate exceptions based on
39
+ the status code and response content. Maps backend errors to specific
40
+ exception types for better error handling in the client code.
41
+
27
42
  Parameters
28
43
  ----------
29
44
  response : Response
30
- The response object.
45
+ The HTTP response object from requests.
31
46
 
32
47
  Returns
33
48
  -------
34
49
  None
50
+
51
+ Raises
52
+ ------
53
+ TimeoutError
54
+ If the request timed out.
55
+ ConnectionError
56
+ If unable to connect to the backend.
57
+ MissingSpecError
58
+ If the backend reports a missing spec (400 status).
59
+ EntityAlreadyExistsError
60
+ If the entity already exists (400 status with specific message).
61
+ BadRequestError
62
+ For other 400 status codes.
63
+ UnauthorizedError
64
+ For 401 status codes.
65
+ ForbiddenError
66
+ For 403 status codes.
67
+ EntityNotExistsError
68
+ For 404 status codes with specific message.
69
+ BackendError
70
+ For other 404 status codes and general backend errors.
71
+ RuntimeError
72
+ For unexpected exceptions.
35
73
  """
36
74
  try:
37
75
  response.raise_for_status()
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  from digitalhub.stores.client._base.key_builder import ClientKeyBuilder
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  from pydantic import BaseModel
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  from digitalhub.entities._commons.enums import ApiCategories, BackendOperations
@@ -6,26 +10,65 @@ from digitalhub.stores.client._base.params_builder import ClientParametersBuilde
6
10
 
7
11
  class ClientDHCoreParametersBuilder(ClientParametersBuilder):
8
12
  """
9
- This class is used to build the parameters for the DHCore client calls.
13
+ Parameter builder for DHCore client API calls.
14
+
15
+ This class constructs HTTP request parameters for different DHCore API
16
+ operations, handling the specific parameter formats and query structures
17
+ required by the DigitalHub Core backend. It supports both base-level
18
+ operations (like project management) and context-level operations
19
+ (entity operations within projects).
20
+
21
+ The builder handles various parameter transformations including:
22
+ - Query parameter formatting for different operations
23
+ - Search filter construction for Solr-based searches
24
+ - Cascade deletion options
25
+ - Versioning parameters
26
+ - Entity sharing parameters
27
+
28
+ Methods
29
+ -------
30
+ build_parameters(category, operation, **kwargs)
31
+ Main entry point for parameter building based on API category.
32
+ build_parameters_base(operation, **kwargs)
33
+ Builds parameters for base-level API operations.
34
+ build_parameters_context(operation, **kwargs)
35
+ Builds parameters for context-level API operations.
10
36
  """
11
37
 
12
38
  def build_parameters(self, category: str, operation: str, **kwargs) -> dict:
13
39
  """
14
- Build the parameters for the client call.
40
+ Build HTTP request parameters for DHCore API calls.
41
+
42
+ Routes parameter building to the appropriate method based on the
43
+ API category (base or context operations) and applies operation-specific
44
+ parameter transformations.
15
45
 
16
46
  Parameters
17
47
  ----------
18
48
  category : str
19
- API category.
49
+ The API category, either 'base' for project-level operations
50
+ or 'context' for entity operations within projects.
20
51
  operation : str
21
- API operation.
52
+ The specific API operation being performed (create, read, update,
53
+ delete, list, search, etc.).
22
54
  **kwargs : dict
23
- Parameters to build.
55
+ Raw parameters to be transformed into proper HTTP request format.
56
+ May include entity identifiers, filter criteria, pagination
57
+ options, etc.
24
58
 
25
59
  Returns
26
60
  -------
27
61
  dict
28
- Parameters formatted.
62
+ Formatted parameters dictionary ready for HTTP request, typically
63
+ containing a 'params' key with query parameters and other
64
+ request-specific parameters.
65
+
66
+ Notes
67
+ -----
68
+ This method acts as a dispatcher, routing to either base or context
69
+ parameter building based on the category. All parameter dictionaries
70
+ are initialized with a 'params' key for query parameters if not
71
+ already present.
29
72
  """
30
73
  if category == ApiCategories.BASE.value:
31
74
  return self.build_parameters_base(operation, **kwargs)
@@ -33,19 +76,37 @@ class ClientDHCoreParametersBuilder(ClientParametersBuilder):
33
76
 
34
77
  def build_parameters_base(self, operation: str, **kwargs) -> dict:
35
78
  """
36
- Build the base parameters for the client call.
79
+ Build parameters for base-level API operations.
80
+
81
+ Constructs HTTP request parameters for operations that work at the
82
+ base level of the API, typically project-level operations and
83
+ entity sharing functionality.
37
84
 
38
85
  Parameters
39
86
  ----------
40
87
  operation : str
41
- API operation.
88
+ The API operation being performed. Supported operations:
89
+ - DELETE: Project deletion with optional cascade
90
+ - SHARE: Entity sharing/unsharing with users
42
91
  **kwargs : dict
43
- Parameters to build.
92
+ Operation-specific parameters including:
93
+ - cascade (bool): For DELETE, whether to cascade delete
94
+ - user (str): For SHARE, target user for sharing
95
+ - unshare (bool): For SHARE, whether to unshare instead
96
+ - id (str): For SHARE unshare, entity ID to unshare
44
97
 
45
98
  Returns
46
99
  -------
47
100
  dict
48
- Parameters formatted.
101
+ Formatted parameters with 'params' containing query parameters
102
+ and other request-specific parameters.
103
+
104
+ Notes
105
+ -----
106
+ Parameter transformations:
107
+ - CASCADE: Boolean values are converted to lowercase strings
108
+ - SHARE: User parameter is moved to query params
109
+ - UNSHARE: Requires both unshare=True and entity id
49
110
  """
50
111
  kwargs = self._set_params(**kwargs)
51
112
  if operation == BackendOperations.DELETE.value:
@@ -60,19 +121,46 @@ class ClientDHCoreParametersBuilder(ClientParametersBuilder):
60
121
 
61
122
  def build_parameters_context(self, operation: str, **kwargs) -> dict:
62
123
  """
63
- Build the context parameters for the client call.
124
+ Build parameters for context-level API operations.
125
+
126
+ Constructs HTTP request parameters for operations that work within
127
+ a specific context (project), including entity management and
128
+ search functionality.
64
129
 
65
130
  Parameters
66
131
  ----------
67
132
  operation : str
68
- API operation.
133
+ The API operation being performed. Supported operations:
134
+ - SEARCH: Search entities with filtering and pagination
135
+ - READ_MANY: Retrieve multiple entities with pagination
136
+ - DELETE: Delete specific entity by ID
137
+ - READ: Read specific entity by ID (with optional embedded)
69
138
  **kwargs : dict
70
- Parameters to build.
139
+ Operation-specific parameters including:
140
+ - params (dict): Search filters and conditions
141
+ - page (int): Page number for pagination (default: 0)
142
+ - size (int): Number of items per page (default: 20)
143
+ - order_by (str): Field to order results by
144
+ - order (str): Order direction ('asc' or 'desc')
145
+ - embedded (bool): For READ, whether to include embedded entities
146
+ - id (str): For READ/DELETE, entity identifier
71
147
 
72
148
  Returns
73
149
  -------
74
150
  dict
75
- Parameters formatted.
151
+ Formatted parameters with 'params' containing query parameters
152
+ and other request-specific parameters like 'id' for entity operations.
153
+
154
+ Notes
155
+ -----
156
+ Search and pagination:
157
+ - Filters are applied via 'filter' parameter in query string
158
+ - Pagination uses 'page' and 'size' parameters
159
+ - Results can be ordered using 'sort' parameter format
160
+
161
+ Entity operations:
162
+ - READ: Supports embedded entity inclusion via 'embedded' param
163
+ - DELETE: Requires entity 'id' parameter
76
164
  """
77
165
  kwargs = self._set_params(**kwargs)
78
166
 
@@ -159,17 +247,29 @@ class ClientDHCoreParametersBuilder(ClientParametersBuilder):
159
247
  @staticmethod
160
248
  def _set_params(**kwargs) -> dict:
161
249
  """
162
- Format params parameter.
250
+ Initialize parameter dictionary with query parameters structure.
251
+
252
+ Ensures that the parameter dictionary has a 'params' key for
253
+ HTTP query parameters. This is a utility method used by all
254
+ parameter building methods to guarantee consistent structure.
163
255
 
164
256
  Parameters
165
257
  ----------
166
258
  **kwargs : dict
167
- Keyword arguments.
259
+ Keyword arguments to be formatted. May be empty or contain
260
+ various parameters for API operations.
168
261
 
169
262
  Returns
170
263
  -------
171
264
  dict
172
- Parameters with initialized params.
265
+ Parameters dictionary with guaranteed 'params' key containing
266
+ an empty dict if not already present.
267
+
268
+ Notes
269
+ -----
270
+ This method is called at the beginning of all parameter building
271
+ methods to ensure consistent dictionary structure for query
272
+ parameter handling.
173
273
  """
174
274
  if not kwargs:
175
275
  kwargs = {}
@@ -1,10 +1,14 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  import os
4
8
  import typing
5
9
 
6
10
  from digitalhub.stores.client.api import get_client
7
- from digitalhub.stores.client.dhcore.enums import DhcoreEnvVar
11
+ from digitalhub.stores.credentials.enums import CredsEnvVar
8
12
 
9
13
  if typing.TYPE_CHECKING:
10
14
  from digitalhub.stores.client.dhcore.client import ClientDHCore
@@ -20,53 +24,71 @@ def set_dhcore_env(
20
24
  ) -> None:
21
25
  """
22
26
  Function to set environment variables for DHCore config.
27
+
28
+ Sets the environment variables for DHCore configuration and
29
+ reloads the client configurator to use the new settings.
23
30
  Note that if the environment variable is already set, it
24
31
  will be overwritten.
25
32
 
26
33
  Parameters
27
34
  ----------
28
- endpoint : str
29
- The endpoint of DHCore.
30
- user : str
31
- The user of DHCore.
32
- password : str
33
- The password of DHCore.
34
- access_token : str
35
- The access token of DHCore.
36
- refresh_token : str
37
- The refresh token of DHCore.
38
- client_id : str
39
- The client id of DHCore.
35
+ endpoint : str, optional
36
+ The endpoint URL of the DHCore backend.
37
+ user : str, optional
38
+ The username for basic authentication.
39
+ password : str, optional
40
+ The password for basic authentication.
41
+ access_token : str, optional
42
+ The OAuth2 access token.
43
+ refresh_token : str, optional
44
+ The OAuth2 refresh token.
45
+ client_id : str, optional
46
+ The OAuth2 client identifier.
40
47
 
41
48
  Returns
42
49
  -------
43
50
  None
51
+
52
+ Notes
53
+ -----
54
+ After setting the environment variables, this function automatically
55
+ reloads the client configurator to apply the new configuration.
44
56
  """
45
57
  if endpoint is not None:
46
- os.environ[DhcoreEnvVar.ENDPOINT.value] = endpoint
58
+ os.environ[CredsEnvVar.DHCORE_ENDPOINT.value] = endpoint
47
59
  if user is not None:
48
- os.environ[DhcoreEnvVar.USER.value] = user
60
+ os.environ[CredsEnvVar.DHCORE_USER.value] = user
49
61
  if password is not None:
50
- os.environ[DhcoreEnvVar.PASSWORD.value] = password
62
+ os.environ[CredsEnvVar.DHCORE_PASSWORD.value] = password
51
63
  if access_token is not None:
52
- os.environ[DhcoreEnvVar.ACCESS_TOKEN.value] = access_token
64
+ os.environ[CredsEnvVar.DHCORE_ACCESS_TOKEN.value] = access_token
53
65
  if refresh_token is not None:
54
- os.environ[DhcoreEnvVar.REFRESH_TOKEN.value] = refresh_token
66
+ os.environ[CredsEnvVar.DHCORE_REFRESH_TOKEN.value] = refresh_token
55
67
  if client_id is not None:
56
- os.environ[DhcoreEnvVar.CLIENT_ID.value] = client_id
68
+ os.environ[CredsEnvVar.DHCORE_CLIENT_ID.value] = client_id
57
69
 
58
70
  client: ClientDHCore = get_client(local=False)
59
- client._configurator.configure()
71
+ client._configurator.load_env_vars()
60
72
 
61
73
 
62
74
  def refresh_token() -> None:
63
75
  """
64
- Function to refresh token.
76
+ Function to refresh the OAuth2 access token.
77
+
78
+ Attempts to refresh the current OAuth2 access token using the
79
+ refresh token stored in the client configuration. This function
80
+ requires that the client be configured with OAuth2 authentication.
65
81
 
66
82
  Returns
67
83
  -------
68
84
  None
85
+
86
+ Raises
87
+ ------
88
+ ClientError
89
+ If the client is not properly configured or if the token
90
+ refresh fails.
69
91
  """
70
92
  client: ClientDHCore = get_client(local=False)
71
93
  client._configurator.check_config()
72
- client._configurator.get_new_access_token()
94
+ client._configurator.refresh_credentials()
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  from digitalhub.entities._commons.enums import ApiCategories, BackendOperations
@@ -69,6 +73,23 @@ class ClientLocalApiBuilder(ClientApiBuilder):
69
73
  def build_api_context(self, operation: str, **kwargs) -> str:
70
74
  """
71
75
  Build the context API for the client.
76
+
77
+ Parameters
78
+ ----------
79
+ operation : str
80
+ The API operation.
81
+ **kwargs : dict
82
+ Additional parameters including project, entity_type, entity_id, etc.
83
+
84
+ Returns
85
+ -------
86
+ str
87
+ The formatted context API endpoint.
88
+
89
+ Raises
90
+ ------
91
+ BackendError
92
+ If the operation is not supported for the entity type.
72
93
  """
73
94
  try:
74
95
  entity_type = kwargs["entity_type"] + "s"
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  from copy import deepcopy
@@ -533,18 +537,16 @@ class ClientLocal(Client):
533
537
  Parameters
534
538
  ----------
535
539
  error_code : int
536
- Error code.
537
- project : str
538
- Project name.
539
- entity_type : str
540
- Entity type.
541
- entity_id : str
542
- Entity ID.
540
+ Error code identifying the type of error.
541
+ entity_type : str, optional
542
+ Entity type that caused the error.
543
+ entity_id : str, optional
544
+ Entity ID that caused the error.
543
545
 
544
546
  Returns
545
547
  -------
546
548
  str
547
- The formatted message.
549
+ The formatted error message.
548
550
  """
549
551
  msg = {
550
552
  1: f"Object '{entity_type}' to create is not valid",
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  from enum import Enum
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  from digitalhub.stores.client._base.key_builder import ClientKeyBuilder
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  from digitalhub.entities._commons.enums import ApiCategories, BackendOperations
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,35 @@
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 digitalhub.stores.credentials.handler import creds_handler
8
+
9
+
10
+ def set_current_profile(environment: str) -> None:
11
+ """
12
+ Set the current credentials profile.
13
+
14
+ Parameters
15
+ ----------
16
+ environment : str
17
+ Name of the credentials profile to set.
18
+
19
+ Returns
20
+ -------
21
+ None
22
+ """
23
+ creds_handler.set_current_profile(environment)
24
+
25
+
26
+ def get_current_profile() -> str:
27
+ """
28
+ Get the name of the current credentials profile.
29
+
30
+ Returns
31
+ -------
32
+ str
33
+ Name of the current credentials profile.
34
+ """
35
+ return creds_handler.get_current_profile()