Skip to content

Commit 7f878ce

Browse files
Merge pull request #1050 from UiPath/feat/get-blob-file-access-uri
feat: add support to access attachment blob uri
2 parents 523adea + edda70a commit 7f878ce

File tree

5 files changed

+139
-4
lines changed

5 files changed

+139
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath"
3-
version = "2.2.43"
3+
version = "2.2.44"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath/platform/attachments/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
This module contains models related to UiPath Attachments service.
44
"""
55

6-
from .attachments import Attachment, AttachmentMode
6+
from .attachments import Attachment, AttachmentMode, BlobFileAccessInfo
77

88
__all__ = [
99
"Attachment",
1010
"AttachmentMode",
11+
"BlobFileAccessInfo",
1112
]

src/uipath/platform/attachments/attachments.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Module defining the attachment model for attachments."""
22

33
import uuid
4+
from dataclasses import dataclass
45
from enum import Enum
56
from typing import Optional
67

@@ -20,3 +21,18 @@ class Attachment(BaseModel):
2021
id: Optional[uuid.UUID] = Field(None, alias="ID")
2122
full_name: str = Field(..., alias="FullName")
2223
mime_type: str = Field(..., alias="MimeType")
24+
25+
26+
@dataclass
27+
class BlobFileAccessInfo:
28+
"""Information about blob file access for an attachment.
29+
30+
Attributes:
31+
id: The unique identifier (UUID) of the attachment.
32+
uri: The blob storage URI for accessing the file.
33+
name: The name of the attachment file.
34+
"""
35+
36+
id: uuid.UUID
37+
uri: str
38+
name: str

src/uipath/platform/orchestrator/_attachments_service.py

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from ..._utils._ssl_context import get_httpx_client_kwargs
1616
from ..._utils.constants import TEMP_ATTACHMENTS_FOLDER
1717
from ...tracing import traced
18-
from ..attachments import Attachment, AttachmentMode
18+
from ..attachments import Attachment, AttachmentMode, BlobFileAccessInfo
1919
from ..common import BaseService, FolderContext, UiPathApiConfig, UiPathExecutionContext
2020

2121

@@ -709,6 +709,124 @@ async def main():
709709

710710
return attachment_key
711711

712+
@traced(name="attachments_get_blob_uri", run_type="uipath")
713+
def get_blob_file_access_uri(
714+
self,
715+
*,
716+
key: uuid.UUID,
717+
folder_key: str | None = None,
718+
folder_path: str | None = None,
719+
) -> BlobFileAccessInfo:
720+
"""Get the BlobFileAccess information for an attachment.
721+
722+
This method retrieves the blob storage URI and filename for downloading
723+
an attachment without actually downloading the file.
724+
725+
Args:
726+
key (uuid.UUID): The key of the attachment.
727+
folder_key (str | None): The key of the folder. Override the default one set in the SDK config.
728+
folder_path (str | None): The path of the folder. Override the default one set in the SDK config.
729+
730+
Returns:
731+
BlobFileAccessInfo: Object containing the blob storage URI and attachment name.
732+
733+
Raises:
734+
Exception: If the attachment is not found or the request fails.
735+
736+
Examples:
737+
```python
738+
from uipath.platform import UiPath
739+
740+
client = UiPath()
741+
742+
info = client.attachments.get_blob_file_access_uri(
743+
key=uuid.UUID("123e4567-e89b-12d3-a456-426614174000")
744+
)
745+
print(f"Attachment ID: {info.id}")
746+
print(f"Blob URI: {info.uri}")
747+
print(f"File name: {info.name}")
748+
```
749+
"""
750+
spec = self._retrieve_download_uri_spec(
751+
key=key,
752+
folder_key=folder_key,
753+
folder_path=folder_path,
754+
)
755+
756+
result = self.request(
757+
spec.method,
758+
url=spec.endpoint,
759+
params=spec.params,
760+
headers=spec.headers,
761+
).json()
762+
763+
return BlobFileAccessInfo(
764+
id=key,
765+
uri=result["BlobFileAccess"]["Uri"],
766+
name=result["Name"],
767+
)
768+
769+
@traced(name="attachments_get_blob_uri", run_type="uipath")
770+
async def get_blob_file_access_uri_async(
771+
self,
772+
*,
773+
key: uuid.UUID,
774+
folder_key: str | None = None,
775+
folder_path: str | None = None,
776+
) -> BlobFileAccessInfo:
777+
"""Get the BlobFileAccess information for an attachment asynchronously.
778+
779+
This method asynchronously retrieves the blob storage URI and filename
780+
for downloading an attachment without actually downloading the file.
781+
782+
Args:
783+
key (uuid.UUID): The key of the attachment.
784+
folder_key (str | None): The key of the folder. Override the default one set in the SDK config.
785+
folder_path (str | None): The path of the folder. Override the default one set in the SDK config.
786+
787+
Returns:
788+
BlobFileAccessInfo: Object containing the blob storage URI and attachment name.
789+
790+
Raises:
791+
Exception: If the attachment is not found or the request fails.
792+
793+
Examples:
794+
```python
795+
import asyncio
796+
from uipath.platform import UiPath
797+
798+
client = UiPath()
799+
800+
async def main():
801+
info = await client.attachments.get_blob_file_access_uri_async(
802+
key=uuid.UUID("123e4567-e89b-12d3-a456-426614174000")
803+
)
804+
print(f"Attachment ID: {info.id}")
805+
print(f"Blob URI: {info.uri}")
806+
print(f"File name: {info.name}")
807+
```
808+
"""
809+
spec = self._retrieve_download_uri_spec(
810+
key=key,
811+
folder_key=folder_key,
812+
folder_path=folder_path,
813+
)
814+
815+
result = (
816+
await self.request_async(
817+
spec.method,
818+
url=spec.endpoint,
819+
params=spec.params,
820+
headers=spec.headers,
821+
)
822+
).json()
823+
824+
return BlobFileAccessInfo(
825+
id=key,
826+
uri=result["BlobFileAccess"]["Uri"],
827+
name=result["Name"],
828+
)
829+
712830
@traced(name="attachments_delete", run_type="uipath")
713831
def delete(
714832
self,

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)