Skip to content

Commit

Permalink
import: source-twilio through airbyte @ 8c862a8
Browse files Browse the repository at this point in the history
Remote Repo URL: git@github.com:airbytehq/airbyte.git
Source name: 8c862a8
Source Commit ID: 8c862a8013150cfee238c379e66ff9e84550da6b
Source Repo Prefix: airbyte-integrations/connectors/source-twilio/
Import Path: source-twilio/
License Type: MIT
License Path: airbyte-integrations/connectors/source-twilio/metadata.yaml

git-merge-subpath: 8c862a8013150cfee238c379e66ff9e84550da6b airbyte-integrations/connectors/source-twilio source-twilio
  • Loading branch information
Luishfs committed Mar 13, 2024
1 parent 3139e30 commit dbfc4bc
Show file tree
Hide file tree
Showing 59 changed files with 5,506 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source-twilio/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!Dockerfile
!main.py
!source_twilio
!setup.py
!secrets
91 changes: 91 additions & 0 deletions source-twilio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Twilio source connector


This is the repository for the Twilio source connector, written in Python.
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/twilio).

## Local development

### Prerequisites
* Python (~=3.9)
* Poetry (~=1.7) - installation instructions [here](https://python-poetry.org/docs/#installation)


### Installing the connector
From this connector directory, run:
```bash
poetry install --with dev
```


### Create credentials
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/twilio)
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_twilio/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 `sample_files/sample_config.json` for a sample config file.


### Locally running the connector
```
poetry run source-twilio spec
poetry run source-twilio check --config secrets/config.json
poetry run source-twilio discover --config secrets/config.json
poetry run source-twilio read --config secrets/config.json --catalog integration_tests/constant_records_catalog.json
```

### Running unit tests
To run unit tests locally, from the connector directory run:
```
poetry run pytest unit_tests
```

### Building the docker image
1. Install [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
2. Run the following command to build the docker image:
```bash
airbyte-ci connectors --name=source-twilio build
```

An image will be available on your host with the tag `airbyte/source-twilio:dev`.


### Running as a docker container
Then run any of the connector commands as follows:
```
docker run --rm airbyte/source-twilio:dev spec
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-twilio:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-twilio:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-twilio:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
```

### Running our CI test suite
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
```bash
airbyte-ci connectors --name=source-twilio test
```

### Customizing acceptance Tests
Customize `acceptance-test-config.yml` file to configure acceptance tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-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.

### Dependency Management
All of your dependencies should be managed via Poetry.
To add a new dependency, run:
```bash
poetry add <package-name>
```

Please commit the changes to `pyproject.toml` and `poetry.lock` files.

## 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 our test suite: `airbyte-ci connectors --name=source-twilio test`
2. Bump the connector version (please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors)):
- bump the `dockerImageTag` value in in `metadata.yaml`
- bump the `version` value in `pyproject.toml`
3. Make sure the `metadata.yaml` content is up to date.
4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/twilio.md`).
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
6. Pat yourself on the back for being an awesome contributor.
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
8. Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.
74 changes: 74 additions & 0 deletions source-twilio/acceptance-test-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
connector_image: airbyte/source-twilio:dev
test_strictness_level: high
acceptance_tests:
spec:
tests:
- spec_path: "source_twilio/spec.json"
connection:
tests:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
discovery:
tests:
- config_path: "secrets/config.json"
basic_read:
tests:
- config_path: "secrets/config.json"
expect_records:
path: "integration_tests/expected_records.jsonl"
empty_streams:
# TODO: SAT should be able to exclude expected records validation on the stream > field level
# to avoid exposures such as `auth_token`
# reference: https://github.com/airbytehq/airbyte/pull/20430
- name: "accounts"
bypass_reason: "expected records could not be provided without field bypassing, skipping for now. Read #TODO above."
- name: "alerts"
bypass_reason: "alerts are transient - they emerge and disappear from time to time"
- name: "dependent_phone_numbers"
bypass_reason: "stream not filled yet"
- name: "conference_participants"
bypass_reason: "stream not filled yet"
- name: "keys"
bypass_reason: "stream not filled yet"
- name: "available_phone_numbers_local"
bypass_reason: "very volatile data"
- name: "available_phone_numbers_mobile"
bypass_reason: "very volatile data"
- name: "available_phone_numbers_toll_free"
bypass_reason: "very volatile data"
- name: "usage_records"
bypass_reason: "very volatile data"
- name: step
bypass_reason: "No data for this stream currently"
- name: executions
bypass_reason: "No data for this stream currently"
timeout_seconds: 600
fail_on_extra_columns: false
incremental:
tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/incremental_catalog.json"
future_state:
future_state_path: "integration_tests/abnormal_state.json"
timeout_seconds: 3600
- config_path: "secrets/config_with_lookback.json"
configured_catalog_path: "integration_tests/incremental_catalog.json"
future_state:
future_state_path: "integration_tests/abnormal_state.json"
timeout_seconds: 3600
full_refresh:
tests:
- config_path:
"secrets/config.json"
# `constant_records_catalog.json` does not contain the available phone numbers streams,
# as they may change on each request
configured_catalog_path: "integration_tests/constant_records_catalog.json"
ignored_fields:
transcriptions:
- name: "date_created"
bypass_reason: "Floating data"
- name: "date_updated"
bypass_reason: "Floating data"
timeout_seconds: 3600
1 change: 1 addition & 0 deletions source-twilio/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
79 changes: 79 additions & 0 deletions source-twilio/integration_tests/abnormal_state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[
{
"type": "STREAM",
"stream": {
"stream_state": {
"end_time": "2030-10-01T00:00:00Z"
},
"stream_descriptor": {
"name": "calls"
}
}
},
{
"type": "STREAM",
"stream": {
"stream_state": {
"date_created": "2030-10-01T00:00:00Z"
},
"stream_descriptor": {
"name": "conferences"
}
}
},
{
"type": "STREAM",
"stream": {
"stream_state": {
"date_created": "2030-10-01T00:00:00Z"
},
"stream_descriptor": {
"name": "recordings"
}
}
},
{
"type": "STREAM",
"stream": {
"stream_state": {
"date_sent": "2030-10-01T00:00:00Z"
},
"stream_descriptor": {
"name": "messages"
}
}
},
{
"type": "STREAM",
"stream": {
"stream_state": {
"date_created": "2030-10-01T00:00:00Z"
},
"stream_descriptor": {
"name": "message_media"
}
}
},
{
"type": "STREAM",
"stream": {
"stream_state": {
"start_date": "2030-10-01T00:00:00Z"
},
"stream_descriptor": {
"name": "usage_records"
}
}
},
{
"type": "STREAM",
"stream": {
"stream_state": {
"date_generated": "2030-10-01T00:00:00Z"
},
"stream_descriptor": {
"name": "alerts"
}
}
}
]
14 changes: 14 additions & 0 deletions source-twilio/integration_tests/acceptance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#


import pytest

pytest_plugins = ("connector_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."""
yield
Loading

0 comments on commit dbfc4bc

Please sign in to comment.