-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨Source Iterable: Migrate to low code (#36231)
- Loading branch information
Showing
18 changed files
with
837 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 26 additions & 28 deletions
54
airbyte-integrations/connectors/source-iterable/poetry.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
airbyte-integrations/connectors/source-iterable/source_iterable/components.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import json | ||
from dataclasses import dataclass | ||
from io import StringIO | ||
|
||
import requests | ||
from airbyte_cdk.sources.declarative.extractors.dpath_extractor import DpathExtractor | ||
from airbyte_cdk.sources.declarative.types import Config, Record, StreamSlice, StreamState | ||
|
||
|
||
@dataclass | ||
class XJsonRecordExtractor(DpathExtractor): | ||
def extract_records(self, response: requests.Response) -> list[Record]: | ||
return [json.loads(record) for record in response.iter_lines()] | ||
|
||
|
||
@dataclass | ||
class ListUsersRecordExtractor(DpathExtractor): | ||
def extract_records(self, response: requests.Response) -> list[Record]: | ||
return [{"email": record.decode()} for record in response.iter_lines()] | ||
|
||
|
||
@dataclass | ||
class EventsRecordExtractor(DpathExtractor): | ||
common_fields = ("itblInternal", "_type", "createdAt", "email") | ||
|
||
def extract_records(self, response: requests.Response) -> list[Record]: | ||
jsonl_records = StringIO(response.text) | ||
records = [] | ||
for record in jsonl_records: | ||
record_dict = json.loads(record) | ||
record_dict_common_fields = {} | ||
for field in self.common_fields: | ||
record_dict_common_fields[field] = record_dict.pop(field, None) | ||
|
||
records.append({**record_dict_common_fields, "data": record_dict}) | ||
|
||
return records |
Oops, something went wrong.