forked from MeltanoLabs/tap-gmail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ken Payne
committed
Aug 13, 2022
1 parent
9c6c70e
commit d449a4b
Showing
6 changed files
with
48 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,3 +136,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# IDE | ||
.vscode/ |
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
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
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,13 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "string", | ||
"description": "The immutable ID of the message." | ||
}, | ||
"threadId": { | ||
"type": "string", | ||
"description": "The ID of the thread the message belongs to." | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,22 +1,43 @@ | ||
"""Stream type classes for tap-gmail.""" | ||
|
||
from pathlib import Path | ||
from typing import Optional | ||
|
||
from tap_gmail.client import GmailStream | ||
|
||
SCHEMAS_DIR = Path(__file__).parent / Path("./schemas") | ||
|
||
|
||
class MessagesStream(GmailStream): | ||
class MessageListStream(GmailStream): | ||
"""Define custom stream.""" | ||
|
||
name = "messages" | ||
name = "message_list" | ||
primary_keys = ["id"] | ||
replication_key = None | ||
# Optionally, you may also use `schema_filepath` in place of `schema`: | ||
schema_filepath = SCHEMAS_DIR / "messages.json" | ||
schema_filepath = SCHEMAS_DIR / "message_list.json" | ||
records_jsonpath = "$.messages[*]" | ||
next_page_token_jsonpath = "$.nextPageToken" | ||
|
||
@property | ||
def path(self): | ||
"""Set the path for the stream.""" | ||
return "/gmail/v1/users/" + self.config["user_id"] + "/messages" | ||
|
||
def get_child_context(self, record: dict, context: Optional[dict]) -> dict: | ||
"""Return a context dictionary for child streams.""" | ||
return {"message_id": record["id"]} | ||
|
||
|
||
class MessagesStream(GmailStream): | ||
|
||
name = "messages" | ||
replication_key = None | ||
schema_filepath = SCHEMAS_DIR / "messages.json" | ||
parent_stream_type = MessageListStream | ||
ignore_parent_replication_keys = True | ||
state_partitioning_keys = [] | ||
|
||
@property | ||
def path(self): | ||
"""Set the path for the stream.""" | ||
return "/gmail/v1/users/" + self.config["user_id"] + "/messages/{message_id}" |
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