-
Notifications
You must be signed in to change notification settings - Fork 5
add v2 event type schema and updates endpoints #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ea633e3
964b8fc
1ebdc62
6d8aeab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -655,6 +655,42 @@ def get_event_types(self, include_inactive=False, include_schema=False, version= | |
| def get_event_schema(self, event_type): | ||
| return self._get(f'activity/events/schema/eventtype/{event_type}') | ||
|
|
||
| def get_event_type_schema(self, event_type_value, pre_render=False): | ||
| """ | ||
| Get the schema for a single event type (v2 API). | ||
|
|
||
| :param event_type_value: The event type 'value' identifier (e.g. 'rainfall_rep') | ||
| :param pre_render: If True, return the pre-rendered schema | ||
| """ | ||
| return self._get( | ||
| f'eventtypes/{event_type_value}/schema', | ||
| base_url=self._api_root('v2.0'), | ||
| params={'pre_render': pre_render}, | ||
| ) | ||
|
|
||
| def get_event_type_updates(self, event_type_value): | ||
| """ | ||
| Get the revision history for a single event type (v2 API). | ||
|
|
||
| :param event_type_value: The event type 'value' identifier | ||
| """ | ||
| return self._get( | ||
| f'eventtypes/{event_type_value}/updates', | ||
| base_url=self._api_root('v2.0'), | ||
| ) | ||
|
|
||
| def get_event_type_schemas(self, pre_render=False): | ||
| """ | ||
| Get schemas for all event types in bulk (v2 API). | ||
|
|
||
| :param pre_render: If True, return pre-rendered schemas | ||
| """ | ||
| return self._get( | ||
| 'eventtypes/schemas', | ||
| base_url=self._api_root('v2.0'), | ||
| params={'pre_render': pre_render}, | ||
| ) | ||
|
Comment on lines
+658
to
+692
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this indicative of v1 EOL? |
||
|
|
||
| def _get_objects_count(self, params): | ||
| params = params.copy() | ||
| params["page"] = 1 | ||
|
|
@@ -1544,6 +1580,42 @@ async def patch_event_type(self, event_type, version=DEFAULT_VERSION): | |
| # self.logger.debug('Result of event type patch is: %s', result) | ||
| return result | ||
|
|
||
| async def get_event_type_schema(self, event_type_value, pre_render=False): | ||
| """ | ||
| Get the schema for a single event type (v2 API). | ||
|
|
||
| :param event_type_value: The event type 'value' identifier (e.g. 'rainfall_rep') | ||
| :param pre_render: If True, return the pre-rendered schema | ||
| """ | ||
| return await self._get( | ||
| f'eventtypes/{event_type_value}/schema', | ||
| base_url=self._api_root(VERSION_2_0), | ||
| params={'pre_render': pre_render}, | ||
| ) | ||
|
|
||
| async def get_event_type_updates(self, event_type_value): | ||
| """ | ||
| Get the revision history for a single event type (v2 API). | ||
|
|
||
| :param event_type_value: The event type 'value' identifier | ||
| """ | ||
| return await self._get( | ||
| f'eventtypes/{event_type_value}/updates', | ||
| base_url=self._api_root(VERSION_2_0), | ||
| ) | ||
|
|
||
| async def get_event_type_schemas(self, pre_render=False): | ||
| """ | ||
| Get schemas for all event types in bulk (v2 API). | ||
|
|
||
| :param pre_render: If True, return pre-rendered schemas | ||
| """ | ||
| return await self._get( | ||
| 'eventtypes/schemas', | ||
| base_url=self._api_root(VERSION_2_0), | ||
| params={'pre_render': pre_render}, | ||
| ) | ||
|
|
||
| async def get_subjectgroups( | ||
| self, | ||
| include_inactive=False, | ||
|
|
@@ -1646,38 +1718,6 @@ async def _get_data(self, endpoint, params, batch_size=0): | |
| async def _get(self, path, base_url=None, params=None): | ||
| return await self._call(path=path, payload=None, method="GET", params=params, base_url=base_url) | ||
|
|
||
| async def _delete(self, path): | ||
| """Issue DELETE request. Returns True on success; raises ERClient* on error.""" | ||
| try: | ||
| auth_headers = await self.auth_headers() | ||
| except httpx.HTTPStatusError as e: | ||
| self._handle_http_status_error(path, "DELETE", e) | ||
| headers = {'User-Agent': self.user_agent, **auth_headers} | ||
| if not path.startswith('http'): | ||
| path = self._er_url(path) | ||
| try: | ||
| response = await self._http_session.delete(path, headers=headers) | ||
| except httpx.RequestError as e: | ||
| reason = str(e) | ||
| self.logger.error('Request to ER failed', extra=dict(provider_key=self.provider_key, | ||
| url=path, | ||
| reason=reason)) | ||
| raise ERClientException(f'Request to ER failed: {reason}') | ||
| if response.is_success: | ||
| return True | ||
| if response.status_code == 404: | ||
| self.logger.error("404 when calling %s", path) | ||
| raise ERClientNotFound() | ||
| if response.status_code == 403: | ||
| try: | ||
| reason = response.json().get('status', {}).get('detail', 'unknown reason') | ||
| except Exception: | ||
| reason = 'unknown reason' | ||
| raise ERClientPermissionDenied(reason) | ||
| raise ERClientException( | ||
| f'Failed to delete: {response.status_code} {response.text}' | ||
| ) | ||
|
|
||
| async def get_file(self, url): | ||
| """ | ||
| Download a file (e.g. attachment URL). Returns the httpx response; body is read into memory. | ||
|
|
@@ -1722,7 +1762,6 @@ async def _delete(self, path, params=None, base_url=None): | |
| return await self._call( | ||
| path=path, payload=None, method="DELETE", params=params, base_url=base_url | ||
| ) | ||
|
|
||
| async def _call(self, path, payload, method, params=None, base_url=None): | ||
| try: | ||
| auth_headers = await self.auth_headers() | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,187 @@ | ||||||||
| import re | ||||||||
|
|
||||||||
|
Comment on lines
+1
to
+2
|
||||||||
| import re |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable result is not used.
| assert route.called | |
| assert route.called | |
| assert result == schema_response |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable result is not used.
| result = await er_client.get_event_type_schemas(pre_render=True) | |
| await er_client.get_event_type_schemas(pre_render=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new sync client methods
get_event_type_schema,get_event_type_updates, andget_event_type_schemaslack test coverage. While there are 8 comprehensive tests for the async versions of these methods, there are no corresponding tests for the sync client. The repository shows a pattern of comprehensive testing for the async client but lacks tests for the sync client entirely. Consider adding test coverage for the sync client methods to match the async client test coverage.