From ea4a48ca1a85a534585bf7a54da501836a4e0a98 Mon Sep 17 00:00:00 2001 From: Titas Skrebe Date: Mon, 10 Jan 2022 13:23:30 +0200 Subject: [PATCH 01/11] New source: Chartmogul --- .../src/main/resources/icons/chartmogul.svg | 13 ++ .../resources/seed/source_definitions.yaml | 7 + .../connectors/source-chartmogul/Dockerfile | 38 +++++ .../connectors/source-chartmogul/README.md | 132 +++++++++++++++++ .../acceptance-test-config.yml | 31 ++++ .../acceptance-test-docker.sh | 16 +++ .../connectors/source-chartmogul/build.gradle | 9 ++ .../integration_tests/__init__.py | 3 + .../integration_tests/acceptance.py | 14 ++ .../integration_tests/configured_catalog.json | 22 +++ .../integration_tests/invalid_config.json | 3 + .../integration_tests/sample_config.json | 4 + .../connectors/source-chartmogul/main.py | 13 ++ .../source-chartmogul/requirements.txt | 2 + .../sample_files/configured_catalog.json | 22 +++ .../connectors/source-chartmogul/setup.py | 30 ++++ .../source_chartmogul/__init__.py | 8 ++ .../source_chartmogul/schemas/activities.json | 48 +++++++ .../source_chartmogul/schemas/customers.json | 135 ++++++++++++++++++ .../source_chartmogul/source.py | 102 +++++++++++++ .../source_chartmogul/spec.json | 25 ++++ .../source-chartmogul/unit_tests/__init__.py | 3 + .../unit_tests/test_source.py | 28 ++++ .../unit_tests/test_streams.py | 115 +++++++++++++++ docs/SUMMARY.md | 1 + docs/integrations/sources/chartmogul.md | 47 ++++++ 26 files changed, 871 insertions(+) create mode 100644 airbyte-config/init/src/main/resources/icons/chartmogul.svg create mode 100644 airbyte-integrations/connectors/source-chartmogul/Dockerfile create mode 100644 airbyte-integrations/connectors/source-chartmogul/README.md create mode 100644 airbyte-integrations/connectors/source-chartmogul/acceptance-test-config.yml create mode 100755 airbyte-integrations/connectors/source-chartmogul/acceptance-test-docker.sh create mode 100644 airbyte-integrations/connectors/source-chartmogul/build.gradle create mode 100644 airbyte-integrations/connectors/source-chartmogul/integration_tests/__init__.py create mode 100644 airbyte-integrations/connectors/source-chartmogul/integration_tests/acceptance.py create mode 100644 airbyte-integrations/connectors/source-chartmogul/integration_tests/configured_catalog.json create mode 100644 airbyte-integrations/connectors/source-chartmogul/integration_tests/invalid_config.json create mode 100644 airbyte-integrations/connectors/source-chartmogul/integration_tests/sample_config.json create mode 100644 airbyte-integrations/connectors/source-chartmogul/main.py create mode 100644 airbyte-integrations/connectors/source-chartmogul/requirements.txt create mode 100644 airbyte-integrations/connectors/source-chartmogul/sample_files/configured_catalog.json create mode 100644 airbyte-integrations/connectors/source-chartmogul/setup.py create mode 100644 airbyte-integrations/connectors/source-chartmogul/source_chartmogul/__init__.py create mode 100644 airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/activities.json create mode 100644 airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json create mode 100644 airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py create mode 100644 airbyte-integrations/connectors/source-chartmogul/source_chartmogul/spec.json create mode 100644 airbyte-integrations/connectors/source-chartmogul/unit_tests/__init__.py create mode 100644 airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py create mode 100644 airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py create mode 100644 docs/integrations/sources/chartmogul.md diff --git a/airbyte-config/init/src/main/resources/icons/chartmogul.svg b/airbyte-config/init/src/main/resources/icons/chartmogul.svg new file mode 100644 index 0000000000000..4957ba4e9b413 --- /dev/null +++ b/airbyte-config/init/src/main/resources/icons/chartmogul.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml index adf054c624ccc..0d2d3a0d067f2 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -116,6 +116,13 @@ documentationUrl: https://docs.airbyte.io/integrations/sources/chargebee icon: chargebee.svg sourceType: api +- name: Chartmogul + sourceDefinitionId: b6604cbd-1b12-4c08-8767-e140d0fb0877 + dockerRepository: airbyte/source-chartmogul + dockerImageTag: 0.1.0 + documentationUrl: https://docs.airbyte.io/integrations/sources/chartmogul + icon: chartmogul.svg + sourceType: api - name: ClickHouse sourceDefinitionId: bad83517-5e54-4a3d-9b53-63e85fbd4d7c dockerRepository: airbyte/source-clickhouse diff --git a/airbyte-integrations/connectors/source-chartmogul/Dockerfile b/airbyte-integrations/connectors/source-chartmogul/Dockerfile new file mode 100644 index 0000000000000..35cef5c730227 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/Dockerfile @@ -0,0 +1,38 @@ +FROM python:3.7.11-alpine3.14 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_chartmogul ./source_chartmogul + +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-chartmogul diff --git a/airbyte-integrations/connectors/source-chartmogul/README.md b/airbyte-integrations/connectors/source-chartmogul/README.md new file mode 100644 index 0000000000000..2ba338da1728d --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/README.md @@ -0,0 +1,132 @@ +# Chartmogul Source + +This is the repository for the Chartmogul source connector, written in Python. +For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/chartmogul). + +## Local development + +### Prerequisites +**To iterate on this connector, make sure to complete this prerequisites section.** + +#### Minimum Python version required `= 3.7.0` + +#### Build & Activate Virtual Environment and install dependencies +From this connector directory, create a virtual environment: +``` +python3 -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 +pip install '.[tests]' +``` +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 +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-chartmogul:build +``` + +#### Create credentials +**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/chartmogul) +to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_chartmogul/spec.json` 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 chartmogul test creds` +and place them into `secrets/config.json`. + +### Locally running the connector +``` +python main.py spec +python main.py check --config secrets/config.json +python main.py discover --config secrets/config.json +python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json +``` + +### Locally running the connector docker image + +#### Build +First, make sure you build the latest Docker image: +``` +docker build . -t airbyte/source-chartmogul:dev +``` + +You can also build the connector image via Gradle: +``` +./gradlew :airbyte-integrations:connectors:source-chartmogul: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-chartmogul:dev spec +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-chartmogul:dev check --config /secrets/config.json +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-chartmogul:dev discover --config /secrets/config.json +docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-chartmogul:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json +``` +## Testing +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] +``` +### Unit Tests +To run unit tests locally, from the connector directory run: +``` +python -m pytest unit_tests +``` + +### Integration Tests +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). +#### Custom Integration tests +Place custom tests inside `integration_tests/` folder, then, from the connector root, run +``` +python -m pytest integration_tests +``` +#### 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 acceptance tests, from the connector root, run +``` +python -m pytest integration_tests -p integration_tests.acceptance +``` +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-chartmogul:unitTest +``` +To run acceptance and custom integration tests: +``` +./gradlew :airbyte-integrations:connectors:source-chartmogul: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. diff --git a/airbyte-integrations/connectors/source-chartmogul/acceptance-test-config.yml b/airbyte-integrations/connectors/source-chartmogul/acceptance-test-config.yml new file mode 100644 index 0000000000000..7426cd979323c --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/acceptance-test-config.yml @@ -0,0 +1,31 @@ +# See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference) +# for more information about how to configure these tests +connector_image: airbyte/source-chartmogul:dev +tests: + spec: + - spec_path: "source_chartmogul/spec.json" + 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: [] +# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file +# expect_records: +# path: "integration_tests/expected_records.txt" +# extra_fields: no +# exact_order: no +# extra_records: yes +# TODO uncomment when incremental is implemented + # incremental: + # - config_path: "secrets/config.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.json" diff --git a/airbyte-integrations/connectors/source-chartmogul/acceptance-test-docker.sh b/airbyte-integrations/connectors/source-chartmogul/acceptance-test-docker.sh new file mode 100755 index 0000000000000..c51577d10690c --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/acceptance-test-docker.sh @@ -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 + diff --git a/airbyte-integrations/connectors/source-chartmogul/build.gradle b/airbyte-integrations/connectors/source-chartmogul/build.gradle new file mode 100644 index 0000000000000..0f9c12cdb8203 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/build.gradle @@ -0,0 +1,9 @@ +plugins { + id 'airbyte-python' + id 'airbyte-docker' + id 'airbyte-source-acceptance-test' +} + +airbytePython { + moduleDirectory 'source_chartmogul' +} diff --git a/airbyte-integrations/connectors/source-chartmogul/integration_tests/__init__.py b/airbyte-integrations/connectors/source-chartmogul/integration_tests/__init__.py new file mode 100644 index 0000000000000..46b7376756ec6 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/integration_tests/__init__.py @@ -0,0 +1,3 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# diff --git a/airbyte-integrations/connectors/source-chartmogul/integration_tests/acceptance.py b/airbyte-integrations/connectors/source-chartmogul/integration_tests/acceptance.py new file mode 100644 index 0000000000000..0347f2a0b143d --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/integration_tests/acceptance.py @@ -0,0 +1,14 @@ +# +# Copyright (c) 2021 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.""" + yield diff --git a/airbyte-integrations/connectors/source-chartmogul/integration_tests/configured_catalog.json b/airbyte-integrations/connectors/source-chartmogul/integration_tests/configured_catalog.json new file mode 100644 index 0000000000000..3b788b27041d1 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/integration_tests/configured_catalog.json @@ -0,0 +1,22 @@ +{ + "streams": [ + { + "stream": { + "name": "customers", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "activities", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-chartmogul/integration_tests/invalid_config.json b/airbyte-integrations/connectors/source-chartmogul/integration_tests/invalid_config.json new file mode 100644 index 0000000000000..dc521ade7acf9 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/integration_tests/invalid_config.json @@ -0,0 +1,3 @@ +{ + "api_key": "" +} diff --git a/airbyte-integrations/connectors/source-chartmogul/integration_tests/sample_config.json b/airbyte-integrations/connectors/source-chartmogul/integration_tests/sample_config.json new file mode 100644 index 0000000000000..c09fca36f4670 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/integration_tests/sample_config.json @@ -0,0 +1,4 @@ +{ + "api_key": "", + "start_date": "2022-01-05T12:09:00Z" +} diff --git a/airbyte-integrations/connectors/source-chartmogul/main.py b/airbyte-integrations/connectors/source-chartmogul/main.py new file mode 100644 index 0000000000000..89e0ffbb29778 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/main.py @@ -0,0 +1,13 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +import sys + +from airbyte_cdk.entrypoint import launch +from source_chartmogul import SourceChartmogul + +if __name__ == "__main__": + source = SourceChartmogul() + launch(source, sys.argv[1:]) diff --git a/airbyte-integrations/connectors/source-chartmogul/requirements.txt b/airbyte-integrations/connectors/source-chartmogul/requirements.txt new file mode 100644 index 0000000000000..0411042aa0911 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/requirements.txt @@ -0,0 +1,2 @@ +-e ../../bases/source-acceptance-test +-e . diff --git a/airbyte-integrations/connectors/source-chartmogul/sample_files/configured_catalog.json b/airbyte-integrations/connectors/source-chartmogul/sample_files/configured_catalog.json new file mode 100644 index 0000000000000..3b788b27041d1 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/sample_files/configured_catalog.json @@ -0,0 +1,22 @@ +{ + "streams": [ + { + "stream": { + "name": "customers", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "activities", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-chartmogul/setup.py b/airbyte-integrations/connectors/source-chartmogul/setup.py new file mode 100644 index 0000000000000..446c4426fb9bb --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/setup.py @@ -0,0 +1,30 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +from setuptools import find_packages, setup + +MAIN_REQUIREMENTS = [ + "airbyte-cdk~=0.1", +] + +TEST_REQUIREMENTS = [ + "pytest~=6.1", + "pytest-mock~=3.6.1", + "source-acceptance-test", + "requests-mock", +] + +setup( + name="source_chartmogul", + description="Source implementation for Chartmogul.", + author="Titas Skrebe", + author_email="titas@omnisend.com", + packages=find_packages(), + install_requires=MAIN_REQUIREMENTS, + package_data={"": ["*.json", "schemas/*.json", "schemas/shared/*.json"]}, + extras_require={ + "tests": TEST_REQUIREMENTS, + }, +) diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/__init__.py b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/__init__.py new file mode 100644 index 0000000000000..9d8418296529d --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/__init__.py @@ -0,0 +1,8 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +from .source import SourceChartmogul + +__all__ = ["SourceChartmogul"] diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/activities.json b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/activities.json new file mode 100644 index 0000000000000..6000eb2828965 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/activities.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "description": { + "type": ["null", "string"] + }, + "activity-mrr-movement": { + "type": ["null", "integer"] + }, + "activity-mrr": { + "type": ["null", "integer"] + }, + "activity-arr": { + "type": ["null", "integer"] + }, + "date": { + "type": ["null", "string"] + }, + "type": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + }, + "subscription-external-id": { + "type": ["null", "string"] + }, + "plan-external-id": { + "type": ["null", "string"] + }, + "customer-name": { + "type": ["null", "string"] + }, + "customer-uuid": { + "type": ["null", "string"] + }, + "customer-external-id": { + "type": ["null", "string"] + }, + "billing-connector-uuid": { + "type": ["null", "string"] + }, + "uuid": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json new file mode 100644 index 0000000000000..636e520e2dfa5 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json @@ -0,0 +1,135 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "string"] + }, + "uuid": { + "type": ["null", "string"] + }, + "external_id": { + "type": ["null", "string"] + }, + "name": { + "type": ["null", "string"] + }, + "email": { + "type": ["null", "string"] + }, + "status": { + "type": ["null", "string"] + }, + "customer_since": { + "type": ["null", "string"] + }, + "attributes": { + "type": ["null", "object"], + "properties": { + "custom": { + "type": ["null", "object"], + "properties": { + "initial_sale_mrr": { + "type": ["null", "integer"] + }, + "initial_sale_mrr_currency": { + "type": ["null", "string"] + } + } + }, + "clearbit": { + "type": ["null", "object"], + "properties": {} + }, + "stripe": { + "type": ["null", "object"], + "properties": { + "brandID": { + "type": ["null", "string"] + }, + "brandName": { + "type": ["null", "string"] + }, + "createdAt": { + "type": ["null", "string"] + }, + "platformName": { + "type": ["null", "string"] + } + } + }, + "tags": { + "type": ["null", "array"] + } + } + }, + "data_source_uuid": { + "type": ["null", "string"] + }, + "data_source_uuids": { + "type": ["null", "array"] + }, + "external_ids": { + "type": ["null", "array"] + }, + "company": { + "type": ["null", "string"] + }, + "country": { + "type": ["null", "string"] + }, + "state": { + "type": ["null", "string"] + }, + "city": { + "type": ["null", "string"] + }, + "zip": { + "type": ["null", "string"] + }, + "lead_created_at": { + "type": ["null", "string"] + }, + "free_trial_started_at": { + "type": ["null", "string"] + }, + "address": { + "type": ["null", "object"], + "properties": { + "country": { + "type": ["null", "string"] + }, + "state": { + "type": ["null", "string"] + }, + "city": { + "type": ["null", "string"] + }, + "address_zip": { + "type": ["null", "string"] + } + } + }, + "mrr": { + "type": ["null", "integer"] + }, + "arr": { + "type": ["null", "integer"] + }, + "billing-system-url": { + "type": ["null", "string"] + }, + "chartmogul-url": { + "type": ["null", "string"] + }, + "billing-system-type": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + }, + "currency-sign": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py new file mode 100644 index 0000000000000..531f9a3acb6f0 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py @@ -0,0 +1,102 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + +from abc import ABC +from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple, Union +from base64 import b64encode +from datetime import datetime + +import requests +from airbyte_cdk.sources import AbstractSource +from airbyte_cdk.sources.streams import Stream +from airbyte_cdk.sources.streams.http import HttpStream +from airbyte_cdk.sources.streams.http.auth import TokenAuthenticator + + +# Basic full refresh stream +class ChartmogulStream(HttpStream, ABC): + url_base = "https://api.chartmogul.com" + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + yield from response.json().get("entries", []) + + +class Customers(ChartmogulStream): + primary_key = "uuid" + + def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]: + json_response = response.json() + if not json_response.get("has_more", False): + return None + + return { + "page": json_response.get("current_page")+1 + } + + def request_params( + self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_page_token: Mapping[str, Any] = None + ) -> MutableMapping[str, Any]: + return { + "page": 1 if not next_page_token else next_page_token["page"] + } + + def path(self, **kwargs) -> str: + return "v1/customers" + + +class Activities(ChartmogulStream): + primary_key = "uuid" + + def __init__(self, start_date: str, **kwargs): + super().__init__(**kwargs) + self.start_date = start_date + + def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]: + json_response = response.json() + if not json_response.get("has_more", False): + return None + + return { + "start-after": json_response["entries"][-1][self.primary_key] + } + + def request_params( + self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_page_token: Mapping[str, Any] = None + ) -> MutableMapping[str, Any]: + params = {} + + if next_page_token: + params["start-after"] = next_page_token["start-after"] + elif self.start_date: + params["start-date"] = self.start_date + + return params + + def path(self, **kwargs) -> str: + return "v1/activities" + +class HttpBasicAuthenticator(TokenAuthenticator): + def __init__(self, token: str, auth_method: str = "Basic", **kwargs): + auth_string = f"{token}:".encode("utf8") + b64_encoded = b64encode(auth_string).decode("utf8") + super().__init__(token=b64_encoded, auth_method=auth_method, **kwargs) + +# Source +class SourceChartmogul(AbstractSource): + def check_connection(self, logger, config) -> Tuple[bool, any]: + auth = HttpBasicAuthenticator(config["api_key"], auth_method="Basic").get_auth_header() + url = f"{ChartmogulStream.url_base}/v1/ping" + try: + resp = requests.get(url, headers=auth) + resp.raise_for_status() + return True, None + except Exception as e: + return False, e + + def streams(self, config: Mapping[str, Any]) -> List[Stream]: + auth = HttpBasicAuthenticator(config["api_key"], auth_method="Basic") + return [ + Customers(authenticator=auth), + Activities(authenticator=auth, start_date=config.get("start_date")) + ] diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/spec.json b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/spec.json new file mode 100644 index 0000000000000..d6f16407e70ce --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/spec.json @@ -0,0 +1,25 @@ +{ + "documentationUrl": "https://docs.airbyte.io/integrations/sources/chartmogul", + "connectionSpecification": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Chartmogul Spec", + "type": "object", + "required": ["api_key"], + "additionalProperties": false, + "properties": { + "api_key": { + "type": "string", + "description": "Chartmogul API key", + "airbyte_secret": true, + "order": 0 + }, + "start_date": { + "type": "string", + "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$", + "description": "UTC date and time in the format 2017-01-25T00:00:00Z. When feasible, any data before this date will not be replicated.", + "examples": ["2017-01-25T00:00:00Z"], + "order": 1 + } + } + } +} diff --git a/airbyte-integrations/connectors/source-chartmogul/unit_tests/__init__.py b/airbyte-integrations/connectors/source-chartmogul/unit_tests/__init__.py new file mode 100644 index 0000000000000..46b7376756ec6 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/unit_tests/__init__.py @@ -0,0 +1,3 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# diff --git a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py new file mode 100644 index 0000000000000..d9cf60f1a11f0 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py @@ -0,0 +1,28 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + +from unittest.mock import ANY, MagicMock + +from source_chartmogul.source import SourceChartmogul +from requests import HTTPError + +def test_check_connection(mocker, requests_mock): + source = SourceChartmogul() + logger_mock, config_mock = MagicMock(), MagicMock() + + # success + requests_mock.get("https://api.chartmogul.com/v1/ping", json={ "data":"pong!" }) + assert source.check_connection(logger_mock, config_mock) == (True, None) + + # failure + requests_mock.get("https://api.chartmogul.com/v1/ping", status_code=500) + assert source.check_connection(logger_mock, config_mock) == (False, ANY) + + +def test_streams(mocker): + source = SourceChartmogul() + config_mock = MagicMock() + streams = source.streams(config_mock) + expected_streams_number = 2 + assert len(streams) == expected_streams_number diff --git a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py new file mode 100644 index 0000000000000..4944239f098d4 --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py @@ -0,0 +1,115 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + +from http import HTTPStatus +from unittest.mock import MagicMock, patch + +import pytest +from source_chartmogul.source import Customers, Activities, ChartmogulStream + + +@pytest.fixture +def patch_base_class(mocker): + # Mock abstract methods to enable instantiating abstract class + mocker.patch.object(Customers, "__abstractmethods__", set()) + mocker.patch.object(Activities, "__abstractmethods__", set()) + + +# Customer stream tests + +def test_request_params(): + stream = Customers() + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} + expected_params = {"page": 1} + assert stream.request_params(**inputs) == expected_params + + next_page_token = {"page": 3} + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": next_page_token} + expected_params = {"page": 3} + assert stream.request_params(**inputs) == expected_params + + +def test_next_page_token(): + stream = Customers() + response = MagicMock() + + # no more results + response.json.return_value = {"has_more": False} + inputs = {"response": response} + assert stream.next_page_token(**inputs) == None + + # there is more results + response.json.return_value = {"has_more": True, "current_page": 42} + inputs = {"response": response} + assert stream.next_page_token(**inputs) == {"page": 43} + + +def test_parse_response(): + stream = Customers() + response = MagicMock() + response.json.return_value = {"entries": [{"one": 1}, {"two": 2}]} + inputs = {"response": response} + expected_parsed_object = {"one": 1} + assert next(stream.parse_response(**inputs)) == expected_parsed_object + +# Activites stream tests + +def test_request_params_activities(): + # no start_date set + stream = Activities(start_date=None) + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} + assert stream.request_params(**inputs) == {} + + # start_date is set + stream.start_date = "2010-01-01" + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} + assert stream.request_params(**inputs) == {"start-date": stream.start_date} + + # start-after is available + next_page_token = {"start-after": "a-b-c"} + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": next_page_token} + expected_params = next_page_token + assert stream.request_params(**inputs) == expected_params + + +def test_next_page_token_activities(): + stream = Activities(start_date=None) + response = MagicMock() + + # no more results + response.json.return_value = {"has_more": False} + inputs = {"response": response} + assert stream.next_page_token(**inputs) == None + + # there is more results + response.json.return_value = {"has_more": True, "entries": [{"uuid": "unique-uuid"}]} + inputs = {"response": response} + assert stream.next_page_token(**inputs) == {"start-after": "unique-uuid"} + + +# Default tests + +@pytest.mark.parametrize( + ("http_status", "should_retry"), + [ + (HTTPStatus.OK, False), + (HTTPStatus.BAD_REQUEST, False), + (HTTPStatus.TOO_MANY_REQUESTS, True), + (HTTPStatus.INTERNAL_SERVER_ERROR, True), + ], +) + +def test_should_retry(http_status, should_retry): + response_mock = MagicMock() + response_mock.status_code = http_status + stream = Customers() + assert stream.should_retry(response_mock) == should_retry + + +def test_backoff_time(): + response_mock = MagicMock() + stream = Customers() + expected_backoff_time = None + assert stream.backoff_time(response_mock) == expected_backoff_time + diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 34ff335e9cf59..8869919eb3d47 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -50,6 +50,7 @@ * [Braintree](integrations/sources/braintree.md) * [Cart](integrations/sources/cart.md) * [Chargebee](integrations/sources/chargebee.md) + * [Chartmogul](integrations/sources/chartmogul.md) * [ClickHouse](integrations/sources/clickhouse.md) * [Close.com](integrations/sources/close-com.md) * [CockroachDB](integrations/sources/cockroachdb.md) diff --git a/docs/integrations/sources/chartmogul.md b/docs/integrations/sources/chartmogul.md new file mode 100644 index 0000000000000..ee9bf3b94328b --- /dev/null +++ b/docs/integrations/sources/chartmogul.md @@ -0,0 +1,47 @@ +# Chartmogul + +## Sync overview + +The Chartmogul source supports Full Refresh syncs only. + +This source syncs data for the [Chartmogul API](https://dev.chartmogul.com/reference/). + +### Notes + +If `start_date` is set, it will only apply to `Activities` stream. `Customers`' endpoint does not provide a way to filter by creation or update dates. + +### Output schema + +This Source is capable of syncing the following streams: + +* [Customers](https://dev.chartmogul.com/reference/list-customers) +* [Activities](https://dev.chartmogul.com/reference/list-activities) + +### Features + +| Feature | Supported?\(Yes/No\) +| :--- | :--- | +| Full Refresh Sync | Yes | +| Incremental - Append Sync | No | +| Namespaces | No | + +### Performance considerations + +The Chartmogul connector should not run into Chartmogul API limitations under normal usage. Please [create an issue](https://github.com/airbytehq/airbyte/issues) if you see any rate limit issues that are not automatically retried successfully. + +## Getting started + +### Requirements + +* Chartmogul Account +* Chartmogul API Key + +### Setup guide + +Please read [How to find your API key](https://dev.chartmogul.com/docs/authentication). + +## Changelog + +| Version | Date | Pull Request | Subject | +| :--- | :--- | :--- | :--- | +| 0.1.0 | 2022-01-xx | [7062](https://github.com/airbytehq/airbyte/pull/xxxx) | New Source: Chartmogul | From 5257c420d27f7a58e34c8658a2bcad57848087c0 Mon Sep 17 00:00:00 2001 From: Titas Skrebe Date: Mon, 10 Jan 2022 13:43:19 +0200 Subject: [PATCH 02/11] update changelog --- docs/integrations/README.md | 1 + docs/integrations/sources/chartmogul.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/integrations/README.md b/docs/integrations/README.md index f91687ce224ae..91b6163db9d6b 100644 --- a/docs/integrations/README.md +++ b/docs/integrations/README.md @@ -30,6 +30,7 @@ Airbyte uses a grading system for connectors to help users understand what to ex | [Bing Ads](sources/bing-ads.md) | Beta | | [Cart.com](sources/cart.md) | Beta | | [Chargebee](sources/chargebee.md) | Alpha | +| [Chartmogul](sources/chartmogul.md) | Alpha | | [ClickHouse](sources/clickhouse.md) | Beta | | [Close.com](sources/close-com.md) | Beta | | [CockroachDB](sources/cockroachdb.md) | Beta | diff --git a/docs/integrations/sources/chartmogul.md b/docs/integrations/sources/chartmogul.md index ee9bf3b94328b..e8d19c2ddda27 100644 --- a/docs/integrations/sources/chartmogul.md +++ b/docs/integrations/sources/chartmogul.md @@ -44,4 +44,4 @@ Please read [How to find your API key](https://dev.chartmogul.com/docs/authentic | Version | Date | Pull Request | Subject | | :--- | :--- | :--- | :--- | -| 0.1.0 | 2022-01-xx | [7062](https://github.com/airbytehq/airbyte/pull/xxxx) | New Source: Chartmogul | +| 0.1.0 | 2022-01-10 | [9381](https://github.com/airbytehq/airbyte/pull/9381) | New Source: Chartmogul | From 33858291e6ed55ff00737c6a980140c76d56a369 Mon Sep 17 00:00:00 2001 From: Titas Skrebe Date: Mon, 10 Jan 2022 15:14:49 +0200 Subject: [PATCH 03/11] bootstrap.md --- .../connectors/source-chartmogul/bootstrap.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 airbyte-integrations/connectors/source-chartmogul/bootstrap.md diff --git a/airbyte-integrations/connectors/source-chartmogul/bootstrap.md b/airbyte-integrations/connectors/source-chartmogul/bootstrap.md new file mode 100644 index 0000000000000..d6fee29243dad --- /dev/null +++ b/airbyte-integrations/connectors/source-chartmogul/bootstrap.md @@ -0,0 +1,21 @@ +# Chartmogul +Chartmogul is an online subscription analytics platform. It retrieves data from payment processors (e.g. Stripe) and makes sense out of it. + +## Streams + +Connector currently implements following full refresh streams: +* [Customers](https://dev.chartmogul.com/reference/list-customers) +* [Activities](https://dev.chartmogul.com/reference/list-activities) + +`start_date` config is used for retrieving `Activies`. `Customers` stream does not use this config. Even if it was possible to filter by `start_date`, it would cause issues when modeling data. That is because activies after `start_date` can be triggered by customers who were created way before that. + +### Incremental streams +Incremental streams were not implemented due to following reasons: +* `Customers` API endpoint does not provide filtering by creation/update date. +* `Activities` API does provide pagination based on last entries UUID, however it is not stable, since it is possible to for activity to disappear retrospectively. + +### Next steps +It is theoretically possible to make `Activities` stream incremental. One would need to keep track of both UUID and created_at and read stream until `datetime.now()`. Dynamic end date would be necessary since activities can also have a future date. Since data can be changed retrospectively, a `lookback window` would also be necessary to catch all the changes. + +### Rate limits +The API rate limit is at 40 requests/second. Read [Rate Limits](https://dev.chartmogul.com/docs/rate-limits) for more informations. \ No newline at end of file From 8c7751c5e30754579af995883af31525f381d8eb Mon Sep 17 00:00:00 2001 From: Titas Skrebe Date: Mon, 10 Jan 2022 15:45:51 +0200 Subject: [PATCH 04/11] reorder schema --- .../source_chartmogul/schemas/customers.json | 85 +++++++++---------- 1 file changed, 39 insertions(+), 46 deletions(-) diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json index 636e520e2dfa5..88e9052595830 100644 --- a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json @@ -11,35 +11,53 @@ "external_id": { "type": ["null", "string"] }, + "external_ids": { + "type": ["null", "array"] + }, + "data_source_uuid": { + "type": ["null", "string"] + }, + "data_source_uuids": { + "type": ["null", "array"] + }, "name": { "type": ["null", "string"] }, + "company": { + "type": ["null", "string"] + }, "email": { "type": ["null", "string"] }, "status": { "type": ["null", "string"] }, + "lead_created_at": { + "type": ["null", "string"] + }, + "free_trial_started_at": { + "type": ["null", "string"] + }, "customer_since": { "type": ["null", "string"] }, + "city": { + "type": ["null", "string"] + }, + "state": { + "type": ["null", "string"] + }, + "country": { + "type": ["null", "string"] + }, + "zip": { + "type": ["null", "string"] + }, "attributes": { "type": ["null", "object"], "properties": { - "custom": { - "type": ["null", "object"], - "properties": { - "initial_sale_mrr": { - "type": ["null", "integer"] - }, - "initial_sale_mrr_currency": { - "type": ["null", "string"] - } - } - }, - "clearbit": { - "type": ["null", "object"], - "properties": {} + "tags": { + "type": ["null", "array"] }, "stripe": { "type": ["null", "object"], @@ -58,41 +76,16 @@ } } }, - "tags": { - "type": ["null", "array"] + "clearbit": { + "type": ["null", "object"], + "properties": {} + }, + "custom": { + "type": ["null", "object"], + "properties": {} } } }, - "data_source_uuid": { - "type": ["null", "string"] - }, - "data_source_uuids": { - "type": ["null", "array"] - }, - "external_ids": { - "type": ["null", "array"] - }, - "company": { - "type": ["null", "string"] - }, - "country": { - "type": ["null", "string"] - }, - "state": { - "type": ["null", "string"] - }, - "city": { - "type": ["null", "string"] - }, - "zip": { - "type": ["null", "string"] - }, - "lead_created_at": { - "type": ["null", "string"] - }, - "free_trial_started_at": { - "type": ["null", "string"] - }, "address": { "type": ["null", "object"], "properties": { From 66135762b6dca4a4e77a41ec9daad11c8c488a68 Mon Sep 17 00:00:00 2001 From: alafanechere Date: Fri, 14 Jan 2022 10:33:29 +0100 Subject: [PATCH 05/11] make acceptance test pass --- .../acceptance-test-config.yml | 13 +----- .../source_chartmogul/schemas/activities.json | 2 +- .../source_chartmogul/schemas/customers.json | 4 +- .../source_chartmogul/source.py | 28 +++++------- .../unit_tests/test_source.py | 6 +-- .../unit_tests/test_streams.py | 45 ++++++++++--------- 6 files changed, 40 insertions(+), 58 deletions(-) diff --git a/airbyte-integrations/connectors/source-chartmogul/acceptance-test-config.yml b/airbyte-integrations/connectors/source-chartmogul/acceptance-test-config.yml index 7426cd979323c..ba3029611366a 100644 --- a/airbyte-integrations/connectors/source-chartmogul/acceptance-test-config.yml +++ b/airbyte-integrations/connectors/source-chartmogul/acceptance-test-config.yml @@ -14,18 +14,7 @@ tests: basic_read: - config_path: "secrets/config.json" configured_catalog_path: "integration_tests/configured_catalog.json" - empty_streams: [] -# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file -# expect_records: -# path: "integration_tests/expected_records.txt" -# extra_fields: no -# exact_order: no -# extra_records: yes -# TODO uncomment when incremental is implemented - # incremental: - # - config_path: "secrets/config.json" - # configured_catalog_path: "integration_tests/configured_catalog.json" - # future_state_path: "integration_tests/abnormal_state.json" + empty_streams: ["activities"] full_refresh: - config_path: "secrets/config.json" configured_catalog_path: "integration_tests/configured_catalog.json" diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/activities.json b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/activities.json index 6000eb2828965..6cf82203be202 100644 --- a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/activities.json +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/activities.json @@ -42,7 +42,7 @@ "type": ["null", "string"] }, "uuid": { - "type": ["null", "string"] + "type": ["string"] } } } diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json index 88e9052595830..eb499b01a0d83 100644 --- a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/schemas/customers.json @@ -3,10 +3,10 @@ "type": "object", "properties": { "id": { - "type": ["null", "string"] + "type": ["integer"] }, "uuid": { - "type": ["null", "string"] + "type": ["string"] }, "external_id": { "type": ["null", "string"] diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py index 531f9a3acb6f0..d3071b191e21b 100644 --- a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py @@ -3,9 +3,8 @@ # from abc import ABC -from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple, Union from base64 import b64encode -from datetime import datetime +from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple import requests from airbyte_cdk.sources import AbstractSource @@ -17,7 +16,7 @@ # Basic full refresh stream class ChartmogulStream(HttpStream, ABC): url_base = "https://api.chartmogul.com" - + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: yield from response.json().get("entries", []) @@ -30,16 +29,12 @@ def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, if not json_response.get("has_more", False): return None - return { - "page": json_response.get("current_page")+1 - } + return {"page": json_response.get("current_page") + 1} def request_params( self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_page_token: Mapping[str, Any] = None ) -> MutableMapping[str, Any]: - return { - "page": 1 if not next_page_token else next_page_token["page"] - } + return {"page": 1 if not next_page_token else next_page_token["page"]} def path(self, **kwargs) -> str: return "v1/customers" @@ -47,7 +42,7 @@ def path(self, **kwargs) -> str: class Activities(ChartmogulStream): primary_key = "uuid" - + def __init__(self, start_date: str, **kwargs): super().__init__(**kwargs) self.start_date = start_date @@ -57,9 +52,7 @@ def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, if not json_response.get("has_more", False): return None - return { - "start-after": json_response["entries"][-1][self.primary_key] - } + return {"start-after": json_response["entries"][-1][self.primary_key]} def request_params( self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_page_token: Mapping[str, Any] = None @@ -72,16 +65,18 @@ def request_params( params["start-date"] = self.start_date return params - + def path(self, **kwargs) -> str: return "v1/activities" + class HttpBasicAuthenticator(TokenAuthenticator): def __init__(self, token: str, auth_method: str = "Basic", **kwargs): auth_string = f"{token}:".encode("utf8") b64_encoded = b64encode(auth_string).decode("utf8") super().__init__(token=b64_encoded, auth_method=auth_method, **kwargs) + # Source class SourceChartmogul(AbstractSource): def check_connection(self, logger, config) -> Tuple[bool, any]: @@ -96,7 +91,4 @@ def check_connection(self, logger, config) -> Tuple[bool, any]: def streams(self, config: Mapping[str, Any]) -> List[Stream]: auth = HttpBasicAuthenticator(config["api_key"], auth_method="Basic") - return [ - Customers(authenticator=auth), - Activities(authenticator=auth, start_date=config.get("start_date")) - ] + return [Customers(authenticator=auth), Activities(authenticator=auth, start_date=config.get("start_date"))] diff --git a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py index d9cf60f1a11f0..7cb9dea9f11b4 100644 --- a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py @@ -5,14 +5,14 @@ from unittest.mock import ANY, MagicMock from source_chartmogul.source import SourceChartmogul -from requests import HTTPError + def test_check_connection(mocker, requests_mock): source = SourceChartmogul() logger_mock, config_mock = MagicMock(), MagicMock() - + # success - requests_mock.get("https://api.chartmogul.com/v1/ping", json={ "data":"pong!" }) + requests_mock.get("https://api.chartmogul.com/v1/ping", json={"data": "pong!"}) assert source.check_connection(logger_mock, config_mock) == (True, None) # failure diff --git a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py index 4944239f098d4..8d957226832e3 100644 --- a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py +++ b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py @@ -3,10 +3,9 @@ # from http import HTTPStatus -from unittest.mock import MagicMock, patch import pytest -from source_chartmogul.source import Customers, Activities, ChartmogulStream +from source_chartmogul.source import Activities, Customers @pytest.fixture @@ -18,6 +17,7 @@ def patch_base_class(mocker): # Customer stream tests + def test_request_params(): stream = Customers() inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} @@ -30,37 +30,39 @@ def test_request_params(): assert stream.request_params(**inputs) == expected_params -def test_next_page_token(): +def test_next_page_token(mocker): stream = Customers() - response = MagicMock() + response = mocker.MagicMock() # no more results - response.json.return_value = {"has_more": False} + response.json.return_value = {"has_more": False} inputs = {"response": response} - assert stream.next_page_token(**inputs) == None + assert stream.next_page_token(**inputs) is None # there is more results - response.json.return_value = {"has_more": True, "current_page": 42} + response.json.return_value = {"has_more": True, "current_page": 42} inputs = {"response": response} assert stream.next_page_token(**inputs) == {"page": 43} -def test_parse_response(): +def test_parse_response(mocker): stream = Customers() - response = MagicMock() - response.json.return_value = {"entries": [{"one": 1}, {"two": 2}]} + response = mocker.MagicMock() + response.json.return_value = {"entries": [{"one": 1}, {"two": 2}]} inputs = {"response": response} expected_parsed_object = {"one": 1} assert next(stream.parse_response(**inputs)) == expected_parsed_object + # Activites stream tests + def test_request_params_activities(): # no start_date set stream = Activities(start_date=None) inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} assert stream.request_params(**inputs) == {} - + # start_date is set stream.start_date = "2010-01-01" inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} @@ -73,23 +75,24 @@ def test_request_params_activities(): assert stream.request_params(**inputs) == expected_params -def test_next_page_token_activities(): +def test_next_page_token_activities(mocker): stream = Activities(start_date=None) - response = MagicMock() + response = mocker.MagicMock() # no more results - response.json.return_value = {"has_more": False} + response.json.return_value = {"has_more": False} inputs = {"response": response} - assert stream.next_page_token(**inputs) == None + assert stream.next_page_token(**inputs) is None # there is more results - response.json.return_value = {"has_more": True, "entries": [{"uuid": "unique-uuid"}]} + response.json.return_value = {"has_more": True, "entries": [{"uuid": "unique-uuid"}]} inputs = {"response": response} assert stream.next_page_token(**inputs) == {"start-after": "unique-uuid"} # Default tests + @pytest.mark.parametrize( ("http_status", "should_retry"), [ @@ -99,17 +102,15 @@ def test_next_page_token_activities(): (HTTPStatus.INTERNAL_SERVER_ERROR, True), ], ) - -def test_should_retry(http_status, should_retry): - response_mock = MagicMock() +def test_should_retry(http_status, should_retry, mocker): + response_mock = mocker.MagicMock() response_mock.status_code = http_status stream = Customers() assert stream.should_retry(response_mock) == should_retry -def test_backoff_time(): - response_mock = MagicMock() +def test_backoff_time(mocker): + response_mock = mocker.MagicMock() stream = Customers() expected_backoff_time = None assert stream.backoff_time(response_mock) == expected_backoff_time - From bd82338c454e3e5cc14c13e1dd3ce23869812599 Mon Sep 17 00:00:00 2001 From: alafanechere Date: Fri, 14 Jan 2022 10:46:15 +0100 Subject: [PATCH 06/11] add chartmogul to builds.md --- airbyte-integrations/builds.md | 1 + 1 file changed, 1 insertion(+) diff --git a/airbyte-integrations/builds.md b/airbyte-integrations/builds.md index 001ae80fd3248..c1adc5af18e50 100644 --- a/airbyte-integrations/builds.md +++ b/airbyte-integrations/builds.md @@ -20,6 +20,7 @@ | BigQuery | [![source-bigquery](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-bigquery%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-bigquery/) | | Bing Ads | [![source-bing-ads](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-bing-ads%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-bing-ads) | | Chargebee | [![source-chargebee](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-chargebee%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-chargebee/) | +| Chartmogul | [![source-chartmogul](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-chartmogul%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-chartmogul/) | | Cart.com | [![source-cart](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-cart%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-cart/) | | Close.com | [![source-close-com](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-close-com%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-close-com/) | | Dixa | [![source-dixa](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-dixa%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-dixa) | From d631e30641eeb50230d5742235cde8f8a856785e Mon Sep 17 00:00:00 2001 From: Titas Skrebe Date: Fri, 14 Jan 2022 14:42:54 +0200 Subject: [PATCH 07/11] Update airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py Co-authored-by: Augustin --- .../source-chartmogul/source_chartmogul/source.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py index d3071b191e21b..52f98c72c7fb0 100644 --- a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py @@ -26,10 +26,10 @@ class Customers(ChartmogulStream): def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]: json_response = response.json() - if not json_response.get("has_more", False): - return None + if json_response.get("has_more", False): + return {"page": json_response.get("current_page") + 1} - return {"page": json_response.get("current_page") + 1} + return None def request_params( self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_page_token: Mapping[str, Any] = None From 61a04cdc4f5dc668d876b97fc22357dc09ec747d Mon Sep 17 00:00:00 2001 From: Titas Skrebe Date: Fri, 14 Jan 2022 14:48:54 +0200 Subject: [PATCH 08/11] Update airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py Co-authored-by: Augustin --- .../connectors/source-chartmogul/source_chartmogul/source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py index 52f98c72c7fb0..2a6505c3027ad 100644 --- a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py @@ -60,7 +60,7 @@ def request_params( params = {} if next_page_token: - params["start-after"] = next_page_token["start-after"] + params.update(next_page_token) elif self.start_date: params["start-date"] = self.start_date From 649fbd2396ff67911fb456904b25529b5cfb8f9b Mon Sep 17 00:00:00 2001 From: Titas Skrebe Date: Mon, 17 Jan 2022 11:55:34 +0200 Subject: [PATCH 09/11] address comments --- .../source_chartmogul/source.py | 2 +- .../unit_tests/test_source.py | 6 +- .../unit_tests/test_streams.py | 133 +++++++----------- 3 files changed, 58 insertions(+), 83 deletions(-) diff --git a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py index 2a6505c3027ad..6a3a8fb675fe2 100644 --- a/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py +++ b/airbyte-integrations/connectors/source-chartmogul/source_chartmogul/source.py @@ -22,7 +22,7 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp class Customers(ChartmogulStream): - primary_key = "uuid" + primary_key = "id" def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]: json_response = response.json() diff --git a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py index 7cb9dea9f11b4..a602d1b663416 100644 --- a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py @@ -5,7 +5,7 @@ from unittest.mock import ANY, MagicMock from source_chartmogul.source import SourceChartmogul - +from requests.exceptions import HTTPError def test_check_connection(mocker, requests_mock): source = SourceChartmogul() @@ -17,8 +17,8 @@ def test_check_connection(mocker, requests_mock): # failure requests_mock.get("https://api.chartmogul.com/v1/ping", status_code=500) - assert source.check_connection(logger_mock, config_mock) == (False, ANY) - + ok, err = source.check_connection(logger_mock, config_mock) + assert (ok, type(err)) == (False, HTTPError) def test_streams(mocker): source = SourceChartmogul() diff --git a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py index 8d957226832e3..f8820ac6fad70 100644 --- a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py +++ b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py @@ -15,102 +15,77 @@ def patch_base_class(mocker): mocker.patch.object(Activities, "__abstractmethods__", set()) -# Customer stream tests +class TestCustomers: + def test_request_params(self): + stream = Customers() + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} + expected_params = {"page": 1} + assert stream.request_params(**inputs) == expected_params -def test_request_params(): - stream = Customers() - inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} - expected_params = {"page": 1} - assert stream.request_params(**inputs) == expected_params + next_page_token = {"page": 3} + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": next_page_token} + expected_params = {"page": 3} + assert stream.request_params(**inputs) == expected_params - next_page_token = {"page": 3} - inputs = {"stream_slice": None, "stream_state": None, "next_page_token": next_page_token} - expected_params = {"page": 3} - assert stream.request_params(**inputs) == expected_params + def test_next_page_token(self, mocker): + stream = Customers() + response = mocker.MagicMock() -def test_next_page_token(mocker): - stream = Customers() - response = mocker.MagicMock() + # no more results + response.json.return_value = {"has_more": False} + inputs = {"response": response} + assert stream.next_page_token(**inputs) is None - # no more results - response.json.return_value = {"has_more": False} - inputs = {"response": response} - assert stream.next_page_token(**inputs) is None + # there is more results + response.json.return_value = {"has_more": True, "current_page": 42} + inputs = {"response": response} + assert stream.next_page_token(**inputs) == {"page": 43} - # there is more results - response.json.return_value = {"has_more": True, "current_page": 42} - inputs = {"response": response} - assert stream.next_page_token(**inputs) == {"page": 43} - -def test_parse_response(mocker): - stream = Customers() - response = mocker.MagicMock() - response.json.return_value = {"entries": [{"one": 1}, {"two": 2}]} - inputs = {"response": response} - expected_parsed_object = {"one": 1} - assert next(stream.parse_response(**inputs)) == expected_parsed_object + def test_parse_response(self, mocker): + stream = Customers() + response = mocker.MagicMock() + response.json.return_value = {"entries": [{"one": 1}, {"two": 2}]} + inputs = {"response": response} + expected_parsed_object = {"one": 1} + assert next(stream.parse_response(**inputs)) == expected_parsed_object # Activites stream tests +class TestActivities: -def test_request_params_activities(): - # no start_date set - stream = Activities(start_date=None) - inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} - assert stream.request_params(**inputs) == {} - - # start_date is set - stream.start_date = "2010-01-01" - inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} - assert stream.request_params(**inputs) == {"start-date": stream.start_date} - - # start-after is available - next_page_token = {"start-after": "a-b-c"} - inputs = {"stream_slice": None, "stream_state": None, "next_page_token": next_page_token} - expected_params = next_page_token - assert stream.request_params(**inputs) == expected_params - - -def test_next_page_token_activities(mocker): - stream = Activities(start_date=None) - response = mocker.MagicMock() - - # no more results - response.json.return_value = {"has_more": False} - inputs = {"response": response} - assert stream.next_page_token(**inputs) is None + def test_request_params(self): + # no start_date set + stream = Activities(start_date=None) + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} + assert stream.request_params(**inputs) == {} - # there is more results - response.json.return_value = {"has_more": True, "entries": [{"uuid": "unique-uuid"}]} - inputs = {"response": response} - assert stream.next_page_token(**inputs) == {"start-after": "unique-uuid"} + # start_date is set + stream.start_date = "2010-01-01" + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} + assert stream.request_params(**inputs) == {"start-date": stream.start_date} + # start-after is available + next_page_token = {"start-after": "a-b-c"} + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": next_page_token} + expected_params = next_page_token + assert stream.request_params(**inputs) == expected_params -# Default tests + def test_next_page_token(self, mocker): + stream = Activities(start_date=None) + response = mocker.MagicMock() -@pytest.mark.parametrize( - ("http_status", "should_retry"), - [ - (HTTPStatus.OK, False), - (HTTPStatus.BAD_REQUEST, False), - (HTTPStatus.TOO_MANY_REQUESTS, True), - (HTTPStatus.INTERNAL_SERVER_ERROR, True), - ], -) -def test_should_retry(http_status, should_retry, mocker): - response_mock = mocker.MagicMock() - response_mock.status_code = http_status - stream = Customers() - assert stream.should_retry(response_mock) == should_retry + # no more results + response.json.return_value = {"has_more": False} + inputs = {"response": response} + assert stream.next_page_token(**inputs) is None + # there is more results + response.json.return_value = {"has_more": True, "entries": [{"uuid": "unique-uuid"}]} + inputs = {"response": response} + assert stream.next_page_token(**inputs) == {"start-after": "unique-uuid"} -def test_backoff_time(mocker): - response_mock = mocker.MagicMock() - stream = Customers() - expected_backoff_time = None - assert stream.backoff_time(response_mock) == expected_backoff_time From dd7d5640f14e7f010a386913a28747d3d46c58c3 Mon Sep 17 00:00:00 2001 From: alafanechere Date: Tue, 18 Jan 2022 17:25:53 +0100 Subject: [PATCH 10/11] fix unused imports --- .../source-chartmogul/unit_tests/test_source.py | 6 ++++-- .../source-chartmogul/unit_tests/test_streams.py | 9 +-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py index a602d1b663416..32b7774924343 100644 --- a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_source.py @@ -2,10 +2,11 @@ # Copyright (c) 2021 Airbyte, Inc., all rights reserved. # -from unittest.mock import ANY, MagicMock +from unittest.mock import MagicMock -from source_chartmogul.source import SourceChartmogul from requests.exceptions import HTTPError +from source_chartmogul.source import SourceChartmogul + def test_check_connection(mocker, requests_mock): source = SourceChartmogul() @@ -20,6 +21,7 @@ def test_check_connection(mocker, requests_mock): ok, err = source.check_connection(logger_mock, config_mock) assert (ok, type(err)) == (False, HTTPError) + def test_streams(mocker): source = SourceChartmogul() config_mock = MagicMock() diff --git a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py index f8820ac6fad70..fc11b843aba87 100644 --- a/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py +++ b/airbyte-integrations/connectors/source-chartmogul/unit_tests/test_streams.py @@ -2,8 +2,6 @@ # Copyright (c) 2021 Airbyte, Inc., all rights reserved. # -from http import HTTPStatus - import pytest from source_chartmogul.source import Activities, Customers @@ -16,7 +14,6 @@ def patch_base_class(mocker): class TestCustomers: - def test_request_params(self): stream = Customers() inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} @@ -28,7 +25,6 @@ def test_request_params(self): expected_params = {"page": 3} assert stream.request_params(**inputs) == expected_params - def test_next_page_token(self, mocker): stream = Customers() response = mocker.MagicMock() @@ -43,7 +39,6 @@ def test_next_page_token(self, mocker): inputs = {"response": response} assert stream.next_page_token(**inputs) == {"page": 43} - def test_parse_response(self, mocker): stream = Customers() response = mocker.MagicMock() @@ -55,8 +50,8 @@ def test_parse_response(self, mocker): # Activites stream tests -class TestActivities: +class TestActivities: def test_request_params(self): # no start_date set stream = Activities(start_date=None) @@ -74,7 +69,6 @@ def test_request_params(self): expected_params = next_page_token assert stream.request_params(**inputs) == expected_params - def test_next_page_token(self, mocker): stream = Activities(start_date=None) response = mocker.MagicMock() @@ -88,4 +82,3 @@ def test_next_page_token(self, mocker): response.json.return_value = {"has_more": True, "entries": [{"uuid": "unique-uuid"}]} inputs = {"response": response} assert stream.next_page_token(**inputs) == {"start-after": "unique-uuid"} - From ae49ee3b1caf6808f959cce08f008fa1f33de9e8 Mon Sep 17 00:00:00 2001 From: alafanechere Date: Tue, 18 Jan 2022 19:22:25 +0100 Subject: [PATCH 11/11] update source_specs --- .../src/main/resources/seed/source_specs.yaml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/airbyte-config/init/src/main/resources/seed/source_specs.yaml b/airbyte-config/init/src/main/resources/seed/source_specs.yaml index ecf1dee8fdd65..005c5af601381 100644 --- a/airbyte-config/init/src/main/resources/seed/source_specs.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_specs.yaml @@ -1000,6 +1000,33 @@ supportsNormalization: false supportsDBT: false supported_destination_sync_modes: [] +- dockerImage: "airbyte/source-chartmogul:0.1.0" + spec: + documentationUrl: "https://docs.airbyte.io/integrations/sources/chartmogul" + connectionSpecification: + $schema: "http://json-schema.org/draft-07/schema#" + title: "Chartmogul Spec" + type: "object" + required: + - "api_key" + additionalProperties: false + properties: + api_key: + type: "string" + description: "Chartmogul API key" + airbyte_secret: true + order: 0 + start_date: + type: "string" + pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" + description: "UTC date and time in the format 2017-01-25T00:00:00Z. When\ + \ feasible, any data before this date will not be replicated." + examples: + - "2017-01-25T00:00:00Z" + order: 1 + supportsNormalization: false + supportsDBT: false + supported_destination_sync_modes: [] - dockerImage: "airbyte/source-clickhouse:0.1.7" spec: documentationUrl: "https://docs.airbyte.io/integrations/destinations/clickhouse"