@@ -1551,6 +1551,69 @@ class ReviewsStream(GitHubRestStream):
15511551 th .Property ("author_association" , th .StringType ),
15521552 ).to_dict ()
15531553
1554+ class PullRequestLabelEventsStream (GitHubRestStream ):
1555+ """A stream dedicated to fetching label events (added/removed) for pull requests in a repository.
1556+ Note: This stream uses the issues timeline API since GitHub treats PRs as issues internally."""
1557+
1558+ name = "pull_request_label_events"
1559+ path = "/repos/{org}/{repo}/issues/{pull_number}/timeline"
1560+ primary_keys : ClassVar [list [str ]] = ["node_id" ]
1561+ parent_stream_type = PullRequestsStream
1562+ ignore_parent_replication_key = True
1563+ state_partitioning_keys : ClassVar [list [str ]] = ["repo" , "org" , "pull_number" ]
1564+ tolerated_http_errors : ClassVar [list [int ]] = [404 ]
1565+
1566+ def parse_response (self , response : requests .Response ) -> Iterable [dict ]:
1567+ """Parse the response and filter for label events only."""
1568+ for event in super ().parse_response (response ):
1569+ if event .get ("event" ) == "labeled" or event .get ("event" ) == "unlabeled" :
1570+ yield event
1571+
1572+ schema = th .PropertiesList (
1573+ # Parent Keys
1574+ th .Property ("repo" , th .StringType ),
1575+ th .Property ("org" , th .StringType ),
1576+ th .Property ("repo_id" , th .IntegerType ),
1577+ # Event Keys
1578+ th .Property ("id" , th .IntegerType ),
1579+ th .Property ("node_id" , th .StringType ),
1580+ th .Property ("url" , th .StringType ),
1581+ th .Property ("event" , th .StringType ),
1582+ th .Property ("commit_id" , th .StringType ),
1583+ th .Property ("created_at" , th .DateTimeType ),
1584+ th .Property (
1585+ "actor" ,
1586+ th .ObjectType (
1587+ th .Property ("login" , th .StringType ),
1588+ th .Property ("id" , th .IntegerType ),
1589+ th .Property ("node_id" , th .StringType ),
1590+ th .Property ("avatar_url" , th .StringType ),
1591+ th .Property ("gravatar_id" , th .StringType ),
1592+ th .Property ("url" , th .StringType ),
1593+ th .Property ("html_url" , th .StringType ),
1594+ th .Property ("followers_url" , th .StringType ),
1595+ th .Property ("following_url" , th .StringType ),
1596+ th .Property ("gists_url" , th .StringType ),
1597+ th .Property ("starred_url" , th .StringType ),
1598+ th .Property ("subscriptions_url" , th .StringType ),
1599+ th .Property ("organizations_url" , th .StringType ),
1600+ th .Property ("repos_url" , th .StringType ),
1601+ th .Property ("events_url" , th .StringType ),
1602+ th .Property ("received_events_url" , th .StringType ),
1603+ th .Property ("type" , th .StringType ),
1604+ th .Property ("site_admin" , th .BooleanType ),
1605+ ),
1606+ ),
1607+ th .Property (
1608+ "label" ,
1609+ th .ObjectType (
1610+ th .Property ("name" , th .StringType ),
1611+ th .Property ("color" , th .StringType ),
1612+ ),
1613+ ),
1614+ th .Property ("performed_via_github_app" , th .StringType ),
1615+ ).to_dict ()
1616+
15541617
15551618class ReviewCommentsStream (GitHubRestStream ):
15561619 name = "review_comments"
0 commit comments