Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/uipath-platform/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-platform"
version = "0.1.21"
version = "0.1.22"
description = "HTTP client library for programmatic access to UiPath Platform"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
4 changes: 3 additions & 1 deletion packages/uipath-platform/src/uipath/platform/_uipath.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ def llm(self) -> UiPathLlmChatService:

@property
def entities(self) -> EntitiesService:
return EntitiesService(self._config, self._execution_context)
return EntitiesService(
self._config, self._execution_context, folders_service=self.folders
)

@cached_property
def resource_catalog(self) -> ResourceCatalogService:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ._base_service import BaseService
from ._bindings import (
ConnectionResourceOverwrite,
EntityResourceOverwrite,
GenericResourceOverwrite,
ResourceOverwrite,
ResourceOverwriteParser,
Expand Down Expand Up @@ -100,6 +101,7 @@
"EndpointManager",
"jsonschema_to_pydantic",
"ConnectionResourceOverwrite",
"EntityResourceOverwrite",
"GenericResourceOverwrite",
"ResourceOverwrite",
"ResourceOverwriteParser",
Expand Down
54 changes: 50 additions & 4 deletions packages/uipath-platform/src/uipath/platform/common/_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
Union,
)

from pydantic import AliasChoices, BaseModel, ConfigDict, Field, TypeAdapter
from pydantic import (
AliasChoices,
BaseModel,
ConfigDict,
Field,
TypeAdapter,
model_validator,
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -45,7 +52,7 @@ def folder_identifier(self) -> str:

class GenericResourceOverwrite(ResourceOverwrite):
resource_type: Literal[
"process", "index", "app", "asset", "bucket", "mcpServer", "queue", "entity"
"process", "index", "app", "asset", "bucket", "mcpServer", "queue"
]
name: str = Field(alias="name")
folder_path: str = Field(alias="folderPath")
Expand All @@ -59,6 +66,29 @@ def folder_identifier(self) -> str:
return self.folder_path


class EntityResourceOverwrite(ResourceOverwrite):
resource_type: Literal["entity"]
name: str = Field(alias="name")
folder_id: Optional[str] = Field(default=None, alias="folderId")
folder_path: Optional[str] = Field(default=None, alias="folderPath")

@model_validator(mode="after")
def validate_folder_identifier(self) -> "EntityResourceOverwrite":
if self.folder_id and self.folder_path:
raise ValueError("Only one of folderId or folderPath may be provided.")
if not self.folder_id and not self.folder_path:
raise ValueError("Either folderId or folderPath must be provided.")
return self

@property
def resource_identifier(self) -> str:
return self.name

@property
def folder_identifier(self) -> str:
return self.folder_id or self.folder_path or ""


class ConnectionResourceOverwrite(ResourceOverwrite):
resource_type: Literal["connection"]
# In eval context, studio web provides "ConnectionId".
Expand All @@ -83,7 +113,9 @@ def folder_identifier(self) -> str:


ResourceOverwriteUnion = Annotated[
Union[GenericResourceOverwrite, ConnectionResourceOverwrite],
Union[
GenericResourceOverwrite, EntityResourceOverwrite, ConnectionResourceOverwrite
],
Field(discriminator="resource_type"),
]

Expand Down Expand Up @@ -112,9 +144,23 @@ def parse(cls, key: str, value: dict[str, Any]) -> ResourceOverwrite:
The appropriate ResourceOverwrite subclass instance
"""
resource_type = key.split(".")[0]
value_with_type = {"resource_type": resource_type, **value}
normalized_value = cls._normalize_value(resource_type, value)
value_with_type = {"resource_type": resource_type, **normalized_value}
return cls._adapter.validate_python(value_with_type)

@staticmethod
def _normalize_value(resource_type: str, value: dict[str, Any]) -> dict[str, Any]:
if resource_type != "entity":
return value

normalized = dict(value)
if "folderId" in normalized:
normalized["folder_id"] = normalized.pop("folderId")
if "folderPath" in normalized:
normalized["folder_path"] = normalized.pop("folderPath")

return normalized


_resource_overwrites: ContextVar[Optional[dict[str, ResourceOverwrite]]] = ContextVar(
"resource_overwrites", default=None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

from ._entities_service import EntitiesService
from .entities import (
DataFabricEntityItem,
Entity,
EntityField,
EntityFieldMetadata,
EntityRecord,
EntityRecordsBatchResponse,
EntityRouting,
EntitySetResolution,
ExternalField,
ExternalObject,
ExternalSourceFields,
Expand All @@ -22,12 +24,14 @@
)

__all__ = [
"DataFabricEntityItem",
"EntitiesService",
"Entity",
"EntityField",
"EntityRecord",
"EntityFieldMetadata",
"EntityRouting",
"EntitySetResolution",
"FieldDataType",
"FieldMetadata",
"EntityRecordsBatchResponse",
Expand Down
Loading
Loading