Skip to content
Merged
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.2.22"
version = "0.2.23"
description = "HTTP client library for programmatic access to UiPath Platform"
Comment thread
avichalsri24 marked this conversation as resolved.
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,6 @@ def list_records(
start: Optional[int] = None,
limit: Optional[int] = None,
expansion_level: Optional[int] = None,
filter: Optional[str] = None,
orderby: Optional[str] = None,
select: Optional[List[str]] = None,
expand: Optional[List[str]] = None,
) -> EntityRecordsListResponse:
"""List records from an entity with optional pagination and schema validation.

Expand Down Expand Up @@ -637,14 +633,6 @@ class CustomerRecord:
expansion_level (Optional[int]): Depth of foreign-key expansion in the
response (``0`` means no expansion). Higher values inline related
records up to that many hops.
filter (Optional[str]): OData ``$filter`` expression
(e.g. ``"status eq 'active'"``).
orderby (Optional[str]): OData ``$orderby`` expression
(e.g. ``"created_at desc"``).
select (Optional[List[str]]): Column projection — field names to
include (rendered as ``$select``).
expand (Optional[List[str]]): Relationship names to expand inline
(rendered as ``$expand``).

Returns:
EntityRecordsListResponse: A list-compatible response with
Expand Down Expand Up @@ -674,15 +662,25 @@ class CustomerRecord:
"Customers", start=50, limit=50
)

With OData filter, sorting, projection, and expansion::
With foreign-key expansion::

records = entities_service.list_records(
records = entities_service.list_records("Customers", expansion_level=1)

To filter, sort, or project, use :meth:`retrieve_records` — this
endpoint only pages::

result = entities_service.retrieve_records(
"Customers",
filter="status eq 'active'",
orderby="created_at desc",
select=["name", "email", "status"],
expand=["company"],
expansion_level=1,
filter_group=EntityQueryFilterGroup(
logical_operator=LogicalOperator.And,
query_filters=[
EntityQueryFilter(
field_name="status",
operator=QueryFilterOperator.Equals,
value="active",
)
],
),
)

With schema validation::
Expand All @@ -709,10 +707,6 @@ class CustomerRecord:
start=start,
limit=limit,
expansion_level=expansion_level,
filter=filter,
orderby=orderby,
select=select,
expand=expand,
)

@traced(name="entity_list_records", run_type="uipath")
Expand All @@ -723,10 +717,6 @@ async def list_records_async(
start: Optional[int] = None,
limit: Optional[int] = None,
expansion_level: Optional[int] = None,
filter: Optional[str] = None,
orderby: Optional[str] = None,
select: Optional[List[str]] = None,
expand: Optional[List[str]] = None,
) -> EntityRecordsListResponse:
"""Asynchronously list records from an entity with optional pagination and schema validation.

Expand Down Expand Up @@ -767,14 +757,6 @@ class CustomerRecord:
expansion_level (Optional[int]): Depth of foreign-key expansion in the
response (``0`` means no expansion). Higher values inline related
records up to that many hops.
filter (Optional[str]): OData ``$filter`` expression
(e.g. ``"status eq 'active'"``).
orderby (Optional[str]): OData ``$orderby`` expression
(e.g. ``"created_at desc"``).
select (Optional[List[str]]): Column projection — field names to
include (rendered as ``$select``).
expand (Optional[List[str]]): Relationship names to expand inline
(rendered as ``$expand``).

Returns:
EntityRecordsListResponse: A list-compatible response with
Expand Down Expand Up @@ -804,17 +786,15 @@ class CustomerRecord:
"Customers", start=50, limit=50
)

With OData filter, sorting, projection, and expansion::
With foreign-key expansion::

records = await entities_service.list_records_async(
"Customers",
filter="status eq 'active'",
orderby="created_at desc",
select=["name", "email", "status"],
expand=["company"],
expansion_level=1,
"Customers", expansion_level=1
)

To filter, sort, or project, use :meth:`retrieve_records_async` —
this endpoint only pages.

With schema validation::

class CustomerRecord:
Expand All @@ -839,10 +819,6 @@ class CustomerRecord:
start=start,
limit=limit,
expansion_level=expansion_level,
filter=filter,
orderby=orderby,
select=select,
expand=expand,
)

