Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions nodestream_github/client/githubclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,3 +617,27 @@ async def fetch_teams_for_repo(self, *, owner_login: str, repo_name: str):
yield team
except httpx.HTTPError as e:
_fetch_problem(f"teams for repo {owner_login}/{repo_name}", e)

async def fetch_branch_protection(
self,
*,
owner_login: str,
repo_name: str,
branch: str,
) -> types.BranchProtection | None:
"""Fetches the branch protection for a given branch.

https://docs.github.com/en/[email protected]/rest/branches/branch-protection?apiVersion=2022-11-28#get-branch-protection
"""

try:
return await self._get_item(
f"repos/{owner_login}/{repo_name}/branches/{branch}/protection"
)
except httpx.HTTPError as e:
_fetch_problem(
f"branch protection for branch {branch} on "
f"repo {owner_login}/{repo_name}",
e,
)
return None
2 changes: 2 additions & 0 deletions nodestream_github/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .github import (
BranchProtection,
GithubAuditLog,
GithubOrg,
GithubOrgSummary,
Expand All @@ -19,6 +20,7 @@
from .httpx import HeaderTypes, PrimitiveData, QueryParamTypes

__all__ = [
"BranchProtection",
"GithubAuditLog",
"GithubOrg",
"GithubOrgSummary",
Expand Down
2 changes: 2 additions & 0 deletions nodestream_github/types/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@

SimplifiedRepo: TypeAlias = JSONObject
SimplifiedUser: TypeAlias = JSONObject

BranchProtection: TypeAlias = JSONObject
Loading