diff --git a/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/492b56d1-937c-462e-8076-21ad2031e784.json b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/492b56d1-937c-462e-8076-21ad2031e784.json new file mode 100644 index 0000000000000..6f5f3febef56b --- /dev/null +++ b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/492b56d1-937c-462e-8076-21ad2031e784.json @@ -0,0 +1,7 @@ +{ + "sourceDefinitionId": "492b56d1-937c-462e-8076-21ad2031e784", + "name": "Hellobaton", + "dockerRepository": "airbyte/source-hellobaton", + "dockerImageTag": "0.1.0", + "documentationUrl": "https://docs.airbyte.io/integrations/sources/hellobaton" +} 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 1302890f6e688..7df59d480d51e 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -284,6 +284,12 @@ documentationUrl: https://docs.airbyte.io/integrations/sources/harvest icon: harvest.svg sourceType: api +- name: Hellobaton + sourceDefinitionId: 492b56d1-937c-462e-8076-21ad2031e784 + dockerRepository: airbyte/source-hellobaton + dockerImageTag: 0.1.0 + documentationUrl: https://docs.airbyte.io/integrations/sources/hellobaton + sourceType: api - name: HubSpot sourceDefinitionId: 36c891d9-4bd9-43ac-bad2-10e12756272c dockerRepository: airbyte/source-hubspot 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 ed9459b0c5bbc..4909346bbea47 100644 --- a/airbyte-config/init/src/main/resources/seed/source_specs.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_specs.yaml @@ -2846,6 +2846,32 @@ path_in_connector_config: - "credentials" - "client_secret" +- dockerImage: "airbyte/source-hellobaton:0.1.0" + spec: + documentationUrl: "https://docsurl.com" + connectionSpecification: + $schema: "http://json-schema.org/draft-07/schema#" + title: "Hellobaton Spec" + type: "object" + required: + - "api_key" + - "company" + additionalProperties: false + properties: + api_key: + type: "string" + description: "authentication key required to access the api endpoints" + airbyte_secret: true + company: + type: "string" + description: "Company name that generates your base api url" + examples: + - "google" + - "facebook" + - "microsoft" + supportsNormalization: false + supportsDBT: false + supported_destination_sync_modes: [] - dockerImage: "airbyte/source-hubspot:0.1.32" spec: documentationUrl: "https://docs.airbyte.io/integrations/sources/hubspot" diff --git a/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeDestinationTest.java b/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeDestinationTest.java index bfa451bbd0c9b..8125613834c00 100644 --- a/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeDestinationTest.java +++ b/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeDestinationTest.java @@ -18,16 +18,28 @@ import io.airbyte.db.jdbc.JdbcDatabase; import io.airbyte.integrations.base.AirbyteMessageConsumer; import io.airbyte.integrations.base.Destination; +<<<<<<< HEAD +import io.airbyte.protocol.models.AirbyteMessage; +import io.airbyte.protocol.models.AirbyteRecordMessage; +import io.airbyte.protocol.models.CatalogHelpers; +import io.airbyte.protocol.models.ConfiguredAirbyteCatalog; +import io.airbyte.protocol.models.DestinationSyncMode; +import io.airbyte.protocol.models.Field; +import io.airbyte.protocol.models.JsonSchemaPrimitive; +======= import io.airbyte.protocol.models.*; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +>>>>>>> master import java.nio.file.Path; import java.sql.SQLException; import java.time.Instant; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; public class SnowflakeDestinationTest { @@ -78,40 +90,40 @@ public void testCleanupStageOnFailure() throws Exception { final var testMessages = generateTestMessages(); final JsonNode config = Jsons.deserialize(MoreResources.readResource("insert_config.json"), JsonNode.class); AirbyteMessageConsumer airbyteMessageConsumer = new SnowflakeInternalStagingConsumerFactory() - .create(Destination::defaultOutputRecordCollector, mockDb, + .create(Destination::defaultOutputRecordCollector, mockDb, sqlOperations, new SnowflakeSQLNameTransformer(), config, getCatalog()); - doThrow(SQLException.class).when(sqlOperations).copyIntoTmpTableFromStage(any(),anyString(),anyString(),anyString()); + doThrow(SQLException.class).when(sqlOperations).copyIntoTmpTableFromStage(any(), anyString(), anyString(), anyString()); airbyteMessageConsumer.start(); for (AirbyteMessage m : testMessages) { - airbyteMessageConsumer.accept(m); + airbyteMessageConsumer.accept(m); } assertThrows(RuntimeException.class, airbyteMessageConsumer::close); - verify(sqlOperations, times(1)).cleanUpStage(any(),anyString()); + verify(sqlOperations, times(1)).cleanUpStage(any(), anyString()); } private List generateTestMessages() { return IntStream.range(0, 3) - .boxed() - .map(i -> new AirbyteMessage() - .withType(AirbyteMessage.Type.RECORD) - .withRecord(new AirbyteRecordMessage() - .withStream("test") - .withNamespace("test_staging") - .withEmittedAt(Instant.now().toEpochMilli()) - .withData(Jsons.jsonNode(ImmutableMap.of("id", i, "name", "human " + i))))) - .collect(Collectors.toList()); + .boxed() + .map(i -> new AirbyteMessage() + .withType(AirbyteMessage.Type.RECORD) + .withRecord(new AirbyteRecordMessage() + .withStream("test") + .withNamespace("test_staging") + .withEmittedAt(Instant.now().toEpochMilli()) + .withData(Jsons.jsonNode(ImmutableMap.of("id", i, "name", "human " + i))))) + .collect(Collectors.toList()); } ConfiguredAirbyteCatalog getCatalog() { return new ConfiguredAirbyteCatalog().withStreams(List.of( - CatalogHelpers.createConfiguredAirbyteStream( - "test", - "test_staging", - Field.of("id", JsonSchemaPrimitive.NUMBER), - Field.of("name", JsonSchemaPrimitive.STRING)) - .withDestinationSyncMode(DestinationSyncMode.OVERWRITE))); + CatalogHelpers.createConfiguredAirbyteStream( + "test", + "test_staging", + Field.of("id", JsonSchemaPrimitive.NUMBER), + Field.of("name", JsonSchemaPrimitive.STRING)) + .withDestinationSyncMode(DestinationSyncMode.OVERWRITE))); } } diff --git a/airbyte-integrations/connectors/source-hellobaton/.dockerignore b/airbyte-integrations/connectors/source-hellobaton/.dockerignore new file mode 100644 index 0000000000000..2e018bfa07087 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/.dockerignore @@ -0,0 +1,7 @@ +* +!Dockerfile +!Dockerfile.test +!main.py +!source_hellobaton +!setup.py +!secrets diff --git a/airbyte-integrations/connectors/source-hellobaton/Dockerfile b/airbyte-integrations/connectors/source-hellobaton/Dockerfile new file mode 100644 index 0000000000000..f8bf6c037c6e1 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/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_hellobaton ./source_hellobaton + +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-hellobaton diff --git a/airbyte-integrations/connectors/source-hellobaton/README.md b/airbyte-integrations/connectors/source-hellobaton/README.md new file mode 100644 index 0000000000000..1b3bc774802a2 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/README.md @@ -0,0 +1,132 @@ +# Hellobaton Source + +This is the repository for the Hellobaton source connector, written in Python. +For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/hellobaton). + +## 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: +``` +python -m venv .venv +``` + +This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your +development environment of choice. To activate it from the terminal, run: +``` +source .venv/bin/activate +pip install -r requirements.txt +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-hellobaton:build +``` + +#### Create credentials +**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/hellobaton) +to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_hellobaton/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 hellobaton 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-hellobaton:dev +``` + +You can also build the connector image via Gradle: +``` +./gradlew :airbyte-integrations:connectors:source-hellobaton: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-hellobaton:dev spec +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-hellobaton:dev check --config /secrets/config.json +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-hellobaton:dev discover --config /secrets/config.json +docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-hellobaton: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-hellobaton:unitTest +``` +To run acceptance and custom integration tests: +``` +./gradlew :airbyte-integrations:connectors:source-hellobaton: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-hellobaton/acceptance-test-config.yml b/airbyte-integrations/connectors/source-hellobaton/acceptance-test-config.yml new file mode 100644 index 0000000000000..79787e5b96207 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/acceptance-test-config.yml @@ -0,0 +1,20 @@ +# 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-hellobaton:dev +tests: + spec: + - spec_path: "source_hellobaton/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: ["templates", "time_entries"] + full_refresh: + - config_path: "secrets/config.json" + configured_catalog_path: "integration_tests/configured_catalog.json" diff --git a/airbyte-integrations/connectors/source-hellobaton/acceptance-test-docker.sh b/airbyte-integrations/connectors/source-hellobaton/acceptance-test-docker.sh new file mode 100644 index 0000000000000..e4d8b1cef8961 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/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-hellobaton/build.gradle b/airbyte-integrations/connectors/source-hellobaton/build.gradle new file mode 100644 index 0000000000000..55c27d3615676 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/build.gradle @@ -0,0 +1,9 @@ +plugins { + id 'airbyte-python' + id 'airbyte-docker' + id 'airbyte-source-acceptance-test' +} + +airbytePython { + moduleDirectory 'source_hellobaton' +} diff --git a/airbyte-integrations/connectors/source-hellobaton/integration_tests/__init__.py b/airbyte-integrations/connectors/source-hellobaton/integration_tests/__init__.py new file mode 100644 index 0000000000000..46b7376756ec6 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/integration_tests/__init__.py @@ -0,0 +1,3 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# diff --git a/airbyte-integrations/connectors/source-hellobaton/integration_tests/abnormal_state.json b/airbyte-integrations/connectors/source-hellobaton/integration_tests/abnormal_state.json new file mode 100644 index 0000000000000..52b0f2c2118f4 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/integration_tests/abnormal_state.json @@ -0,0 +1,5 @@ +{ + "todo-stream-name": { + "todo-field-name": "todo-abnormal-value" + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/integration_tests/acceptance.py b/airbyte-integrations/connectors/source-hellobaton/integration_tests/acceptance.py new file mode 100644 index 0000000000000..056971f954502 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/integration_tests/acceptance.py @@ -0,0 +1,16 @@ +# +# 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.""" + # TODO: setup test dependencies if needed. otherwise remove the TODO comments + yield + # TODO: clean up test dependencies diff --git a/airbyte-integrations/connectors/source-hellobaton/integration_tests/catalog.json b/airbyte-integrations/connectors/source-hellobaton/integration_tests/catalog.json new file mode 100644 index 0000000000000..db86d334a63d8 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/integration_tests/catalog.json @@ -0,0 +1,9 @@ +{ + "streams": [ + { + "name": "tasks", + "supported_sync_modes": ["full_refresh"], + "json_schema": {} + } + ] +} diff --git a/airbyte-integrations/connectors/source-hellobaton/integration_tests/configured_catalog.json b/airbyte-integrations/connectors/source-hellobaton/integration_tests/configured_catalog.json new file mode 100644 index 0000000000000..8261b74756911 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/integration_tests/configured_catalog.json @@ -0,0 +1,103 @@ +{ + "streams": [ + { + "stream": { + "name": "activity", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "companies", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "milestones", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "phases", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "project_attachments", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "projects", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "task_attachments", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "tasks", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "templates", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "time_entries", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "users", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-hellobaton/integration_tests/invalid_config.json b/airbyte-integrations/connectors/source-hellobaton/integration_tests/invalid_config.json new file mode 100644 index 0000000000000..792b2d6ed172b --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/integration_tests/invalid_config.json @@ -0,0 +1,4 @@ +{ + "api_key": "invalid-api-key", + "company": "non-valid" +} diff --git a/airbyte-integrations/connectors/source-hellobaton/integration_tests/sample_config.json b/airbyte-integrations/connectors/source-hellobaton/integration_tests/sample_config.json new file mode 100644 index 0000000000000..792b2d6ed172b --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/integration_tests/sample_config.json @@ -0,0 +1,4 @@ +{ + "api_key": "invalid-api-key", + "company": "non-valid" +} diff --git a/airbyte-integrations/connectors/source-hellobaton/integration_tests/sample_state.json b/airbyte-integrations/connectors/source-hellobaton/integration_tests/sample_state.json new file mode 100644 index 0000000000000..3587e579822d0 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/integration_tests/sample_state.json @@ -0,0 +1,5 @@ +{ + "todo-stream-name": { + "todo-field-name": "value" + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/main.py b/airbyte-integrations/connectors/source-hellobaton/main.py new file mode 100644 index 0000000000000..978a73078c1b6 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/main.py @@ -0,0 +1,13 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +import sys + +from airbyte_cdk.entrypoint import launch +from source_hellobaton import SourceHellobaton + +if __name__ == "__main__": + source = SourceHellobaton() + launch(source, sys.argv[1:]) diff --git a/airbyte-integrations/connectors/source-hellobaton/requirements.txt b/airbyte-integrations/connectors/source-hellobaton/requirements.txt new file mode 100644 index 0000000000000..0411042aa0911 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/requirements.txt @@ -0,0 +1,2 @@ +-e ../../bases/source-acceptance-test +-e . diff --git a/airbyte-integrations/connectors/source-hellobaton/sample_files/configured_catalog.json b/airbyte-integrations/connectors/source-hellobaton/sample_files/configured_catalog.json new file mode 100644 index 0000000000000..0a6393a2c4ecf --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/sample_files/configured_catalog.json @@ -0,0 +1,815 @@ +{ + "streams": [ + { + "stream": { + "name": "activity", + "json_schema": { + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "type": { + "type": ["string", "null"] + }, + "group": { + "type": "string" + }, + "parent": { + "type": ["string", "null"] + }, + "child": { + "type": ["string", "null"] + }, + "actor": { + "type": "string" + }, + "project": { + "type": "string" + }, + "parent_type": { + "type": "string" + }, + "child_type": { + "type": "string" + }, + "meta": { + "type": ["object", "null"] + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "companies", + "json_schema": { + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "milestones", + "json_schema": { + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": ["string", "null"] + }, + "project": { + "type": "string" + }, + "task_list": { + "type": "string" + }, + "phase": { + "type": ["object", "null"], + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "name": { + "type": "string" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + }, + "deadline_fixed": { + "type": "boolean" + }, + "deadline_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "risk_profiles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "risk_level": { + "type": "string" + }, + "formula": { + "type": "string" + }, + "over_run": { + "type": "integer" + } + } + } + }, + "start_datetime": { + "type": "string" + }, + "finish_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "created_from": { + "type": ["string", "null"] + }, + "duration": { + "type": "integer" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "projects", + "json_schema": { + "properties": { + "_self": { + "type": "string" + }, + "annual_contract_value": { + "type": "string" + }, + "attachment_list": { + "type": "string" + }, + "client_systems": { + "type": ["string", "null"] + }, + "companies": { + "type": "array", + "items": { + "type": "string" + } + }, + "completed_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "cost": { + "type": ["integer", "null"] + }, + "created": { + "type": "string", + "format": "date-time" + }, + "created_from": { + "type": ["string", "null"] + }, + "created_from_template": { + "type": ["string", "null"] + }, + "creator": { + "type": ["string", "null"] + }, + "deadline_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "estimated_duration": { + "type": ["integer", "null"] + }, + "id": { + "type": "integer" + }, + "implementation_budget": { + "type": "string" + }, + "milestone_list": { + "type": "string" + }, + "modified": { + "type": ["string", "null"], + "format": "date-time" + }, + "phase": { + "type": ["object", "null"], + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "name": { + "type": ["string", "null"] + }, + "order": { + "type": "integer" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + }, + "risk_profiles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "risk_score": { + "type": "number" + }, + "level": { + "type": "string" + }, + "variance": { + "type": "integer" + }, + "formula": { + "type": "string" + }, + "projected_golive_datetime": { + "type": ["string", "null"], + "format": "date-time" + } + } + } + }, + "start_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "started_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "status": { + "type": "string" + }, + "task_list": { + "type": "string" + }, + "time_entry_list": { + "type": "string" + }, + "title": { + "type": "string" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "phases", + "json_schema": { + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "name": { + "type": ["string", "null"] + }, + "order": { + "type": "integer" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "project_attachments", + "json_schema": { + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "project": { + "type": "string" + }, + "url": { + "type": "string" + }, + "label": { + "type": ["string", "null"] + }, + "created_by": { + "type": "string" + }, + "type": { + "type": "string" + }, + "is_sow": { + "type": "boolean" + }, + "original_filename": { + "type": ["string", "null"] + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "datetime" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "tasks", + "json_schema": { + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": ["string", "null"] + }, + "project": { + "type": "string" + }, + "status": { + "type": "string" + }, + "dependency": { + "type": ["string", "null"] + }, + "start_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "due_datetime": { + "type": "string", + "format": "date-time" + }, + "started_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "finished_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "started_overridden_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "finished_overridden_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "estimated_duration": { + "type": ["integer", "null"] + }, + "milestone": { + "type": "string" + }, + "created_by": { + "type": ["string", "null"] + }, + "assigned_to": { + "type": ["string", "null"] + }, + "created_from": { + "type": ["string", "null"] + }, + "risk_profiles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "risk_level": { + "type": "string" + }, + "formula": { + "type": "string" + }, + "over_run": { + "type": "integer" + }, + "task_variance": { + "type": "integer" + }, + "cool_down": { + "type": "integer" + }, + "reason": { + "type": "integer" + }, + "duration": { + "type": "integer" + }, + "estimated_duration": { + "type": "integer" + } + } + } + }, + "time_entry_list": { + "type": "string" + }, + "attachment_list": { + "type": "string" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "task_attachments", + "json_schema": { + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "task": { + "type": "string" + }, + "url": { + "type": "string" + }, + "type": { + "type": "string" + }, + "label": { + "type": ["string", "null"] + }, + "deliverable": { + "type": "boolean" + }, + "requires_approval": { + "type": "boolean" + }, + "approved": { + "type": ["boolean", "null"] + }, + "revision_task": { + "type": ["string", "null"] + }, + "original_filename": { + "type": ["string", "null"] + }, + "created_by": { + "type": ["string", "null"] + }, + "created": { + "type": "string" + }, + "modified": { + "type": "string" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "templates", + "json_schema": { + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "title": { + "type": "string" + }, + "status": { + "type": "string" + }, + "cost": { + "type": ["string", "null"] + }, + "annual_contract_value": { + "type": ["string", "null"] + }, + "implementation_budget": { + "type": ["string", "null"] + }, + "estimated_duration": { + "type": ["integer", "null"] + }, + "created_from_template": { + "type": ["string", "null"] + }, + "created_from": { + "type": ["string", "null"] + }, + "start_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "started_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "deadline_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "completed_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "client_systems": { + "type": ["string", "null"] + }, + "phase": { + "type": ["object", "null"], + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "order": { + "type": "integer" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + }, + "creator": { + "type": ["string", "null"] + }, + "task_list": { + "type": "string" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "time_entries", + "json_schema": { + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "user": { + "type": "string" + }, + "created_by": { + "type": "string" + }, + "project": { + "type": "string" + }, + "task": { + "type": ["string", "null"] + }, + "rate": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "hourly_rate": { + "type": "string" + } + } + }, + "started_at": { + "type": ["string", "null"], + "format": "date-time" + }, + "ended_at": { + "type": ["string", "null"], + "format": "date-time" + }, + "reference_date": { + "type": "string", + "format": "date-time" + }, + "billable": { + "type": "boolean" + }, + "calculated_duration": { + "type": ["integer", "null"] + }, + "inputted_duration": { + "type": ["integer", "null"] + }, + "notes": { + "type": "string" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "users", + "json_schema": { + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "first_name": { + "type": "string" + }, + "last_name": { + "type": "string" + }, + "email": { + "type": "string" + }, + "account_type": { + "type": "string" + }, + "job_title": { + "type": "string" + }, + "company": { + "type": "string" + }, + "avatar_url": { + "type": ["string", "null"] + }, + "created_by": { + "type": ["string", "null"] + }, + "signed_up_at": { + "type": ["string", "null"], + "format": "date-time" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + } + }, + "supported_sync_modes": ["full_refresh"], + "source_defined_primary_key": [["id"]], + "user_defined_primary_key": [["id"]], + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-hellobaton/sample_files/sample_config.json b/airbyte-integrations/connectors/source-hellobaton/sample_files/sample_config.json new file mode 100644 index 0000000000000..cc58f6f0f835c --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/sample_files/sample_config.json @@ -0,0 +1,4 @@ +{ + "company": "google", + "api_key": "" +} diff --git a/airbyte-integrations/connectors/source-hellobaton/setup.py b/airbyte-integrations/connectors/source-hellobaton/setup.py new file mode 100644 index 0000000000000..eda15c9efb4b2 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/setup.py @@ -0,0 +1,29 @@ +# +# 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", +] + +setup( + name="source_hellobaton", + description="Source implementation for Hellobaton.", + author="Airbyte", + author_email="contact@airbyte.io", + 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-hellobaton/source_hellobaton/__init__.py b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/__init__.py new file mode 100644 index 0000000000000..9137ca503a673 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/__init__.py @@ -0,0 +1,8 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +from .source import SourceHellobaton + +__all__ = ["SourceHellobaton"] diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/activity.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/activity.json new file mode 100644 index 0000000000000..cc4a631b4d81f --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/activity.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "type": { + "type": ["string", "null"] + }, + "group": { + "type": "string" + }, + "parent": { + "type": ["string", "null"] + }, + "child": { + "type": ["string", "null"] + }, + "actor": { + "type": ["string", "null"] + }, + "project": { + "type": ["string", "null"] + }, + "parent_type": { + "type": ["string", "null"] + }, + "child_type": { + "type": ["string", "null"] + }, + "meta": { + "type": ["object", "null"] + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/companies.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/companies.json new file mode 100644 index 0000000000000..ebbb25699ee35 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/companies.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "integer" + }, + + "_self": { + "type": "string" + }, + + "name": { + "type": "string" + }, + + "type": { + "type": "string" + }, + + "created": { + "type": "string", + "format": "date-time" + }, + + "modified": { + "type": "string", + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/milestones.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/milestones.json new file mode 100644 index 0000000000000..16e0f0060b470 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/milestones.json @@ -0,0 +1,95 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": ["string", "null"] + }, + "project": { + "type": "string" + }, + "task_list": { + "type": "string" + }, + "phase": { + "type": ["object", "null"], + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "name": { + "type": "string" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + }, + "deadline_fixed": { + "type": "boolean" + }, + "deadline_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "risk_profiles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "risk_level": { + "type": "string" + }, + "formula": { + "type": "string" + }, + "over_run": { + "type": "integer" + } + } + } + }, + "start_datetime": { + "type": "string" + }, + "finish_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "created_from": { + "type": ["string", "null"] + }, + "duration": { + "type": "integer" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/phases.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/phases.json new file mode 100644 index 0000000000000..476437ea6774b --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/phases.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "name": { + "type": ["string", "null"] + }, + "order": { + "type": "integer" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/project_attachments.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/project_attachments.json new file mode 100644 index 0000000000000..7d90c8628a27d --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/project_attachments.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "project": { + "type": "string" + }, + "url": { + "type": "string" + }, + "label": { + "type": ["string", "null"] + }, + "created_by": { + "type": "string" + }, + "type": { + "type": "string" + }, + "is_sow": { + "type": "boolean" + }, + "original_filename": { + "type": ["string", "null"] + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "datetime" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/projects.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/projects.json new file mode 100644 index 0000000000000..e52493d79752b --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/projects.json @@ -0,0 +1,137 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "_self": { + "type": "string" + }, + "annual_contract_value": { + "type": "string" + }, + "attachment_list": { + "type": "string" + }, + "client_systems": { + "type": ["string", "null"] + }, + "companies": { + "type": "array", + "items": { + "type": "string" + } + }, + "completed_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "cost": { + "type": ["integer", "null"] + }, + "created": { + "type": "string", + "format": "date-time" + }, + "created_from": { + "type": ["string", "null"] + }, + "created_from_template": { + "type": ["string", "null"] + }, + "creator": { + "type": ["string", "null"] + }, + "deadline_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "estimated_duration": { + "type": ["integer", "null"] + }, + "id": { + "type": "integer" + }, + "implementation_budget": { + "type": "string" + }, + "milestone_list": { + "type": "string" + }, + "modified": { + "type": ["string", "null"], + "format": "date-time" + }, + "phase": { + "type": ["object", "null"], + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "name": { + "type": ["string", "null"] + }, + "order": { + "type": "integer" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + }, + "risk_profiles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "risk_score": { + "type": "number" + }, + "level": { + "type": "string" + }, + "variance": { + "type": "integer" + }, + "formula": { + "type": "string" + }, + "projected_golive_datetime": { + "type": ["string", "null"], + "format": "date-time" + } + } + } + }, + "start_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "started_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "status": { + "type": "string" + }, + "task_list": { + "type": "string" + }, + "time_entry_list": { + "type": "string" + }, + "title": { + "type": "string" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/task_attachments.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/task_attachments.json new file mode 100644 index 0000000000000..90da99ec9d51f --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/task_attachments.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "task": { + "type": "string" + }, + "url": { + "type": "string" + }, + "type": { + "type": "string" + }, + "label": { + "type": ["string", "null"] + }, + "deliverable": { + "type": "boolean" + }, + "requires_approval": { + "type": "boolean" + }, + "approved": { + "type": ["boolean", "null"] + }, + "revision_task": { + "type": ["string", "null"] + }, + "original_filename": { + "type": ["string", "null"] + }, + "created_by": { + "type": ["string", "null"] + }, + "created": { + "type": "string" + }, + "modified": { + "type": "string" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/tasks.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/tasks.json new file mode 100644 index 0000000000000..980c82d5f5ced --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/tasks.json @@ -0,0 +1,116 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": ["string", "null"] + }, + "project": { + "type": "string" + }, + "status": { + "type": "string" + }, + "dependency": { + "type": ["string", "null"] + }, + "start_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "due_datetime": { + "type": "string", + "format": "date-time" + }, + "started_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "finished_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "started_overridden_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "finished_overridden_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "estimated_duration": { + "type": ["integer", "null"] + }, + "milestone": { + "type": "string" + }, + "created_by": { + "type": ["string", "null"] + }, + "assigned_to": { + "type": ["string", "null"] + }, + "created_from": { + "type": ["string", "null"] + }, + "risk_profiles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "risk_level": { + "type": "string" + }, + "formula": { + "type": "string" + }, + "over_run": { + "type": "integer" + }, + "task_variance": { + "type": "integer" + }, + "cool_down": { + "type": "integer" + }, + "reason": { + "type": "integer" + }, + "duration": { + "type": "integer" + }, + "estimated_duration": { + "type": "integer" + } + } + } + }, + "time_entry_list": { + "type": "string" + }, + "attachment_list": { + "type": "string" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/templates.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/templates.json new file mode 100644 index 0000000000000..e2d02743d883a --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/templates.json @@ -0,0 +1,84 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "title": { + "type": "string" + }, + "status": { + "type": "string" + }, + "cost": { + "type": ["string", "null"] + }, + "annual_contract_value": { + "type": ["string", "null"] + }, + "implementation_budget": { + "type": ["string", "null"] + }, + "estimated_duration": { + "type": ["integer", "null"] + }, + "created_from_template": { + "type": ["string", "null"] + }, + "created_from": { + "type": ["string", "null"] + }, + "start_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "started_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "deadline_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "completed_datetime": { + "type": ["string", "null"], + "format": "date-time" + }, + "client_systems": { + "type": ["string", "null"] + }, + "phase": { + "type": ["object", "null"], + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "order": { + "type": "integer" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } + }, + "creator": { + "type": ["string", "null"] + }, + "task_list": { + "type": "string" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/time_entries.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/time_entries.json new file mode 100644 index 0000000000000..7ea2f5553be25 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/time_entries.json @@ -0,0 +1,60 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "user": { + "type": "string" + }, + "created_by": { + "type": "string" + }, + "project": { + "type": "string" + }, + "task": { + "type": ["string", "null"] + }, + "rate": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "hourly_rate": { + "type": "string" + } + } + }, + "started_at": { + "type": ["string", "null"], + "format": "date-time" + }, + "ended_at": { + "type": ["string", "null"], + "format": "date-time" + }, + "reference_date": { + "type": "string", + "format": "date-time" + }, + "billable": { + "type": "boolean" + }, + "calculated_duration": { + "type": ["integer", "null"] + }, + "inputted_duration": { + "type": ["integer", "null"] + }, + "notes": { + "type": "string" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/users.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/users.json new file mode 100644 index 0000000000000..3e6d3d73a6037 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/schemas/users.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "integer" + }, + "_self": { + "type": "string" + }, + "first_name": { + "type": "string" + }, + "last_name": { + "type": "string" + }, + "email": { + "type": "string" + }, + "account_type": { + "type": "string" + }, + "job_title": { + "type": "string" + }, + "company": { + "type": "string" + }, + "avatar_url": { + "type": ["string", "null"] + }, + "created_by": { + "type": ["string", "null"] + }, + "signed_up_at": { + "type": ["string", "null"], + "format": "date-time" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "modified": { + "type": "string", + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/source.py b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/source.py new file mode 100644 index 0000000000000..1c6edc6479c45 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/source.py @@ -0,0 +1,59 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +from typing import Any, List, Mapping, Tuple + +import requests +from airbyte_cdk import AirbyteLogger +from airbyte_cdk.sources import AbstractSource +from airbyte_cdk.sources.streams import Stream + +from .streams import ( + Activity, + Companies, + Milestones, + Phases, + ProjectAttachments, + Projects, + TaskAttachments, + Tasks, + Templates, + TimeEntries, + Users, +) + +STREAMS = [Activity, Companies, Milestones, Projects, Phases, ProjectAttachments, Tasks, TaskAttachments, Templates, TimeEntries, Users] + + +# Source +class SourceHellobaton(AbstractSource): + def check_connection(self, logger: AirbyteLogger, config: Mapping[str, any]) -> Tuple[bool, any]: + """ + :param config: the user-input config object conforming to the connector's spec.json + :param logger: logger object + :return Tuple[bool, any]: (True, None) if the input config can be used to connect to the API successfully, (False, error) otherwise. + """ + url_template = "https://{company}.hellobaton.com/api/" + try: + params = { + "api_key": config["api_key"], + } + base_url = url_template.format(company=config["company"]) + # This is just going to return a mapping of available endpoints + response = requests.get(base_url, params=params) + status_code = response.status_code + logger.info(f"Status code: {status_code}") + if status_code == 200: + return True, None + + except Exception as e: + return False, e + + def streams(self, config: Mapping[str, Any]) -> List[Stream]: + """ + + :param config: A Mapping of the user input configuration as defined in the connector spec. + """ + return [stream(company=config["company"], api_key=config["api_key"]) for stream in STREAMS] diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/spec.json b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/spec.json new file mode 100644 index 0000000000000..50793f64fae2e --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/spec.json @@ -0,0 +1,22 @@ +{ + "documentationUrl": "https://docsurl.com", + "connectionSpecification": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Hellobaton Spec", + "type": "object", + "required": ["api_key", "company"], + "additionalProperties": false, + "properties": { + "api_key": { + "type": "string", + "description": "authentication key required to access the api endpoints", + "airbyte_secret": true + }, + "company": { + "type": "string", + "description": "Company name that generates your base api url", + "examples": ["google", "facebook", "microsoft"] + } + } + } +} diff --git a/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/streams.py b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/streams.py new file mode 100644 index 0000000000000..9b36eab622041 --- /dev/null +++ b/airbyte-integrations/connectors/source-hellobaton/source_hellobaton/streams.py @@ -0,0 +1,204 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +from abc import ABC +from typing import Any, Iterable, Mapping, MutableMapping, Optional +from urllib.parse import parse_qs, urlparse + +import requests +from airbyte_cdk.sources.streams.http import HttpStream + + +# Basic full refresh stream +class HellobatonStream(HttpStream, ABC): + """ + This class represents a stream output by the connector. + This is an abstract base class meant to contain all the common functionality at the API level e.g: the API base URL, pagination strategy, + parsing responses etc.. + """ + + page_size: int = 100 + primary_key: str = "id" + + def __init__(self, company: str, api_key: str, **kwargs): + super().__init__(**kwargs) + self.api_key = api_key + self.company = company + + @property + def url_base(self) -> str: + """ + Using this method instead of class init to dynamically generate base url based on config + """ + company = self.company + return f"https://{company}.hellobaton.com/api/" + + def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]: + """ + Logic to generate next page token based on the response + """ + + payload = response.json() + result_count = payload["count"] + + if result_count > self.page_size: + query_string = urlparse(payload["next"]).query + next_page_token = parse_qs(query_string).get("page", None) + + else: + next_page_token = None + + return next_page_token + + 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]: + """ + API request params which expect an api key for auth and any pagination is done using defined in the next_page_token method + """ + + params = {"api_key": self.api_key, "page_size": self.page_size, "page": next_page_token} + + return params + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + """ + May want to add logic here to unpack foreign keys from urls but tbd + For now each response record is accessed through the results key in the JSON payload + """ + for results in response.json()["results"]: + yield results + + +class Activity(HellobatonStream): + """ + Activity stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "activity" + + +class Companies(HellobatonStream): + """ + Companies stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "companies" + + +class Milestones(HellobatonStream): + """ + Milestones stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "milestones" + + +class Phases(HellobatonStream): + """ + Phases stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "phases" + + +class ProjectAttachments(HellobatonStream): + """ + Project attachments stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "project_attachments" + + +class Projects(HellobatonStream): + """ + Projects stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "projects" + + +class Tasks(HellobatonStream): + """ + Tasks stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "tasks" + + +class TaskAttachments(HellobatonStream): + """ + Task attachments stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "task_attachments" + + +class Templates(HellobatonStream): + """ + Templates stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "templates" + + +class TimeEntries(HellobatonStream): + """ + Time entries stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "time_entries" + + +class Users(HellobatonStream): + """ + Users stream class + """ + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + + return "users" diff --git a/docs/integrations/sources/hellobaton.md b/docs/integrations/sources/hellobaton.md new file mode 100644 index 0000000000000..16d8d401d884f --- /dev/null +++ b/docs/integrations/sources/hellobaton.md @@ -0,0 +1,50 @@ +# Baton + +## Sync overview + +This source can sync data from the [baton API](https://app.hellobaton.com/api/redoc/). At present this connector only supports full refresh syncs meaning that each time you use the connector it will sync all available records from scratch. Please use cautiously if you expect your API to have a lot of records. + +## This Source Supports the Following Streams + +* activity +* companies +* milestones +* phases +* project_attachments +* projects +* task_attachemnts +* tasks +* templates +* time_entries +* users + +Baton adds new streams fairly regularly please submit an issue or PR if this project doesn't support required streams for your use case. + +### Data type mapping + +| Integration Type | Airbyte Type | Notes | +| :--- | :--- | :--- | +| `string` | `string` | | +| `integer` | `integer` | | +| `number` | `number` | | +| `array` | `array` | | +| `object` | `object` | | + +### Features + +| Feature | Supported?\(Yes/No\) | Notes | +| :--- | :--- | :--- | +| Full Refresh Sync | Yes | | +| Incremental Sync | No | | +| Namespaces | No | | + +### Performance considerations + +The connector is rate limited at 1000 requests per minute per api key. If you find yourself receiving errors contact your customer success manager and request a rate limit increase. + +## Getting started + +### Requirements + +* Baton account +* Baton api key \ No newline at end of file