diff --git a/tap_github/repository_streams.py b/tap_github/repository_streams.py index b2658637..0d5e2b8d 100644 --- a/tap_github/repository_streams.py +++ b/tap_github/repository_streams.py @@ -2548,3 +2548,75 @@ 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() + + +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 f72861d9..3f69eb02 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, @@ -42,6 +43,7 @@ StargazersGraphqlStream, StargazersStream, StatsContributorsStream, + TagsStream, TrafficClonesStream, TrafficPageViewsStream, TrafficReferralPathsStream, @@ -73,6 +75,7 @@ def __init__(self, valid_queries: set[str], streams: list[type[Stream]]) -> None [ AnonymousContributorsStream, AssigneesStream, + BranchesStream, CollaboratorsStream, CommitCommentsStream, CommitsStream, @@ -103,6 +106,7 @@ def __init__(self, valid_queries: set[str], streams: list[type[Stream]]) -> None StargazersGraphqlStream, StargazersStream, StatsContributorsStream, + TagsStream, TrafficClonesStream, TrafficPageViewsStream, TrafficReferralPathsStream,