Skip to content
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

🐛 Source ZenDesk Support: fix 404 responses for the ticket_comments stream #6513

Merged
merged 15 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/publish-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ jobs:
ZENDESK_SUNSHINE_TEST_CREDS: ${{ secrets.ZENDESK_SUNSHINE_TEST_CREDS }}
ZENDESK_TALK_TEST_CREDS: ${{ secrets.ZENDESK_TALK_TEST_CREDS }}
ZENDESK_SUPPORT_TEST_CREDS: ${{ secrets.ZENDESK_SUPPORT_TEST_CREDS }}
ZENDESK_SUPPORT_OAUTH_TEST_CREDS: ${{ secrets.ZENDESK_SUPPORT_OAUTH_TEST_CREDS }}
ZOOM_INTEGRATION_TEST_CREDS: ${{ secrets.ZOOM_INTEGRATION_TEST_CREDS }}
PLAID_INTEGRATION_TEST_CREDS: ${{ secrets.PLAID_INTEGRATION_TEST_CREDS }}
DESTINATION_S3_INTEGRATION_TEST_CREDS: ${{ secrets.DESTINATION_S3_INTEGRATION_TEST_CREDS }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ jobs:
ZENDESK_SUNSHINE_TEST_CREDS: ${{ secrets.ZENDESK_SUNSHINE_TEST_CREDS }}
ZENDESK_TALK_TEST_CREDS: ${{ secrets.ZENDESK_TALK_TEST_CREDS }}
ZENDESK_SUPPORT_TEST_CREDS: ${{ secrets.ZENDESK_SUPPORT_TEST_CREDS }}
ZENDESK_SUPPORT_OAUTH_TEST_CREDS: ${{ secrets.ZENDESK_SUPPORT_OAUTH_TEST_CREDS }}
ZOOM_INTEGRATION_TEST_CREDS: ${{ secrets.ZOOM_INTEGRATION_TEST_CREDS }}
PLAID_INTEGRATION_TEST_CREDS: ${{ secrets.PLAID_INTEGRATION_TEST_CREDS }}
DESTINATION_S3_INTEGRATION_TEST_CREDS: ${{ secrets.DESTINATION_S3_INTEGRATION_TEST_CREDS }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"sourceDefinitionId": "79c1aa37-dae3-42ae-b333-d1c105477715",
"name": "Zendesk Support",
"dockerRepository": "airbyte/source-zendesk-support",
"dockerImageTag": "0.1.1",
"dockerImageTag": "0.1.2",
"documentationUrl": "https://docs.airbyte.io/integrations/sources/zendesk-support",
"icon": "zendesk.svg"
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
- sourceDefinitionId: 79c1aa37-dae3-42ae-b333-d1c105477715
name: Zendesk Support
dockerRepository: airbyte/source-zendesk-support
dockerImageTag: 0.1.1
dockerImageTag: 0.1.2
documentationUrl: https://docs.airbyte.io/integrations/sources/zendesk-support
icon: zendesk.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM base as builder


RUN apk --no-cache upgrade \
&& pip install --upgrade pip
&& pip install --upgrade pip \
&& apk --no-cache add tzdata build-base

WORKDIR /airbyte/integration_code
COPY setup.py ./
Expand All @@ -12,6 +13,9 @@ RUN pip install --prefix=/install .

FROM base
COPY --from=builder /install /usr/local
# add default timezone settings
COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN echo "Etc/UTC" > /etc/timezone

WORKDIR /airbyte/integration_code
COPY main.py ./
Expand All @@ -21,5 +25,5 @@ COPY source_zendesk_support ./source_zendesk_support
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.version=0.1.2
LABEL io.airbyte.name=airbyte/source-zendesk-support
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ tests:
connection:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "secrets/config_oauth.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
discovery:
- config_path: "secrets/config.json"
- config_path: "secrets/config_oauth.json"
basic_read:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pendulum
import requests_mock
from source_zendesk_support import SourceZendeskSupport
from source_zendesk_support.streams import Macros, TicketAudits, TicketMetrics, Tickets, Users
from source_zendesk_support.streams import LAST_END_TIME_KEY, Macros, TicketAudits, TicketMetrics, Tickets, Users

CONFIG_FILE = "secrets/config.json"

Expand All @@ -32,12 +32,12 @@ def _test_export_stream(self, stream_cls: type):
# save the first 5 records
if len(record_timestamps) > 5:
break
if stream._last_end_time not in record_timestamps.values():
record_timestamps[record["id"]] = stream._last_end_time
if stream.last_end_time not in record_timestamps.values():
record_timestamps[record["id"]] = stream.last_end_time

stream.page_size = 10
for record_id, timestamp in record_timestamps.items():
state = {"_last_end_time": timestamp}
state = {LAST_END_TIME_KEY: timestamp}
for record in stream.read_records(sync_mode=None, stream_state=state):
assert record["id"] != record_id
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from setuptools import find_packages, setup

MAIN_REQUIREMENTS = ["airbyte-cdk", "pytz"]
MAIN_REQUIREMENTS = ["airbyte-cdk~=0.1.23", "pytz"]

TEST_REQUIREMENTS = ["pytest~=6.1", "source-acceptance-test", "requests-mock==1.9.3"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import requests
from airbyte_cdk.sources import AbstractSource
from airbyte_cdk.sources.streams import Stream
from airbyte_cdk.sources.streams.http.auth import TokenAuthenticator
from airbyte_cdk.sources.streams.http.requests_native_auth import TokenAuthenticator

from .streams import (
GroupMemberships,
Expand All @@ -29,6 +29,8 @@
UserSettingsStream,
)

# from airbyte_cdk.sources.streams.http.auth.token import TokenAuthenticator

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# from airbyte_cdk.sources.streams.http.auth.token import TokenAuthenticator


class BasicApiTokenAuthenticator(TokenAuthenticator):
"""basic Authorization header"""
Expand All @@ -47,7 +49,9 @@ class SourceZendeskSupport(AbstractSource):

@classmethod
def get_authenticator(cls, config: Mapping[str, Any]) -> BasicApiTokenAuthenticator:
if config["auth_method"].get("email") and config["auth_method"].get("api_token"):
if config["auth_method"].get("access_token"):
return TokenAuthenticator(token=config["auth_method"]["access_token"])
elif config["auth_method"].get("email") and config["auth_method"].get("api_token"):
return BasicApiTokenAuthenticator(config["auth_method"]["email"], config["auth_method"]["api_token"])
raise SourceZendeskException(f"Not implemented authorization method: {config['auth_method']}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,32 @@
"default": "api_token",
"description": "Zendesk service provides 2 auth method: API token and oAuth2. Now only the first one is available. Another one will be added in the future",
"oneOf": [
{
"type": "object",
"title": "OAuth2.0 authorization",
"properties": {
"auth_method": {
"type": "string",
"const": "access_token"
},
"client_id": {
"type": "string",
"description": "This is the name of your client for use in code."
},
"client_secret": {
"type": "string",
"airbyte_secret": true,
"description": "This secret token is used by apps redirecting to your client. "
},
"access_token": {
"type": "string",
"airbyte_secret": true,
"description": "Using for authorization. The access token doesn't expire."
}
},
"required": ["access_token"],
"additionalProperties": false
},
{
"title": "API Token",
"type": "object",
Expand All @@ -47,5 +73,13 @@
]
}
}
},
"authSpecification": {
"auth_type": "oauth2.0",
"oauth2Specification": {
"rootObject": ["auth_method", 0],
"oauthFlowInitParameters": [["client_id"], ["client_secret"]],
"oauthFlowOutputParameters": [["access_token"]]
}
}
}
Loading