Skip to content

Commit 6cd991b

Browse files
alexchourakimarcosmarxmoctavia-squidington-iii
authored
🎉 New Connector: Zendesk Sell [python cdk] (#17888)
* first working connector - overwrite only * edit readme and source definitions * Update source_definitions.yaml * changing catalog and adding all available streams * remove custom fields * remove documents * manage incremental syncs * add unit tests ; add start date to specs * try catch for next page token method * Create source_to_test.py * Update source.py * Update source_to_test.py * working source * Delete TODO.md * Update source.py * Update spec.yaml * Update test_streams.py * give up on incremental and have something that works * removing start date necessity in spec and sample configs * add connector to source def * run format * update airbyte cdk version * correct unit test * run format * auto-bump connector version Co-authored-by: marcosmarxm <[email protected]> Co-authored-by: Octavia Squidington III <[email protected]>
1 parent 85e6792 commit 6cd991b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2171
-0
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,14 @@
13161316
icon: zendesk.svg
13171317
sourceType: api
13181318
releaseStage: generally_available
1319+
- name: Zendesk Sell
1320+
sourceDefinitionId: 982eaa4c-bba1-4cce-a971-06a41f700b8c
1321+
dockerRepository: airbyte/source-zendesk-sell
1322+
dockerImageTag: 0.1.0
1323+
documentationUrl: https://docs.airbyte.com/integrations/sources/zendesk-sell
1324+
icon: zendesk.svg
1325+
sourceType: api
1326+
releaseStage: alpha
13191327
- name: Zendesk Sunshine
13201328
sourceDefinitionId: 325e0640-e7b3-4e24-b823-3361008f603f
13211329
dockerRepository: airbyte/source-zendesk-sunshine

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12883,6 +12883,26 @@
1288312883
path_in_connector_config:
1288412884
- "credentials"
1288512885
- "client_secret"
12886+
- dockerImage: "airbyte/source-zendesk-sell:0.1.0"
12887+
spec:
12888+
documentationUrl: "https://docs.airbyte.com/integrations/sources/zendesk-sell"
12889+
connectionSpecification:
12890+
$schema: "http://json-schema.org/draft-07/schema#"
12891+
title: "Source Zendesk Sell Spec"
12892+
type: "object"
12893+
required:
12894+
- "api_token"
12895+
properties:
12896+
api_token:
12897+
title: "API token"
12898+
type: "string"
12899+
description: "The API token for authenticating to Zendesk Sell"
12900+
examples:
12901+
- "f23yhd630otl94y85a8bf384958473pto95847fd006da49382716or937ruw059"
12902+
airbyte_secret: true
12903+
supportsNormalization: false
12904+
supportsDBT: false
12905+
supported_destination_sync_modes: []
1288612906
- dockerImage: "airbyte/source-zendesk-sunshine:0.1.1"
1288712907
spec:
1288812908
documentationUrl: "https://docs.airbyte.com/integrations/sources/zendesk_sunshine"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
!Dockerfile
3+
!main.py
4+
!source_zendesk_sell
5+
!setup.py
6+
!secrets
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM python:3.9.13-alpine3.15 as base
2+
3+
# build and load all requirements
4+
FROM base as builder
5+
WORKDIR /airbyte/integration_code
6+
7+
# upgrade pip to the latest version
8+
RUN apk --no-cache upgrade \
9+
&& pip install --upgrade pip \
10+
&& apk --no-cache add tzdata build-base
11+
12+
13+
COPY setup.py ./
14+
# install necessary packages to a temporary folder
15+
RUN pip install --prefix=/install .
16+
17+
# build a clean environment
18+
FROM base
19+
WORKDIR /airbyte/integration_code
20+
21+
# copy all loaded and built libraries to a pure basic image
22+
COPY --from=builder /install /usr/local
23+
# add default timezone settings
24+
COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
25+
RUN echo "Etc/UTC" > /etc/timezone
26+
27+
# bash is installed for more convenient debugging.
28+
RUN apk --no-cache add bash
29+
30+
# copy payload code only
31+
COPY main.py ./
32+
COPY source_zendesk_sell ./source_zendesk_sell
33+
34+
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
35+
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
36+
37+
LABEL io.airbyte.version=0.1.0
38+
LABEL io.airbyte.name=airbyte/source-zendesk-sell
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Zendesk Sell Source
2+
3+
This is the repository for the Zendesk Sell source connector, written in Python.
4+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/zendesk-sell).
5+
6+
## Local development
7+
8+
### Prerequisites
9+
**To iterate on this connector, make sure to complete this prerequisites section.**
10+
11+
#### Minimum Python version required `= 3.9.0`
12+
13+
#### Build & Activate Virtual Environment and install dependencies
14+
From this connector directory, create a virtual environment:
15+
```
16+
python -m venv .venv
17+
```
18+
19+
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
20+
development environment of choice. To activate it from the terminal, run:
21+
```
22+
source .venv/bin/activate
23+
pip install -r requirements.txt
24+
pip install '.[tests]'
25+
```
26+
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
27+
28+
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
29+
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
30+
If this is mumbo jumbo to you, don't worry about it, just put your deps in `setup.py` but install using `pip install -r requirements.txt` and everything
31+
should work as you expect.
32+
33+
#### Building via Gradle
34+
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.
35+
36+
To build using Gradle, from the Airbyte repository root, run:
37+
```
38+
./gradlew :airbyte-integrations:connectors:source-zendesk-sell:build
39+
```
40+
41+
#### Create credentials
42+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/zendesk-sell)
43+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_zendesk_sell/spec.yaml` file.
44+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
45+
See `integration_tests/sample_config.json` for a sample config file.
46+
Note that the full process to generate api tokens is available [here](https://developer.zendesk.com/documentation/sales-crm/first-call/#1-generate-an-access-token)
47+
48+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source zendesk-sell test creds`
49+
and place them into `secrets/config.json`.
50+
51+
### Locally running the connector
52+
```
53+
python main.py spec
54+
python main.py check --config secrets/config.json
55+
python main.py discover --config secrets/config.json
56+
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
57+
```
58+
59+
### Locally running the connector docker image
60+
61+
#### Build
62+
First, make sure you build the latest Docker image:
63+
```
64+
docker build . -t airbyte/source-zendesk-sell:dev
65+
```
66+
67+
You can also build the connector image via Gradle:
68+
```
69+
./gradlew :airbyte-integrations:connectors:source-zendesk-sell:airbyteDocker
70+
```
71+
When building via Gradle, the docker image name and tag, respectively, are the values of the `io.airbyte.name` and `io.airbyte.version` `LABEL`s in
72+
the Dockerfile.
73+
74+
#### Run
75+
Then run any of the connector commands as follows:
76+
```
77+
docker run --rm airbyte/source-zendesk-sell:dev spec
78+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-zendesk-sell:dev check --config /secrets/config.json
79+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-zendesk-sell:dev discover --config /secrets/config.json
80+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-zendesk-sell:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
81+
```
82+
## Testing
83+
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.
84+
First install test dependencies into your virtual environment:
85+
```
86+
pip install .[tests]
87+
```
88+
### Unit Tests
89+
To run unit tests locally, from the connector directory run:
90+
```
91+
python -m pytest unit_tests
92+
```
93+
94+
### Integration Tests
95+
There are two types of integration tests: Acceptance Tests (Airbyte's test suite for all source connectors) and custom integration tests (which are specific to this connector).
96+
#### Custom Integration tests
97+
Place custom tests inside `integration_tests/` folder, then, from the connector root, run
98+
```
99+
python -m pytest integration_tests
100+
```
101+
#### Acceptance Tests
102+
Customize `acceptance-test-config.yml` file to configure tests. See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference) for more information.
103+
If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
104+
To run your integration tests with acceptance tests, from the connector root, run
105+
```
106+
python -m pytest integration_tests -p integration_tests.acceptance
107+
```
108+
To run your integration tests with docker
109+
110+
### Using gradle to run tests
111+
All commands should be run from airbyte project root.
112+
To run unit tests:
113+
```
114+
./gradlew :airbyte-integrations:connectors:source-zendesk-sell:unitTest
115+
```
116+
To run acceptance and custom integration tests:
117+
```
118+
./gradlew :airbyte-integrations:connectors:source-zendesk-sell:integrationTest
119+
```
120+
121+
## Dependency Management
122+
All of your dependencies should go in `setup.py`, NOT `requirements.txt`. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development.
123+
We split dependencies between two groups, dependencies that are:
124+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
125+
* required for the testing need to go to `TEST_REQUIREMENTS` list
126+
127+
### Publishing a new version of the connector
128+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
129+
1. Make sure your changes are passing unit and integration tests.
130+
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
131+
1. Create a Pull Request.
132+
1. Pat yourself on the back for being an awesome contributor.
133+
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference)
2+
# for more information about how to configure these tests
3+
connector_image: airbyte/source-zendesk-sell:dev
4+
tests:
5+
spec:
6+
- spec_path: "source_zendesk_sell/spec.yaml"
7+
connection:
8+
- config_path: "secrets/config.json"
9+
status: "succeed"
10+
- config_path: "integration_tests/invalid_config.json"
11+
status: "failed"
12+
discovery:
13+
- config_path: "secrets/config.json"
14+
basic_read:
15+
- config_path: "secrets/config.json"
16+
configured_catalog_path: "integration_tests/configured_catalog.json"
17+
empty_streams: []
18+
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
19+
# expect_records:
20+
# path: "integration_tests/expected_records.txt"
21+
# extra_fields: no
22+
# exact_order: no
23+
# extra_records: yes
24+
incremental: # TODO if your connector does not implement incremental sync, remove this block
25+
- config_path: "secrets/config.json"
26+
configured_catalog_path: "integration_tests/configured_catalog.json"
27+
future_state_path: "integration_tests/abnormal_state.json"
28+
full_refresh:
29+
- config_path: "secrets/config.json"
30+
configured_catalog_path: "integration_tests/configured_catalog.json"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
3+
# Build latest connector image
4+
docker build . -t $(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2-)
5+
6+
# Pull latest acctest image
7+
docker pull airbyte/source-acceptance-test:latest
8+
9+
# Run
10+
docker run --rm -it \
11+
-v /var/run/docker.sock:/var/run/docker.sock \
12+
-v /tmp:/tmp \
13+
-v $(pwd):/test_input \
14+
airbyte/source-acceptance-test \
15+
--acceptance-test-config /test_input
16+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id 'airbyte-python'
3+
id 'airbyte-docker'
4+
id 'airbyte-source-acceptance-test'
5+
}
6+
7+
airbytePython {
8+
moduleDirectory 'source_zendesk_sell'
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
#
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"contacts": {
3+
"created_at": "33190962600"
4+
}
5+
}

0 commit comments

Comments
 (0)