Skip to content

Commit 2e58a78

Browse files
committed
add GetTagShasStream
1 parent 9033fe4 commit 2e58a78

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

tap_github/repository_streams.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,6 +2625,53 @@ class TagsStream(GitHubRestStream):
26252625
th.Property("tarball_url", th.StringType),
26262626
th.Property("node_id", th.StringType),
26272627
).to_dict()
2628+
2629+
def get_child_context(self, record: dict, context: dict | None) -> dict:
2630+
"""Return a child context object from the record and optional provided context.
2631+
By default, will return context if provided and otherwise the record dict.
2632+
Developers may override this behavior to send specific information to child
2633+
streams for context.
2634+
"""
2635+
return {
2636+
"org": context["org"] if context else None,
2637+
"repo": context["repo"] if context else None,
2638+
"tag_name": record["name"],
2639+
"repo_id": context["repo_id"] if context else None,
2640+
}
2641+
2642+
class GetTagShasStream(GitHubRestStream):
2643+
"""A stream dedicated to fetching tag shas of a tag in a repository.
2644+
2645+
API docs: https://docs.github.com/en/rest/git/refs#get-a-reference
2646+
"""
2647+
2648+
name = "get_tag_shas"
2649+
path = "/repos/{org}/{repo}/git/ref/tags/{tag_name}"
2650+
primary_keys: ClassVar[list[str]] = ["node_id"]
2651+
parent_stream_type = TagsStream
2652+
ignore_parent_replication_key = True
2653+
state_partitioning_keys: ClassVar[list[str]] = ["repo", "org", "tag_name"]
2654+
tolerated_http_errors: ClassVar[list[int]] = [404]
2655+
2656+
schema = th.PropertiesList(
2657+
# Parent Keys
2658+
th.Property("repo", th.StringType),
2659+
th.Property("org", th.StringType),
2660+
th.Property("repo_id", th.IntegerType),
2661+
th.Property("tag_name", th.StringType),
2662+
# Tag Sha Details
2663+
th.Property("ref", th.StringType),
2664+
th.Property("node_id", th.StringType),
2665+
th.Property("url", th.StringType),
2666+
th.Property(
2667+
"object",
2668+
th.ObjectType(
2669+
th.Property("type", th.StringType),
2670+
th.Property("sha", th.StringType),
2671+
th.Property("url", th.StringType),
2672+
),
2673+
),
2674+
).to_dict()
26282675

26292676

26302677
class DeploymentsStream(GitHubRestStream):

tap_github/streams.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
DeploymentStatusesStream,
2525
EventsStream,
2626
ExtraMetricsStream,
27+
GetTagShasStream,
2728
IssueCommentsStream,
2829
IssueEventsStream,
2930
IssuesStream,
@@ -88,6 +89,7 @@ def __init__(self, valid_queries: set[str], streams: list[type[Stream]]) -> None
8889
DeploymentsStream,
8990
DeploymentStatusesStream,
9091
EventsStream,
92+
GetTagShasStream,
9193
IssueCommentsStream,
9294
IssueEventsStream,
9395
IssuesStream,

0 commit comments

Comments
 (0)