Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,14 @@
icon: twilio.svg
sourceType: api
releaseStage: generally_available
- name: Twilio Taskrouter
sourceDefinitionId: 2446953b-b794-429b-a9b3-c821ba992a48
dockerRepository: airbyte/source-twilio-taskrouter
dockerImageTag: 0.1.0
documentationUrl: https://docs.airbyte.com/integrations/sources/twilio-taskrouter
icon: twilio.svg
sourceType: api
releaseStage: alpha
- name: Twitter
sourceDefinitionId: d7fd4f40-5e5a-4b8b-918f-a73077f8c131
dockerRepository: airbyte/source-twitter
Expand Down
25 changes: 25 additions & 0 deletions airbyte-config/init/src/main/resources/seed/source_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14904,6 +14904,31 @@
supportsDBT: false
supported_destination_sync_modes:
- "append"
- dockerImage: "airbyte/source-twilio-taskrouter:0.1.0"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/twilio-taskrouter"
connectionSpecification:
$schema: "http://json-schema.org/draft-07/schema#"
title: "Twilio Taskrouter Spec"
type: "object"
required:
- "account_sid"
- "auth_token"
additionalProperties: true
properties:
account_sid:
title: "Account SID"
type: "string"
description: "Twilio Account ID"
airbyte_secret: true
auth_token:
type: "string"
description: "Twilio Auth Token"
airbyte_secret: true
title: "Auth Token"
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-twitter:0.1.0"
spec:
documentationUrl: "https://docsurl.com"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!Dockerfile
!main.py
!source_twilio_taskrouter
!setup.py
!secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM python:3.9.11-alpine3.15 as base

# build and load all requirements
FROM base as builder
WORKDIR /airbyte/integration_code

# upgrade pip to the latest version
RUN apk --no-cache upgrade \
&& pip install --upgrade pip \
&& apk --no-cache add tzdata build-base


COPY setup.py ./
# install necessary packages to a temporary folder
RUN pip install --prefix=/install .

# build a clean environment
FROM base
WORKDIR /airbyte/integration_code

# copy all loaded and built libraries to a pure basic image
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

# bash is installed for more convenient debugging.
RUN apk --no-cache add bash

# copy payload code only
COPY main.py ./
COPY source_twilio_taskrouter ./source_twilio_taskrouter

ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.name=airbyte/source-twilio-taskrouter
79 changes: 79 additions & 0 deletions airbyte-integrations/connectors/source-twilio-taskrouter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Twilio Taskrouter Source

This is the repository for the Twilio Taskrouter configuration based source connector.
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/twilio-taskrouter).

## Local development

#### Building via Gradle
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.

To build using Gradle, from the Airbyte repository root, run:
```
./gradlew :airbyte-integrations:connectors:source-twilio-taskrouter:build
```

#### Create credentials
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/twilio-taskrouter)
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_twilio_taskrouter/spec.yaml` file.
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
See `integration_tests/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 twilio-taskrouter test creds`
and place them into `secrets/config.json`.

### Locally running the connector docker image

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

You can also build the connector image via Gradle:
```
./gradlew :airbyte-integrations:connectors:source-twilio-taskrouter: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-twilio-taskrouter:dev spec
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-twilio-taskrouter:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-twilio-taskrouter:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-twilio-taskrouter:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
```
## Testing

#### Acceptance Tests
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.
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.

To run your integration tests with docker

### Using gradle to run tests
All commands should be run from airbyte project root.
To run unit tests:
```
./gradlew :airbyte-integrations:connectors:source-twilio-taskrouter:unitTest
```
To run acceptance and custom integration tests:
```
./gradlew :airbyte-integrations:connectors:source-twilio-taskrouter:integrationTest
```

## 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.
We split dependencies between two groups, dependencies that are:
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
* required for the testing need to go to `TEST_REQUIREMENTS` list

### 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](https://semver.org/)).
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# See [Source Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/source-acceptance-tests-reference)
# for more information about how to configure these tests
connector_image: airbyte/source-twilio-taskrouter:dev
tests:
spec:
- spec_path: "source_twilio_taskrouter/spec.yaml"
connection:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
discovery:
- config_path: "secrets/config.json"
basic_read:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
full_refresh:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

# Build latest connector image
docker build . -t $(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2-)

# Pull latest acctest image
docker pull airbyte/source-acceptance-test:latest

# Run
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/tmp \
-v $(pwd):/test_input \
airbyte/source-acceptance-test \
--acceptance-test-config /test_input

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id 'airbyte-python'
id 'airbyte-docker'
id 'airbyte-source-acceptance-test'
}

airbytePython {
moduleDirectory 'source_twilio_taskrouter'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"workspaces": {
"date_created": "2999-10-5"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#


import pytest

pytest_plugins = ("source_acceptance_test.plugin",)


@pytest.fixture(scope="session", autouse=True)
def connector_setup():
"""This fixture is a placeholder for external resources that acceptance test might require."""
# TODO: setup test dependencies if needed. otherwise remove the TODO comments
yield
# TODO: clean up test dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"streams": [
{
"stream": {
"name": "workspaces",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "workers",
"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,5 @@
{
"account_sid": "definitye wrong jet",
"auth_token": "somehtin wrong too",
"workspaceId": "wrong sid too"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"account_sid": "Your Account ID",
"auth_token": "Your Auth Token",
"workspaceId": "Your Workspace ID"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"workspaces": {
"timeout_actvity_name": "Offline",
"friendly_name": "Testing"
}
}
13 changes: 13 additions & 0 deletions airbyte-integrations/connectors/source-twilio-taskrouter/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#


import sys

from airbyte_cdk.entrypoint import launch
from source_twilio_taskrouter import SourceTwilioTaskrouter

if __name__ == "__main__":
source = SourceTwilioTaskrouter()
launch(source, sys.argv[1:])
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../../bases/source-acceptance-test
-e .
29 changes: 29 additions & 0 deletions airbyte-integrations/connectors/source-twilio-taskrouter/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#


from setuptools import find_packages, setup

MAIN_REQUIREMENTS = [
"airbyte-cdk~=0.4",
]

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

setup(
name="source_twilio_taskrouter",
description="Source implementation for Twilio Taskrouter.",
author="Airbyte",
author_email="contact@airbyte.io",
packages=find_packages(),
install_requires=MAIN_REQUIREMENTS,
package_data={"": ["*.json", "*.yaml", "schemas/*.json", "schemas/shared/*.json"]},
extras_require={
"tests": TEST_REQUIREMENTS,
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#


from .source import SourceTwilioTaskrouter

__all__ = ["SourceTwilioTaskrouter"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"type": "object",
"properties": {
"account_sid": {
"type": ["null", "string"]
},
"date_created": {
"type": ["null", "string"],
"format": "date-time"
},
"date_updated": {
"type": ["null", "string"],
"format": "date-time"
},
"workspace_sid": {
"type": ["null", "string"]
},
"attributes": {
"type": ["null", "string"]
},
"date_status_changed": {
"type": ["null", "string"],
"format": "date-time"
},
"friendly_name": {
"type": ["null", "string"]
},
"available":{
"type": ["null", "boolean"]
},
"sid": {
"type": ["null", "string"]
},
"actvity_name": {
"type": ["null", "string"]
},
"activity_sid": {
"type": ["null", "string"]
},
"url": {
"type": ["null", "string"]
},
"links": {
"type": ["null", "object"]
}
}
}
Loading