Skip to content

Commit

Permalink
Source Freshdesk: handle change subscription level (#26978)
Browse files Browse the repository at this point in the history
* Source Freshdesk: skip the stream if subscription level had changed during sync

* Source Freshdesk: update docs
  • Loading branch information
artem1205 committed Jun 5, 2023
1 parent be1084f commit cb8a166
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_freshdesk ./source_freshdesk
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=3.0.2
LABEL io.airbyte.version=3.0.3
LABEL io.airbyte.name=airbyte/source-freshdesk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: ec4b9503-13cb-48ab-a4ab-6ade4be46567
dockerImageTag: 3.0.2
dockerImageTag: 3.0.3
dockerRepository: airbyte/source-freshdesk
githubIssueLabel: source-freshdesk
icon: freshdesk.svg
Expand Down
3 changes: 1 addition & 2 deletions airbyte-integrations/connectors/source-freshdesk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
MAIN_REQUIREMENTS = [
"airbyte-cdk",
"backoff==1.10.0",
"requests==2.25.1",
"pendulum==2.1.2",
"requests==2.25.1"
]

TEST_REQUIREMENTS = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#


import logging
import re
from abc import ABC
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional
Expand All @@ -20,6 +19,9 @@
from source_freshdesk.utils import CallCredit


logger = logging.getLogger("airbyte")


class FreshdeskStream(HttpStream, ABC):
"""Basic stream API that allows to iterate over entities"""

Expand Down Expand Up @@ -98,6 +100,15 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Muta
return []
return response.json() or []

def should_retry(self, response: requests.Response) -> bool:
if response.status_code == requests.codes.FORBIDDEN:
# Issue: https://github.com/airbytehq/airbyte/issues/26717
# we should skip the stream if subscription level had changed during sync
self.forbidden_stream = True
setattr(self, "raise_on_http_errors", False)
logger.warning(f"Stream `{self.name}` is not available. {response.text}")
return super().should_retry(response)


class IncrementalFreshdeskStream(FreshdeskStream, IncrementalMixin):

Expand Down
3 changes: 2 additions & 1 deletion docs/integrations/sources/freshdesk.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ If you don't use the start date Freshdesk will retrieve only the last 30 days. M

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:--------------------------------------------------------------------------------------|
| 3.0.2 | 2023-02-06 | [21970](https://github.com/airbytehq/airbyte/pull/21970) | Enable availability strategy for all streams |
| 3.0.3 | 2023-06-02 | [26978](https://github.com/airbytehq/airbyte/pull/26978) | Skip the stream if subscription level had changed during sync |
| 3.0.2 | 2023-02-06 | [21970](https://github.com/airbytehq/airbyte/pull/21970) | Enable availability strategy for all streams |
| 3.0.0 | 2023-01-31 | [22164](https://github.com/airbytehq/airbyte/pull/22164) | Rename nested `business_hours` table to `working_hours` |
| 2.0.1 | 2023-01-27 | [21888](https://github.com/airbytehq/airbyte/pull/21888) | Set `AvailabilityStrategy` for streams explicitly to `None` |
| 2.0.0 | 2022-12-20 | [20416](https://github.com/airbytehq/airbyte/pull/20416) | Fix `SlaPolicies` stream schema |
Expand Down

0 comments on commit cb8a166

Please sign in to comment.