@traced(name="entity_insert_record", run_type="uipath")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ async def get_choiceset_values_async(
return self._parse_choiceset_values(response)

# ------------------------------------------------------------------
# List records (multi-record read with OData filters)
# List records (multi-record read: paging and expansion only)
# ------------------------------------------------------------------

def list_records(
Expand All @@ -144,21 +144,13 @@ def list_records(
start: Optional[int] = None,
limit: Optional[int] = None,
expansion_level: Optional[int] = None,
filter: Optional[str] = None,
orderby: Optional[str] = None,
select: Optional[List[str]] = None,
expand: Optional[List[str]] = None,
) -> EntityRecordsListResponse:
"""Internal implementation; see :meth:`EntitiesService.list_records`."""
Comment thread
avichalsri24 marked this conversation as resolved.
spec = self._list_records_spec(
entity_key,
start=start,
limit=limit,
expansion_level=expansion_level,
filter=filter,
orderby=orderby,
select=select,
expand=expand,
)
response = self.request(spec.method, spec.endpoint, params=spec.params)
return self._build_records_list_response(response, schema, start, limit)
Expand All @@ -170,21 +162,13 @@ async def list_records_async(
start: Optional[int] = None,
limit: Optional[int] = None,
expansion_level: Optional[int] = None,
filter: Optional[str] = None,
orderby: Optional[str] = None,
select: Optional[List[str]] = None,
expand: Optional[List[str]] = None,
) -> EntityRecordsListResponse:
"""Async variant of :meth:`list_records`."""
spec = self._list_records_spec(
entity_key,
start=start,
limit=limit,
expansion_level=expansion_level,
filter=filter,
orderby=orderby,
select=select,
expand=expand,
)
response = await self.request_async(
spec.method, spec.endpoint, params=spec.params
Expand Down Expand Up @@ -714,27 +698,21 @@ def _list_records_spec(
start: Optional[int] = None,
limit: Optional[int] = None,
expansion_level: Optional[int] = None,
filter: Optional[str] = None,
orderby: Optional[str] = None,
select: Optional[List[str]] = None,
expand: Optional[List[str]] = None,
) -> RequestSpec:
"""Build the GET spec for the multi-record read endpoint."""
"""Build the GET spec for the multi-record read endpoint.

The endpoint implements only ``start``, ``limit`` and ``expansionLevel``.
OData-style ``$filter`` / ``$orderby`` / ``$select`` / ``$expand`` params
are accepted and silently ignored by the backend, so they are not sent —
use :meth:`retrieve_records` (``POST .../query``) to filter or sort.
"""
params: Dict[str, Any] = {}
if start is not None:
params["start"] = start
if limit is not None:
params["limit"] = limit
if expansion_level is not None:
params["expansionLevel"] = expansion_level
if filter is not None:
params["$filter"] = filter
if orderby is not None:
params["$orderby"] = orderby
if select:
params["$select"] = ",".join(select)
if expand:
params["$expand"] = ",".join(expand)
return RequestSpec(
method="GET",
endpoint=Endpoint(
Expand Down
38 changes: 30 additions & 8 deletions packages/uipath-platform/tests/services/test_entities_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,10 +1709,6 @@ def test_list_records_returns_paginated_metadata(
start=0,
limit=3,
expansion_level=2,
filter="status eq 'active'",
orderby="name asc",
select=["Id", "name"],
expand=["Company"],
)

# New pagination metadata: backend totalCount surfaced verbatim.
Expand All @@ -1729,11 +1725,37 @@ def test_list_records_returns_paginated_metadata(
sent = httpx_mock.get_request()
assert sent is not None
params = sent.url.params
assert params.get("start") == "0"
assert params.get("limit") == "3"
assert params.get("expansionLevel") == "2"
assert params.get("$filter") == "status eq 'active'"
assert params.get("$orderby") == "name asc"
assert params.get("$select") == "Id,name"
assert params.get("$expand") == "Company"
# The /read endpoint implements paging and expansion only — it accepts
# OData params and silently ignores them, returning the unfiltered set.
# Sending them would promise filtering this endpoint cannot do.
assert [key for key in params if key.startswith("$")] == []

@pytest.mark.parametrize(
"kwarg,value",
[
("filter", "status eq 'active'"),
("orderby", "name asc"),
("select", ["Id"]),
("expand", ["Company"]),
],
)
def test_list_records_rejects_odata_kwargs(
self,
service: EntitiesService,
kwarg: str,
value: object,
) -> None:
"""The /read endpoint cannot filter, sort or project.

Accepting these kwargs again — directly or via ``**kwargs`` — would
return the full unfiltered set while looking like it filtered. Failing
loudly points callers at ``retrieve_records`` instead.
"""
with pytest.raises(TypeError, match=kwarg):
service.list_records(entity_key=str(uuid.uuid4()), **{kwarg: value})

def test_insert_records_passes_expansion_level_and_fail_on_first(
self,
Expand Down
2 changes: 1 addition & 1 deletion packages/uipath-platform/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/uipath/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading