Skip to content

Commit

Permalink
🎉 New source: Zendesk Talk (#2775)
Browse files Browse the repository at this point in the history
* Zendesk Talk #2346: full refresh/incremental sync connector with adopt best practices

Co-authored-by: ykurochkin <y.kurochkin@zazmic.com>
Co-authored-by: Sherif A. Nada <snadalive@gmail.com>
  • Loading branch information
3 people committed Apr 13, 2021
1 parent 82c8768 commit 1294e41
Show file tree
Hide file tree
Showing 41 changed files with 2,770 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/publish-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ jobs:
TEMPO_INTEGRATION_TEST_CREDS: ${{ secrets.TEMPO_INTEGRATION_TEST_CREDS }}
TWILIO_TEST_CREDS: ${{ secrets.TWILIO_TEST_CREDS }}
ZENDESK_SECRETS_CREDS: ${{ secrets.ZENDESK_SECRETS_CREDS }}
ZENDESK_TALK_TEST_CREDS: ${{ secrets.ZENDESK_TALK_TEST_CREDS }}
ZOOM_INTEGRATION_TEST_CREDS: ${{ secrets.ZOOM_INTEGRATION_TEST_CREDS }}
PLAID_INTEGRATION_TEST_CREDS: ${{ secrets.PLAID_INTEGRATION_TEST_CREDS }}
- run: |
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 @@ -81,6 +81,7 @@ jobs:
TEMPO_INTEGRATION_TEST_CREDS: ${{ secrets.TEMPO_INTEGRATION_TEST_CREDS }}
TWILIO_TEST_CREDS: ${{ secrets.TWILIO_TEST_CREDS }}
ZENDESK_SECRETS_CREDS: ${{ secrets.ZENDESK_SECRETS_CREDS }}
ZENDESK_TALK_TEST_CREDS: ${{ secrets.ZENDESK_TALK_TEST_CREDS }}
ZOOM_INTEGRATION_TEST_CREDS: ${{ secrets.ZOOM_INTEGRATION_TEST_CREDS }}
PLAID_INTEGRATION_TEST_CREDS: ${{ secrets.PLAID_INTEGRATION_TEST_CREDS }}
- run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sourceDefinitionId": "c8630570-086d-4a40-99ae-ea5b18673071",
"name": "Zendesk Talk",
"dockerRepository": "airbyte/source-zendesk-talk",
"dockerImageTag": "0.1.0",
"documentationUrl": "https://hub.docker.com/r/airbyte/source-zendesk-talk"
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,8 @@
dockerRepository: airbyte/source-oracle
dockerImageTag: 0.2.0
documentationUrl: https://hub.docker.com/r/airbyte/source-oracle
- sourceDefinitionId: c8630570-086d-4a40-99ae-ea5b18673071
name: Zendesk Talk
dockerRepository: airbyte/source-zendesk-talk
dockerImageTag: 0.1.0
documentationUrl: https://hub.docker.com/r/airbyte/source-zendesk-talk
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public abstract class StandardSourceTest {
"airbyte/source-stripe-singer",
"airbyte/source-github-singer",
"airbyte/source-gitlab-singer",
"airbyte/source-google-workspace-admin-reports");
"airbyte/source-google-workspace-admin-reports",
"airbyte/source-zendesk-talk");

/**
* FIXME: Some sources can't guarantee that there will be no events between two sequential sync
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!Dockerfile
!Dockerfile.test
!source_zendesk_talk
!setup.py
!secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEW_SOURCE_CHECKLIST.md
16 changes: 16 additions & 0 deletions airbyte-integrations/connectors/source-zendesk-talk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM airbyte/integration-base-python:0.1.0

# Bash is installed for more convenient debugging.
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/*

ENV CODE_PATH="source_zendesk_talk"
ENV AIRBYTE_IMPL_MODULE="source_zendesk_talk"
ENV AIRBYTE_IMPL_PATH="SourceZendeskTalk"

WORKDIR /airbyte/integration_code
COPY $CODE_PATH ./$CODE_PATH
COPY setup.py ./
RUN pip install .

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.name=airbyte/source-zendesk-talk
98 changes: 98 additions & 0 deletions airbyte-integrations/connectors/source-zendesk-talk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Zendesk Talk Source

This is the repository for the Zendesk Talk source connector, written in Python.
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/zendesk-talk).

## Local development

### Prerequisites
**To iterate on this connector, make sure to complete this prerequisites section.**

#### Build & Activate Virtual Environment and install dependencies
From this connector directory, create a virtual environment:
```
python -m venv .venv
```

This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
development environment of choice. To activate it from the terminal, run:
```
source .venv/bin/activate
pip install -r requirements.txt
```
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.

Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
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
should work as you expect.

#### Building via Gradle
From the Airbyte repository root, run:
```
./gradlew :airbyte-integrations:connectors:source-zendesk-talk:build
```

#### Create credentials
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/zendesk-talk)
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_zendesk_talk/spec.json` file.
Note that the `secrets` directory is gitignored by default, so there is no danger of accidentally checking in sensitive information.
See `sample_files/sample_config.json` for a sample config file.

**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source zendesk-talk test creds`
and place them into `secrets/config.json`.


### Locally running the connector
```
python main_dev.py spec
python main_dev.py check --config secrets/config.json
python main_dev.py discover --config secrets/config.json
python main_dev.py read --config secrets/config.json --catalog sample_files/configured_catalog.json
```

### Unit Tests
To run unit tests locally, from the connector directory run:
```
python -m pytest unit_tests
```

### Locally running the connector docker image

#### Build
First, make sure you build the latest Docker image:
```
docker build . -t airbyte/zendesk-talk:dev
```

You can also build the connector image via Gradle:
```
./gradlew :airbyte-integrations:connectors:source-zendesk-talk:airbyteDocker
```
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
the Dockerfile.

#### Run
Then run any of the connector commands as follows:
```
docker run --rm airbyte/source-zendesk-talk:dev spec
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-zendesk-talk:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-zendesk-talk:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/sample_files:/sample_files airbyte/source-zendesk-talk:dev read --config /secrets/config.json --catalog /sample_files/configured_catalog.json
```

### Integration Tests
1. From the airbyte project root, run `./gradlew :airbyte-integrations:connectors:source-zendesk-talk:integrationTest` to run the standard integration test suite.
1. To run additional integration tests, place your integration tests in a new directory `integration_tests` and run them with `python -m pytest -s integration_tests`.
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.

## Dependency Management
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.

### Publishing a new version of the connector
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
1. Make sure your changes are passing unit and integration tests
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use SemVer).
1. Create a Pull Request
1. Pat yourself on the back for being an awesome contributor
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master
27 changes: 27 additions & 0 deletions airbyte-integrations/connectors/source-zendesk-talk/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
plugins {
id 'airbyte-python'
id 'airbyte-docker'
id 'airbyte-standard-source-test-file'
}

airbytePython {
moduleDirectory 'source_zendesk_talk'
}

airbyteStandardSourceTestFile {
specPath = "source_zendesk_talk/spec.json"
configPath = "secrets/config.json"
configuredCatalogPath = "sample_files/configured_catalog.json"
}

task("pythonIntegrationTests", type: PythonTask, dependsOn: installTestReqs) {
module = "pytest"
command = "-s integration_tests"
}

integrationTest.dependsOn("pythonIntegrationTests")

dependencies {
implementation files(project(':airbyte-integrations:bases:base-standard-source-test-file').airbyteDocker.outputs)
implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
MIT License
Copyright (c) 2020 Airbyte
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

import json
from pathlib import Path

import pytest
from airbyte_protocol import ConfiguredAirbyteCatalog, Type
from base_python import AirbyteLogger
from source_zendesk_talk.source import SourceZendeskTalk

BASE_DIRECTORY = Path(__file__).resolve().parent.parent


@pytest.fixture(name="config_credentials")
def config_credentials_fixture():
with open(str(BASE_DIRECTORY / "secrets/config.json"), "r") as f:
return json.load(f)


@pytest.fixture(name="configured_catalog")
def configured_catalog_fixture():
return ConfiguredAirbyteCatalog.parse_file(BASE_DIRECTORY / "sample_files/configured_catalog_activities_overview.json")


class TestZendeskTalkSource:
def test_streams_outputs_records(self, config_credentials, configured_catalog):
"""
Using standard tests is unreliable for Agent Activities and Agent Overview streams,
because the data there changes in real-time, therefore additional pytests are used.
"""
records = []
for message in SourceZendeskTalk().read(AirbyteLogger(), config_credentials, configured_catalog):
if message.type == Type.RECORD:
records.append(message)

assert len(records) > 0
32 changes: 32 additions & 0 deletions airbyte-integrations/connectors/source-zendesk-talk/main_dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
MIT License
Copyright (c) 2020 Airbyte
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

import sys

from base_python.entrypoint import launch
from source_zendesk_talk import SourceZendeskTalk

if __name__ == "__main__":
source = SourceZendeskTalk()
launch(source, sys.argv[1:])
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is autogenerated -- only edit if you know what you are doing. Use setup.py for declaring dependencies.
-e ../../bases/airbyte-protocol
-e ../../bases/base-python
-e .
Loading

0 comments on commit 1294e41

Please sign in to comment.