mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Add support for 'visibility' attribute preview for Repositories (#1872)
Expose the new 'visibility' attribute for repository objects. Fixes #1446
This commit is contained in:
@@ -125,3 +125,6 @@ deploymentEnhancementsPreview = "application/vnd.github.ant-man-preview+json"
|
||||
|
||||
# https://developer.github.com/changes/2018-10-16-deployments-environments-states-and-auto-inactive-updates/
|
||||
deploymentStatusEnhancementsPreview = "application/vnd.github.flash-preview+json"
|
||||
|
||||
# https://developer.github.com/changes/2019-12-03-internal-visibility-changes/
|
||||
repoVisibilityPreview = "application/vnd.github.nebula-preview+json"
|
||||
|
||||
+14
-2
@@ -463,6 +463,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
|
||||
description=github.GithubObject.NotSet,
|
||||
homepage=github.GithubObject.NotSet,
|
||||
private=github.GithubObject.NotSet,
|
||||
visibility=github.GithubObject.NotSet,
|
||||
has_issues=github.GithubObject.NotSet,
|
||||
has_wiki=github.GithubObject.NotSet,
|
||||
has_downloads=github.GithubObject.NotSet,
|
||||
@@ -506,6 +507,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
|
||||
assert private is github.GithubObject.NotSet or isinstance(
|
||||
private, bool
|
||||
), private
|
||||
assert visibility is github.GithubObject.NotSet or isinstance(
|
||||
visibility, str
|
||||
), visibility
|
||||
assert has_issues is github.GithubObject.NotSet or isinstance(
|
||||
has_issues, bool
|
||||
), has_issues
|
||||
@@ -551,6 +555,8 @@ class Organization(github.GithubObject.CompletableGithubObject):
|
||||
post_parameters["homepage"] = homepage
|
||||
if private is not github.GithubObject.NotSet:
|
||||
post_parameters["private"] = private
|
||||
if visibility is not github.GithubObject.NotSet:
|
||||
post_parameters["visibility"] = visibility
|
||||
if has_issues is not github.GithubObject.NotSet:
|
||||
post_parameters["has_issues"] = has_issues
|
||||
if has_wiki is not github.GithubObject.NotSet:
|
||||
@@ -576,7 +582,10 @@ class Organization(github.GithubObject.CompletableGithubObject):
|
||||
if delete_branch_on_merge is not github.GithubObject.NotSet:
|
||||
post_parameters["delete_branch_on_merge"] = delete_branch_on_merge
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST", f"{self.url}/repos", input=post_parameters
|
||||
"POST",
|
||||
f"{self.url}/repos",
|
||||
input=post_parameters,
|
||||
headers={"Accept": Consts.repoVisibilityPreview},
|
||||
)
|
||||
return github.Repository.Repository(
|
||||
self._requester, headers, data, completed=True
|
||||
@@ -987,7 +996,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
assert isinstance(name, str), name
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", f"/repos/{self.login}/{name}"
|
||||
"GET",
|
||||
f"/repos/{self.login}/{name}",
|
||||
headers={"Accept": Consts.repoVisibilityPreview},
|
||||
)
|
||||
return github.Repository.Repository(
|
||||
self._requester, headers, data, completed=True
|
||||
@@ -1024,6 +1035,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
|
||||
self._requester,
|
||||
f"{self.url}/repos",
|
||||
url_parameters,
|
||||
headers={"Accept": Consts.repoVisibilityPreview},
|
||||
)
|
||||
|
||||
def get_team(self, id):
|
||||
|
||||
@@ -787,6 +787,14 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
self._completeIfNotSet(self._url)
|
||||
return self._url.value
|
||||
|
||||
@property
|
||||
def visibility(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._visibility)
|
||||
return self._visibility.value
|
||||
|
||||
@property
|
||||
def watchers(self):
|
||||
"""
|
||||
@@ -3759,6 +3767,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
self._trees_url = github.GithubObject.NotSet
|
||||
self._updated_at = github.GithubObject.NotSet
|
||||
self._url = github.GithubObject.NotSet
|
||||
self._visibility = github.GithubObject.NotSet
|
||||
self._watchers = github.GithubObject.NotSet
|
||||
self._watchers_count = github.GithubObject.NotSet
|
||||
|
||||
@@ -3965,6 +3974,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
|
||||
if "url" in attributes: # pragma no branch
|
||||
self._url = self._makeStringAttribute(attributes["url"])
|
||||
if "visibility" in attributes: # pragma no branch
|
||||
self._visibility = self._makeStringAttribute(attributes["visibility"])
|
||||
if "watchers" in attributes: # pragma no branch
|
||||
self._watchers = self._makeIntAttribute(attributes["watchers"])
|
||||
if "watchers_count" in attributes: # pragma no branch
|
||||
|
||||
Reference in New Issue
Block a user