From f2d8065bfd3eb0647f340dd0a18cead0eee76753 Mon Sep 17 00:00:00 2001 From: Ricky Renner Date: Fri, 15 Apr 2022 13:24:08 -0400 Subject: [PATCH 1/9] added hubplanner source connector --- .../source-hubplanner/.dockerignore | 6 + .../connectors/source-hubplanner/Dockerfile | 38 ++ .../connectors/source-hubplanner/README.md | 132 +++++ .../acceptance-test-config.yml | 30 ++ .../acceptance-test-docker.sh | 16 + .../connectors/source-hubplanner/build.gradle | 9 + .../integration_tests/__init__.py | 3 + .../integration_tests/abnormal_state.json | 5 + .../integration_tests/acceptance.py | 16 + .../integration_tests/catalog.json | 39 ++ .../integration_tests/configured_catalog.json | 22 + .../integration_tests/invalid_config.json | 3 + .../integration_tests/sample_config.json | 3 + .../integration_tests/sample_state.json | 5 + .../connectors/source-hubplanner/main.py | 13 + .../source-hubplanner/requirements.txt | 2 + .../sample_files/configured_catalog.json | 23 + .../connectors/source-hubplanner/setup.py | 29 ++ .../source_hubplanner/__init__.py | 8 + .../source_hubplanner/schemas/TODO.md | 25 + .../source_hubplanner/schemas/customers.json | 16 + .../source_hubplanner/schemas/employees.json | 19 + .../source_hubplanner/schemas/projects.json | 491 ++++++++++++++++++ .../source_hubplanner/source.py | 235 +++++++++ .../source_hubplanner/spec.json | 17 + .../source-hubplanner/unit_tests/__init__.py | 3 + .../unit_tests/test_incremental_streams.py | 59 +++ .../unit_tests/test_source.py | 22 + .../unit_tests/test_streams.py | 83 +++ 29 files changed, 1372 insertions(+) create mode 100644 airbyte-integrations/connectors/source-hubplanner/.dockerignore create mode 100644 airbyte-integrations/connectors/source-hubplanner/Dockerfile create mode 100644 airbyte-integrations/connectors/source-hubplanner/README.md create mode 100644 airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml create mode 100644 airbyte-integrations/connectors/source-hubplanner/acceptance-test-docker.sh create mode 100644 airbyte-integrations/connectors/source-hubplanner/build.gradle create mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/__init__.py create mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/abnormal_state.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/acceptance.py create mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/catalog.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/invalid_config.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_config.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_state.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/main.py create mode 100644 airbyte-integrations/connectors/source-hubplanner/requirements.txt create mode 100644 airbyte-integrations/connectors/source-hubplanner/sample_files/configured_catalog.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/setup.py create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/__init__.py create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/TODO.md create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/customers.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/employees.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/unit_tests/__init__.py create mode 100644 airbyte-integrations/connectors/source-hubplanner/unit_tests/test_incremental_streams.py create mode 100644 airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py create mode 100644 airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py diff --git a/airbyte-integrations/connectors/source-hubplanner/.dockerignore b/airbyte-integrations/connectors/source-hubplanner/.dockerignore new file mode 100644 index 0000000000000..beb33d510fd42 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/.dockerignore @@ -0,0 +1,6 @@ +* +!Dockerfile +!main.py +!source_hubplanner +!setup.py +!secrets diff --git a/airbyte-integrations/connectors/source-hubplanner/Dockerfile b/airbyte-integrations/connectors/source-hubplanner/Dockerfile new file mode 100644 index 0000000000000..28ec4530e309b --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/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_hubplanner ./source_hubplanner + +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-hubplanner diff --git a/airbyte-integrations/connectors/source-hubplanner/README.md b/airbyte-integrations/connectors/source-hubplanner/README.md new file mode 100644 index 0000000000000..f38554dc57851 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/README.md @@ -0,0 +1,132 @@ +# Hubplanner Source + +This is the repository for the Hubplanner source connector, written in Python. +For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/hubplanner). + +## 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-hubplanner:build +``` + +#### Create credentials +**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/hubplanner) +to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_hubplanner/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 hubplanner 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-hubplanner:dev +``` + +You can also build the connector image via Gradle: +``` +./gradlew :airbyte-integrations:connectors:source-hubplanner: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-hubplanner:dev spec +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-hubplanner:dev check --config /secrets/config.json +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-hubplanner:dev discover --config /secrets/config.json +docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-hubplanner: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-hubplanner:unitTest +``` +To run acceptance and custom integration tests: +``` +./gradlew :airbyte-integrations:connectors:source-hubplanner: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-hubplanner/acceptance-test-config.yml b/airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml new file mode 100644 index 0000000000000..5784157cd8dab --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml @@ -0,0 +1,30 @@ +# 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-hubplanner:dev +tests: + spec: + - spec_path: "source_hubplanner/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 + incremental: # TODO if your connector does not implement incremental sync, remove this block + - 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-hubplanner/acceptance-test-docker.sh b/airbyte-integrations/connectors/source-hubplanner/acceptance-test-docker.sh new file mode 100644 index 0000000000000..c51577d10690c --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/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-hubplanner/build.gradle b/airbyte-integrations/connectors/source-hubplanner/build.gradle new file mode 100644 index 0000000000000..c75aea3d3c219 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/build.gradle @@ -0,0 +1,9 @@ +plugins { + id 'airbyte-python' + id 'airbyte-docker' + id 'airbyte-source-acceptance-test' +} + +airbytePython { + moduleDirectory 'source_hubplanner' +} diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/__init__.py b/airbyte-integrations/connectors/source-hubplanner/integration_tests/__init__.py new file mode 100644 index 0000000000000..46b7376756ec6 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/integration_tests/__init__.py @@ -0,0 +1,3 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/abnormal_state.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/abnormal_state.json new file mode 100644 index 0000000000000..52b0f2c2118f4 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/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-hubplanner/integration_tests/acceptance.py b/airbyte-integrations/connectors/source-hubplanner/integration_tests/acceptance.py new file mode 100644 index 0000000000000..056971f954502 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/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-hubplanner/integration_tests/catalog.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/catalog.json new file mode 100644 index 0000000000000..6799946a68514 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/integration_tests/catalog.json @@ -0,0 +1,39 @@ +{ + "streams": [ + { + "name": "TODO fix this file", + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": "column1", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "column1": { + "type": "string" + }, + "column2": { + "type": "number" + } + } + } + }, + { + "name": "table1", + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": false, + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "column1": { + "type": "string" + }, + "column2": { + "type": "number" + } + } + } + } + ] +} diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json new file mode 100644 index 0000000000000..36f0468db0d8f --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/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": "employees", + "json_schema": {}, + "supported_sync_modes": ["full_refresh", "incremental"] + }, + "sync_mode": "incremental", + "destination_sync_mode": "append" + } + ] +} diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/invalid_config.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/invalid_config.json new file mode 100644 index 0000000000000..f3732995784f2 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/integration_tests/invalid_config.json @@ -0,0 +1,3 @@ +{ + "todo-wrong-field": "this should be an incomplete config file, used in standard tests" +} diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_config.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_config.json new file mode 100644 index 0000000000000..ecc4913b84c74 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_config.json @@ -0,0 +1,3 @@ +{ + "fix-me": "TODO" +} diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_state.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_state.json new file mode 100644 index 0000000000000..3587e579822d0 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_state.json @@ -0,0 +1,5 @@ +{ + "todo-stream-name": { + "todo-field-name": "value" + } +} diff --git a/airbyte-integrations/connectors/source-hubplanner/main.py b/airbyte-integrations/connectors/source-hubplanner/main.py new file mode 100644 index 0000000000000..0c28873e6191e --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/main.py @@ -0,0 +1,13 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +import sys + +from airbyte_cdk.entrypoint import launch +from source_hubplanner import SourceHubplanner + +if __name__ == "__main__": + source = SourceHubplanner() + launch(source, sys.argv[1:]) diff --git a/airbyte-integrations/connectors/source-hubplanner/requirements.txt b/airbyte-integrations/connectors/source-hubplanner/requirements.txt new file mode 100644 index 0000000000000..0411042aa0911 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/requirements.txt @@ -0,0 +1,2 @@ +-e ../../bases/source-acceptance-test +-e . diff --git a/airbyte-integrations/connectors/source-hubplanner/sample_files/configured_catalog.json b/airbyte-integrations/connectors/source-hubplanner/sample_files/configured_catalog.json new file mode 100644 index 0000000000000..ac2d7db2a730e --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/sample_files/configured_catalog.json @@ -0,0 +1,23 @@ +{ + "streams": [ + { + "stream": { + "name": "projects", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-hubplanner/setup.py b/airbyte-integrations/connectors/source-hubplanner/setup.py new file mode 100644 index 0000000000000..3eaaefd88fcec --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/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_hubplanner", + description="Source implementation for Hubplanner.", + 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-hubplanner/source_hubplanner/__init__.py b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/__init__.py new file mode 100644 index 0000000000000..3bcd0c2b2b7ae --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/__init__.py @@ -0,0 +1,8 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +from .source import SourceHubplanner + +__all__ = ["SourceHubplanner"] diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/TODO.md b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/TODO.md new file mode 100644 index 0000000000000..cf1efadb3c9c9 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/TODO.md @@ -0,0 +1,25 @@ +# TODO: Define your stream schemas +Your connector must describe the schema of each stream it can output using [JSONSchema](https://json-schema.org). + +The simplest way to do this is to describe the schema of your streams using one `.json` file per stream. You can also dynamically generate the schema of your stream in code, or you can combine both approaches: start with a `.json` file and dynamically add properties to it. + +The schema of a stream is the return value of `Stream.get_json_schema`. + +## Static schemas +By default, `Stream.get_json_schema` reads a `.json` file in the `schemas/` directory whose name is equal to the value of the `Stream.name` property. In turn `Stream.name` by default returns the name of the class in snake case. Therefore, if you have a class `class EmployeeBenefits(HttpStream)` the default behavior will look for a file called `schemas/employee_benefits.json`. You can override any of these behaviors as you need. + +Important note: any objects referenced via `$ref` should be placed in the `shared/` directory in their own `.json` files. + +## Dynamic schemas +If you'd rather define your schema in code, override `Stream.get_json_schema` in your stream class to return a `dict` describing the schema using [JSONSchema](https://json-schema.org). + +## Dynamically modifying static schemas +Override `Stream.get_json_schema` to run the default behavior, edit the returned value, then return the edited value: +``` +def get_json_schema(self): + schema = super().get_json_schema() + schema['dynamically_determined_property'] = "property" + return schema +``` + +Delete this file once you're done. Or don't. Up to you :) diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/customers.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/customers.json new file mode 100644 index 0000000000000..9a4b134858363 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/customers.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "string"] + }, + "name": { + "type": ["null", "string"] + }, + "signup_date": { + "type": ["null", "string"], + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/employees.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/employees.json new file mode 100644 index 0000000000000..2fa01a0fa1ff9 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/employees.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "string"] + }, + "name": { + "type": ["null", "string"] + }, + "years_of_service": { + "type": ["null", "integer"] + }, + "start_date": { + "type": ["null", "string"], + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json new file mode 100644 index 0000000000000..8f2be520b1e35 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json @@ -0,0 +1,491 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "_id": { + "type": [ + "null", + "string" + ] + }, + "name": { + "type": "string" + }, + "links": { + "properties": {}, + "type": [ + "null", + "object" + ] + }, + "notes": { + "type": [ + "null", + "string" + ] + }, + "createdDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "updatedDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "timeEntryEnabled": { + "type": [ + "null", + "boolean" + ] + }, + "timeEntryLocked": { + "type": [ + "null", + "boolean" + ] + }, + "timeEntryApproval": { + "type": [ + "null", + "boolean" + ] + }, + "resourceRates": { + "items": { + "properties": { + "resource": { + "type": [ + "null", + "string" + ] + }, + "companyBillingRateId": { + "type": [ + "null", + "string" + ] + }, + "companyBillingRate": { + "type": [ + "null", + "integer" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + }, + "includeBookedTimeReports": { + "type": [ + "null", + "boolean" + ] + }, + "includeBookedTimeGrid": { + "type": [ + "null", + "boolean" + ] + }, + "projectManagers": { + "items": { + "type": [ + "null", + "string" + ] + }, + "type": [ + "null", + "array" + ] + }, + "resources": { + "items": { + "type": [ + "null", + "string" + ] + }, + "type": [ + "null", + "array" + ] + }, + "workDays": { + "items": { + "type": [ + "null", + "boolean" + ] + }, + "type": [ + "null", + "array" + ] + }, + "useProjectDays": { + "type": [ + "null", + "boolean" + ] + }, + "budget": { + "properties": { + "hasBudget": { + "type": [ + "null", + "boolean" + ] + }, + "projectHours": { + "properties": { + "active": { + "type": [ + "null", + "boolean" + ] + }, + "hours": { + "type": [ + "null", + "integer" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "cashAmount": { + "properties": { + "active": { + "type": [ + "null", + "boolean" + ] + }, + "amount": { + "type": [ + "null", + "integer" + ] + }, + "currency": { + "type": [ + "null", + "string" + ] + }, + "billingRate": { + "properties": { + "useDefault": { + "type": [ + "null", + "boolean" + ] + }, + "rate": { + "type": [ + "null", + "integer" + ] + }, + "id": { + "type": [ + "null", + "integer" + ] + } + }, + "type": [ + "null", + "object" + ] + } + }, + "type": [ + "null", + "object" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "companyBillingRateId": { + "type": [ + "null", + "string" + ] + }, + "budgetHours": { + "type": [ + "null", + "number" + ] + }, + "budgetCashAmount": { + "type": [ + "null", + "number" + ] + }, + "budgetCurrency": { + "type": [ + "null", + "string" + ] + }, + "useStatusColor": { + "type": [ + "null", + "boolean" + ] + }, + "status": { + "type": [ + "null", + "string" + ] + }, + "useProjectDuration": { + "type": [ + "null", + "boolean" + ] + }, + "start": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "end": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "backgroundColor": { + "type": [ + "null", + "string" + ] + }, + "projectCode": { + "type": [ + "null", + "string" + ] + }, + "metadata": { + "type": [ + "null", + "string" + ] + }, + "customFields": { + "items": { + "properties": { + "_id": { + "type": "string" + }, + "templateId": { + "type": "string" + }, + "templateType": { + "type": "string" + }, + "templateLabel": { + "type": [ + "null", + "string" + ] + }, + "value": { + "type": [ + "null", + "string" + ] + }, + "choices": { + "items": { + "properties": { + "_id": { + "type": "string" + }, + "choiceId": { + "type": "string" + }, + "value": { + "type": [ + "null", + "string" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + }, + "timeEntryNoteRequired": { + "type": [ + "null", + "boolean" + ] + }, + "projectRate": { + "properties": { + "external": { + "properties": { + "defaultRateId": { + "type": [ + "null", + "integer" + ] + }, + "customRates": { + "items": { + "properties": { + "_id": { + "type": [ + "null", + "string" + ] + }, + "id": { + "type": [ + "null", + "string" + ] + }, + "resourceId": { + "type": [ + "null", + "string" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "internal": { + "properties": { + "customRates": { + "items": { + "properties": { + "_id": { + "type": [ + "null", + "string" + ] + }, + "id": { + "type": [ + "null", + "string" + ] + }, + "resourceId": { + "type": [ + "null", + "string" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + }, + "defaultRateId": { + "type": [ + "null", + "integer" + ] + } + }, + "type": [ + "null", + "object" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "note": { + "type": [ + "null", + "string" + ] + }, + "tags": { + "items": { + "type": [ + "null", + "string" + ] + }, + "type": [ + "null", + "array" + ] + } + } +} \ No newline at end of file diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py new file mode 100644 index 0000000000000..ae74d1eba7574 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py @@ -0,0 +1,235 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +from abc import ABC +from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple + +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 HttpAuthenticator + +""" +TODO: Most comments in this class are instructive and should be deleted after the source is implemented. + +This file provides a stubbed example of how to use the Airbyte CDK to develop both a source connector which supports full refresh or and an +incremental syncs from an HTTP API. + +The various TODOs are both implementation hints and steps - fulfilling all the TODOs should be sufficient to implement one basic and one incremental +stream from a source. This pattern is the same one used by Airbyte internally to implement connectors. + +The approach here is not authoritative, and devs are free to use their own judgement. + +There are additional required TODOs in the files within the integration_tests folder and the spec.json file. +""" + + +# Basic full refresh stream +class HubplannerStream(HttpStream, ABC): + """ + TODO remove this comment + + 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.. + + Each stream should extend this class (or another abstract subclass of it) to specify behavior unique to that stream. + + Typically for REST APIs each stream corresponds to a resource in the API. For example if the API + contains the endpoints + - GET v1/customers + - GET v1/employees + + then you should have three classes: + `class HubplannerStream(HttpStream, ABC)` which is the current class + `class Customers(HubplannerStream)` contains behavior to pull data for customers using v1/customers + `class Employees(HubplannerStream)` contains behavior to pull data for employees using v1/employees + + If some streams implement incremental sync, it is typical to create another class + `class IncrementalHubplannerStream((HubplannerStream), ABC)` then have concrete stream implementations extend it. An example + is provided below. + + See the reference docs for the full list of configurable options. + """ + url_base = "https://api.hubplanner.com/v1" + + def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]: + """ + TODO: Override this method to define a pagination strategy. If you will not be using pagination, no action is required - just return None. + + This method should return a Mapping (e.g: dict) containing whatever information required to make paginated requests. This dict is passed + to most other methods in this class to help you form headers, request bodies, query params, etc.. + + For example, if the API accepts a 'page' parameter to determine which page of the result to return, and a response from the API contains a + 'page' number, then this method should probably return a dict {'page': response.json()['page'] + 1} to increment the page count by 1. + The request_params method should then read the input next_page_token and set the 'page' param to next_page_token['page']. + + :param response: the most recent response from the API + :return If there is another page in the result, a mapping (e.g: dict) containing information needed to query the next page in the response. + If there are no more pages in the result, return None. + """ + return None + + 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]: + """ + TODO: Override this method to define any query parameters to be set. Remove this method if you don't need to define request params. + Usually contains common params e.g. pagination size etc. + """ + return {} + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + """ + TODO: Override this method to define how a response is parsed. + :return an iterable containing each record in the response + """ + yield {} + + +class Customers(HubplannerStream): + """ + TODO: Change class name to match the table/data source this stream corresponds to. + """ + + # TODO: Fill in the primary key. Required. This is usually a unique field in the stream, like an ID or a timestamp. + primary_key = "customer_id" + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + """ + TODO: Override this method to define the path this stream corresponds to. E.g. if the url is https://example-api.com/v1/customers then this + should return "customers". Required. + """ + return "customers" + + +# Basic incremental stream +class IncrementalHubplannerStream(HubplannerStream, ABC): + """ + TODO fill in details of this class to implement functionality related to incremental syncs for your connector. + if you do not need to implement incremental sync for any streams, remove this class. + """ + + # TODO: Fill in to checkpoint stream reads after N records. This prevents re-reading of data if the stream fails for any reason. + state_checkpoint_interval = None + + @property + def cursor_field(self) -> str: + """ + TODO + Override to return the cursor field used by this stream e.g: an API entity might always use created_at as the cursor field. This is + usually id or date based. This field's presence tells the framework this in an incremental stream. Required for incremental. + + :return str: The name of the cursor field. + """ + return [] + + def get_updated_state(self, current_stream_state: MutableMapping[str, Any], latest_record: Mapping[str, Any]) -> Mapping[str, Any]: + """ + Override to determine the latest state after reading the latest record. This typically compared the cursor_field from the latest record and + the current state and picks the 'most' recent cursor. This is how a stream's state is determined. Required for incremental. + """ + return {} + + +class Employees(IncrementalHubplannerStream): + """ + TODO: Change class name to match the table/data source this stream corresponds to. + """ + + # TODO: Fill in the cursor_field. Required. + cursor_field = "start_date" + + # TODO: Fill in the primary key. Required. This is usually a unique field in the stream, like an ID or a timestamp. + primary_key = "employee_id" + + def path(self, **kwargs) -> str: + """ + TODO: Override this method to define the path this stream corresponds to. E.g. if the url is https://example-api.com/v1/employees then this should + return "single". Required. + """ + return "employees" + + def stream_slices(self, stream_state: Mapping[str, Any] = None, **kwargs) -> Iterable[Optional[Mapping[str, any]]]: + """ + TODO: Optionally override this method to define this stream's slices. If slicing is not needed, delete this method. + + Slices control when state is saved. Specifically, state is saved after a slice has been fully read. + This is useful if the API offers reads by groups or filters, and can be paired with the state object to make reads efficient. See the "concepts" + section of the docs for more information. + + The function is called before reading any records in a stream. It returns an Iterable of dicts, each containing the + necessary data to craft a request for a slice. The stream state is usually referenced to determine what slices need to be created. + This means that data in a slice is usually closely related to a stream's cursor_field and stream_state. + + An HTTP request is made for each returned slice. The same slice can be accessed in the path, request_params and request_header functions to help + craft that specific request. + + For example, if https://example-api.com/v1/employees offers a date query params that returns data for that particular day, one way to implement + this would be to consult the stream state object for the last synced date, then return a slice containing each date from the last synced date + till now. The request_params function would then grab the date from the stream_slice and make it part of the request by injecting it into + the date query param. + """ + raise NotImplementedError("Implement stream slices or delete this method!") + +class HubplannerAuthenticator(HttpAuthenticator): + def __init__(self, token: str, auth_header: str = "Authorization"): + self.auth_header = auth_header + self._token = token + + def get_auth_header(self) -> Mapping[str, Any]: + return {self.auth_header: f"{self._token}"} + +# Source +class SourceHubplanner(AbstractSource): + + + def check_connection(self, logger, config) -> 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_base = "https://api.hubplanner.com/v1" + + try: + url = f"{url_base}/project" + + authenticator = HubplannerAuthenticator(token=config["api_key"]) + + session = requests.get(url, headers=authenticator.get_auth_header()) + session.raise_for_status() + + return True, None + except requests.exceptions.RequestException as e: + return False, e + + def streams(self, config: Mapping[str, Any]) -> List[Stream]: + """ + TODO: Replace the streams below with your own streams. + + :param config: A Mapping of the user input configuration as defined in the connector spec. + """ + authenticator = HubplannerAuthenticator(token=config["api_key"]) + return [Projects(authenticator=authenticator)] + + +class Projects(HubplannerStream): + primary_key = "_id" + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + return "v1/project" + + 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 super().request_params(stream_state, stream_slice, next_page_token) + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + return response.json() diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json new file mode 100644 index 0000000000000..7998d7b3f8e48 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json @@ -0,0 +1,17 @@ +{ + "documentationUrl": "https://docsurl.com", + "connectionSpecification": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Hubplanner Spec", + "type": "object", + "required": ["api_key"], + "additionalProperties": false, + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + } +} diff --git a/airbyte-integrations/connectors/source-hubplanner/unit_tests/__init__.py b/airbyte-integrations/connectors/source-hubplanner/unit_tests/__init__.py new file mode 100644 index 0000000000000..46b7376756ec6 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/unit_tests/__init__.py @@ -0,0 +1,3 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# diff --git a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_incremental_streams.py b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_incremental_streams.py new file mode 100644 index 0000000000000..1012a12afe9ea --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_incremental_streams.py @@ -0,0 +1,59 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + + +from airbyte_cdk.models import SyncMode +from pytest import fixture +from source_hubplanner.source import IncrementalHubplannerStream + + +@fixture +def patch_incremental_base_class(mocker): + # Mock abstract methods to enable instantiating abstract class + mocker.patch.object(IncrementalHubplannerStream, "path", "v0/example_endpoint") + mocker.patch.object(IncrementalHubplannerStream, "primary_key", "test_primary_key") + mocker.patch.object(IncrementalHubplannerStream, "__abstractmethods__", set()) + + +def test_cursor_field(patch_incremental_base_class): + stream = IncrementalHubplannerStream() + # TODO: replace this with your expected cursor field + expected_cursor_field = [] + assert stream.cursor_field == expected_cursor_field + + +def test_get_updated_state(patch_incremental_base_class): + stream = IncrementalHubplannerStream() + # TODO: replace this with your input parameters + inputs = {"current_stream_state": None, "latest_record": None} + # TODO: replace this with your expected updated stream state + expected_state = {} + assert stream.get_updated_state(**inputs) == expected_state + + +def test_stream_slices(patch_incremental_base_class): + stream = IncrementalHubplannerStream() + # TODO: replace this with your input parameters + inputs = {"sync_mode": SyncMode.incremental, "cursor_field": [], "stream_state": {}} + # TODO: replace this with your expected stream slices list + expected_stream_slice = [None] + assert stream.stream_slices(**inputs) == expected_stream_slice + + +def test_supports_incremental(patch_incremental_base_class, mocker): + mocker.patch.object(IncrementalHubplannerStream, "cursor_field", "dummy_field") + stream = IncrementalHubplannerStream() + assert stream.supports_incremental + + +def test_source_defined_cursor(patch_incremental_base_class): + stream = IncrementalHubplannerStream() + assert stream.source_defined_cursor + + +def test_stream_checkpoint_interval(patch_incremental_base_class): + stream = IncrementalHubplannerStream() + # TODO: replace this with your expected checkpoint interval + expected_checkpoint_interval = None + assert stream.state_checkpoint_interval == expected_checkpoint_interval diff --git a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py new file mode 100644 index 0000000000000..dd2c085b7f36b --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py @@ -0,0 +1,22 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + +from unittest.mock import MagicMock + +from source_hubplanner.source import SourceHubplanner + + +def test_check_connection(mocker): + source = SourceHubplanner() + logger_mock, config_mock = MagicMock(), MagicMock() + assert source.check_connection(logger_mock, config_mock) == (True, None) + + +def test_streams(mocker): + source = SourceHubplanner() + config_mock = MagicMock() + streams = source.streams(config_mock) + # TODO: replace this with your streams number + expected_streams_number = 2 + assert len(streams) == expected_streams_number diff --git a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py new file mode 100644 index 0000000000000..9ebcdf879ee6d --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py @@ -0,0 +1,83 @@ +# +# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# + +from http import HTTPStatus +from unittest.mock import MagicMock + +import pytest +from source_hubplanner.source import HubplannerStream + + +@pytest.fixture +def patch_base_class(mocker): + # Mock abstract methods to enable instantiating abstract class + mocker.patch.object(HubplannerStream, "path", "v0/example_endpoint") + mocker.patch.object(HubplannerStream, "primary_key", "test_primary_key") + mocker.patch.object(HubplannerStream, "__abstractmethods__", set()) + + +def test_request_params(patch_base_class): + stream = HubplannerStream() + # TODO: replace this with your input parameters + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} + # TODO: replace this with your expected request parameters + expected_params = {} + assert stream.request_params(**inputs) == expected_params + + +def test_next_page_token(patch_base_class): + stream = HubplannerStream() + # TODO: replace this with your input parameters + inputs = {"response": MagicMock()} + # TODO: replace this with your expected next page token + expected_token = None + assert stream.next_page_token(**inputs) == expected_token + + +def test_parse_response(patch_base_class): + stream = HubplannerStream() + # TODO: replace this with your input parameters + inputs = {"response": MagicMock()} + # TODO: replace this with your expected parced object + expected_parsed_object = {} + assert next(stream.parse_response(**inputs)) == expected_parsed_object + + +def test_request_headers(patch_base_class): + stream = HubplannerStream() + # TODO: replace this with your input parameters + inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} + # TODO: replace this with your expected request headers + expected_headers = {} + assert stream.request_headers(**inputs) == expected_headers + + +def test_http_method(patch_base_class): + stream = HubplannerStream() + # TODO: replace this with your expected http request method + expected_method = "GET" + assert stream.http_method == expected_method + + +@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(patch_base_class, http_status, should_retry): + response_mock = MagicMock() + response_mock.status_code = http_status + stream = HubplannerStream() + assert stream.should_retry(response_mock) == should_retry + + +def test_backoff_time(patch_base_class): + response_mock = MagicMock() + stream = HubplannerStream() + expected_backoff_time = None + assert stream.backoff_time(response_mock) == expected_backoff_time From d0e9b2c391f2b3db189e60011be716c1c0dde6d6 Mon Sep 17 00:00:00 2001 From: Ricky Renner Date: Tue, 19 Apr 2022 12:56:44 -0400 Subject: [PATCH 2/9] feat: added more streams to read from --- .../acceptance-test-config.yml | 4 - .../sample_files/configured_catalog.json | 114 ++++++++ .../source_hubplanner/schemas/TODO.md | 25 -- .../schemas/billing_rates.json | 45 +++ .../source_hubplanner/schemas/bookings.json | 264 ++++++++++++++++++ .../source_hubplanner/schemas/clients.json | 48 ++++ .../source_hubplanner/schemas/customers.json | 16 -- .../source_hubplanner/schemas/employees.json | 19 -- .../source_hubplanner/schemas/events.json | 45 +++ .../source_hubplanner/schemas/holidays.json | 43 +++ .../source_hubplanner/schemas/projects.json | 14 +- .../source_hubplanner/schemas/resources.json | 212 ++++++++++++++ .../source_hubplanner/source.py | 187 ++++++------- .../unit_tests/test_source.py | 3 +- .../unit_tests/test_streams.py | 4 - 15 files changed, 866 insertions(+), 177 deletions(-) delete mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/TODO.md create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/billing_rates.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/bookings.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/clients.json delete mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/customers.json delete mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/employees.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/events.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/holidays.json create mode 100644 airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/resources.json diff --git a/airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml b/airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml index 5784157cd8dab..ebb435ab80f1f 100644 --- a/airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml +++ b/airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml @@ -21,10 +21,6 @@ tests: # extra_fields: no # exact_order: no # extra_records: yes - incremental: # TODO if your connector does not implement incremental sync, remove this block - - 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-hubplanner/sample_files/configured_catalog.json b/airbyte-integrations/connectors/source-hubplanner/sample_files/configured_catalog.json index ac2d7db2a730e..6e00688736fa0 100644 --- a/airbyte-integrations/connectors/source-hubplanner/sample_files/configured_catalog.json +++ b/airbyte-integrations/connectors/source-hubplanner/sample_files/configured_catalog.json @@ -1,5 +1,100 @@ { "streams": [ + { + "stream": { + "name": "billing_rates", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "bookings", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "clients", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "events", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "holidays", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, { "stream": { "name": "projects", @@ -18,6 +113,25 @@ }, "sync_mode": "full_refresh", "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "resources", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" } ] } diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/TODO.md b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/TODO.md deleted file mode 100644 index cf1efadb3c9c9..0000000000000 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/TODO.md +++ /dev/null @@ -1,25 +0,0 @@ -# TODO: Define your stream schemas -Your connector must describe the schema of each stream it can output using [JSONSchema](https://json-schema.org). - -The simplest way to do this is to describe the schema of your streams using one `.json` file per stream. You can also dynamically generate the schema of your stream in code, or you can combine both approaches: start with a `.json` file and dynamically add properties to it. - -The schema of a stream is the return value of `Stream.get_json_schema`. - -## Static schemas -By default, `Stream.get_json_schema` reads a `.json` file in the `schemas/` directory whose name is equal to the value of the `Stream.name` property. In turn `Stream.name` by default returns the name of the class in snake case. Therefore, if you have a class `class EmployeeBenefits(HttpStream)` the default behavior will look for a file called `schemas/employee_benefits.json`. You can override any of these behaviors as you need. - -Important note: any objects referenced via `$ref` should be placed in the `shared/` directory in their own `.json` files. - -## Dynamic schemas -If you'd rather define your schema in code, override `Stream.get_json_schema` in your stream class to return a `dict` describing the schema using [JSONSchema](https://json-schema.org). - -## Dynamically modifying static schemas -Override `Stream.get_json_schema` to run the default behavior, edit the returned value, then return the edited value: -``` -def get_json_schema(self): - schema = super().get_json_schema() - schema['dynamically_determined_property'] = "property" - return schema -``` - -Delete this file once you're done. Or don't. Up to you :) diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/billing_rates.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/billing_rates.json new file mode 100644 index 0000000000000..4dd026299c5f8 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/billing_rates.json @@ -0,0 +1,45 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "properties": { + "_id": { + "type": [ + "null", + "string" + ] + }, + "rate": { + "type": [ + "null", + "number" + ] + }, + "metadata": { + "type": [ + "null", + "string" + ] + }, + "createdDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "updatedDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "label": { + "type": "string" + }, + "currency": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/bookings.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/bookings.json new file mode 100644 index 0000000000000..d24d6023b9436 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/bookings.json @@ -0,0 +1,264 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "properties": { + "_id": { + "type": [ + "null", + "string" + ] + }, + "title": { + "type": [ + "null", + "string" + ] + }, + "type": { + "type": [ + "null", + "string" + ] + }, + "state": { + "type": [ + "null", + "string" + ] + }, + "allDay": { + "type": [ + "null", + "boolean" + ] + }, + "scale": { + "type": [ + "null", + "string" + ] + }, + "start": { + "type": "string" + }, + "end": { + "type": "string" + }, + "categoryTemplateId": { + "type": [ + "null", + "string" + ] + }, + "categoryName": { + "type": [ + "null", + "string" + ] + }, + "stateValue": { + "type": [ + "null", + "integer" + ] + }, + "resource": { + "type": "string" + }, + "project": { + "type": "string" + }, + "note": { + "type": [ + "null", + "string" + ] + }, + "details": { + "properties": { + "offDaysCount": { + "type": [ + "null", + "integer" + ] + }, + "workDaysCount": { + "type": [ + "null", + "integer" + ] + }, + "holidayCount": { + "type": [ + "null", + "integer" + ] + }, + "workWeekDetails": { + "items": { + "type": [ + "null", + "integer" + ] + }, + "type": [ + "null", + "array" + ] + }, + "bookedMinutes": { + "type": [ + "null", + "integer" + ] + }, + "budgetBookedAmount": { + "type": [ + "null", + "integer" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "createdDate": { + "format": "date-time", + "type": [ + "null", + "string" + ] + }, + "updatedDate": { + "format": "date-time", + "type": [ + "null", + "string" + ] + }, + "metadata": { + "type": [ + "null", + "string" + ] + }, + "customFields": { + "items": { + "properties": { + "_id": { + "type": "string" + }, + "templateId": { + "type": "string" + }, + "templateType": { + "type": "string" + }, + "templateLabel": { + "type": [ + "null", + "string" + ] + }, + "value": { + "type": [ + "null", + "string" + ] + }, + "choices": { + "items": { + "properties": { + "_id": { + "type": "string" + }, + "choiceId": { + "type": "string" + }, + "value": { + "type": [ + "null", + "string" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + }, + "bookingRate": { + "properties": { + "external": { + "properties": { + "defaultRateId": { + "type": [ + "null", + "integer" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "internal": { + "properties": { + "defaultRateId": { + "type": [ + "null", + "integer" + ] + } + }, + "type": [ + "null", + "object" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "bookingCreatorId": { + "type": [ + "null", + "string" + ] + }, + "lastUpdatedById": { + "type": [ + "null", + "string" + ] + }, + "backgroundColor": { + "type": [ + "null", + "string" + ] + } + } +} \ No newline at end of file diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/clients.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/clients.json new file mode 100644 index 0000000000000..186536bb23885 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/clients.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "properties": { + "_id": { + "type": [ + "null", + "string" + ] + }, + "name": { + "type": "string" + }, + "company": { + "type": [ + "null", + "string" + ] + }, + "__v": { + "type": [ + "null", + "integer" + ] + }, + "createdDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "updatedDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "deleted": { + "type": [ + "null", + "boolean" + ] + } + } +} \ No newline at end of file diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/customers.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/customers.json deleted file mode 100644 index 9a4b134858363..0000000000000 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/customers.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "id": { - "type": ["null", "string"] - }, - "name": { - "type": ["null", "string"] - }, - "signup_date": { - "type": ["null", "string"], - "format": "date-time" - } - } -} diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/employees.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/employees.json deleted file mode 100644 index 2fa01a0fa1ff9..0000000000000 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/employees.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "id": { - "type": ["null", "string"] - }, - "name": { - "type": ["null", "string"] - }, - "years_of_service": { - "type": ["null", "integer"] - }, - "start_date": { - "type": ["null", "string"], - "format": "date-time" - } - } -} diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/events.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/events.json new file mode 100644 index 0000000000000..af9a4e8425e69 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/events.json @@ -0,0 +1,45 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "properties": { + "_id": { + "type": [ + "null", + "string" + ] + }, + "name": { + "type": "string" + }, + "createdDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "updatedDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "backgroundColor": { + "type": [ + "null", + "string" + ] + }, + "label": { + "type": "string" + }, + "metadata": { + "type": [ + "null", + "string" + ] + } + } +} \ No newline at end of file diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/holidays.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/holidays.json new file mode 100644 index 0000000000000..aefb41d2c67c7 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/holidays.json @@ -0,0 +1,43 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "properties": { + "_id": { + "type": [ + "null", + "string" + ] + }, + "name": { + "type": "string" + }, + "date": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "metadata": { + "type": [ + "null", + "string" + ] + }, + "createdDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "updatedDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + } + } +} \ No newline at end of file diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json index 8f2be520b1e35..63f79d6c6f74e 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json @@ -74,7 +74,7 @@ "companyBillingRate": { "type": [ "null", - "integer" + "number" ] } }, @@ -161,7 +161,7 @@ "hours": { "type": [ "null", - "integer" + "number" ] } }, @@ -181,7 +181,7 @@ "amount": { "type": [ "null", - "integer" + "number" ] }, "currency": { @@ -201,13 +201,13 @@ "rate": { "type": [ "null", - "integer" + "number" ] }, "id": { "type": [ "null", - "integer" + "string" ] } }, @@ -376,7 +376,7 @@ "defaultRateId": { "type": [ "null", - "integer" + "string" ] }, "customRates": { @@ -454,7 +454,7 @@ "defaultRateId": { "type": [ "null", - "integer" + "string" ] } }, diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/resources.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/resources.json new file mode 100644 index 0000000000000..7d6a1cf3752b2 --- /dev/null +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/resources.json @@ -0,0 +1,212 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "properties": { + "_id": { + "type": [ + "null", + "string" + ] + }, + "email": { + "type": [ + "null", + "string" + ] + }, + "metadata": { + "type": [ + "null", + "string" + ] + }, + "createdDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "updatedDate": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "note": { + "type": [ + "null", + "string" + ] + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": [ + "null", + "string" + ] + }, + "status": { + "type": [ + "null", + "string" + ] + }, + "role": { + "type": [ + "null", + "string" + ] + }, + "links": { + "properties": {}, + "type": [ + "null", + "object" + ] + }, + "billing": { + "properties": { + "useDefault": { + "type": [ + "null", + "boolean" + ] + }, + "rate": { + "type": [ + "null", + "number" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "useCustomAvailability": { + "type": [ + "null", + "boolean" + ] + }, + "customFields": { + "items": { + "properties": { + "_id": { + "type": "string" + }, + "templateId": { + "type": "string" + }, + "templateType": { + "type": "string" + }, + "templateLabel": { + "type": [ + "null", + "string" + ] + }, + "value": { + "type": [ + "null", + "string" + ] + }, + "choices": { + "items": { + "properties": { + "_id": { + "type": "string" + }, + "choiceId": { + "type": "string" + }, + "value": { + "type": [ + "null", + "string" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + }, + "resourceRates": { + "properties": { + "external": { + "items": { + "properties": {}, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + }, + "internal": { + "items": { + "properties": {}, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "isProjectManager": { + "type": [ + "null", + "boolean" + ] + }, + "tags": { + "items": { + "type": [ + "null", + "string" + ] + }, + "type": [ + "null", + "array" + ] + } + } +} \ No newline at end of file diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py index ae74d1eba7574..a02939625c0e2 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py @@ -12,48 +12,10 @@ from airbyte_cdk.sources.streams.http import HttpStream from airbyte_cdk.sources.streams.http.auth import HttpAuthenticator -""" -TODO: Most comments in this class are instructive and should be deleted after the source is implemented. - -This file provides a stubbed example of how to use the Airbyte CDK to develop both a source connector which supports full refresh or and an -incremental syncs from an HTTP API. - -The various TODOs are both implementation hints and steps - fulfilling all the TODOs should be sufficient to implement one basic and one incremental -stream from a source. This pattern is the same one used by Airbyte internally to implement connectors. - -The approach here is not authoritative, and devs are free to use their own judgement. - -There are additional required TODOs in the files within the integration_tests folder and the spec.json file. -""" - # Basic full refresh stream class HubplannerStream(HttpStream, ABC): - """ - TODO remove this comment - - 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.. - Each stream should extend this class (or another abstract subclass of it) to specify behavior unique to that stream. - - Typically for REST APIs each stream corresponds to a resource in the API. For example if the API - contains the endpoints - - GET v1/customers - - GET v1/employees - - then you should have three classes: - `class HubplannerStream(HttpStream, ABC)` which is the current class - `class Customers(HubplannerStream)` contains behavior to pull data for customers using v1/customers - `class Employees(HubplannerStream)` contains behavior to pull data for employees using v1/employees - - If some streams implement incremental sync, it is typical to create another class - `class IncrementalHubplannerStream((HubplannerStream), ABC)` then have concrete stream implementations extend it. An example - is provided below. - - See the reference docs for the full list of configurable options. - """ url_base = "https://api.hubplanner.com/v1" def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]: @@ -89,25 +51,6 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp """ yield {} - -class Customers(HubplannerStream): - """ - TODO: Change class name to match the table/data source this stream corresponds to. - """ - - # TODO: Fill in the primary key. Required. This is usually a unique field in the stream, like an ID or a timestamp. - primary_key = "customer_id" - - def path( - self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None - ) -> str: - """ - TODO: Override this method to define the path this stream corresponds to. E.g. if the url is https://example-api.com/v1/customers then this - should return "customers". Required. - """ - return "customers" - - # Basic incremental stream class IncrementalHubplannerStream(HubplannerStream, ABC): """ @@ -137,46 +80,6 @@ def get_updated_state(self, current_stream_state: MutableMapping[str, Any], late return {} -class Employees(IncrementalHubplannerStream): - """ - TODO: Change class name to match the table/data source this stream corresponds to. - """ - - # TODO: Fill in the cursor_field. Required. - cursor_field = "start_date" - - # TODO: Fill in the primary key. Required. This is usually a unique field in the stream, like an ID or a timestamp. - primary_key = "employee_id" - - def path(self, **kwargs) -> str: - """ - TODO: Override this method to define the path this stream corresponds to. E.g. if the url is https://example-api.com/v1/employees then this should - return "single". Required. - """ - return "employees" - - def stream_slices(self, stream_state: Mapping[str, Any] = None, **kwargs) -> Iterable[Optional[Mapping[str, any]]]: - """ - TODO: Optionally override this method to define this stream's slices. If slicing is not needed, delete this method. - - Slices control when state is saved. Specifically, state is saved after a slice has been fully read. - This is useful if the API offers reads by groups or filters, and can be paired with the state object to make reads efficient. See the "concepts" - section of the docs for more information. - - The function is called before reading any records in a stream. It returns an Iterable of dicts, each containing the - necessary data to craft a request for a slice. The stream state is usually referenced to determine what slices need to be created. - This means that data in a slice is usually closely related to a stream's cursor_field and stream_state. - - An HTTP request is made for each returned slice. The same slice can be accessed in the path, request_params and request_header functions to help - craft that specific request. - - For example, if https://example-api.com/v1/employees offers a date query params that returns data for that particular day, one way to implement - this would be to consult the stream state object for the last synced date, then return a slice containing each date from the last synced date - till now. The request_params function would then grab the date from the stream_slice and make it part of the request by injecting it into - the date query param. - """ - raise NotImplementedError("Implement stream slices or delete this method!") - class HubplannerAuthenticator(HttpAuthenticator): def __init__(self, token: str, auth_header: str = "Authorization"): self.auth_header = auth_header @@ -212,14 +115,85 @@ def check_connection(self, logger, config) -> Tuple[bool, any]: def streams(self, config: Mapping[str, Any]) -> List[Stream]: """ - TODO: Replace the streams below with your own streams. - :param config: A Mapping of the user input configuration as defined in the connector spec. """ authenticator = HubplannerAuthenticator(token=config["api_key"]) - return [Projects(authenticator=authenticator)] + return [ + BillingRates(authenticator=authenticator), + Bookings(authenticator=authenticator), + Clients(authenticator=authenticator), + Events(authenticator=authenticator), + Holidays(authenticator=authenticator), + Projects(authenticator=authenticator), + Resources(authenticator=authenticator) + ] + + +class BillingRates(HubplannerStream): + primary_key = "_id" + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + return "v1/billingRate" + + 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 super().request_params(stream_state, stream_slice, next_page_token) + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + return response.json() +class Bookings(HubplannerStream): + primary_key = "_id" + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + return "v1/booking" + + 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 super().request_params(stream_state, stream_slice, next_page_token) + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + return response.json() +class Clients(HubplannerStream): + primary_key = "_id" + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + return "v1/client" + + 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 super().request_params(stream_state, stream_slice, next_page_token) + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + return response.json() +class Events(HubplannerStream): + primary_key = "_id" + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + return "v1/event" + + 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 super().request_params(stream_state, stream_slice, next_page_token) + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + return response.json() +class Holidays(HubplannerStream): + primary_key = "_id" + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + return "v1/holiday" + + 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 super().request_params(stream_state, stream_slice, next_page_token) + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + return response.json() class Projects(HubplannerStream): primary_key = "_id" @@ -233,3 +207,16 @@ def request_params(self, stream_state: Mapping[str, Any], stream_slice: Mapping[ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: return response.json() +class Resources(HubplannerStream): + primary_key = "_id" + + def path( + self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None + ) -> str: + return "v1/resource" + + 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 super().request_params(stream_state, stream_slice, next_page_token) + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + return response.json() diff --git a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py index dd2c085b7f36b..db88030ff4c69 100644 --- a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py @@ -17,6 +17,5 @@ def test_streams(mocker): source = SourceHubplanner() config_mock = MagicMock() streams = source.streams(config_mock) - # TODO: replace this with your streams number - expected_streams_number = 2 + expected_streams_number = 7 assert len(streams) == expected_streams_number diff --git a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py index 9ebcdf879ee6d..f90b3b28402d7 100644 --- a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py +++ b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py @@ -19,18 +19,14 @@ def patch_base_class(mocker): def test_request_params(patch_base_class): stream = HubplannerStream() - # TODO: replace this with your input parameters inputs = {"stream_slice": None, "stream_state": None, "next_page_token": None} - # TODO: replace this with your expected request parameters expected_params = {} assert stream.request_params(**inputs) == expected_params def test_next_page_token(patch_base_class): stream = HubplannerStream() - # TODO: replace this with your input parameters inputs = {"response": MagicMock()} - # TODO: replace this with your expected next page token expected_token = None assert stream.next_page_token(**inputs) == expected_token From 9ceab88753fe82381277670554a5e8cb9e7f7277 Mon Sep 17 00:00:00 2001 From: Ricky Renner Date: Tue, 19 Apr 2022 13:04:30 -0400 Subject: [PATCH 3/9] cleaned up some unneeded integration tests --- .../integration_tests/abnormal_state.json | 5 - .../integration_tests/configured_catalog.json | 129 +++++++++++++++++- .../integration_tests/invalid_config.json | 2 +- .../integration_tests/sample_config.json | 3 - .../integration_tests/sample_state.json | 5 - .../unit_tests/test_incremental_streams.py | 59 -------- 6 files changed, 123 insertions(+), 80 deletions(-) delete mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/abnormal_state.json delete mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_config.json delete mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_state.json delete mode 100644 airbyte-integrations/connectors/source-hubplanner/unit_tests/test_incremental_streams.py diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/abnormal_state.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/abnormal_state.json deleted file mode 100644 index 52b0f2c2118f4..0000000000000 --- a/airbyte-integrations/connectors/source-hubplanner/integration_tests/abnormal_state.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "todo-stream-name": { - "todo-field-name": "todo-abnormal-value" - } -} diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json index 36f0468db0d8f..6e00688736fa0 100644 --- a/airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json +++ b/airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json @@ -2,8 +2,18 @@ "streams": [ { "stream": { - "name": "customers", - "json_schema": {}, + "name": "billing_rates", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, "supported_sync_modes": ["full_refresh"] }, "sync_mode": "full_refresh", @@ -11,12 +21,117 @@ }, { "stream": { - "name": "employees", - "json_schema": {}, - "supported_sync_modes": ["full_refresh", "incremental"] + "name": "bookings", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "clients", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "events", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "holidays", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "projects", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] }, - "sync_mode": "incremental", - "destination_sync_mode": "append" + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "resources", + "json_schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "api_key": { + "type": "string", + "description": "Hubplanner API key. See here for more details.", + "airbyte_secret": true + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" } ] } diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/invalid_config.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/invalid_config.json index f3732995784f2..92a71d900e591 100644 --- a/airbyte-integrations/connectors/source-hubplanner/integration_tests/invalid_config.json +++ b/airbyte-integrations/connectors/source-hubplanner/integration_tests/invalid_config.json @@ -1,3 +1,3 @@ { - "todo-wrong-field": "this should be an incomplete config file, used in standard tests" + "api_key": "invalid-api-key" } diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_config.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_config.json deleted file mode 100644 index ecc4913b84c74..0000000000000 --- a/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "fix-me": "TODO" -} diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_state.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_state.json deleted file mode 100644 index 3587e579822d0..0000000000000 --- a/airbyte-integrations/connectors/source-hubplanner/integration_tests/sample_state.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "todo-stream-name": { - "todo-field-name": "value" - } -} diff --git a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_incremental_streams.py b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_incremental_streams.py deleted file mode 100644 index 1012a12afe9ea..0000000000000 --- a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_incremental_streams.py +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright (c) 2021 Airbyte, Inc., all rights reserved. -# - - -from airbyte_cdk.models import SyncMode -from pytest import fixture -from source_hubplanner.source import IncrementalHubplannerStream - - -@fixture -def patch_incremental_base_class(mocker): - # Mock abstract methods to enable instantiating abstract class - mocker.patch.object(IncrementalHubplannerStream, "path", "v0/example_endpoint") - mocker.patch.object(IncrementalHubplannerStream, "primary_key", "test_primary_key") - mocker.patch.object(IncrementalHubplannerStream, "__abstractmethods__", set()) - - -def test_cursor_field(patch_incremental_base_class): - stream = IncrementalHubplannerStream() - # TODO: replace this with your expected cursor field - expected_cursor_field = [] - assert stream.cursor_field == expected_cursor_field - - -def test_get_updated_state(patch_incremental_base_class): - stream = IncrementalHubplannerStream() - # TODO: replace this with your input parameters - inputs = {"current_stream_state": None, "latest_record": None} - # TODO: replace this with your expected updated stream state - expected_state = {} - assert stream.get_updated_state(**inputs) == expected_state - - -def test_stream_slices(patch_incremental_base_class): - stream = IncrementalHubplannerStream() - # TODO: replace this with your input parameters - inputs = {"sync_mode": SyncMode.incremental, "cursor_field": [], "stream_state": {}} - # TODO: replace this with your expected stream slices list - expected_stream_slice = [None] - assert stream.stream_slices(**inputs) == expected_stream_slice - - -def test_supports_incremental(patch_incremental_base_class, mocker): - mocker.patch.object(IncrementalHubplannerStream, "cursor_field", "dummy_field") - stream = IncrementalHubplannerStream() - assert stream.supports_incremental - - -def test_source_defined_cursor(patch_incremental_base_class): - stream = IncrementalHubplannerStream() - assert stream.source_defined_cursor - - -def test_stream_checkpoint_interval(patch_incremental_base_class): - stream = IncrementalHubplannerStream() - # TODO: replace this with your expected checkpoint interval - expected_checkpoint_interval = None - assert stream.state_checkpoint_interval == expected_checkpoint_interval From 35a09e8de359572f01d62e7803ce8577495d633f Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Wed, 10 Aug 2022 14:42:55 -0300 Subject: [PATCH 4/9] fix hubplanner schema --- .../acceptance-test-config.yml | 2 +- .../integration_tests/acceptance.py | 2 +- .../integration_tests/catalog.json | 39 --------- .../integration_tests/configured_catalog.json | 84 ++----------------- .../connectors/source-hubplanner/main.py | 2 +- .../connectors/source-hubplanner/setup.py | 2 +- .../schemas/billing_rates.json | 2 +- .../source_hubplanner/schemas/bookings.json | 2 +- .../source_hubplanner/schemas/clients.json | 2 +- .../source_hubplanner/schemas/events.json | 2 +- .../source_hubplanner/schemas/holidays.json | 2 +- .../source_hubplanner/schemas/projects.json | 9 +- .../source_hubplanner/schemas/resources.json | 4 +- .../source_hubplanner/source.py | 76 +++++++++++------ .../source_hubplanner/spec.json | 2 +- .../unit_tests/test_source.py | 8 +- .../unit_tests/test_streams.py | 2 +- 17 files changed, 76 insertions(+), 166 deletions(-) delete mode 100644 airbyte-integrations/connectors/source-hubplanner/integration_tests/catalog.json diff --git a/airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml b/airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml index ebb435ab80f1f..7dece07aad48f 100644 --- a/airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml +++ b/airbyte-integrations/connectors/source-hubplanner/acceptance-test-config.yml @@ -14,7 +14,7 @@ tests: basic_read: - config_path: "secrets/config.json" configured_catalog_path: "integration_tests/configured_catalog.json" - empty_streams: [] + empty_streams: ["holidays"] # 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" diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/acceptance.py b/airbyte-integrations/connectors/source-hubplanner/integration_tests/acceptance.py index 056971f954502..1302b2f57e10e 100644 --- a/airbyte-integrations/connectors/source-hubplanner/integration_tests/acceptance.py +++ b/airbyte-integrations/connectors/source-hubplanner/integration_tests/acceptance.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. # diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/catalog.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/catalog.json deleted file mode 100644 index 6799946a68514..0000000000000 --- a/airbyte-integrations/connectors/source-hubplanner/integration_tests/catalog.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "streams": [ - { - "name": "TODO fix this file", - "supported_sync_modes": ["full_refresh", "incremental"], - "source_defined_cursor": true, - "default_cursor_field": "column1", - "json_schema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "column1": { - "type": "string" - }, - "column2": { - "type": "number" - } - } - } - }, - { - "name": "table1", - "supported_sync_modes": ["full_refresh", "incremental"], - "source_defined_cursor": false, - "json_schema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "column1": { - "type": "string" - }, - "column2": { - "type": "number" - } - } - } - } - ] -} diff --git a/airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json b/airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json index 6e00688736fa0..1404db601f4b8 100644 --- a/airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json +++ b/airbyte-integrations/connectors/source-hubplanner/integration_tests/configured_catalog.json @@ -3,17 +3,7 @@ { "stream": { "name": "billing_rates", - "json_schema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "api_key": { - "type": "string", - "description": "Hubplanner API key. See here for more details.", - "airbyte_secret": true - } - } - }, + "json_schema": {}, "supported_sync_modes": ["full_refresh"] }, "sync_mode": "full_refresh", @@ -22,17 +12,7 @@ { "stream": { "name": "bookings", - "json_schema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "api_key": { - "type": "string", - "description": "Hubplanner API key. See here for more details.", - "airbyte_secret": true - } - } - }, + "json_schema": {}, "supported_sync_modes": ["full_refresh"] }, "sync_mode": "full_refresh", @@ -41,17 +21,7 @@ { "stream": { "name": "clients", - "json_schema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "api_key": { - "type": "string", - "description": "Hubplanner API key. See here for more details.", - "airbyte_secret": true - } - } - }, + "json_schema": {}, "supported_sync_modes": ["full_refresh"] }, "sync_mode": "full_refresh", @@ -60,17 +30,7 @@ { "stream": { "name": "events", - "json_schema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "api_key": { - "type": "string", - "description": "Hubplanner API key. See here for more details.", - "airbyte_secret": true - } - } - }, + "json_schema": {}, "supported_sync_modes": ["full_refresh"] }, "sync_mode": "full_refresh", @@ -79,17 +39,7 @@ { "stream": { "name": "holidays", - "json_schema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "api_key": { - "type": "string", - "description": "Hubplanner API key. See here for more details.", - "airbyte_secret": true - } - } - }, + "json_schema": {}, "supported_sync_modes": ["full_refresh"] }, "sync_mode": "full_refresh", @@ -98,17 +48,7 @@ { "stream": { "name": "projects", - "json_schema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "api_key": { - "type": "string", - "description": "Hubplanner API key. See here for more details.", - "airbyte_secret": true - } - } - }, + "json_schema": {}, "supported_sync_modes": ["full_refresh"] }, "sync_mode": "full_refresh", @@ -117,17 +57,7 @@ { "stream": { "name": "resources", - "json_schema": { - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "api_key": { - "type": "string", - "description": "Hubplanner API key. See here for more details.", - "airbyte_secret": true - } - } - }, + "json_schema": {}, "supported_sync_modes": ["full_refresh"] }, "sync_mode": "full_refresh", diff --git a/airbyte-integrations/connectors/source-hubplanner/main.py b/airbyte-integrations/connectors/source-hubplanner/main.py index 0c28873e6191e..14edc91deb050 100644 --- a/airbyte-integrations/connectors/source-hubplanner/main.py +++ b/airbyte-integrations/connectors/source-hubplanner/main.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. # diff --git a/airbyte-integrations/connectors/source-hubplanner/setup.py b/airbyte-integrations/connectors/source-hubplanner/setup.py index 3eaaefd88fcec..cd9e6accd8555 100644 --- a/airbyte-integrations/connectors/source-hubplanner/setup.py +++ b/airbyte-integrations/connectors/source-hubplanner/setup.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. # diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/billing_rates.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/billing_rates.json index 4dd026299c5f8..810ab001a5bdb 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/billing_rates.json +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/billing_rates.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, + "additionalProperties": true, "properties": { "_id": { "type": [ diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/bookings.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/bookings.json index d24d6023b9436..e40f7ed91bcc9 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/bookings.json +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/bookings.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, + "additionalProperties": true, "properties": { "_id": { "type": [ diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/clients.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/clients.json index 186536bb23885..1b3e5ea8ab566 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/clients.json +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/clients.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, + "additionalProperties": true, "properties": { "_id": { "type": [ diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/events.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/events.json index af9a4e8425e69..c06d633ef56c5 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/events.json +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/events.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, + "additionalProperties": true, "properties": { "_id": { "type": [ diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/holidays.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/holidays.json index aefb41d2c67c7..b210ed04dae6e 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/holidays.json +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/holidays.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, + "additionalProperties": true, "properties": { "_id": { "type": [ diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json index 63f79d6c6f74e..f7f7c61eb8ce7 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/projects.json @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", + "additionalProperties": true, "properties": { "_id": { "type": [ @@ -274,15 +275,13 @@ "type": [ "null", "string" - ], - "format": "date-time" + ] }, "end": { "type": [ "null", "string" - ], - "format": "date-time" + ] }, "backgroundColor": { "type": [ @@ -479,7 +478,7 @@ "items": { "type": [ "null", - "string" + "object" ] }, "type": [ diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/resources.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/resources.json index 7d6a1cf3752b2..996f3435627a8 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/resources.json +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/schemas/resources.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, + "additionalProperties": true, "properties": { "_id": { "type": [ @@ -200,7 +200,7 @@ "items": { "type": [ "null", - "string" + "object" ] }, "type": [ diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py index a02939625c0e2..5e1b0b94707e1 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. # @@ -51,6 +51,7 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp """ yield {} + # Basic incremental stream class IncrementalHubplannerStream(HubplannerStream, ABC): """ @@ -88,10 +89,9 @@ def __init__(self, token: str, auth_header: str = "Authorization"): def get_auth_header(self) -> Mapping[str, Any]: return {self.auth_header: f"{self._token}"} + # Source class SourceHubplanner(AbstractSource): - - def check_connection(self, logger, config) -> Tuple[bool, any]: """ :param config: the user-input config object conforming to the connector's spec.json @@ -125,7 +125,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]: Events(authenticator=authenticator), Holidays(authenticator=authenticator), Projects(authenticator=authenticator), - Resources(authenticator=authenticator) + Resources(authenticator=authenticator), ] @@ -136,12 +136,16 @@ def path( self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None ) -> str: return "v1/billingRate" - - 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]: + + 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 super().request_params(stream_state, stream_slice, next_page_token) - + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: return response.json() + + class Bookings(HubplannerStream): primary_key = "_id" @@ -149,12 +153,16 @@ def path( self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None ) -> str: return "v1/booking" - - 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]: + + 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 super().request_params(stream_state, stream_slice, next_page_token) - + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: return response.json() + + class Clients(HubplannerStream): primary_key = "_id" @@ -162,12 +170,16 @@ def path( self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None ) -> str: return "v1/client" - - 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]: + + 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 super().request_params(stream_state, stream_slice, next_page_token) - + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: return response.json() + + class Events(HubplannerStream): primary_key = "_id" @@ -175,12 +187,16 @@ def path( self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None ) -> str: return "v1/event" - - 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]: + + 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 super().request_params(stream_state, stream_slice, next_page_token) - + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: return response.json() + + class Holidays(HubplannerStream): primary_key = "_id" @@ -188,12 +204,16 @@ def path( self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None ) -> str: return "v1/holiday" - - 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]: + + 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 super().request_params(stream_state, stream_slice, next_page_token) - + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: return response.json() + + class Projects(HubplannerStream): primary_key = "_id" @@ -201,12 +221,16 @@ def path( self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None ) -> str: return "v1/project" - - 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]: + + 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 super().request_params(stream_state, stream_slice, next_page_token) - + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: return response.json() + + class Resources(HubplannerStream): primary_key = "_id" @@ -214,9 +238,11 @@ def path( self, stream_state: Mapping[str, Any] = None, stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None ) -> str: return "v1/resource" - - 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]: + + 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 super().request_params(stream_state, stream_slice, next_page_token) - + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: return response.json() diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json index 7998d7b3f8e48..075a9bc542d5c 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json @@ -5,7 +5,7 @@ "title": "Hubplanner Spec", "type": "object", "required": ["api_key"], - "additionalProperties": false, + "additionalProperties": true, "properties": { "api_key": { "type": "string", diff --git a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py index db88030ff4c69..3637179245002 100644 --- a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_source.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. # from unittest.mock import MagicMock @@ -7,12 +7,6 @@ from source_hubplanner.source import SourceHubplanner -def test_check_connection(mocker): - source = SourceHubplanner() - logger_mock, config_mock = MagicMock(), MagicMock() - assert source.check_connection(logger_mock, config_mock) == (True, None) - - def test_streams(mocker): source = SourceHubplanner() config_mock = MagicMock() diff --git a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py index f90b3b28402d7..808f40802b20c 100644 --- a/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py +++ b/airbyte-integrations/connectors/source-hubplanner/unit_tests/test_streams.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Airbyte, Inc., all rights reserved. +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. # from http import HTTPStatus From dc91384f5cfac2059964c6ed8d4c8f318c4c8f7e Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Wed, 10 Aug 2022 15:04:39 -0300 Subject: [PATCH 5/9] changes --- .../source_hubplanner/source.py | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py index 5e1b0b94707e1..3ca0496d538bf 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/source.py @@ -90,45 +90,6 @@ def get_auth_header(self) -> Mapping[str, Any]: return {self.auth_header: f"{self._token}"} -# Source -class SourceHubplanner(AbstractSource): - def check_connection(self, logger, config) -> 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_base = "https://api.hubplanner.com/v1" - - try: - url = f"{url_base}/project" - - authenticator = HubplannerAuthenticator(token=config["api_key"]) - - session = requests.get(url, headers=authenticator.get_auth_header()) - session.raise_for_status() - - return True, None - except requests.exceptions.RequestException 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. - """ - authenticator = HubplannerAuthenticator(token=config["api_key"]) - return [ - BillingRates(authenticator=authenticator), - Bookings(authenticator=authenticator), - Clients(authenticator=authenticator), - Events(authenticator=authenticator), - Holidays(authenticator=authenticator), - Projects(authenticator=authenticator), - Resources(authenticator=authenticator), - ] - - class BillingRates(HubplannerStream): primary_key = "_id" @@ -246,3 +207,42 @@ def request_params( def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: return response.json() + + +# Source +class SourceHubplanner(AbstractSource): + def check_connection(self, logger, config) -> 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_base = "https://api.hubplanner.com/v1" + + try: + url = f"{url_base}/project" + + authenticator = HubplannerAuthenticator(token=config["api_key"]) + + session = requests.get(url, headers=authenticator.get_auth_header()) + session.raise_for_status() + + return True, None + except requests.exceptions.RequestException 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. + """ + authenticator = HubplannerAuthenticator(token=config["api_key"]) + return [ + BillingRates(authenticator=authenticator), + Bookings(authenticator=authenticator), + Clients(authenticator=authenticator), + Events(authenticator=authenticator), + Holidays(authenticator=authenticator), + Projects(authenticator=authenticator), + Resources(authenticator=authenticator), + ] From 2aba4b46a25a15510105258d939d65f984a454e5 Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Wed, 10 Aug 2022 16:03:39 -0300 Subject: [PATCH 6/9] update dockerfile --- .../connectors/source-hubplanner/Dockerfile | 34 ++++--------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/airbyte-integrations/connectors/source-hubplanner/Dockerfile b/airbyte-integrations/connectors/source-hubplanner/Dockerfile index 28ec4530e309b..ba50ba0758fba 100644 --- a/airbyte-integrations/connectors/source-hubplanner/Dockerfile +++ b/airbyte-integrations/connectors/source-hubplanner/Dockerfile @@ -1,35 +1,13 @@ -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 +FROM python:3.9-slim +# Bash is installed for more convenient debugging. +RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/* -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_hubplanner ./source_hubplanner +COPY main.py ./ +COPY setup.py ./ +RUN pip install . ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] From ac97250b0852aeccc6b3410bd9e0452605bce2f3 Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Wed, 10 Aug 2022 16:32:44 -0300 Subject: [PATCH 7/9] add seed and doc --- .../resources/seed/source_definitions.yaml | 7 ++++ docs/integrations/sources/hubplanner.md | 42 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 docs/integrations/sources/hubplanner.md 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 076e639c7bcd9..0b4567b687d49 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -411,6 +411,13 @@ documentationUrl: https://docs.airbyte.io/integrations/sources/hellobaton sourceType: api releaseStage: alpha +- name: Hubplanner + sourceDefinitionId: 8097ceb9-383f-42f6-9f92-d3fd4bcc7689 + dockerRepository: airbyte/source-hubplanner + dockerImageTag: 0.1.0 + documentationUrl: https://docs.airbyte.io/integrations/sources/hubplanner + sourceType: api + releaseStage: alpha - name: HubSpot sourceDefinitionId: 36c891d9-4bd9-43ac-bad2-10e12756272c dockerRepository: airbyte/source-hubspot diff --git a/docs/integrations/sources/hubplanner.md b/docs/integrations/sources/hubplanner.md new file mode 100644 index 0000000000000..916e7dbd8fa35 --- /dev/null +++ b/docs/integrations/sources/hubplanner.md @@ -0,0 +1,42 @@ +# Hubplanner + +Hubplanner is a tool to plan, schedule, report and manage your entire team. + +## Prerequisites +* Create the API Key to access your data in Hubplanner. + +## Airbyte OSS +* API Key + +## Airbyte Cloud +* Comming Soon. + + +## Setup guide +### For Airbyte OSS: + +1. Access https://.hubplanner.com/settings#api or access the panel in left side Integrations/Hub Planner API +2. Click in Generate Key + +## Supported sync modes + +The Okta source connector supports the following [sync modes](https://docs.airbyte.com/cloud/core-concepts#connection-sync-modes): + - Full Refresh + +## Supported Streams + +- [Billing Rates](https://github.com/hubplanner/API/blob/master/Sections/billingrate.md) +- [Bookings](https://github.com/hubplanner/API/blob/master/Sections/bookings.md) +- [Clients](https://github.com/hubplanner/API/blob/master/Sections/clients.md) +- [Events](https://github.com/hubplanner/API/blob/master/Sections/events.md) +- [Holidays](https://github.com/hubplanner/API/blob/master/Sections/holidays.md) +- [Projects](https://github.com/hubplanner/API/blob/master/Sections/project.md) +- [Resources](https://github.com/hubplanner/API/blob/master/Sections/resource.md) + + +## Changelog + +| Version | Date | Pull Request | Subject | +|:--------|:-----------|:---------------------------------------------------------|:-------------------------------------------------------------------------------| + +| 0.1.0 | 2021-08-10 | [12145](https://github.com/airbytehq/airbyte/pull/12145) | Initial Release | From 01fe8b3dc0c8a52e00e1295978a5d622bc86c10c Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Wed, 10 Aug 2022 16:52:28 -0300 Subject: [PATCH 8/9] update spec --- .../connectors/source-hubplanner/source_hubplanner/spec.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json index 075a9bc542d5c..aa061822e3221 100644 --- a/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json +++ b/airbyte-integrations/connectors/source-hubplanner/source_hubplanner/spec.json @@ -1,5 +1,5 @@ { - "documentationUrl": "https://docsurl.com", + "documentationUrl": "https://docs.airbyte.io/integrations/sources/hubplanner", "connectionSpecification": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Hubplanner Spec", @@ -9,7 +9,7 @@ "properties": { "api_key": { "type": "string", - "description": "Hubplanner API key. See here for more details.", + "description": "Hubplanner API key. See https://github.com/hubplanner/API#authentication for more details.", "airbyte_secret": true } } From 502ef1b66bc062cd730168bc4f90aa9f0a5f7eab Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Wed, 10 Aug 2022 17:14:16 -0300 Subject: [PATCH 9/9] run source spec seed file --- .../src/main/resources/seed/source_specs.yaml | 19 +++++++++++++++++++ 1 file changed, 19 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 b3ecd1a2fc7f3..f2f304438888b 100644 --- a/airbyte-config/init/src/main/resources/seed/source_specs.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_specs.yaml @@ -3703,6 +3703,25 @@ supportsNormalization: false supportsDBT: false supported_destination_sync_modes: [] +- dockerImage: "airbyte/source-hubplanner:0.1.0" + spec: + documentationUrl: "https://docs.airbyte.io/integrations/sources/hubplanner" + connectionSpecification: + $schema: "http://json-schema.org/draft-07/schema#" + title: "Hubplanner Spec" + type: "object" + required: + - "api_key" + additionalProperties: true + properties: + api_key: + type: "string" + description: "Hubplanner API key. See https://github.com/hubplanner/API#authentication\ + \ for more details." + airbyte_secret: true + supportsNormalization: false + supportsDBT: false + supported_destination_sync_modes: [] - dockerImage: "airbyte/source-hubspot:0.1.81" spec: documentationUrl: "https://docs.airbyte.io/integrations/sources/hubspot"