Skip to content

feat(entities): support v1, v2, and v3 Data Fabric entities APIs#1799

Open
RohanKharvi1211 wants to merge 1 commit into
mainfrom
feat/entities-v2-v3
Open

feat(entities): support v1, v2, and v3 Data Fabric entities APIs#1799
RohanKharvi1211 wants to merge 1 commit into
mainfrom
feat/entities-v2-v3

Conversation

@RohanKharvi1211

Copy link
Copy Markdown

Summary

Adds selectable v2 and v3 Entities API surfaces alongside the existing (unchanged) v1 sdk.entities. The entities SDK previously used hardcoded endpoint strings with no version concept; this introduces version-aware access points without altering v1 behavior.

  • sdk.entitiesv1 (unchanged, default)
  • sdk.entities_v2v2 — partial surface (the v2 backend only implements retrieve_records (query), get_record (read by id), and list_entities); reuses v1 models/parsing, only re-points endpoints to /api/v2/...
  • sdk.entities_v3v3 — mirrors the v1 operation set on /api/v3/entities/*, returning new v3 response models

v3 models (entities_v3.py)

  • EntityWriteResponseV3 — replicates the backend's flattening: root-entity fields fold into root_fields on parse and re-flatten to the top level on dump; updatedCount omitted when zero
  • QueryResponseV3, BatchOperationResponse, EntityRecordV3, CompositeEntityMetadataResponse (composite/member aware), GetAllResponseV3, plus ChildArrayBlock helpers

Notes / scope

  • Federated SQL (query_entity_records) and entity-set resolution are version-agnostic and delegate to the shared engine.
  • import_records (CSV bulk upload) has no v3 endpoint → raises NotImplementedError on v3.
  • Extracted a shared build_query_body() used by v1/v2/v3 (pure refactor).
  • v3 record ops route by name ({entityName}), matching how existing SDK examples pass entity names as entity_key.

⚠️ One inferred detail worth confirming against a live v3 tenant: v3 create_entity reuses v1's entityDefinition payload shape (the v3 controller accepts a generic body).

Testing

  • All 130 existing entity tests pass (the build_query_body extraction preserves v1 behavior).
  • 22 new v2/v3 tests added (endpoint routing, EntityWriteResponseV3 flatten round-trip, composite metadata, batch, NotImplementedError).
  • Full uipath-platform suite: 1361 passed, 11 skipped.
  • ruff check, ruff format --check, and mypy clean on all touched files.

🤖 Generated with Claude Code

The entities SDK previously talked to the Data Service through hardcoded
endpoint strings with no version concept. Add selectable v2 and v3 surfaces
alongside the existing (unchanged) v1 `sdk.entities`:

- `sdk.entities`    -> v1 (unchanged)
- `sdk.entities_v2` -> v2 (partial: query + read + list_entities, v1 models)
- `sdk.entities_v3` -> v3 (mirrors the v1 op set on /api/v3/entities/*,
  returning new V3 models)

v2 shares v1's wire shape, so `EntitiesServiceV2` reuses v1 parsing/models and
only re-points endpoints; it exposes exactly what the v2 backend implements.

v3 is a redesign: new models in `entities_v3.py` (`EntityWriteResponseV3` with
the root-field flattening converter, `QueryResponseV3`, `BatchOperationResponse`,
`EntityRecordV3`, `CompositeEntityMetadataResponse`, `GetAllResponseV3`).
Federated SQL and entity-set resolution stay version-agnostic; CSV import raises
NotImplementedError on v3 (no v3 endpoint).

Extracted the shared `build_query_body()` helper (used by v1/v2/v3). No change
to v1 behavior — all 130 existing entity tests pass; 22 new v2/v3 tests added.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 7, 2026 13:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds version-aware Entities SDK surfaces so consumers can choose v1 (existing), v2 (limited surface), or v3 (new models + routing) Data Fabric entities APIs without changing v1 behavior.

Changes:

  • Introduces EntitiesServiceV2 and EntitiesServiceV3 facades and wires them into UiPathPlatform as sdk.entities_v2 / sdk.entities_v3.
  • Adds v3-specific response models (notably EntityWriteResponseV3 with fold/flatten behavior) plus v3 schema/data service implementations targeting /datafabric_/api/v3/entities/....
  • Refactors shared structured-query body construction into build_query_body() and reuses it across v1/v2/v3.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/uipath-platform/tests/services/test_entities_v3_service.py Adds v3 facade + v3 model behavior tests (endpoints, batch, composite metadata, NotImplementedError).
packages/uipath-platform/tests/services/test_entities_v2.py Adds v2 facade tests for endpoint routing and intentionally-missing operations.
packages/uipath-platform/src/uipath/platform/entities/entities_v3.py Introduces v3 response models (flattened envelope + composite metadata/catalog types).
packages/uipath-platform/src/uipath/platform/entities/_entity_schema_service_v3.py Adds v3 schema HTTP service targeting /api/v3/entities and returning v3 schema models.
packages/uipath-platform/src/uipath/platform/entities/_entity_data_service.py Extracts build_query_body() and switches v1 structured query builder to use it.
packages/uipath-platform/src/uipath/platform/entities/_entity_data_service_v3.py Adds v3 data HTTP service (CRUD/query/batch/attachments/choicesets) targeting /api/v3/entities/....
packages/uipath-platform/src/uipath/platform/entities/_entities_service_v3.py Adds public v3 facade (EntitiesServiceV3) composing schema+data services and delegating federated SQL to v1.
packages/uipath-platform/src/uipath/platform/entities/_entities_service_v2.py Adds public v2 facade (EntitiesServiceV2) exposing only the v2 backend’s supported operations.
packages/uipath-platform/src/uipath/platform/entities/init.py Exports v2/v3 facades and v3 models from the uipath.platform.entities package surface.
packages/uipath-platform/src/uipath/platform/_uipath.py Wires entities_v2/entities_v3 onto the main SDK entrypoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +475 to +485
@staticmethod
def _choiceset_values_spec(
choiceset_id: str,
start: Optional[int] = None,
limit: Optional[int] = None,
) -> RequestSpec:
return RequestSpec(
method="POST",
endpoint=Endpoint(f"{_V3_BASE}/entity/{choiceset_id}/query_expansion"),
json=build_query_body(start=start, limit=limit),
)
Comment on lines +66 to +70
self._routing_strategy: RoutingStrategy = (
routing_strategy
if routing_strategy is not None
else create_routing_strategy(
folders_map=folders_map,
Comment on lines +397 to +401
def upload_attachment(
self,
entity_id: str,
record_id: str,
field_name: str,
Comment on lines +213 to +217
def get_choiceset_values(
self,
choiceset_id: str,
start: Optional[int] = None,
limit: Optional[int] = None,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants