Migrate CDK Stripe source to PyPi and new structure (#3302)
Co-authored-by: Davin Chia <davinchia@gmail.com>
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
FROM airbyte/integration-base-python:0.1.5
|
||||
FROM python:3.7-slim
|
||||
|
||||
# Bash is installed for more convenient debugging.
|
||||
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV CODE_PATH="source_stripe"
|
||||
ENV AIRBYTE_IMPL_MODULE="source_stripe"
|
||||
ENV AIRBYTE_IMPL_PATH="SourceStripe"
|
||||
|
||||
WORKDIR /airbyte/integration_code
|
||||
COPY $CODE_PATH ./$CODE_PATH
|
||||
COPY source_stripe ./source_stripe
|
||||
COPY main.py ./
|
||||
COPY setup.py ./
|
||||
RUN pip install .
|
||||
|
||||
LABEL io.airbyte.version=0.1.4
|
||||
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
|
||||
|
||||
LABEL io.airbyte.version=0.1.6
|
||||
LABEL io.airbyte.name=airbyte/source-stripe
|
||||
|
||||
@@ -10,23 +10,20 @@ airbytePython {
|
||||
|
||||
airbyteStandardSourceTestFile {
|
||||
// For more information on standard source tests, see https://docs.airbyte.io/contributing-to-airbyte/building-new-connector/testing-connectors
|
||||
|
||||
// All these input paths must live inside this connector's directory (or subdirectories)
|
||||
// TODO update the spec JSON file
|
||||
|
||||
specPath = "source_stripe/spec.json"
|
||||
|
||||
// configPath points to a config file which matches the spec.json supplied above. secrets/ is gitignored by default, so place your config file
|
||||
// there (in case it contains any credentials)
|
||||
// TODO update the config file to contain actual credentials
|
||||
configPath = "secrets/config.json"
|
||||
// TODO update the sample configured_catalog JSON for use in testing
|
||||
|
||||
// Note: If your source supports incremental syncing, then make sure that the catalog that is returned in the get_catalog method is configured
|
||||
// for incremental syncing (e.g. include cursor fields, etc).
|
||||
configuredCatalogPath = "sample_files/full_catalog.json"
|
||||
configuredCatalogPath = "sample_files/configured_catalog.json"
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation files(project(':airbyte-integrations:bases:base-standard-source-test-file').airbyteDocker.outputs)
|
||||
implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs)
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Stripe Source Spec",
|
||||
"type": "object",
|
||||
"required": ["client_secret", "account_id", "start_date"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"client_secret": {
|
||||
"type": "string",
|
||||
"pattern": "^(s|r)k_(live|test)_[a-zA-Z0-9]+$",
|
||||
"description": "Stripe API key (usually starts with 'sk_live_'; find yours <a href=\"https://dashboard.stripe.com/apikeys\">here</a>).",
|
||||
"airbyte_secret": true
|
||||
},
|
||||
"account_id": {
|
||||
"type": "string",
|
||||
"pattern": "^acct_[a-zA-Z0-9]+$",
|
||||
"description": "Your Stripe account ID (starts with 'acct_', find yours <a href=\"https://dashboard.stripe.com/settings/account\">here</a>)."
|
||||
},
|
||||
"start_date": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
|
||||
"description": "UTC date and time in the format 2017-01-25T00:00:00Z. Any data before this date will not be replicated.",
|
||||
"examples": ["2017-01-25T00:00:00Z"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from base_python.entrypoint import launch
|
||||
from airbyte_cdk.entrypoint import launch
|
||||
from source_stripe import SourceStripe
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -1,3 +0,0 @@
|
||||
-e ../../bases/airbyte-protocol
|
||||
-e ../../bases/base-python
|
||||
-e .
|
||||
@@ -30,5 +30,5 @@ setup(
|
||||
author_email="contact@airbyte.io",
|
||||
packages=find_packages(),
|
||||
package_data={"": ["*.json", "schemas/*.json", "schemas/shared/*.json"]},
|
||||
install_requires=["airbyte-protocol", "base-python", "stripe"],
|
||||
install_requires=["airbyte-cdk==0.1.0rc5", "stripe"],
|
||||
)
|
||||
|
||||
@@ -27,8 +27,12 @@ from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple
|
||||
|
||||
import requests
|
||||
import stripe
|
||||
from airbyte_protocol import SyncMode
|
||||
from base_python import AbstractSource, HttpStream, Stream, TokenAuthenticator
|
||||
from airbyte_cdk import AirbyteLogger
|
||||
from airbyte_cdk.models import SyncMode
|
||||
from airbyte_cdk.sources import AbstractSource
|
||||
from airbyte_cdk.sources.streams import Stream
|
||||
from airbyte_cdk.sources.streams.http import HttpStream
|
||||
from airbyte_cdk.sources.streams.http.auth import TokenAuthenticator
|
||||
|
||||
|
||||
class StripeStream(HttpStream, ABC):
|
||||
@@ -260,7 +264,7 @@ class BankAccounts(StripeStream):
|
||||
|
||||
|
||||
class SourceStripe(AbstractSource):
|
||||
def check_connection(self, logger, config) -> Tuple[bool, any]:
|
||||
def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, any]:
|
||||
try:
|
||||
stripe.api_key = config["client_secret"]
|
||||
stripe.Account.retrieve(config["account_id"])
|
||||
|
||||
Reference in New Issue
Block a user