ERA-12664: event provider and event source CRUD parity#31
Open
JoshuaVulcan wants to merge 5 commits intomainfrom
Open
ERA-12664: event provider and event source CRUD parity#31JoshuaVulcan wants to merge 5 commits intomainfrom
JoshuaVulcan wants to merge 5 commits intomainfrom
Conversation
Add full CRUD methods for event providers and event sources to both sync (ERClient) and async (AsyncERClient) clients for parity: Sync client: - get_eventproviders(), get_eventprovider(), patch_eventprovider() - get_eventsources(), get_eventsource(), patch_eventsource() Async client: - post_eventprovider(), post_eventsource() - get_eventproviders(), get_eventprovider(), patch_eventprovider() - get_eventsources(), get_eventsource(), patch_eventsource() Includes 28 new tests covering success and error cases for all methods across both clients. Co-authored-by: Cursor <cursoragent@cursor.com>
# Conflicts: # tests/sync_client/conftest.py
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds CRUD parity for EarthRanger “event providers” and “event sources” across both ERClient (sync) and AsyncERClient (async), along with new pytest coverage for these endpoints.
Changes:
- Add sync client methods:
get_eventproviders,get_eventprovider,patch_eventprovider,get_eventsources,get_eventsource,patch_eventsource - Add async client methods:
post_eventprovider,post_eventsource, plus the same GET/PATCH methods as sync - Add new async + sync test suites for event provider/source CRUD behaviors
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
erclient/client.py |
Adds new sync and async client methods for event provider/source GET/PATCH (+ async POST parity). |
tests/sync_client/test_eventproviders.py |
New sync tests for provider/source POST/GET/PATCH flows. |
tests/async_client/test_eventproviders.py |
New async tests for provider/source POST/GET/PATCH flows using respx. |
💡 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.
| import pytest | ||
|
|
||
| from erclient.client import ERClient | ||
| from erclient import ERClientNotFound, ERClientPermissionDenied |
Comment on lines
+393
to
+426
| def get_eventproviders(self): | ||
| """ | ||
| Get a list of event providers. | ||
| :return: list of event provider dicts | ||
| """ | ||
| return self._get('activity/eventproviders') | ||
|
|
||
| def get_eventprovider(self, eventprovider_id): | ||
| """ | ||
| Get a single event provider by ID. | ||
| :param eventprovider_id: UUID of the event provider | ||
| :return: event provider data dict | ||
| """ | ||
| return self._get(f'activity/eventprovider/{eventprovider_id}') | ||
|
|
||
| def patch_eventprovider(self, eventprovider_id, payload): | ||
| """ | ||
| Update an event provider with partial data. | ||
| :param eventprovider_id: UUID of the event provider | ||
| :param payload: dict of fields to update | ||
| :return: updated event provider data dict | ||
| """ | ||
| self.logger.debug('Patching eventprovider %s: %s', eventprovider_id, payload) | ||
| result = self._patch(f'activity/eventprovider/{eventprovider_id}', payload=payload) | ||
| self.logger.debug('Result of eventprovider patch is: %s', result) | ||
| return result | ||
|
|
||
| def get_eventsources(self, eventprovider_id): | ||
| """ | ||
| Get the list of event sources for a given event provider. | ||
| :param eventprovider_id: UUID of the event provider | ||
| :return: list of event source dicts | ||
| """ | ||
| return self._get(f'activity/eventprovider/{eventprovider_id}/eventsources') |
Comment on lines
+1414
to
+1448
| async def get_eventproviders(self): | ||
| """ | ||
| Get a list of event providers. | ||
| :return: list of event provider dicts | ||
| """ | ||
| return await self._get('activity/eventproviders') | ||
|
|
||
| async def get_eventprovider(self, eventprovider_id): | ||
| """ | ||
| Get a single event provider by ID. | ||
| :param eventprovider_id: UUID of the event provider | ||
| :return: event provider data dict | ||
| """ | ||
| return await self._get(f'activity/eventprovider/{eventprovider_id}') | ||
|
|
||
| async def patch_eventprovider(self, eventprovider_id, payload): | ||
| """ | ||
| Update an event provider with partial data. | ||
| :param eventprovider_id: UUID of the event provider | ||
| :param payload: dict of fields to update | ||
| :return: updated event provider data dict | ||
| """ | ||
| self.logger.debug(f'Patching eventprovider {eventprovider_id}: {payload}') | ||
| result = await self._patch(f'activity/eventprovider/{eventprovider_id}', payload=payload) | ||
| self.logger.debug(f'Result of eventprovider patch is: {result}') | ||
| return result | ||
|
|
||
| async def get_eventsources(self, eventprovider_id): | ||
| """ | ||
| Get the list of event sources for a given event provider. | ||
| :param eventprovider_id: UUID of the event provider | ||
| :return: list of event source dicts | ||
| """ | ||
| return await self._get(f'activity/eventprovider/{eventprovider_id}/eventsources') | ||
|
|
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
ERClient) and async (AsyncERClient) clientsget_eventproviders(),get_eventprovider(),patch_eventprovider(),get_eventsources(),get_eventsource(),patch_eventsource()post_eventprovider(),post_eventsource(),get_eventproviders(),get_eventprovider(),patch_eventprovider(),get_eventsources(),get_eventsource(),patch_eventsource()DAS API Endpoints Covered
activity/eventprovidersget_eventproviders()get_eventproviders()activity/eventproviders/post_eventprovider()(existing)post_eventprovider()(new)activity/eventprovider/{id}get_eventprovider()get_eventprovider()activity/eventprovider/{id}patch_eventprovider()patch_eventprovider()activity/eventprovider/{id}/eventsourcesget_eventsources()get_eventsources()activity/eventprovider/{id}/eventsourcespost_eventsource()(existing)post_eventsource()(new)activity/eventsource/{id}get_eventsource()get_eventsource()activity/eventsource/{id}patch_eventsource()patch_eventsource()Test Plan
Jira
ERA-12664
[ERA-12664]: https://allenai.atlassian.net/browse/ERA-12664?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