uipath 2.0.42__py3-none-any.whl → 2.0.44__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 uipath might be problematic. Click here for more details.
- uipath/_services/_base_service.py +3 -0
- uipath/_services/assets_service.py +109 -60
- uipath/_services/buckets_service.py +334 -101
- uipath/_services/context_grounding_service.py +205 -112
- uipath/_uipath.py +13 -1
- uipath/_utils/_read_overwrites.py +141 -0
- uipath/models/context_grounding_index.py +1 -0
- uipath/models/exceptions.py +9 -2
- {uipath-2.0.42.dist-info → uipath-2.0.44.dist-info}/METADATA +1 -1
- {uipath-2.0.42.dist-info → uipath-2.0.44.dist-info}/RECORD +13 -12
- {uipath-2.0.42.dist-info → uipath-2.0.44.dist-info}/WHEEL +0 -0
- {uipath-2.0.42.dist-info → uipath-2.0.44.dist-info}/entry_points.txt +0 -0
- {uipath-2.0.42.dist-info → uipath-2.0.44.dist-info}/licenses/LICENSE +0 -0
|
@@ -5,7 +5,7 @@ from httpx import request
|
|
|
5
5
|
from .._config import Config
|
|
6
6
|
from .._execution_context import ExecutionContext
|
|
7
7
|
from .._folder_context import FolderContext
|
|
8
|
-
from .._utils import Endpoint, RequestSpec, infer_bindings
|
|
8
|
+
from .._utils import Endpoint, RequestSpec, header_folder, infer_bindings
|
|
9
9
|
from ..tracing._traced import traced
|
|
10
10
|
from ._base_service import BaseService
|
|
11
11
|
|
|
@@ -28,25 +28,41 @@ class BucketsService(FolderContext, BaseService):
|
|
|
28
28
|
@traced(name="buckets_download", run_type="uipath")
|
|
29
29
|
def download(
|
|
30
30
|
self,
|
|
31
|
-
|
|
31
|
+
*,
|
|
32
|
+
name: Optional[str] = None,
|
|
33
|
+
key: Optional[str] = None,
|
|
32
34
|
blob_file_path: str,
|
|
33
35
|
destination_path: str,
|
|
36
|
+
folder_key: Optional[str] = None,
|
|
37
|
+
folder_path: Optional[str] = None,
|
|
34
38
|
) -> None:
|
|
35
39
|
"""Download a file from a bucket.
|
|
36
40
|
|
|
37
41
|
Args:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
key (Optional[str]): The key of the bucket.
|
|
43
|
+
name (Optional[str]): The name of the bucket.
|
|
44
|
+
blob_file_path (str): The path to the file in the bucket.
|
|
45
|
+
destination_path (str): The local path where the file will be saved.
|
|
46
|
+
folder_key (Optional[str]): The key of the folder where the bucket resides.
|
|
47
|
+
folder_path (Optional[str]): The path of the folder where the bucket resides.
|
|
48
|
+
|
|
49
|
+
Raises:
|
|
50
|
+
ValueError: If neither key nor name is provided.
|
|
51
|
+
Exception: If the bucket with the specified key is not found.
|
|
41
52
|
"""
|
|
42
|
-
bucket = self.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
endpoint = Endpoint(
|
|
46
|
-
f"/orchestrator_/odata/Buckets({bucket_id})/UiPath.Server.Configuration.OData.GetReadUri"
|
|
53
|
+
bucket = self.retrieve(
|
|
54
|
+
name=name, key=key, folder_key=folder_key, folder_path=folder_path
|
|
47
55
|
)
|
|
56
|
+
spec = self._retrieve_readUri_spec(
|
|
57
|
+
bucket, blob_file_path, folder_key=folder_key, folder_path=folder_path
|
|
58
|
+
)
|
|
59
|
+
result = self.request(
|
|
60
|
+
spec.method,
|
|
61
|
+
url=spec.endpoint,
|
|
62
|
+
params=spec.params,
|
|
63
|
+
headers=spec.headers,
|
|
64
|
+
).json()
|
|
48
65
|
|
|
49
|
-
result = self.request("GET", endpoint, params={"path": blob_file_path}).json()
|
|
50
66
|
read_uri = result["Uri"]
|
|
51
67
|
|
|
52
68
|
headers = {
|
|
@@ -68,39 +84,50 @@ class BucketsService(FolderContext, BaseService):
|
|
|
68
84
|
def upload(
|
|
69
85
|
self,
|
|
70
86
|
*,
|
|
71
|
-
|
|
72
|
-
|
|
87
|
+
key: Optional[str] = None,
|
|
88
|
+
name: Optional[str] = None,
|
|
73
89
|
blob_file_path: str,
|
|
74
90
|
content_type: str,
|
|
75
91
|
source_path: str,
|
|
92
|
+
folder_key: Optional[str] = None,
|
|
93
|
+
folder_path: Optional[str] = None,
|
|
76
94
|
) -> None:
|
|
77
95
|
"""Upload a file to a bucket.
|
|
78
96
|
|
|
79
97
|
Args:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
blob_file_path: The path where the file will be stored in the bucket
|
|
83
|
-
content_type: The MIME type of the file
|
|
84
|
-
source_path: The local path of the file to upload
|
|
98
|
+
key (Optional[str]): The key of the bucket.
|
|
99
|
+
name (Optional[str]): The name of the bucket.
|
|
100
|
+
blob_file_path (str): The path where the file will be stored in the bucket.
|
|
101
|
+
content_type (str): The MIME type of the file.
|
|
102
|
+
source_path (str): The local path of the file to upload.
|
|
103
|
+
folder_key (Optional[str]): The key of the folder where the bucket resides.
|
|
104
|
+
folder_path (Optional[str]): The path of the folder where the bucket resides.
|
|
105
|
+
|
|
106
|
+
Raises:
|
|
107
|
+
ValueError: If neither key nor name is provided.
|
|
108
|
+
Exception: If the bucket with the specified key or name is not found.
|
|
85
109
|
"""
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
bucket = self.retrieve(bucket_name)
|
|
90
|
-
else:
|
|
91
|
-
raise ValueError("Must specify a bucket name or bucket key")
|
|
110
|
+
bucket = self.retrieve(
|
|
111
|
+
name=name, key=key, folder_key=folder_key, folder_path=folder_path
|
|
112
|
+
)
|
|
92
113
|
|
|
93
114
|
bucket_id = bucket["Id"]
|
|
94
115
|
|
|
95
|
-
|
|
96
|
-
|
|
116
|
+
spec = self._retrieve_writeri_spec(
|
|
117
|
+
bucket_id,
|
|
118
|
+
content_type,
|
|
119
|
+
blob_file_path,
|
|
120
|
+
folder_key=folder_key,
|
|
121
|
+
folder_path=folder_path,
|
|
97
122
|
)
|
|
98
123
|
|
|
99
124
|
result = self.request(
|
|
100
|
-
|
|
101
|
-
endpoint,
|
|
102
|
-
params=
|
|
125
|
+
spec.method,
|
|
126
|
+
url=spec.endpoint,
|
|
127
|
+
params=spec.params,
|
|
128
|
+
headers=spec.headers,
|
|
103
129
|
).json()
|
|
130
|
+
|
|
104
131
|
write_uri = result["Uri"]
|
|
105
132
|
|
|
106
133
|
headers = {
|
|
@@ -116,6 +143,73 @@ class BucketsService(FolderContext, BaseService):
|
|
|
116
143
|
else:
|
|
117
144
|
request("PUT", write_uri, headers=headers, files={"file": file})
|
|
118
145
|
|
|
146
|
+
@traced(name="buckets_upload", run_type="uipath")
|
|
147
|
+
async def upload_async(
|
|
148
|
+
self,
|
|
149
|
+
*,
|
|
150
|
+
key: Optional[str] = None,
|
|
151
|
+
name: Optional[str] = None,
|
|
152
|
+
blob_file_path: str,
|
|
153
|
+
content_type: str,
|
|
154
|
+
source_path: str,
|
|
155
|
+
folder_key: Optional[str] = None,
|
|
156
|
+
folder_path: Optional[str] = None,
|
|
157
|
+
) -> None:
|
|
158
|
+
"""Upload a file to a bucket asynchronously.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
key (Optional[str]): The key of the bucket.
|
|
162
|
+
name (Optional[str]): The name of the bucket.
|
|
163
|
+
blob_file_path (str): The path where the file will be stored in the bucket.
|
|
164
|
+
content_type (str): The MIME type of the file.
|
|
165
|
+
source_path (str): The local path of the file to upload.
|
|
166
|
+
folder_key (Optional[str]): The key of the folder where the bucket resides.
|
|
167
|
+
folder_path (Optional[str]): The path of the folder where the bucket resides.
|
|
168
|
+
|
|
169
|
+
Raises:
|
|
170
|
+
ValueError: If neither key nor name is provided.
|
|
171
|
+
Exception: If the bucket with the specified key or name is not found.
|
|
172
|
+
"""
|
|
173
|
+
bucket = await self.retrieve_async(
|
|
174
|
+
name=name, key=key, folder_key=folder_key, folder_path=folder_path
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
bucket_id = bucket["Id"]
|
|
178
|
+
|
|
179
|
+
spec = self._retrieve_writeri_spec(
|
|
180
|
+
bucket_id,
|
|
181
|
+
content_type,
|
|
182
|
+
blob_file_path,
|
|
183
|
+
folder_key=folder_key,
|
|
184
|
+
folder_path=folder_path,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
result = (
|
|
188
|
+
await self.request_async(
|
|
189
|
+
spec.method,
|
|
190
|
+
url=spec.endpoint,
|
|
191
|
+
params=spec.params,
|
|
192
|
+
headers=spec.headers,
|
|
193
|
+
)
|
|
194
|
+
).json()
|
|
195
|
+
|
|
196
|
+
write_uri = result["Uri"]
|
|
197
|
+
|
|
198
|
+
headers = {
|
|
199
|
+
key: value
|
|
200
|
+
for key, value in zip(
|
|
201
|
+
result["Headers"]["Keys"], result["Headers"]["Values"], strict=False
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
with open(source_path, "rb") as file:
|
|
206
|
+
if result["RequiresAuth"]:
|
|
207
|
+
await self.request_async(
|
|
208
|
+
"PUT", write_uri, headers=headers, files={"file": file}
|
|
209
|
+
)
|
|
210
|
+
else:
|
|
211
|
+
request("PUT", write_uri, headers=headers, files={"file": file})
|
|
212
|
+
|
|
119
213
|
@traced(
|
|
120
214
|
name="buckets_upload_from_memory",
|
|
121
215
|
run_type="uipath",
|
|
@@ -124,39 +218,49 @@ class BucketsService(FolderContext, BaseService):
|
|
|
124
218
|
def upload_from_memory(
|
|
125
219
|
self,
|
|
126
220
|
*,
|
|
127
|
-
|
|
128
|
-
|
|
221
|
+
key: Optional[str] = None,
|
|
222
|
+
name: Optional[str] = None,
|
|
129
223
|
blob_file_path: str,
|
|
130
224
|
content_type: str,
|
|
131
225
|
content: Union[str, bytes],
|
|
226
|
+
folder_key: Optional[str] = None,
|
|
227
|
+
folder_path: Optional[str] = None,
|
|
132
228
|
) -> None:
|
|
133
229
|
"""Upload content from memory to a bucket.
|
|
134
230
|
|
|
135
231
|
Args:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
blob_file_path: The path where the content will be stored in the bucket
|
|
139
|
-
content_type: The MIME type of the content
|
|
140
|
-
content: The content to upload (string or bytes)
|
|
232
|
+
key (Optional[str]): The key of the bucket.
|
|
233
|
+
name (Optional[str]): The name of the bucket.
|
|
234
|
+
blob_file_path (str): The path where the content will be stored in the bucket.
|
|
235
|
+
content_type (str): The MIME type of the content.
|
|
236
|
+
content (Union[str, bytes]): The content to upload (string or bytes).
|
|
237
|
+
folder_key (Optional[str]): The key of the folder where the bucket resides.
|
|
238
|
+
folder_path (Optional[str]): The path of the folder where the bucket resides.
|
|
239
|
+
|
|
240
|
+
Raises:
|
|
241
|
+
ValueError: If neither key nor name is provided.
|
|
242
|
+
Exception: If the bucket with the specified key or name is not found.
|
|
141
243
|
"""
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
bucket = self.retrieve(bucket_name)
|
|
146
|
-
else:
|
|
147
|
-
raise ValueError("Must specify a bucket name or bucket key")
|
|
148
|
-
|
|
244
|
+
bucket = self.retrieve(
|
|
245
|
+
name=name, key=key, folder_key=folder_key, folder_path=folder_path
|
|
246
|
+
)
|
|
149
247
|
bucket_id = bucket["Id"]
|
|
150
248
|
|
|
151
|
-
|
|
152
|
-
|
|
249
|
+
spec = self._retrieve_writeri_spec(
|
|
250
|
+
bucket_id,
|
|
251
|
+
content_type,
|
|
252
|
+
blob_file_path,
|
|
253
|
+
folder_key=folder_key,
|
|
254
|
+
folder_path=folder_path,
|
|
153
255
|
)
|
|
154
256
|
|
|
155
257
|
result = self.request(
|
|
156
|
-
|
|
157
|
-
endpoint,
|
|
158
|
-
params=
|
|
258
|
+
spec.method,
|
|
259
|
+
url=spec.endpoint,
|
|
260
|
+
params=spec.params,
|
|
261
|
+
headers=spec.headers,
|
|
159
262
|
).json()
|
|
263
|
+
|
|
160
264
|
write_uri = result["Uri"]
|
|
161
265
|
|
|
162
266
|
headers = {
|
|
@@ -175,25 +279,116 @@ class BucketsService(FolderContext, BaseService):
|
|
|
175
279
|
else:
|
|
176
280
|
request("PUT", write_uri, headers=headers, content=content)
|
|
177
281
|
|
|
282
|
+
async def upload_from_memory_async(
|
|
283
|
+
self,
|
|
284
|
+
*,
|
|
285
|
+
key: Optional[str] = None,
|
|
286
|
+
name: Optional[str] = None,
|
|
287
|
+
blob_file_path: str,
|
|
288
|
+
content_type: str,
|
|
289
|
+
content: Union[str, bytes],
|
|
290
|
+
folder_key: Optional[str] = None,
|
|
291
|
+
folder_path: Optional[str] = None,
|
|
292
|
+
) -> None:
|
|
293
|
+
"""Asynchronously upload content from memory to a bucket.
|
|
294
|
+
|
|
295
|
+
Args:
|
|
296
|
+
key (Optional[str]): The key of the bucket.
|
|
297
|
+
name (Optional[str]): The name of the bucket.
|
|
298
|
+
blob_file_path (str): The path where the content will be stored in the bucket.
|
|
299
|
+
content_type (str): The MIME type of the content.
|
|
300
|
+
content (Union[str, bytes]): The content to upload (string or bytes).
|
|
301
|
+
folder_key (Optional[str]): The key of the folder where the bucket resides.
|
|
302
|
+
folder_path (Optional[str]): The path of the folder where the bucket resides.
|
|
303
|
+
|
|
304
|
+
Raises:
|
|
305
|
+
ValueError: If neither key nor name is provided.
|
|
306
|
+
Exception: If the bucket with the specified key or name is not found.
|
|
307
|
+
"""
|
|
308
|
+
bucket = await self.retrieve_async(
|
|
309
|
+
name=name, key=key, folder_key=folder_key, folder_path=folder_path
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
bucket_id = bucket["Id"]
|
|
313
|
+
|
|
314
|
+
spec = self._retrieve_writeri_spec(
|
|
315
|
+
bucket_id,
|
|
316
|
+
content_type,
|
|
317
|
+
blob_file_path,
|
|
318
|
+
folder_key=folder_key,
|
|
319
|
+
folder_path=folder_path,
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
result = (
|
|
323
|
+
await self.request_async(
|
|
324
|
+
spec.method,
|
|
325
|
+
url=spec.endpoint,
|
|
326
|
+
params=spec.params,
|
|
327
|
+
headers=spec.headers,
|
|
328
|
+
)
|
|
329
|
+
).json()
|
|
330
|
+
|
|
331
|
+
write_uri = result["Uri"]
|
|
332
|
+
|
|
333
|
+
headers = {
|
|
334
|
+
key: value
|
|
335
|
+
for key, value in zip(
|
|
336
|
+
result["Headers"]["Keys"], result["Headers"]["Values"], strict=False
|
|
337
|
+
)
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
# Convert string to bytes if needed
|
|
341
|
+
if isinstance(content, str):
|
|
342
|
+
content = content.encode("utf-8")
|
|
343
|
+
|
|
344
|
+
if result["RequiresAuth"]:
|
|
345
|
+
await self.request_async("PUT", write_uri, headers=headers, content=content)
|
|
346
|
+
else:
|
|
347
|
+
request("PUT", write_uri, headers=headers, content=content)
|
|
348
|
+
|
|
178
349
|
@infer_bindings()
|
|
179
350
|
@traced(name="buckets_retrieve", run_type="uipath")
|
|
180
|
-
def retrieve(
|
|
351
|
+
def retrieve(
|
|
352
|
+
self,
|
|
353
|
+
*,
|
|
354
|
+
name: Optional[str] = None,
|
|
355
|
+
key: Optional[str] = None,
|
|
356
|
+
folder_key: Optional[str] = None,
|
|
357
|
+
folder_path: Optional[str] = None,
|
|
358
|
+
) -> Any:
|
|
181
359
|
"""Retrieve bucket information by its name.
|
|
182
360
|
|
|
183
361
|
Args:
|
|
184
|
-
name (str): The name of the bucket to retrieve.
|
|
362
|
+
name (Optional[str]): The name of the bucket to retrieve.
|
|
363
|
+
key (Optional[str]): The key of the bucket.
|
|
364
|
+
folder_key (Optional[str]): The key of the folder where the bucket resides.
|
|
365
|
+
folder_path (Optional[str]): The path of the folder where the bucket resides.
|
|
185
366
|
|
|
186
367
|
Returns:
|
|
187
|
-
Response: The
|
|
188
|
-
its ID, name, and configuration.
|
|
189
|
-
"""
|
|
190
|
-
spec = self._retrieve_spec(name)
|
|
368
|
+
Response: The bucket details.
|
|
191
369
|
|
|
370
|
+
Raises:
|
|
371
|
+
ValueError: If neither bucket key nor bucket name is provided.
|
|
372
|
+
Exception: If the bucket with the specified name is not found.
|
|
373
|
+
"""
|
|
374
|
+
if not (key or name):
|
|
375
|
+
raise ValueError("Must specify a bucket name or bucket key")
|
|
376
|
+
if key:
|
|
377
|
+
spec = self._retrieve_by_key_spec(
|
|
378
|
+
key, folder_key=folder_key, folder_path=folder_path
|
|
379
|
+
)
|
|
380
|
+
else:
|
|
381
|
+
spec = self._retrieve_spec(
|
|
382
|
+
name, # type: ignore
|
|
383
|
+
folder_key=folder_key,
|
|
384
|
+
folder_path=folder_path,
|
|
385
|
+
)
|
|
192
386
|
try:
|
|
193
387
|
response = self.request(
|
|
194
388
|
spec.method,
|
|
195
389
|
url=spec.endpoint,
|
|
196
390
|
params=spec.params,
|
|
391
|
+
headers=spec.headers,
|
|
197
392
|
)
|
|
198
393
|
except Exception as e:
|
|
199
394
|
raise Exception(f"Bucket with name {name} not found") from e
|
|
@@ -202,84 +397,122 @@ class BucketsService(FolderContext, BaseService):
|
|
|
202
397
|
|
|
203
398
|
@infer_bindings()
|
|
204
399
|
@traced(name="buckets_retrieve", run_type="uipath")
|
|
205
|
-
async def retrieve_async(
|
|
400
|
+
async def retrieve_async(
|
|
401
|
+
self,
|
|
402
|
+
*,
|
|
403
|
+
name: Optional[str] = None,
|
|
404
|
+
key: Optional[str] = None,
|
|
405
|
+
folder_key: Optional[str] = None,
|
|
406
|
+
folder_path: Optional[str] = None,
|
|
407
|
+
) -> Any:
|
|
206
408
|
"""Asynchronously retrieve bucket information by its name.
|
|
207
409
|
|
|
208
410
|
Args:
|
|
209
|
-
name (str): The name of the bucket to retrieve.
|
|
411
|
+
name (Optional[str]): The name of the bucket to retrieve.
|
|
412
|
+
key (Optional[str]): The key of the bucket.
|
|
413
|
+
folder_key (Optional[str]): The key of the folder where the bucket resides.
|
|
414
|
+
folder_path (Optional[str]): The path of the folder where the bucket resides.
|
|
210
415
|
|
|
211
416
|
Returns:
|
|
212
|
-
Response: The
|
|
213
|
-
|
|
417
|
+
Response: The bucket details.
|
|
418
|
+
|
|
419
|
+
Raises:
|
|
420
|
+
ValueError: If neither bucket key nor bucket name is provided.
|
|
421
|
+
Exception: If the bucket with the specified name is not found.
|
|
214
422
|
"""
|
|
215
|
-
|
|
423
|
+
if not (key or name):
|
|
424
|
+
raise ValueError("Must specify a bucket name or bucket key")
|
|
425
|
+
if key:
|
|
426
|
+
spec = self._retrieve_by_key_spec(
|
|
427
|
+
key, folder_key=folder_key, folder_path=folder_path
|
|
428
|
+
)
|
|
429
|
+
else:
|
|
430
|
+
spec = self._retrieve_spec(
|
|
431
|
+
name, # type: ignore
|
|
432
|
+
folder_key=folder_key,
|
|
433
|
+
folder_path=folder_path,
|
|
434
|
+
)
|
|
216
435
|
|
|
217
436
|
try:
|
|
218
437
|
response = await self.request_async(
|
|
219
438
|
spec.method,
|
|
220
439
|
url=spec.endpoint,
|
|
221
440
|
params=spec.params,
|
|
441
|
+
headers=spec.headers,
|
|
222
442
|
)
|
|
223
443
|
except Exception as e:
|
|
224
444
|
raise Exception(f"Bucket with name {name} not found") from e
|
|
225
445
|
|
|
226
446
|
return response.json()["value"][0]
|
|
227
447
|
|
|
228
|
-
@traced(name="buckets_retrieve_by_key", run_type="uipath")
|
|
229
|
-
def retrieve_by_key(self, key: str) -> Any:
|
|
230
|
-
"""Retrieve bucket information by its key.
|
|
231
|
-
|
|
232
|
-
Args:
|
|
233
|
-
key (str): The key of the bucket
|
|
234
|
-
|
|
235
|
-
Returns:
|
|
236
|
-
Response: The HTTP response containing the bucket details, including
|
|
237
|
-
its ID, name, and configuration.
|
|
238
|
-
"""
|
|
239
|
-
spec = self._retrieve_by_key_spec(key)
|
|
240
|
-
|
|
241
|
-
try:
|
|
242
|
-
response = self.request(spec.method, url=spec.endpoint)
|
|
243
|
-
except Exception as e:
|
|
244
|
-
raise Exception(f"Bucket with key {key} not found") from e
|
|
245
|
-
|
|
246
|
-
return response.json()
|
|
247
|
-
|
|
248
|
-
@traced(name="buckets_retrieve_by_key", run_type="uipath")
|
|
249
|
-
async def retrieve_by_key_async(self, key: str) -> Any:
|
|
250
|
-
"""Asynchronously retrieve bucket information by its key.
|
|
251
|
-
|
|
252
|
-
Args:
|
|
253
|
-
key (str): The key of the bucket
|
|
254
|
-
|
|
255
|
-
Returns:
|
|
256
|
-
Response: The HTTP response containing the bucket details, including
|
|
257
|
-
its ID, name, and configuration.
|
|
258
|
-
"""
|
|
259
|
-
spec = self._retrieve_by_key_spec(key)
|
|
260
|
-
|
|
261
|
-
try:
|
|
262
|
-
response = await self.request_async(spec.method, url=spec.endpoint)
|
|
263
|
-
except Exception as e:
|
|
264
|
-
raise Exception(f"Bucket with key {key} not found") from e
|
|
265
|
-
|
|
266
|
-
return response.json()
|
|
267
|
-
|
|
268
448
|
@property
|
|
269
449
|
def custom_headers(self) -> Dict[str, str]:
|
|
270
450
|
return self.folder_headers
|
|
271
451
|
|
|
272
|
-
def _retrieve_spec(
|
|
452
|
+
def _retrieve_spec(
|
|
453
|
+
self,
|
|
454
|
+
name: str,
|
|
455
|
+
folder_key: Optional[str] = None,
|
|
456
|
+
folder_path: Optional[str] = None,
|
|
457
|
+
) -> RequestSpec:
|
|
273
458
|
return RequestSpec(
|
|
274
459
|
method="GET",
|
|
275
460
|
endpoint=Endpoint("/orchestrator_/odata/Buckets"),
|
|
276
461
|
params={"$filter": f"Name eq '{name}'", "$top": 1},
|
|
462
|
+
headers={
|
|
463
|
+
**header_folder(folder_key, folder_path),
|
|
464
|
+
},
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
def _retrieve_readUri_spec(
|
|
468
|
+
self,
|
|
469
|
+
bucket_id: str,
|
|
470
|
+
blob_file_path: str,
|
|
471
|
+
folder_key: Optional[str] = None,
|
|
472
|
+
folder_path: Optional[str] = None,
|
|
473
|
+
) -> RequestSpec:
|
|
474
|
+
return RequestSpec(
|
|
475
|
+
method="GET",
|
|
476
|
+
endpoint=Endpoint(
|
|
477
|
+
f"/orchestrator_/odata/Buckets({bucket_id})/UiPath.Server.Configuration.OData.GetReadUri"
|
|
478
|
+
),
|
|
479
|
+
params={"path": blob_file_path},
|
|
480
|
+
headers={
|
|
481
|
+
**header_folder(folder_key, folder_path),
|
|
482
|
+
},
|
|
483
|
+
)
|
|
484
|
+
|
|
485
|
+
def _retrieve_writeri_spec(
|
|
486
|
+
self,
|
|
487
|
+
bucket_id: str,
|
|
488
|
+
content_type: str,
|
|
489
|
+
blob_file_path: str,
|
|
490
|
+
folder_key: Optional[str] = None,
|
|
491
|
+
folder_path: Optional[str] = None,
|
|
492
|
+
) -> RequestSpec:
|
|
493
|
+
return RequestSpec(
|
|
494
|
+
method="GET",
|
|
495
|
+
endpoint=Endpoint(
|
|
496
|
+
f"/orchestrator_/odata/Buckets({bucket_id})/UiPath.Server.Configuration.OData.GetWriteUri"
|
|
497
|
+
),
|
|
498
|
+
params={"path": blob_file_path, "contentType": content_type},
|
|
499
|
+
headers={
|
|
500
|
+
**header_folder(folder_key, folder_path),
|
|
501
|
+
},
|
|
277
502
|
)
|
|
278
503
|
|
|
279
|
-
def _retrieve_by_key_spec(
|
|
504
|
+
def _retrieve_by_key_spec(
|
|
505
|
+
self,
|
|
506
|
+
key: str,
|
|
507
|
+
folder_key: Optional[str] = None,
|
|
508
|
+
folder_path: Optional[str] = None,
|
|
509
|
+
) -> RequestSpec:
|
|
280
510
|
return RequestSpec(
|
|
281
511
|
method="GET",
|
|
282
512
|
endpoint=Endpoint(
|
|
283
513
|
f"/orchestrator_/odata/Buckets/UiPath.Server.Configuration.OData.GetByKey(identifier={key})"
|
|
284
514
|
),
|
|
515
|
+
headers={
|
|
516
|
+
**header_folder(folder_key, folder_path),
|
|
517
|
+
},
|
|
285
518
|
)
|