Skip to content

Commit

Permalink
Added new destination_override tap setting, enabling just the sync of…
Browse files Browse the repository at this point in the history
… destination_children, showing all entities related to your single selected destination
  • Loading branch information
DanielPDWalker committed Jan 28, 2024
1 parent ce74df7 commit e59f226
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tap_theme_parks/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,37 @@ def request_records(self, context: dict | None) -> Iterable[dict]:
for id in self.config.get("live_data_array", []):
self.path = self.path_template.format(live_data_id=id)
yield from super().request_records(context)


class DestinationOverrideStream(ThemeParksStream):
"""Define destination override stream"""

name = "destination_children"
path_template = "/entity/{destination_id}/children"
primary_keys = ["id"]
replication_key = None

schema = th.PropertiesList(
th.Property("id", th.StringType),
th.Property("name", th.StringType),
th.Property("entityType", th.StringType),
th.Property("timezone", th.StringType),
th.Property(
"children",
th.ArrayType(
th.ObjectType(
th.Property("id", th.StringType),
th.Property("name", th.StringType),
th.Property("entityType", th.StringType),
th.Property("slug", th.StringType),
th.Property("externalId", th.StringType),
)
),
),
).to_dict()


def request_records(self, context: dict | None) -> Iterable[dict]:
destination_id = self.config.get("destination_override")
self.path = self.path_template.format(destination_id=destination_id)
yield from super().request_records(context)
6 changes: 6 additions & 0 deletions tap_theme_parks/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TapThemeParks(Tap):

config_jsonschema = th.PropertiesList(
th.Property("live_data_array", th.ArrayType(th.StringType)),
th.Property("destination_override", th.StringType),
).to_dict()

def discover_streams(self) -> list[streams.ThemeParksStream]:
Expand All @@ -34,6 +35,11 @@ def discover_streams(self) -> list[streams.ThemeParksStream]:
if self.config.get("live_data_array"):
selected_streams.append(streams.LiveDataStream(self))

if self.config.get("destination_override"):
selected_streams = [
streams.DestinationOverrideStream(self)
]

return selected_streams


Expand Down

0 comments on commit e59f226

Please sign in to comment.