ERA-12678: Add v2 dynamic schema endpoints to sync and async clients#37
Open
JoshuaVulcan wants to merge 4 commits intomainfrom
Open
ERA-12678: Add v2 dynamic schema endpoints to sync and async clients#37JoshuaVulcan wants to merge 4 commits intomainfrom
JoshuaVulcan wants to merge 4 commits intomainfrom
Conversation
ERA-12678: Adds support for retrieving JSON schemas from the v2.0 API: Both ERClient (sync) and AsyncERClient (async): - get_schema(resource_name): generic schema retrieval - get_users_schema(): users schema - get_sources_schema(): sources schema - get_subjects_schema(): subjects schema - get_choices_schema(): choices schema - get_spatial_features_schema(): spatial features schema - get_event_types_schema(): event types schema - service_root_v2 property: derives v2.0 URL from v1.0 service_root Also updates AsyncERClient._call to support absolute URLs, matching the sync client behavior. Includes 19 tests covering success, not-found, and forbidden scenarios for both sync and async clients. Co-authored-by: Cursor <cursoragent@cursor.com>
…l pattern Replace the brittle `service_root_v2` property (which uses str.replace on '/api/v1.0') with the cleaner `_api_root(version)` + `base_url` parameter pattern from PR #23. This adds `_api_root()`, updates `_er_url()` to accept a `base_url` param, and threads `base_url` through `_get`, `_post`, `_patch`, and `_call` on both sync and async clients. Updates get_schema() and all convenience schema methods to use `base_url=self._api_root('v2.0')` instead of constructing full URLs from `service_root_v2`. Also updates tests to use `_api_root('v2.0')` instead of manual string replace on service_root. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
V2 URL Convention AlignmentReplaced the Changes:
This PR is now compatible with PR #23's infrastructure and will merge cleanly once #23 lands. |
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class client helpers to retrieve JSON Schema documents from the EarthRanger v2.0 API and introduces sync/async test coverage to validate URL construction and error handling.
Changes:
- Add
get_schema()plus convenience methods (get_users_schema(),get_sources_schema(), etc.) to bothERClientandAsyncERClient. - Add new sync and async test modules covering success, 404, and 403 cases for the new schema endpoints.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
erclient/client.py |
Introduces sync/async v2 schema retrieval methods that call _get(..., base_url=_api_root('v2.0')). |
tests/sync_client/test_v2_schemas.py |
New sync tests for generic + convenience schema methods and v2 root URL construction. |
tests/async_client/test_v2_schemas.py |
New async tests (httpx/respx) for generic + convenience schema methods and error cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+8
to
+10
| SCHEMA_NAMES = ['users', 'sources', 'subjects', 'choices', 'spatial_features', 'event_types'] | ||
|
|
||
|
|
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
get_schema(resource_name)method and 6 convenience methods (get_users_schema,get_sources_schema,get_subjects_schema,get_choices_schema,get_spatial_features_schema,get_event_types_schema) to bothERClient(sync) andAsyncERClient(async)service_root_v2property to both clients, deriving the v2.0 API root from the configured v1.0service_rootAsyncERClient._callto support absolute URLs (matching sync client behavior), enabling v2 endpoint callsTest plan
service_root_v2derivation, generic schema retrieval, all 6 individual schemas, plus 404 and 403 error handlingResolves ERA-12678