-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source google-analytics-data-api: upgrade cdk 3 (#42841)
- Loading branch information
1 parent
223717a
commit fd7fa00
Showing
13 changed files
with
435 additions
and
235 deletions.
There are no files selected for viewing
This file contains 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
289 changes: 188 additions & 101 deletions
289
airbyte-integrations/connectors/source-google-analytics-data-api/poetry.lock
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
26 changes: 26 additions & 0 deletions
26
...data-api/source_google_analytics_data_api/google_analytics_data_api_base_error_mapping.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
# | ||
from typing import Mapping, Type, Union | ||
|
||
from airbyte_cdk.models import FailureType | ||
from airbyte_cdk.sources.streams.http.error_handlers.default_error_mapping import DEFAULT_ERROR_MAPPING | ||
from airbyte_cdk.sources.streams.http.error_handlers.response_models import ErrorResolution | ||
from source_google_analytics_data_api.utils import WRONG_CUSTOM_REPORT_CONFIG | ||
|
||
|
||
def get_google_analytics_data_api_base_error_mapping(report_name) -> Mapping[Union[int, str, Type[Exception]], ErrorResolution]: | ||
""" | ||
Updating base default error messages friendly config error message that includes the steam report name | ||
""" | ||
stream_error_mapping = {} | ||
for error_key, base_error_resolution in DEFAULT_ERROR_MAPPING.items(): | ||
if base_error_resolution.failure_type in (FailureType.config_error, FailureType.system_error): | ||
stream_error_mapping[error_key] = ErrorResolution( | ||
response_action=base_error_resolution.response_action, | ||
failure_type=FailureType.config_error, | ||
error_message=WRONG_CUSTOM_REPORT_CONFIG.format(report=report_name), | ||
) | ||
else: | ||
stream_error_mapping[error_key] = base_error_resolution | ||
return stream_error_mapping |
29 changes: 29 additions & 0 deletions
29
...-api/source_google_analytics_data_api/google_analytics_data_api_metadata_error_mapping.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# | ||
# Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
# | ||
from typing import Mapping, Type, Union | ||
|
||
from airbyte_cdk.models import FailureType | ||
from airbyte_cdk.sources.streams.http.error_handlers.default_error_mapping import DEFAULT_ERROR_MAPPING | ||
from airbyte_cdk.sources.streams.http.error_handlers.response_models import ErrorResolution, ResponseAction | ||
|
||
PROPERTY_ID_DOCS_URL = "https://developers.google.com/analytics/devguides/reporting/data/v1/property-id#what_is_my_property_id" | ||
MESSAGE = "Incorrect Property ID: {property_id}. Access was denied to the property ID entered. Check your access to the Property ID or use Google Analytics {property_id_docs_url} to find your Property ID." | ||
|
||
|
||
def get_google_analytics_data_api_metadata_error_mapping(property_id) -> Mapping[Union[int, str, Type[Exception]], ErrorResolution]: | ||
""" | ||
Adding friendly messages to bad request and forbidden responses that includes the property id and the documentation guidance. | ||
""" | ||
return DEFAULT_ERROR_MAPPING | { | ||
403: ErrorResolution( | ||
response_action=ResponseAction.FAIL, | ||
failure_type=FailureType.config_error, | ||
error_message=MESSAGE.format(property_id=property_id, property_id_docs_url=PROPERTY_ID_DOCS_URL), | ||
), | ||
400: ErrorResolution( | ||
response_action=ResponseAction.FAIL, | ||
failure_type=FailureType.config_error, | ||
error_message=MESSAGE.format(property_id=property_id, property_id_docs_url=PROPERTY_ID_DOCS_URL), | ||
), | ||
} |
Oops, something went wrong.