Skip to content

Commit

Permalink
🎉Source Zenloop: migrate to lowcode (#19624)
Browse files Browse the repository at this point in the history
* Migrate to lowcode

* Updated PR

* Updated configured catalog

* Updated to review

* Updated after review

* Add expected records

* Updated docs

* Updated docs

* Fix to linter check

* auto-bump connector version

Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
  • Loading branch information
lazebnyi and octavia-squidington-iii authored Dec 9, 2022
1 parent aa0d171 commit 17c767a
Show file tree
Hide file tree
Showing 17 changed files with 547 additions and 574 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1895,10 +1895,10 @@
- name: Zenloop
sourceDefinitionId: f1e4c7f6-db5c-4035-981f-d35ab4998794
dockerRepository: airbyte/source-zenloop
dockerImageTag: 0.1.3
dockerImageTag: 0.1.4
documentationUrl: https://docs.airbyte.com/integrations/sources/zenloop
sourceType: api
releaseStage: alpha
releaseStage: beta
- sourceDefinitionId: cdaf146a-9b75-49fd-9dd2-9d64a0bb4781
name: Sentry
dockerRepository: airbyte/source-sentry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16433,7 +16433,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-zenloop:0.1.3"
- dockerImage: "airbyte/source-zenloop:0.1.4"
spec:
documentationUrl: "https://docs.airbyte.com/integrations/sources/zenloop"
connectionSpecification:
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-zenloop/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_zenloop ./source_zenloop
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.3
LABEL io.airbyte.version=0.1.4
LABEL io.airbyte.name=airbyte/source-zenloop
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-zenloop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integrat
Make sure to familiarize yourself with [pytest test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery) to know how your test files and methods should be named.
First install test dependencies into your virtual environment:
```
pip install .[tests]
pip install .'[tests]'
```
### Unit Tests
To run unit tests locally, from the connector directory run:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,16 @@ tests:
- config_path: "secrets/config.json"
basic_read:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog_answers.json"
empty_streams: []
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog_surveys.json"
empty_streams: []
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog_answers_survey_group.json"
empty_streams: []
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog_survey_groups.json"
empty_streams: []
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog_properties.json"
empty_streams: []
configured_catalog_path: "integration_tests/configured_catalog.json"
expect_records:
path: "integration_tests/expected_records.txt"
extra_fields: no
exact_order: no
extra_records: yes
incremental:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog_answers.json"
future_state_path: "integration_tests/abnormal_state.json"
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog_answers_survey_group.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog_survey_groups.json"
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog_surveys.json"
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog_properties.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"streams": [
{
"stream": {
"name": "answers",
"json_schema": {},
"supported_sync_modes": ["full_refresh", "incremental"]
},
"sync_mode": "incremental",
"destination_sync_mode": "append"
},
{
"stream": {
"name": "surveys",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "survey_groups",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "answers_survey_group",
"json_schema": {},
"supported_sync_modes": ["full_refresh", "incremental"]
},
"sync_mode": "incremental",
"destination_sync_mode": "append"
},
{
"stream": {
"name": "properties",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{"stream": "answers", "data": {"additional_answers": [], "additional_questions": {}, "comment": "Airbyte is amazing", "email": "sajarin@airbyte.io", "id": "TVRrMlptWmtPRGd0TWprMFl5MDBZbUkwTFRrd01XWXROVE5pWldNMU56WXpNbVV4", "identity": "sajarin@airbyte.io", "identity_type": "email", "inserted_at": "2022-09-19T08:46:22.373163Z", "labels": [], "labels_with_keywords": {}, "metatags": {}, "name": "Sajarin Dider", "property_ids": [348043522, 348043523], "recipient_id": "TVRFMU1qTXhaV1F0Wm1Oa01TMDBOMkUzTFRsbE1ETXRObVEzTjJNd1lqWmpZMkpp", "score": 10, "score_type": "promoter", "sentiment": "positive", "sentiment_per_label_name": {}, "translated_comment": null}, "emitted_at": 1670592045869}
{"stream": "answers", "data": {"additional_answers": [], "additional_questions": {}, "comment": "I love airbyte", "email": "integration-test@airbyte.io", "id": "TXpCaU5tRmtNekl0T1dKa09TMDBPRGd5TFdKbFlURXROalF6WkRkbFlqVmhaR0kw", "identity": "integration-test@airbyte.io", "identity_type": "email", "inserted_at": "2022-09-19T08:46:14.348616Z", "labels": [], "labels_with_keywords": {}, "metatags": {}, "name": "Test Account", "property_ids": [348044048, 348043523], "recipient_id": "TkdOaU5HRTVOMlV0WWpReE1TMDBNRGxrTFdJeU9UUXROVGcxTVRCbE5UVXhaakpo", "score": 10, "score_type": "promoter", "sentiment": "positive", "sentiment_per_label_name": {}, "translated_comment": null}, "emitted_at": 1670592045874}
{"stream": "surveys", "data": {"inserted_at": "2022-09-19T08:36:26Z", "public_hash_id": "WlRBek9ESTFNREl0TmpJMk9DMDBOR0V4TFRoaE16UXRZV1UyWW1SbU56WTNPVGRs", "status": "active", "title": "New Survey 2022-09-19 08:36:26.262267"}, "emitted_at": 1670592046346}
{"stream": "survey_groups", "data": {"inserted_at": "2021-11-09T13:06:59Z", "name": "All Surveys & Survey Groups", "public_hash_id": "WmpGa1ltTmlZbVl0TWpGa015MDBOemhsTFdKbE1XSXRaV05sTXpnMk9USmlOalZp", "surveys": [{"inserted_at": "2022-09-19T08:36:26Z", "public_hash_id": "WlRBek9ESTFNREl0TmpJMk9DMDBOR0V4TFRoaE16UXRZV1UyWW1SbU56WTNPVGRs", "status": "active", "title": "New Survey 2022-09-19 08:36:26.262267"}]}, "emitted_at": 1670592046589}
{"stream": "survey_groups", "data": {"inserted_at": "2022-09-19T08:48:21Z", "name": "Test Group", "public_hash_id": "TnpKaE1UVmhObUV0WkdFME15MDBZMkUyTFRsalpXRXROamt5TkRVd05EZzVOelEy", "surveys": [{"inserted_at": "2022-09-19T08:36:26Z", "public_hash_id": "WlRBek9ESTFNREl0TmpJMk9DMDBOR0V4TFRoaE16UXRZV1UyWW1SbU56WTNPVGRs", "status": "active", "title": "New Survey 2022-09-19 08:36:26.262267"}]}, "emitted_at": 1670592046592}
{"stream": "answers_survey_group", "data": {"additional_questions": {}, "comment": "Airbyte is amazing", "email": "sajarin@airbyte.io", "id": "TVRrMlptWmtPRGd0TWprMFl5MDBZbUkwTFRrd01XWXROVE5pWldNMU56WXpNbVV4", "identity": "sajarin@airbyte.io", "identity_type": "email", "inserted_at": "2022-09-19T08:46:22.373163Z", "labels": [], "labels_with_keywords": {}, "metatags": {}, "name": "Sajarin Dider", "property_ids": [348043522, 348043523], "recipient_id": "TVRFMU1qTXhaV1F0Wm1Oa01TMDBOMkUzTFRsbE1ETXRObVEzTjJNd1lqWmpZMkpp", "score": 10, "score_type": "promoter", "sentiment": "positive", "sentiment_per_label_name": {}, "survey_public_hash_id": "WlRBek9ESTFNREl0TmpJMk9DMDBOR0V4TFRoaE16UXRZV1UyWW1SbU56WTNPVGRs", "translated_comment": null}, "emitted_at": 1670592046844}
{"stream": "answers_survey_group", "data": {"additional_questions": {}, "comment": "I love airbyte", "email": "integration-test@airbyte.io", "id": "TXpCaU5tRmtNekl0T1dKa09TMDBPRGd5TFdKbFlURXROalF6WkRkbFlqVmhaR0kw", "identity": "integration-test@airbyte.io", "identity_type": "email", "inserted_at": "2022-09-19T08:46:14.348616Z", "labels": [], "labels_with_keywords": {}, "metatags": {}, "name": "Test Account", "property_ids": [348044048, 348043523], "recipient_id": "TkdOaU5HRTVOMlV0WWpReE1TMDBNRGxrTFdJeU9UUXROVGcxTVRCbE5UVXhaakpo", "score": 10, "score_type": "promoter", "sentiment": "positive", "sentiment_per_label_name": {}, "survey_public_hash_id": "WlRBek9ESTFNREl0TmpJMk9DMDBOR0V4TFRoaE16UXRZV1UyWW1SbU56WTNPVGRs", "translated_comment": null}, "emitted_at": 1670592046851}
{"stream": "properties", "data": {"id": "WldSa1pUTmtaVGN0TWprNU5pMDBPVEUyTFdGbE9XSXRPVEkwTVRjM1lqUXlNMlU0", "name": "gender", "value": "agender"}, "emitted_at": 1670592047292}
{"stream": "properties", "data": {"id": "WWpsa1pUUmlaVFl0Tmpoa055MDBZV0l3TFRsbE9USXRaV1pqWVdFMFpESTFNR1E0", "name": "gender", "value": "male"}, "emitted_at": 1670592047295}
{"stream": "properties", "data": {"id": "TldKak1qQTNaRFF0WWpVeU5DMDBaVEpqTFdJNFkyVXRPVFJqTldFNU9Ea3haRFps", "name": "country", "value": "US"}, "emitted_at": 1670592047297}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#


from dataclasses import dataclass
from typing import Iterable

from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources.declarative.stream_slicers.substream_slicer import SubstreamSlicer
from airbyte_cdk.sources.declarative.types import StreamSlice, StreamState


@dataclass
class ZenloopSubstreamSlicer(SubstreamSlicer):
def stream_slices(self, sync_mode: SyncMode, stream_state: StreamState) -> Iterable[StreamSlice]:
"""
config_parent_field : parent field name in config
Use parent id's as stream state value if it specified in config or
create stream_slices according SubstreamSlicer logic.
"""
config = self._options.get("config")
parent_field = self._options.get("config_parent_field")
custom_stream_state_value = config.get(parent_field)

if not custom_stream_state_value:
yield from super().stream_slices(sync_mode, stream_state)
else:
for parent_stream_config in self.parent_stream_configs:
stream_state_field = parent_stream_config.stream_slice_field or None
yield {stream_state_field: custom_stream_state_value, "parent_slice": {}}
Loading

0 comments on commit 17c767a

Please sign in to comment.