Expand APIResponse to capture additional HTTP response metadata#11
Merged
stevevanhooser merged 3 commits intoMar 11, 2026
Conversation
Aligns Python's APIResponse with the richer structure returned by MATLAB's ndi.cloud.api apiResponse output argument. All new fields use safe defaults so existing call-sites (including manually-constructed APIResponse instances in pagination helpers) are fully backward-compatible. https://claude.ai/code/session_01Y9G6ysXeXzrXRsZGe2Pe3G
…source of truth Renames (with backward-compatible aliases): - download.downloadFullDataset → download.dataset - filehandler.rewrite_file_info_for_cloud → filehandler.updateFileInfoForRemoteFiles - sync._delete_local_docs → sync.deleteLocalDocuments (now public) - sync._download_docs_by_ids → sync.downloadNdiDocuments (now public) New functions ported from MATLAB: - download.datasetDocuments — per-document download with mode handling - download.downloadGenericFiles — download generic_file docs with extensions - download.setFileInfo — set file_info for local/hybrid modes - download.structsToNdiDocuments — alias for jsons2documents - upload.uploadToNDICloud — legacy upload entry point - upload.scanForUpload — moved from orchestration to match MATLAB location - filehandler.updateFileInfoForLocalFiles — update file_info for local files - internal.duplicateDocuments — find/remove duplicate cloud documents Test cleanup: - Add module-scoped autouse fixture to sweep up any leftover NDI_PYTEST_* datasets after all tests complete, preventing stale dataset accumulation. https://claude.ai/code/session_01Y9G6ysXeXzrXRsZGe2Pe3G
The safety-net fixture now prints a warnings.warn with the names and IDs of every leftover dataset it deletes, making silent teardown failures visible in CI logs. https://claude.ai/code/session_01Y9G6ysXeXzrXRsZGe2Pe3G
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enhanced the
APIResponseclass to capture and expose additional HTTP response metadata, providing callers with more detailed information about API responses.Key Changes
Extended
APIResponseattributes: Added four new fields to__slots__:headers: Response headers as a dict-like objectreason: HTTP reason phrase (e.g., "OK", "Not Found")elapsed: Time elapsed between request and response (asdatetime.timedelta)http_response: Reference to the rawrequests.ResponseobjectUpdated
__init__method: Added corresponding parameters with sensible defaults:headersdefaults to empty dict if not providedreasondefaults to empty stringelapsedandhttp_responsedefault toNoneEnhanced
__repr__method: Improved string representation to conditionally include:Updated
_requestmethod: Modified to populate new fields when constructingAPIResponsefrom actual HTTP responses:resp.headers,resp.reason,resp.elapsed, and the response object itselfgetattr()with defaults for optional attributesImplementation Details
APIResponseinstances (e.g., for paginated aggregations) can omit the new fields__repr__method gracefully handles missing optional fields to avoid cluttering outputhttps://claude.ai/code/session_01Y9G6ysXeXzrXRsZGe2Pe3G