From 30fad481fe35be27b6f373e8dac913dab81173c4 Mon Sep 17 00:00:00 2001 From: Marvin Davila Date: Wed, 12 Feb 2025 14:50:41 -0500 Subject: [PATCH 1/2] add github branches stream --- tap_github/repository_streams.py | 42 ++++++++++++++++++++++++++++++++ tap_github/streams.py | 2 ++ 2 files changed, 44 insertions(+) diff --git a/tap_github/repository_streams.py b/tap_github/repository_streams.py index b2658637..1070c010 100644 --- a/tap_github/repository_streams.py +++ b/tap_github/repository_streams.py @@ -2548,3 +2548,45 @@ class TrafficPageViewsStream(TrafficRestStream): th.Property("count", th.IntegerType), th.Property("uniques", th.IntegerType), ).to_dict() + + +class BranchesStream(GitHubRestStream): + """A stream dedicated to fetching the branches of a repository.""" + + name = "branches" + path = "/repos/{org}/{repo}/branches" + primary_keys: ClassVar[list[str]] = ["repo", "org"] + parent_stream_type = RepositoryStream + ignore_parent_replication_key = True + state_partitioning_keys: ClassVar[list[str]] = ["repo", "org"] + tolerated_http_errors: ClassVar[list[int]] = [404] + + schema = th.PropertiesList( + # Parent Keys + th.Property("repo", th.StringType), + th.Property("org", th.StringType), + th.Property("repo_id", th.IntegerType), + # Branch Keys + th.Property("name", th.StringType), + th.Property( + "commit", + th.ObjectType( + th.Property("sha", th.StringType), + th.Property("url", th.StringType), + ), + ), + th.Property("protected", th.BooleanType), + th.Property( + "protection", + th.ObjectType( + th.Property( + "required_status_checks", + th.ObjectType( + th.Property("enforcement_level", th.StringType), + th.Property("contexts", th.ArrayType(th.StringType)), + ), + ), + ), + ), + th.Property("protection_url", th.StringType), + ).to_dict() diff --git a/tap_github/streams.py b/tap_github/streams.py index f72861d9..d1fd7898 100644 --- a/tap_github/streams.py +++ b/tap_github/streams.py @@ -12,6 +12,7 @@ from tap_github.repository_streams import ( AnonymousContributorsStream, AssigneesStream, + BranchesStream, CollaboratorsStream, CommitCommentsStream, CommitsStream, @@ -73,6 +74,7 @@ def __init__(self, valid_queries: set[str], streams: list[type[Stream]]) -> None [ AnonymousContributorsStream, AssigneesStream, + BranchesStream, CollaboratorsStream, CommitCommentsStream, CommitsStream, From 827af4d79cb85adb560192d3aa19916ab5d01676 Mon Sep 17 00:00:00 2001 From: Marvin Davila Date: Wed, 12 Feb 2025 19:12:53 -0500 Subject: [PATCH 2/2] add TagsStream --- tap_github/repository_streams.py | 30 ++++++++++++++++++++++++++++++ tap_github/streams.py | 2 ++ 2 files changed, 32 insertions(+) diff --git a/tap_github/repository_streams.py b/tap_github/repository_streams.py index 1070c010..0d5e2b8d 100644 --- a/tap_github/repository_streams.py +++ b/tap_github/repository_streams.py @@ -2590,3 +2590,33 @@ class BranchesStream(GitHubRestStream): ), th.Property("protection_url", th.StringType), ).to_dict() + + +class TagsStream(GitHubRestStream): + """A stream dedicated to fetching tags in a repository.""" + + name = "tags" + path = "/repos/{org}/{repo}/tags" + primary_keys: ClassVar[list[str]] = ["repo", "org"] + parent_stream_type = RepositoryStream + ignore_parent_replication_key = True + state_partitioning_keys: ClassVar[list[str]] = ["repo", "org"] + + schema = th.PropertiesList( + # Parent Keys + th.Property("repo", th.StringType), + th.Property("org", th.StringType), + th.Property("repo_id", th.IntegerType), + # Tag Keys + th.Property("name", th.StringType), + th.Property( + "commit", + th.ObjectType( + th.Property("sha", th.StringType), + th.Property("url", th.StringType), + ), + ), + th.Property("zipball_url", th.StringType), + th.Property("tarball_url", th.StringType), + th.Property("node_id", th.StringType), + ).to_dict() diff --git a/tap_github/streams.py b/tap_github/streams.py index d1fd7898..3f69eb02 100644 --- a/tap_github/streams.py +++ b/tap_github/streams.py @@ -43,6 +43,7 @@ StargazersGraphqlStream, StargazersStream, StatsContributorsStream, + TagsStream, TrafficClonesStream, TrafficPageViewsStream, TrafficReferralPathsStream, @@ -105,6 +106,7 @@ def __init__(self, valid_queries: set[str], streams: list[type[Stream]]) -> None StargazersGraphqlStream, StargazersStream, StatsContributorsStream, + TagsStream, TrafficClonesStream, TrafficPageViewsStream, TrafficReferralPathsStream,