From ea32b8dbd68df68e893cea9572a2f876902c3447 Mon Sep 17 00:00:00 2001 From: Haithem SOUALA Date: Sun, 13 Nov 2022 23:52:00 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20New=20Source=20-=20Vantage=20[lo?= =?UTF-8?q?w-code=20cdk]=20(#18665)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * init commit * add streams * add docs * test push: * add vantage to source def * generate source spec Co-authored-by: marcosmarxm --- .../resources/seed/source_definitions.yaml | 7 ++ .../src/main/resources/seed/source_specs.yaml | 20 +++++ .../connectors/source-vantage/.dockerignore | 6 ++ .../connectors/source-vantage/Dockerfile | 38 +++++++++ .../connectors/source-vantage/README.md | 79 +++++++++++++++++++ .../connectors/source-vantage/__init__.py | 3 + .../source-vantage/acceptance-test-config.yml | 40 ++++++++++ .../source-vantage/acceptance-test-docker.sh | 16 ++++ .../connectors/source-vantage/build.gradle | 9 +++ .../integration_tests/__init__.py | 3 + .../integration_tests/abnormal_state.json | 5 ++ .../integration_tests/acceptance.py | 16 ++++ .../integration_tests/configured_catalog.json | 40 ++++++++++ .../integration_tests/invalid_config.json | 3 + .../integration_tests/sample_config.json | 3 + .../integration_tests/sample_state.json | 5 ++ .../connectors/source-vantage/main.py | 13 +++ .../source-vantage/requirements.txt | 2 + .../connectors/source-vantage/setup.py | 29 +++++++ .../source-vantage/source_vantage/__init__.py | 8 ++ .../source_vantage/schemas/products.json | 34 ++++++++ .../source_vantage/schemas/providers.json | 20 +++++ .../source_vantage/schemas/reports.json | 34 ++++++++ .../source_vantage/schemas/services.json | 25 ++++++ .../source-vantage/source_vantage/source.py | 18 +++++ .../source-vantage/source_vantage/spec.yaml | 16 ++++ .../source_vantage/vantage.yaml | 67 ++++++++++++++++ docs/integrations/sources/vantage.md | 35 ++++++++ 28 files changed, 594 insertions(+) create mode 100644 airbyte-integrations/connectors/source-vantage/.dockerignore create mode 100644 airbyte-integrations/connectors/source-vantage/Dockerfile create mode 100644 airbyte-integrations/connectors/source-vantage/README.md create mode 100644 airbyte-integrations/connectors/source-vantage/__init__.py create mode 100644 airbyte-integrations/connectors/source-vantage/acceptance-test-config.yml create mode 100644 airbyte-integrations/connectors/source-vantage/acceptance-test-docker.sh create mode 100644 airbyte-integrations/connectors/source-vantage/build.gradle create mode 100644 airbyte-integrations/connectors/source-vantage/integration_tests/__init__.py create mode 100644 airbyte-integrations/connectors/source-vantage/integration_tests/abnormal_state.json create mode 100644 airbyte-integrations/connectors/source-vantage/integration_tests/acceptance.py create mode 100644 airbyte-integrations/connectors/source-vantage/integration_tests/configured_catalog.json create mode 100644 airbyte-integrations/connectors/source-vantage/integration_tests/invalid_config.json create mode 100644 airbyte-integrations/connectors/source-vantage/integration_tests/sample_config.json create mode 100644 airbyte-integrations/connectors/source-vantage/integration_tests/sample_state.json create mode 100644 airbyte-integrations/connectors/source-vantage/main.py create mode 100644 airbyte-integrations/connectors/source-vantage/requirements.txt create mode 100644 airbyte-integrations/connectors/source-vantage/setup.py create mode 100644 airbyte-integrations/connectors/source-vantage/source_vantage/__init__.py create mode 100644 airbyte-integrations/connectors/source-vantage/source_vantage/schemas/products.json create mode 100644 airbyte-integrations/connectors/source-vantage/source_vantage/schemas/providers.json create mode 100644 airbyte-integrations/connectors/source-vantage/source_vantage/schemas/reports.json create mode 100644 airbyte-integrations/connectors/source-vantage/source_vantage/schemas/services.json create mode 100644 airbyte-integrations/connectors/source-vantage/source_vantage/source.py create mode 100644 airbyte-integrations/connectors/source-vantage/source_vantage/spec.yaml create mode 100644 airbyte-integrations/connectors/source-vantage/source_vantage/vantage.yaml create mode 100644 docs/integrations/sources/vantage.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 ebf73337f5b0..36f48f20756e 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -1546,6 +1546,13 @@ icon: youtube.svg sourceType: api releaseStage: alpha +- name: Vantage + sourceDefinitionId: 28ce1fbd-1e15-453f-aa9f-da6c4d928e92 + dockerRepository: airbyte/source-vantage + dockerImageTag: 0.1.0 + documentationUrl: https://docs.airbyte.com/integrations/sources/vantage + sourceType: api + releaseStage: alpha - name: VictorOps sourceDefinitionId: 7e20ce3e-d820-4327-ad7a-88f3927fd97a dockerRepository: farosai/airbyte-victorops-source 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 ff281c56e9bc..a9a186ed6f7e 100644 --- a/airbyte-config/init/src/main/resources/seed/source_specs.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_specs.yaml @@ -14318,6 +14318,26 @@ - - "client_secret" oauthFlowOutputParameters: - - "refresh_token" +- dockerImage: "airbyte/source-vantage:0.1.0" + spec: + documentationUrl: "https://docs.airbyte.com/integrations/sources/vantage" + connectionSpecification: + $schema: "http://json-schema.org/draft-07/schema#" + title: "Vantage Spec" + type: "object" + required: + - "access_token" + additionalProperties: true + properties: + access_token: + title: "API Access Token" + type: "string" + description: "Your API Access token. See here." + airbyte_secret: true + supportsNormalization: false + supportsDBT: false + supported_destination_sync_modes: [] - dockerImage: "farosai/airbyte-victorops-source:0.1.23" spec: documentationUrl: "https://docs.faros.ai" diff --git a/airbyte-integrations/connectors/source-vantage/.dockerignore b/airbyte-integrations/connectors/source-vantage/.dockerignore new file mode 100644 index 000000000000..c0388c41ee97 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/.dockerignore @@ -0,0 +1,6 @@ +* +!Dockerfile +!main.py +!source_vantage +!setup.py +!secrets diff --git a/airbyte-integrations/connectors/source-vantage/Dockerfile b/airbyte-integrations/connectors/source-vantage/Dockerfile new file mode 100644 index 000000000000..98f4a59e8e03 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/Dockerfile @@ -0,0 +1,38 @@ +FROM python:3.9.11-alpine3.15 as base + +# build and load all requirements +FROM base as builder +WORKDIR /airbyte/integration_code + +# upgrade pip to the latest version +RUN apk --no-cache upgrade \ + && pip install --upgrade pip \ + && apk --no-cache add tzdata build-base + + +COPY setup.py ./ +# install necessary packages to a temporary folder +RUN pip install --prefix=/install . + +# build a clean environment +FROM base +WORKDIR /airbyte/integration_code + +# copy all loaded and built libraries to a pure basic image +COPY --from=builder /install /usr/local +# add default timezone settings +COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime +RUN echo "Etc/UTC" > /etc/timezone + +# bash is installed for more convenient debugging. +RUN apk --no-cache add bash + +# copy payload code only +COPY main.py ./ +COPY source_vantage ./source_vantage + +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-vantage diff --git a/airbyte-integrations/connectors/source-vantage/README.md b/airbyte-integrations/connectors/source-vantage/README.md new file mode 100644 index 000000000000..27ab78efacdf --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/README.md @@ -0,0 +1,79 @@ +# Vantage Source Test + +This is the repository for the Vantage configuration based source connector. +For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/vantage). + +## Local development + +#### Building via Gradle +You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow. + +To build using Gradle, from the Airbyte repository root, run: +``` +./gradlew :airbyte-integrations:connectors:source-vantage:build +``` + +#### Create credentials +**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/vantage) +to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_vantage/spec.yaml` file. +Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information. +See `integration_tests/sample_config.json` for a sample config file. + +**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source vantage test creds` +and place them into `secrets/config.json`. + +### Locally running the connector docker image + +#### Build +First, make sure you build the latest Docker image: +``` +docker build . -t airbyte/source-vantage:dev +``` + +You can also build the connector image via Gradle: +``` +./gradlew :airbyte-integrations:connectors:source-vantage: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-vantage:dev spec +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-vantage:dev check --config /secrets/config.json +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-vantage:dev discover --config /secrets/config.json +docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-vantage:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json +``` +## Testing + +#### Acceptance Tests +Customize `acceptance-test-config.yml` file to configure tests. See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference) for more information. +If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py. + +To run your integration tests with docker + +### Using gradle to run tests +All commands should be run from airbyte project root. +To run unit tests: +``` +./gradlew :airbyte-integrations:connectors:source-vantage:unitTest +``` +To run acceptance and custom integration tests: +``` +./gradlew :airbyte-integrations:connectors:source-vantage: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-vantage/__init__.py b/airbyte-integrations/connectors/source-vantage/__init__.py new file mode 100644 index 000000000000..1100c1c58cf5 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/__init__.py @@ -0,0 +1,3 @@ +# +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. +# diff --git a/airbyte-integrations/connectors/source-vantage/acceptance-test-config.yml b/airbyte-integrations/connectors/source-vantage/acceptance-test-config.yml new file mode 100644 index 000000000000..6a4e59447022 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/acceptance-test-config.yml @@ -0,0 +1,40 @@ +# See [Source Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/source-acceptance-tests-reference) +# for more information about how to configure these tests +connector_image: airbyte/source-vantage:dev +acceptance_tests: + spec: + tests: + - spec_path: "source_vantage/spec.yaml" + connection: + tests: + - config_path: "secrets/config.json" + status: "succeed" + - config_path: "integration_tests/invalid_config.json" + status: "failed" + discovery: + tests: + - config_path: "secrets/config.json" + basic_read: + tests: + - config_path: "secrets/config.json" + configured_catalog_path: "integration_tests/configured_catalog.json" + empty_streams: + - name: reports + bypass_reason: "This stream can't be seeded in our sandbox account" +# 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: + bypass_reason: "This connector does not implement incremental sync" +# TODO uncomment this block this block if your connector implements incremental sync: +# tests: +# - config_path: "secrets/config.json" +# configured_catalog_path: "integration_tests/configured_catalog.json" +# future_state_path: "integration_tests/abnormal_state.json" + full_refresh: + tests: + - config_path: "secrets/config.json" + configured_catalog_path: "integration_tests/configured_catalog.json" diff --git a/airbyte-integrations/connectors/source-vantage/acceptance-test-docker.sh b/airbyte-integrations/connectors/source-vantage/acceptance-test-docker.sh new file mode 100644 index 000000000000..c51577d10690 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/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-vantage/build.gradle b/airbyte-integrations/connectors/source-vantage/build.gradle new file mode 100644 index 000000000000..a6274c8c2cbb --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/build.gradle @@ -0,0 +1,9 @@ +plugins { + id 'airbyte-python' + id 'airbyte-docker' + id 'airbyte-source-acceptance-test' +} + +airbytePython { + moduleDirectory 'source_vantage' +} diff --git a/airbyte-integrations/connectors/source-vantage/integration_tests/__init__.py b/airbyte-integrations/connectors/source-vantage/integration_tests/__init__.py new file mode 100644 index 000000000000..1100c1c58cf5 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/integration_tests/__init__.py @@ -0,0 +1,3 @@ +# +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. +# diff --git a/airbyte-integrations/connectors/source-vantage/integration_tests/abnormal_state.json b/airbyte-integrations/connectors/source-vantage/integration_tests/abnormal_state.json new file mode 100644 index 000000000000..52b0f2c2118f --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/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-vantage/integration_tests/acceptance.py b/airbyte-integrations/connectors/source-vantage/integration_tests/acceptance.py new file mode 100644 index 000000000000..1302b2f57e10 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/integration_tests/acceptance.py @@ -0,0 +1,16 @@ +# +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. +# + + +import pytest + +pytest_plugins = ("source_acceptance_test.plugin",) + + +@pytest.fixture(scope="session", autouse=True) +def connector_setup(): + """This fixture is a placeholder for external resources that acceptance test might require.""" + # TODO: setup test dependencies if needed. otherwise remove the TODO comments + yield + # TODO: clean up test dependencies diff --git a/airbyte-integrations/connectors/source-vantage/integration_tests/configured_catalog.json b/airbyte-integrations/connectors/source-vantage/integration_tests/configured_catalog.json new file mode 100644 index 000000000000..555aeb01ee49 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/integration_tests/configured_catalog.json @@ -0,0 +1,40 @@ +{ + "streams": [ + { + "stream": { + "name": "providers", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "services", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "products", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "reports", + "json_schema": {}, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-vantage/integration_tests/invalid_config.json b/airbyte-integrations/connectors/source-vantage/integration_tests/invalid_config.json new file mode 100644 index 000000000000..e7823c2be36c --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/integration_tests/invalid_config.json @@ -0,0 +1,3 @@ +{ + "access_token": "" +} diff --git a/airbyte-integrations/connectors/source-vantage/integration_tests/sample_config.json b/airbyte-integrations/connectors/source-vantage/integration_tests/sample_config.json new file mode 100644 index 000000000000..1dcd58d49b1d --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/integration_tests/sample_config.json @@ -0,0 +1,3 @@ +{ + "access_token": "6F8-ffwMe87mOd6K3pQopAoZXD4PuNCZYBpB7pgUaRg" +} diff --git a/airbyte-integrations/connectors/source-vantage/integration_tests/sample_state.json b/airbyte-integrations/connectors/source-vantage/integration_tests/sample_state.json new file mode 100644 index 000000000000..3587e579822d --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/integration_tests/sample_state.json @@ -0,0 +1,5 @@ +{ + "todo-stream-name": { + "todo-field-name": "value" + } +} diff --git a/airbyte-integrations/connectors/source-vantage/main.py b/airbyte-integrations/connectors/source-vantage/main.py new file mode 100644 index 000000000000..af2112debc97 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/main.py @@ -0,0 +1,13 @@ +# +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. +# + + +import sys + +from airbyte_cdk.entrypoint import launch +from source_vantage import SourceVantage + +if __name__ == "__main__": + source = SourceVantage() + launch(source, sys.argv[1:]) diff --git a/airbyte-integrations/connectors/source-vantage/requirements.txt b/airbyte-integrations/connectors/source-vantage/requirements.txt new file mode 100644 index 000000000000..0411042aa091 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/requirements.txt @@ -0,0 +1,2 @@ +-e ../../bases/source-acceptance-test +-e . diff --git a/airbyte-integrations/connectors/source-vantage/setup.py b/airbyte-integrations/connectors/source-vantage/setup.py new file mode 100644 index 000000000000..1ddfdb789b6c --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/setup.py @@ -0,0 +1,29 @@ +# +# Copyright (c) 2022 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_vantage", + description="Source implementation for Vantage.", + author="Airbyte", + author_email="contact@airbyte.io", + packages=find_packages(), + install_requires=MAIN_REQUIREMENTS, + package_data={"": ["*.json", "*.yaml", "schemas/*.json", "schemas/shared/*.json"]}, + extras_require={ + "tests": TEST_REQUIREMENTS, + }, +) diff --git a/airbyte-integrations/connectors/source-vantage/source_vantage/__init__.py b/airbyte-integrations/connectors/source-vantage/source_vantage/__init__.py new file mode 100644 index 000000000000..95bc26eee66e --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/source_vantage/__init__.py @@ -0,0 +1,8 @@ +# +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. +# + + +from .source import SourceVantage + +__all__ = ["SourceVantage"] diff --git a/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/products.json b/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/products.json new file mode 100644 index 000000000000..811becb81adc --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/products.json @@ -0,0 +1,34 @@ +{ + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "category": { + "type": "string", + "example": "compute", + "description": "The category of the cloud product" + }, + "name": { + "type": "string", + "example": "EC2", + "description": "The common name of the product." + }, + "service_id": { + "type": "string", + "example": "aws-ec2", + "description": "A unique slug for the service the product belongs to." + }, + "provider_id": { + "type": "string", + "example": "aws", + "description": "A unique slug for the provider the product belongs to." + }, + "details": { + "type": "object", + "description": "An object of metadata about the product." + } + }, + "description": "Products model", + "$schema": "http://json-schema.org/schema#" +} diff --git a/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/providers.json b/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/providers.json new file mode 100644 index 000000000000..f8c9ddc07d5e --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/providers.json @@ -0,0 +1,20 @@ +{ + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string", + "example": "AWS", + "description": "The common name of the provider." + }, + "description": { + "type": "string", + "example": "Amazon Web Services", + "description": "The full descriptive name of the provider." + } + }, + "description": "Providers model", + "$schema": "http://json-schema.org/schema#" +} diff --git a/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/reports.json b/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/reports.json new file mode 100644 index 000000000000..2f9cd14b3e6a --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/reports.json @@ -0,0 +1,34 @@ +{ + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string", + "example": "Production Environment", + "description": "The title of the cost report." + }, + "earliest_cost_date": { + "type": "string", + "example": "2021-07-09T00:00:00Z", + "description": "The date and time, in UTC, the report was created. ISO 8601 Formatted." + }, + "latest_cost_date": { + "type": "string", + "example": "2021-07-09T00:00:00Z", + "description": "The date and time, in UTC, the report was created. ISO 8601 Formatted." + }, + "created_at": { + "type": "string", + "example": "2021-07-09T00:00:00Z", + "description": "The date and time, in UTC, the report was created. ISO 8601 Formatted." + }, + "workspace": { + "type": "string", + "description": "The name of the workspace the report is a part of." + } + }, + "description": "Reports model", + "$schema": "http://json-schema.org/schema#" +} diff --git a/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/services.json b/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/services.json new file mode 100644 index 000000000000..4e5c87a52288 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/source_vantage/schemas/services.json @@ -0,0 +1,25 @@ +{ + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "category": { + "type": "string", + "example": "compute", + "description": "The type of cloud service." + }, + "name": { + "type": "string", + "example": "EC2", + "description": "The common name of the service. Usually an abbreviation." + }, + "description": { + "type": "string", + "example": "Elastic Compute Cloud", + "description": "The full name of the service." + } + }, + "description": "Services model", + "$schema": "http://json-schema.org/schema#" +} diff --git a/airbyte-integrations/connectors/source-vantage/source_vantage/source.py b/airbyte-integrations/connectors/source-vantage/source_vantage/source.py new file mode 100644 index 000000000000..0d907c3358a6 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/source_vantage/source.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2022 Airbyte, Inc., all rights reserved. +# + +from airbyte_cdk.sources.declarative.yaml_declarative_source import YamlDeclarativeSource + +""" +This file provides the necessary constructs to interpret a provided declarative YAML configuration file into +source connector. + +WARNING: Do not modify this file. +""" + + +# Declarative Source +class SourceVantage(YamlDeclarativeSource): + def __init__(self): + super().__init__(**{"path_to_yaml": "vantage.yaml"}) diff --git a/airbyte-integrations/connectors/source-vantage/source_vantage/spec.yaml b/airbyte-integrations/connectors/source-vantage/source_vantage/spec.yaml new file mode 100644 index 000000000000..531ad4ac1372 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/source_vantage/spec.yaml @@ -0,0 +1,16 @@ +documentationUrl: https://docs.airbyte.com/integrations/sources/vantage +connectionSpecification: + $schema: http://json-schema.org/draft-07/schema# + title: Vantage Spec + type: object + required: + - access_token + additionalProperties: true + properties: + access_token: + title: API Access Token + type: string + description: >- + Your API Access token. See here. + airbyte_secret: true diff --git a/airbyte-integrations/connectors/source-vantage/source_vantage/vantage.yaml b/airbyte-integrations/connectors/source-vantage/source_vantage/vantage.yaml new file mode 100644 index 000000000000..76c2367c7a80 --- /dev/null +++ b/airbyte-integrations/connectors/source-vantage/source_vantage/vantage.yaml @@ -0,0 +1,67 @@ +version: "0.1.0" + +definitions: + selector: + extractor: + field_pointer: ["{{ options['name'] }}"] + requester: + url_base: "https://api.vantage.sh/v1" + http_method: "GET" + authenticator: + type: BearerAuthenticator + api_token: "{{ config['access_token'] }}" + increment_paginator: + type: "DefaultPaginator" + url_base: "*ref(definitions.requester.url_base)" + page_size_option: + inject_into: "request_parameter" + field_name: "limit" + pagination_strategy: + type: "PageIncrement" + page_size: 100 + page_token_option: + inject_into: "request_parameter" + field_name: "page" + retriever: + record_selector: + $ref: "*ref(definitions.selector)" + paginator: + $ref: "*ref(definitions.increment_paginator)" + requester: + $ref: "*ref(definitions.requester)" + base_stream: + retriever: + $ref: "*ref(definitions.retriever)" + providers_stream: + $ref: "*ref(definitions.base_stream)" + $options: + name: "providers" + primary_key: "id" + path: "/providers" + services_stream: + $ref: "*ref(definitions.base_stream)" + $options: + name: "services" + primary_key: "id" + path: "/services" + products_stream: + $ref: "*ref(definitions.base_stream)" + $options: + name: "products" + primary_key: "id" + path: "/products" + reports_stream: + $ref: "*ref(definitions.base_stream)" + $options: + name: "reports" + primary_key: "id" + path: "/reports" +streams: + - "*ref(definitions.providers_stream)" + - "*ref(definitions.services_stream)" + - "*ref(definitions.products_stream)" + - "*ref(definitions.reports_stream)" + +check: + stream_names: + - "providers" diff --git a/docs/integrations/sources/vantage.md b/docs/integrations/sources/vantage.md new file mode 100644 index 000000000000..997e065413b8 --- /dev/null +++ b/docs/integrations/sources/vantage.md @@ -0,0 +1,35 @@ +# Vantage API + +## Sync overview + +This source can sync data from the [Vantage API](https://vantage.readme.io/reference/general). At present this connector only supports full refresh syncs meaning that each time you use the connector it will sync all available records from scratch. Please use cautiously if you expect your API to have a lot of records. + +## This Source Supports the Following Streams + +* Providers: Providers are the highest level API Primitive. A Provider represents either cloud infrastructure provider or a cloud service provider. Some examples of Providers include AWS, GCP or Azure. Providers offer many Services, which is documented below. +* Services: Services are what Providers offer to their customers. A Service is always tied to a Provider. Some examples of Services are EC2 or S3 from a Provider of AWS. A Service has one or more Products offered, which is documented below. +* Products: Products are what Services ultimately price on. Using the example of a Provider of 'AWS' and a Service of 'EC2', Products would be the individual EC2 Instance Types available such as 'm5d.16xlarge' or 'c5.xlarge'. A Product has one or more Prices, which is documented below. +* Reports + +### Features + +| Feature | Supported?\(Yes/No\) | Notes | +| :--- | :--- | :--- | +| Full Refresh Sync | Yes | | +| Incremental Sync | No | | + +### Performance considerations + +Vantage APIs are under rate limits for the number of API calls allowed per API keys per second. If you reach a rate limit, API will return a 429 HTTP error code. See [here](https://vantage.readme.io/reference/rate-limiting) + +## Getting started + +### Requirements + +* Vantage Access token + +## Changelog + +| Version | Date | Pull Request | Subject | +| :------ | :--------- | :-------------------------------------------------------- | :----------------------------------------- | +| 0.1.0 | 2022-10-30 | [#18665](https://github.com/airbytehq/airbyte/pull/18665) | 🎉 New Source: Vantage API [low-code CDK] | \ No newline at end of file