uipath 2.0.56__py3-none-any.whl → 2.0.58__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.

@@ -1,6 +1,6 @@
1
1
  from typing import Any, Dict, Optional, Union
2
2
 
3
- from httpx import request
3
+ import httpx
4
4
 
5
5
  from .._config import Config
6
6
  from .._execution_context import ExecutionContext
@@ -25,6 +25,8 @@ class BucketsService(FolderContext, BaseService):
25
25
 
26
26
  def __init__(self, config: Config, execution_context: ExecutionContext) -> None:
27
27
  super().__init__(config=config, execution_context=execution_context)
28
+ self.custom_client = httpx.Client()
29
+ self.custom_client_async = httpx.AsyncClient()
28
30
 
29
31
  @traced(name="buckets_download", run_type="uipath")
30
32
  def download(
@@ -78,7 +80,7 @@ class BucketsService(FolderContext, BaseService):
78
80
  if result["RequiresAuth"]:
79
81
  file_content = self.request("GET", read_uri, headers=headers).content
80
82
  else:
81
- file_content = request("GET", read_uri, headers=headers).content
83
+ file_content = self.custom_client.get(read_uri, headers=headers).content
82
84
  file.write(file_content)
83
85
 
84
86
  @traced(name="buckets_upload", run_type="uipath")
@@ -89,7 +91,8 @@ class BucketsService(FolderContext, BaseService):
89
91
  name: Optional[str] = None,
90
92
  blob_file_path: str,
91
93
  content_type: str,
92
- source_path: str,
94
+ source_path: Optional[str] = None,
95
+ content: Optional[Union[str, bytes]] = None,
93
96
  folder_key: Optional[str] = None,
94
97
  folder_path: Optional[str] = None,
95
98
  ) -> None:
@@ -100,7 +103,8 @@ class BucketsService(FolderContext, BaseService):
100
103
  name (Optional[str]): The name of the bucket.
101
104
  blob_file_path (str): The path where the file will be stored in the bucket.
102
105
  content_type (str): The MIME type of the file.
103
- source_path (str): The local path of the file to upload.
106
+ source_path (Optional[str]): The local path of the file to upload.
107
+ content (Optional[Union[str, bytes]]): The content to upload (string or bytes).
104
108
  folder_key (Optional[str]): The key of the folder where the bucket resides.
105
109
  folder_path (Optional[str]): The path of the folder where the bucket resides.
106
110
 
@@ -108,6 +112,11 @@ class BucketsService(FolderContext, BaseService):
108
112
  ValueError: If neither key nor name is provided.
109
113
  Exception: If the bucket with the specified key or name is not found.
110
114
  """
115
+ if content is not None and source_path is not None:
116
+ raise ValueError("Content and source_path are mutually exclusive")
117
+ if content is None and source_path is None:
118
+ raise ValueError("Either content or source_path must be provided")
119
+
111
120
  bucket = self.retrieve(
112
121
  name=name, key=key, folder_key=folder_key, folder_path=folder_path
113
122
  )
@@ -136,11 +145,25 @@ class BucketsService(FolderContext, BaseService):
136
145
  )
137
146
  }
138
147
 
139
- with open(source_path, "rb") as file:
148
+ if content is not None:
149
+ if isinstance(content, str):
150
+ content = content.encode("utf-8")
151
+
140
152
  if result["RequiresAuth"]:
141
- self.request("PUT", write_uri, headers=headers, files={"file": file})
153
+ self.request("PUT", write_uri, headers=headers, content=content)
142
154
  else:
143
- request("PUT", write_uri, headers=headers, files={"file": file})
155
+ self.custom_client.put(write_uri, headers=headers, content=content)
156
+
157
+ if source_path is not None:
158
+ with open(source_path, "rb") as file:
159
+ if result["RequiresAuth"]:
160
+ self.request(
161
+ "PUT", write_uri, headers=headers, files={"file": file}
162
+ )
163
+ else:
164
+ self.custom_client.put(
165
+ write_uri, headers=headers, files={"file": file}
166
+ )
144
167
 
145
168
  @traced(name="buckets_upload", run_type="uipath")
146
169
  async def upload_async(
@@ -150,7 +173,8 @@ class BucketsService(FolderContext, BaseService):
150
173
  name: Optional[str] = None,
151
174
  blob_file_path: str,
152
175
  content_type: str,
153
- source_path: str,
176
+ source_path: Optional[str] = None,
177
+ content: Optional[Union[str, bytes]] = None,
154
178
  folder_key: Optional[str] = None,
155
179
  folder_path: Optional[str] = None,
156
180
  ) -> None:
@@ -169,6 +193,11 @@ class BucketsService(FolderContext, BaseService):
169
193
  ValueError: If neither key nor name is provided.
170
194
  Exception: If the bucket with the specified key or name is not found.
171
195
  """
