Skip to content

Commit 1d74814

Browse files
committed
add TagDetailsStream
1 parent 2e58a78 commit 1d74814

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

tap_github/repository_streams.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,6 +2673,71 @@ class GetTagShasStream(GitHubRestStream):
26732673
),
26742674
).to_dict()
26752675

2676+
def get_child_context(self, record: dict, context: dict | None) -> dict:
2677+
"""Return a child context object from the record and optional provided context.
2678+
By default, will return context if provided and otherwise the record dict.
2679+
Developers may override this behavior to send specific information to child
2680+
streams for context.
2681+
"""
2682+
return {
2683+
"org": context["org"] if context else None,
2684+
"repo": context["repo"] if context else None,
2685+
"tag_sha": record["object"]["sha"] if record.get("object") else None,
2686+
"repo_id": context["repo_id"] if context else None,
2687+
}
2688+
2689+
2690+
class TagDetailsStream(GitHubRestStream):
2691+
"""A stream dedicated to fetching details of a tag in a repository."""
2692+
2693+
name = "tag_details"
2694+
path = "/repos/{org}/{repo}/git/tags/{tag_sha}"
2695+
primary_keys: ClassVar[list[str]] = ["node_id"]
2696+
parent_stream_type = GetTagShasStream
2697+
ignore_parent_replication_key = True
2698+
state_partitioning_keys: ClassVar[list[str]] = ["repo", "org", "tag_sha"]
2699+
tolerated_http_errors: ClassVar[list[int]] = [404]
2700+
2701+
schema = th.PropertiesList(
2702+
# Parent Keys
2703+
th.Property("repo", th.StringType),
2704+
th.Property("org", th.StringType),
2705+
th.Property("repo_id", th.IntegerType),
2706+
th.Property("tag_sha", th.StringType),
2707+
# Tag Details
2708+
th.Property("node_id", th.StringType),
2709+
th.Property("tag", th.StringType),
2710+
th.Property("sha", th.StringType),
2711+
th.Property("url", th.StringType),
2712+
th.Property("message", th.StringType),
2713+
th.Property(
2714+
"tagger",
2715+
th.ObjectType(
2716+
th.Property("name", th.StringType),
2717+
th.Property("email", th.StringType),
2718+
th.Property("date", th.DateTimeType),
2719+
),
2720+
),
2721+
th.Property(
2722+
"object",
2723+
th.ObjectType(
2724+
th.Property("type", th.StringType),
2725+
th.Property("sha", th.StringType),
2726+
th.Property("url", th.StringType),
2727+
),
2728+
),
2729+
th.Property(
2730+
"verification",
2731+
th.ObjectType(
2732+
th.Property("verified", th.BooleanType),
2733+
th.Property("reason", th.StringType),
2734+
th.Property("signature", th.StringType),
2735+
th.Property("payload", th.StringType),
2736+
th.Property("verified_at", th.StringType),
2737+
),
2738+
),
2739+
).to_dict()
2740+
26762741

26772742
class DeploymentsStream(GitHubRestStream):
26782743
"""A stream dedicated to fetching deployments in a repository."""

tap_github/streams.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
StargazersStream,
4848
StatsContributorsStream,
4949
TagsStream,
50+
TagDetailsStream,
5051
TrafficClonesStream,
5152
TrafficPageViewsStream,
5253
TrafficReferralPathsStream,
@@ -113,6 +114,7 @@ def __init__(self, valid_queries: set[str], streams: list[type[Stream]]) -> None
113114
StargazersStream,
114115
StatsContributorsStream,
115116
TagsStream,
117+
TagDetailsStream,
116118
TrafficClonesStream,
117119
TrafficPageViewsStream,
118120
TrafficReferralPathsStream,

0 commit comments

Comments
 (0)