Add fluent .with_response_details() API for telemetry access#93
Add fluent .with_response_details() API for telemetry access#93tpellissier-msft wants to merge 5 commits intomainfrom
Conversation
Phase 1 SDK restructure: All methods return OperationResult with fluent .with_response_details() API for optional telemetry access. Changes: - Add OperationResult wrapper with dunder methods for transparent behavior - Add RequestTelemetryData and DataverseResponse result types - Unwrap OperationResult in update/delete to allow operation chaining - Rename internal type alias to _ODataRequestResult for clarity - Standardize all _odata.py method return type annotations - Add telemetry printing to walkthrough example Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extends the fluent .with_response_details() API to support paginated queries. Each page batch is now wrapped in OperationResult, allowing telemetry access per page while maintaining backward compatibility. Changes: - Add __add__ and __radd__ to OperationResult for batch concatenation - Modify _get_multiple to yield (batch, metadata) tuples - Update get() to wrap each page in OperationResult - Add per-page telemetry printing to walkthrough example - Add tests for concatenation and per-page telemetry access Backward compatibility: - Existing iteration patterns work unchanged via OperationResult delegation - Batch concatenation (batch1 + batch2) returns raw list as expected Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR implements Phase 1 of an SDK restructure by adding a fluent .with_response_details() API pattern for optional telemetry access. All CRUD methods now return an OperationResult wrapper that provides transparent delegation to the underlying result through dunder methods (__iter__, __getitem__, __len__, etc.), while also enabling explicit telemetry access via .with_response_details().
Changes:
- Introduces new
core/results.pymodule withRequestTelemetryData,DataverseResponse, andOperationResulttypes - Updates
data/_odata.pyto return tuples of(result, RequestTelemetryData)from all internal methods - Updates
client.pyto wrap all method results inOperationResultwhile maintaining backward compatibility - Extends telemetry support to paginated queries with per-page telemetry access
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/PowerPlatform/Dataverse/core/results.py | New module defining RequestTelemetryData, DataverseResponse, and OperationResult with comprehensive dunder method delegation |
| src/PowerPlatform/Dataverse/data/_odata.py | Updated all internal methods to return (result, RequestTelemetryData) tuples; telemetry extracted from response headers |
| src/PowerPlatform/Dataverse/client.py | All public methods now return OperationResult; added unwrapping logic in update() and delete() for ergonomic chaining |
| tests/unit/test_results.py | Comprehensive unit tests for all result types and dunder method behaviors including iteration, indexing, equality, concatenation |
| tests/unit/test_client.py | Updated client tests to verify OperationResult behavior and telemetry access; added pagination telemetry tests |
| tests/unit/data/test_logical_crud.py | Updated CRUD tests to handle tuple return values with telemetry metadata |
| examples/advanced/walkthrough.py | Enhanced with telemetry printing helper and telemetry access examples throughout all operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix docstring in results.py: RequestMetadata -> RequestTelemetryData - Move Tuple import to top of _odata.py with other typing imports Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update internal _request() call sites to unpack (response, telemetry) tuples after Phase 1 changes. Also use duck typing instead of isinstance(x, list) for OperationResult compatibility. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fe11913 to
7b712a9
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
.with_response_details()API pattern for optional telemetry accessOperationResultwrapper with transparent dunder delegation (__iter__,__getitem__,__len__, etc.)RequestTelemetryDataandDataverseResponseresult types for standardized telemetry accessget()queries with per-page telemetry accessChanges
New module:
core/results.pyRequestTelemetryData: Immutable dataclass capturing correlation IDs from HTTP requestsDataverseResponse[T]: Standard response object withresultandtelemetrypropertiesOperationResult[T]: Wrapper enabling fluent.with_response_details()pattern with transparent delegationUpdated
client.pycreate,get,update,delete,query_sql,create_table, etc.) returnOperationResultupdate()anddelete()unwrapOperationResultwhen passed directly fromcreate()Updated
data/_odata.py_ODataRequestResulttype alias forTuple[Any, RequestTelemetryData](result, metadata)tuplesx-ms-service-request-id,x-ms-client-request-id, etc.)Backward Compatibility
for id in client.create(...)ids[0]len(ids)ids == ["guid-1", "guid-2"]batch1 + batch2returns raw listUsage Examples
Test plan
OperationResultdunder methods (iteration, indexing, equality, bool, contains)DataverseResponsestructure__add__,__radd__)OperationResult🤖 Generated with Claude Code