196
+ if content is not None and source_path is not None:
197
+ raise ValueError("Content and source_path are mutually exclusive")
198
+ if content is None and source_path is None:
199
+ raise ValueError("Either content or source_path must be provided")
200
+
172
201
  bucket = await self.retrieve_async(
173
202
  name=name, key=key, folder_key=folder_key, folder_path=folder_path
174
203
  )
@@ -199,148 +228,29 @@ class BucketsService(FolderContext, BaseService):
199
228
  )
200
229
  }
201
230
 
202
- with open(source_path, "rb") as file:
231
+ if content is not None:
232
+ if isinstance(content, str):
233
+ content = content.encode("utf-8")
234
+
203
235
  if result["RequiresAuth"]:
204
236
  await self.request_async(
205
- "PUT", write_uri, headers=headers, files={"file": file}
237
+ "PUT", write_uri, headers=headers, content=content
206
238
  )
207
239
  else:
208
- request("PUT", write_uri, headers=headers, files={"file": file})
209
-
210
- @traced(
211
- name="buckets_upload_from_memory",
212
- run_type="uipath",
213
- input_processor=_upload_from_memory_input_processor,
214
- )
215
- def upload_from_memory(
216
- self,
217
- *,
218
- key: Optional[str] = None,
219
- name: Optional[str] = None,
220
- blob_file_path: str,
221
- content_type: str,
222
- content: Union[str, bytes],
223
- folder_key: Optional[str] = None,
224
- folder_path: Optional[str] = None,
225
- ) -> None:
226
- """Upload content from memory to a bucket.
227
-
228
- Args:
229
- key (Optional[str]): The key of the bucket.
230
- name (Optional[str]): The name of the bucket.
231
- blob_file_path (str): The path where the content will be stored in the bucket.
232
- content_type (str): The MIME type of the content.
233
- content (Union[str, bytes]): The content to upload (string or bytes).
234
- folder_key (Optional[str]): The key of the folder where the bucket resides.
235
- folder_path (Optional[str]): The path of the folder where the bucket resides.
236
-
237
- Raises:
238
- ValueError: If neither key nor name is provided.
239
- Exception: If the bucket with the specified key or name is not found.
240
- """
241
- bucket = self.retrieve(
242
- name=name, key=key, folder_key=folder_key, folder_path=folder_path
243
- )
244
-
245
- spec = self._retrieve_writeri_spec(
246
- bucket.id,
247
- content_type,
248
- blob_file_path,
249
- folder_key=folder_key,
250
- folder_path=folder_path,
251
- )
252
-
253
- result = self.request(
254
- spec.method,
255
- url=spec.endpoint,
256
- params=spec.params,
257
- headers=spec.headers,
258
- ).json()
259
-
260
- write_uri = result["Uri"]
261
-
262
- headers = {
263
- key: value
264
- for key, value in zip(
265
- result["Headers"]["Keys"], result["Headers"]["Values"], strict=False
266
- )
267
- }
268
-
269
- # Convert string to bytes if needed
270
- if isinstance(content, str):
271
- content = content.encode("utf-8")
272
-
273
- if result["RequiresAuth"]:
274
- self.request("PUT", write_uri, headers=headers, content=content)
275
- else:
276
- request("PUT", write_uri, headers=headers, content=content)
277
-
278
- async def upload_from_memory_async(
279
- self,
280
- *,
281
- key: Optional[str] = None,
282
- name: Optional[str] = None,
283
- blob_file_path: str,
284
- content_type: str,
285
- content: Union[str, bytes],
286
- folder_key: Optional[str] = None,
287
- folder_path: Optional[str] = None,
288
- ) -> None:
289
- """Asynchronously upload content from memory to a bucket.
290
-
291
- Args:
292
- key (Optional[str]): The key of the bucket.
293
- name (Optional[str]): The name of the bucket.
294
- blob_file_path (str): The path where the content will be stored in the bucket.
295
- content_type (str): The MIME type of the content.
296
- content (Union[str, bytes]): The content to upload (string or bytes).
297
- folder_key (Optional[str]): The key of the folder where the bucket resides.
298
- folder_path (Optional[str]): The path of the folder where the bucket resides.
299
-
300
- Raises:
301
- ValueError: If neither key nor name is provided.
302
- Exception: If the bucket with the specified key or name is not found.
303
- """
304
- bucket = await self.retrieve_async(
305
- name=name, key=key, folder_key=folder_key, folder_path=folder_path
306
- )
307
-
308
- bucket_id = bucket["Id"]
309
-
310
- spec = self._retrieve_writeri_spec(
311
- bucket_id,
312
- content_type,
313
- blob_file_path,
314
- folder_key=folder_key,
315
- folder_path=folder_path,
316
- )
317
-
318
- result = (
319
- await self.request_async(
320
- spec.method,
321
- url=spec.endpoint,
322
- params=spec.params,
323
- headers=spec.headers,
324
- )
325
- ).json()
326
-
327
- write_uri = result["Uri"]
328
-
329
- headers = {
330
- key: value
331
- for key, value in zip(
332
- result["Headers"]["Keys"], result["Headers"]["Values"], strict=False
333
- )
334
- }
335
-
336
- # Convert string to bytes if needed
337
- if isinstance(content, str):
338
- content = content.encode("utf-8")
240
+ await self.custom_client_async.put(
241
+ write_uri, headers=headers, content=content
242
+ )
339
243
 
340
- if result["RequiresAuth"]:
341
- await self.request_async("PUT", write_uri, headers=headers, content=content)
342
- else:
343
- request("PUT", write_uri, headers=headers, content=content)
244
+ if source_path is not None:
245
+ with open(source_path, "rb") as file:
246
+ if result["RequiresAuth"]:
247
+ await self.request_async(
248
+ "PUT", write_uri, headers=headers, files={"file": file}
249
+ )
250
+ else:
251
+ await self.custom_client_async.put(
252
+ write_uri, headers=headers, files={"file": file}
253
+ )
344
254
 
345
255
  @infer_bindings()
346
256
  @traced(name="buckets_retrieve", run_type="uipath")
@@ -3,6 +3,7 @@ from typing import Any, List, Optional, Tuple, Union
3
3
 
4
4
  import httpx
5
5
  from pydantic import TypeAdapter
6
+ from typing_extensions import deprecated
6
7
 
7
8
  from .._config import Config
8
9
  from .._execution_context import ExecutionContext
@@ -15,8 +16,8 @@ from ..models import IngestionInProgressException
15
16
  from ..models.context_grounding import ContextGroundingQueryResponse
16
17
  from ..models.context_grounding_index import ContextGroundingIndex
17
18
  from ..tracing._traced import traced
18
- from . import BucketsService
19
19
  from ._base_service import BaseService
20
+ from .buckets_service import BucketsService
20
21
  from .folder_service import FolderService
21
22
 
22
23
 
@@ -85,7 +86,7 @@ class ContextGroundingService(FolderContext, BaseService):
85
86
  content_type=content_type,
86
87
  )
87
88
  else:
88
- self._buckets_service.upload_from_memory(
89
+ self._buckets_service.upload(
89
90
  name=bucket_name,
90
91
  content=content,
91
92
  blob_file_path=blob_file_path,
@@ -137,9 +138,9 @@ class ContextGroundingService(FolderContext, BaseService):
137
138
  content_type=content_type,
138
139
  )
139
140
  else:
140
- await self._buckets_service.upload_from_memory_async(
141
+ await self._buckets_service.upload_async(
141
142
  name=bucket_name,
142
- content=content, # type: ignore
143
+ content=content,
143
144
  blob_file_path=blob_file_path,
144
145
  folder_path=bucket_folder_path,
145
146
  content_type=content_type,
@@ -234,6 +235,7 @@ class ContextGroundingService(FolderContext, BaseService):
234
235
  raise Exception("ContextGroundingIndex not found") from e
235
236
 
236
237
  @traced(name="contextgrounding_retrieve_by_id", run_type="uipath")
238
+ @deprecated("Use retrieve instead")
237
239
  def retrieve_by_id(
238
240
  self,
239
241
  id: str,
@@ -266,6 +268,7 @@ class ContextGroundingService(FolderContext, BaseService):
266
268
  ).json()
267
269
 
268
270
  @traced(name="contextgrounding_retrieve_by_id", run_type="uipath")
271
+ @deprecated("Use retrieve_async instead")
269
272
  async def retrieve_by_id_async(
270
273
  self,
271
274
  id: str,
@@ -656,11 +659,11 @@ class ContextGroundingService(FolderContext, BaseService):
656
659
 
657
660
  def _resolve_folder_key(self, folder_key, folder_path):
658
661
  if folder_key is None and folder_path is not None:
659
- folder_key = self._folders_service.retrieve_key_by_folder_path(folder_path)
662
+ folder_key = self._folders_service.retrieve_key(folder_path=folder_path)
660
663
 
661
664
  if folder_key is None and folder_path is None:
662
665
  folder_key = self._folder_key or (
663
- self._folders_service.retrieve_key_by_folder_path(self._folder_path)
666
+ self._folders_service.retrieve_key(folder_path=self._folder_path)
664
667
  if self._folder_path
665
668
  else None
666
669
  )
@@ -1,5 +1,7 @@
1
1
  from typing import Optional
2
2
 
3
+ from typing_extensions import deprecated
4
+
3
5
  from uipath.tracing._traced import traced
4
6
 
5
7
  from .._config import Config
@@ -8,20 +10,6 @@ from .._utils import Endpoint, RequestSpec
8
10
  from ._base_service import BaseService
9
11
 
10
12
 
11
- def _retrieve_spec(folder_path: str) -> RequestSpec:
12
- folder_name = folder_path.split("/")[-1]
13
- return RequestSpec(
14
- method="GET",
15
- endpoint=Endpoint(
16
- "orchestrator_/api/FoldersNavigation/GetFoldersForCurrentUser"
17
- ),
18
- params={
19
- "searchText": folder_name,
20
- "take": 1,
21
- },
22
- )
23
-
24
-
25
13
  class FolderService(BaseService):
26
14
  """Service for managing UiPath Folders.
27
15
 
@@ -34,8 +22,13 @@ class FolderService(BaseService):
34
22
  super().__init__(config=config, execution_context=execution_context)
35
23
 
36
24
  @traced(name="folder_retrieve_key_by_folder_path", run_type="uipath")
25
+ @deprecated("Use retrieve_key instead")
37
26
  def retrieve_key_by_folder_path(self, folder_path: str) -> Optional[str]:
38
- spec = _retrieve_spec(folder_path)
27
+ return self.retrieve_key(folder_path=folder_path)
28
+
29
+ @traced(name="folder_retrieve_key", run_type="uipath")
30
+ def retrieve_key(self, *, folder_path: str) -> Optional[str]:
31
+ spec = self._retrieve_spec(folder_path)
39
32
  response = self.request(
40
33
  spec.method,
41
34
  url=spec.endpoint,
@@ -50,3 +43,16 @@ class FolderService(BaseService):
50
43
  ),
51
44
  None,
52
45
  )
46
+
47
+ def _retrieve_spec(self, folder_path: str) -> RequestSpec:
48
+ folder_name = folder_path.split("/")[-1]
49
+ return RequestSpec(
50
+ method="GET",
51
+ endpoint=Endpoint(
52
+ "orchestrator_/api/FoldersNavigation/GetFoldersForCurrentUser"
53
+ ),
54
+ params={
55
+ "searchText": folder_name,
56
+ "take": 1,
57
+ },
58
+ )