Skip to content

Commit

Permalink
Move FS configs to their own module
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Sep 6, 2024
1 parent 2f45921 commit dab9112
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 83 deletions.
89 changes: 89 additions & 0 deletions tap_csv/filesystem_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"""JSON Schema for each filesystem configuration."""

from __future__ import annotations

from singer_sdk import typing as th # JSON schema typing helpers

FTP = th.Property(
"ftp",
th.ObjectType(
th.Property(
"host",
th.StringType,
required=True,
description="FTP server host",
),
th.Property(
"port",
th.IntegerType,
default=21,
description="FTP server port",
),
th.Property(
"username",
th.StringType,
description="FTP username",
),
th.Property(
"password",
th.StringType,
secret=True,
description="FTP password",
),
th.Property(
"encoding",
th.StringType,
default="utf-8",
description="FTP server encoding",
),
),
description="FTP connection settings",
)

GITHUB = th.Property(
"github",
th.ObjectType(
th.Property(
"org",
th.StringType,
required=True,
description=("GitHub organization or user where the repository is located"),
),
th.Property(
"repo",
th.StringType,
required=True,
description="GitHub repository",
),
th.Property(
"username",
th.StringType,
required=False,
description="GitHub username",
),
th.Property(
"token",
th.StringType,
required=False,
secret=True,
description="GitHub token",
),
),
description="GitHub connection settings",
)

DROPBOX = (
th.Property(
"dropbox",
th.ObjectType(
th.Property(
"token",
th.StringType,
secret=True,
required=True,
description="Dropbox token",
),
),
description="Dropbox connection settings",
),
)
88 changes: 5 additions & 83 deletions tap_csv/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from singer_sdk.helpers._classproperty import classproperty
from singer_sdk.helpers.capabilities import TapCapabilities

from tap_csv.client import CSVStream
from . import client, filesystem_config


class TapCSV(Tap):
Expand Down Expand Up @@ -53,87 +53,9 @@ class TapCSV(Tap):
"dropbox",
],
),
th.Property(
"ftp",
th.ObjectType(
th.Property(
"host",
th.StringType,
required=True,
description="FTP server host",
),
th.Property(
"port",
th.IntegerType,
default=21,
description="FTP server port",
),
th.Property(
"username",
th.StringType,
description="FTP username",
),
th.Property(
"password",
th.StringType,
secret=True,
description="FTP password",
),
th.Property(
"encoding",
th.StringType,
default="utf-8",
description="FTP server encoding",
),
),
description="FTP connection settings",
),
th.Property(
"github",
th.ObjectType(
th.Property(
"org",
th.StringType,
required=True,
description=(
"GitHub organization or user where the repository is located"
),
),
th.Property(
"repo",
th.StringType,
required=True,
description="GitHub repository",
),
th.Property(
"username",
th.StringType,
required=False,
description="GitHub username",
),
th.Property(
"token",
th.StringType,
required=False,
secret=True,
description="GitHub token",
),
),
description="GitHub connection settings",
),
th.Property(
"dropbox",
th.ObjectType(
th.Property(
"token",
th.StringType,
secret=True,
required=True,
description="Dropbox token",
),
),
description="Dropbox connection settings",
),
filesystem_config.FTP,
filesystem_config.GITHUB,
filesystem_config.DROPBOX,
th.Property(
"csv_files_definition",
th.StringType,
Expand Down Expand Up @@ -189,7 +111,7 @@ def discover_streams(self) -> list[Stream]:
raise ConfigValidationError(msg, errors=errors)

return [
CSVStream(
client.CSVStream(
tap=self,
name=file_config.get("entity"),
file_config=file_config,
Expand Down

0 comments on commit dab9112

Please sign in to comment.