Skip to content

Commit

Permalink
🐛 Source Zendesk Support: Fix schema User stream to pull all users (#…
Browse files Browse the repository at this point in the history
…12122)

* Add SourceZendeskUserExportStream

* Format streams

* Update zendesk-support README

* Update dockerfile

* Update changelog to reflect additional fixes

* Review updates

* Fix typo from previous contribution

* Update unit tests

* Remove enum and default from spec

Co-authored-by: Baz <bazarnov@me.com>
  • Loading branch information
2 people authored and suhomud committed May 23, 2022
1 parent edfa86c commit b624b85
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,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.2.5
LABEL io.airbyte.version=0.2.6
LABEL io.airbyte.name=airbyte/source-zendesk-support
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
"credentials": {
"type": "string",
"const": "oauth2.0",
"enum": ["oauth2.0"],
"default": "oauth2.0",
"order": 0
},
"access_token": {
Expand All @@ -54,8 +52,6 @@
"credentials": {
"type": "string",
"const": "api_token",
"enum": ["api_token"],
"default": "api_token",
"order": 0
},
"email": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ def read_records(

class SourceZendeskSupportFullRefreshStream(BaseSourceZendeskSupportStream):
"""
# endpoints don't provide the updated_at/created_at fields
# thus we can't implement an incremental logic for them
Endpoints don't provide the updated_at/created_at fields
Thus we can't implement an incremental logic for them
"""

page_size = 100
Expand Down Expand Up @@ -324,7 +324,7 @@ def request_params(self, next_page_token: Mapping[str, Any] = None, **kwargs) ->

class SourceZendeskSupportCursorPaginationStream(SourceZendeskSupportFullRefreshStream):
"""
# endpoints provide a cursor pagination and sorting mechanism
Endpoints provide a cursor pagination and sorting mechanism
"""

next_page_field = "next_page"
Expand Down Expand Up @@ -361,17 +361,17 @@ def request_params(
return params


class SourceZendeskTicketExportStream(SourceZendeskSupportCursorPaginationStream):
class SourceZendeskIncrementalExportStream(SourceZendeskSupportCursorPaginationStream):
"""Incremental Export from Tickets stream:
https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-ticket-export-time-based
@ param response_list_name: the main nested entity to look at inside of response, defualt = response_list_name
@ param response_list_name: the main nested entity to look at inside of response, default = response_list_name
@ param sideload_param : parameter variable to include various information to response
more info: https://developer.zendesk.com/documentation/ticketing/using-the-zendesk-api/side_loading/#supported-endpoints
"""

cursor_field = "updated_at"
response_list_name: str = "tickets"
response_list_name: str = None
sideload_param: str = None

@staticmethod
Expand Down Expand Up @@ -410,11 +410,11 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp
yield record


class SourceZendeskSupportTicketEventsExportStream(SourceZendeskTicketExportStream):
class SourceZendeskSupportTicketEventsExportStream(SourceZendeskIncrementalExportStream):
"""Incremental Export from TicketEvents stream:
https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-ticket-event-export
@ param response_list_name: the main nested entity to look at inside of response, defualt = "ticket_events"
@ param response_list_name: the main nested entity to look at inside of response, default = "ticket_events"
@ param response_target_entity: nested property inside of `response_list_name`, default = "child_events"
@ param list_entities_from_event : the list of nested child_events entities to include from parent record
@ param event_type : specific event_type to check ["Audit", "Change", "Comment", etc]
Expand All @@ -441,17 +441,21 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp
yield event


class Users(SourceZendeskSupportStream):
"""Users stream: https://developer.zendesk.com/api-reference/ticketing/users/users/"""
class Users(SourceZendeskIncrementalExportStream):
"""Users stream: https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-user-export"""

response_list_name: str = "users"


class Organizations(SourceZendeskSupportStream):
"""Organizations stream: https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/"""


class Tickets(SourceZendeskTicketExportStream):
class Tickets(SourceZendeskIncrementalExportStream):
"""Tickets stream: https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-ticket-export-time-based"""

response_list_name: str = "tickets"


class TicketComments(SourceZendeskSupportTicketEventsExportStream):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
DATETIME_FORMAT,
END_OF_STREAM_KEY,
BaseSourceZendeskSupportStream,
SourceZendeskTicketExportStream,
SourceZendeskIncrementalExportStream,
TicketComments,
Tickets,
)
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_str2unixtime():
def test_check_start_time_param():
expected = 1626936955
start_time = calendar.timegm(pendulum.parse(DATETIME_STR).utctimetuple())
output = SourceZendeskTicketExportStream.check_start_time_param(start_time)
output = SourceZendeskIncrementalExportStream.check_start_time_param(start_time)
assert output == expected


Expand Down
5 changes: 3 additions & 2 deletions docs/integrations/sources/zendesk-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This Source is capable of syncing the following core Streams:
* [Ticket Forms](https://developer.zendesk.com/rest_api/docs/support/ticket_forms)
* [Ticket Metrics](https://developer.zendesk.com/rest_api/docs/support/ticket_metrics)
* [Ticket Metric Events](https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_metric_events/)
* [Users](https://developer.zendesk.com/rest_api/docs/support/users)
* [Users](https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-user-export)

### Data type mapping

Expand Down Expand Up @@ -62,7 +62,7 @@ The Zendesk connector should not run into Zendesk API limitations under normal u

### Requirements

* `Subdomain` - this is your Zendesk subdomain that can be found in your account URL. For example, in `https://{MY_SUBDOMAIN}.zendesk.com/`, where `MY_SUBDOMAIN` is the value of your subdomain.
* `Subdomain` - this is your Zendesk subdomain that can be found in your account URL. For example, in `https://{MY_SUBDOMAIN}.zendesk.com/`, where `MY_SUBDOMAIN` is the value of your subdomain.
* `Authentication` - Zendesk service provides two authentication methods. Choose between: `OAuth2.0` or `API token`.
* Authentication using `OAuth2.0` (Only for Airbyte Cloud) - obtain `access_token` by authorising using your Zendesk Account credentials. Simply proceed by pressing "Authenticate your Zendesk Account" and complete the authentication.
* Authentication using `API Token`:
Expand All @@ -74,6 +74,7 @@ The Zendesk connector should not run into Zendesk API limitations under normal u

| Version | Date | Pull Request | Subject |
|:---------|:-----------| :----- |:-------------------------------------------------------|
| `0.2.6` | 2022-04-19 | [12122](https://github.com/airbytehq/airbyte/pull/12122) | Fixed the bug when only 100,000 Users are synced [11895](https://github.com/airbytehq/airbyte/issues/11895) and fixed bug when `start_date` is not used on user stream [12059](https://github.com/airbytehq/airbyte/issues/12059).
| `0.2.5` | 2022-04-05 | [11727](https://github.com/airbytehq/airbyte/pull/11727) | Fixed the bug when state was not parsed correctly
| `0.2.4` | 2022-04-04 | [11688](https://github.com/airbytehq/airbyte/pull/11688) | Small documentation corrections
| `0.2.3` | 2022-03-23 | [11349](https://github.com/airbytehq/airbyte/pull/11349) | Fixed the bug when Tickets stream didn't return deleted records
Expand Down

0 comments on commit b624b85

Please sign in to comment.