mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Adding support for pending team invitations (#993)
* fixes issue#823 * Update GithubObject.py * Added tests for Pending team invitations(Issue#823) Co-authored-by: Wan Liuyang <tsfdye@gmail.com>
This commit is contained in:
committed by
Wan Liuyang
co-authored by
Wan Liuyang
parent
fd090eccbb
commit
edab176b5d
@@ -225,6 +225,22 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
|
||||
self._completeIfNotSet(self._id)
|
||||
return self._id.value
|
||||
|
||||
@property
|
||||
def invitation_teams_url(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._invitation_teams_url)
|
||||
return self._invitation_teams_url.value
|
||||
|
||||
@property
|
||||
def inviter(self):
|
||||
"""
|
||||
:type: github.NamedUser.NamedUser
|
||||
"""
|
||||
self._completeIfNotSet(self._inviter)
|
||||
return self._inviter.value
|
||||
|
||||
@property
|
||||
def location(self):
|
||||
"""
|
||||
@@ -320,6 +336,13 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
self._completeIfNotSet(self._repos_url)
|
||||
return self._repos_url.value
|
||||
@property
|
||||
def role(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._role)
|
||||
return self._role.value
|
||||
|
||||
@property
|
||||
def site_admin(self):
|
||||
@@ -353,6 +376,14 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
|
||||
self._completeIfNotSet(self._suspended_at)
|
||||
return self._suspended_at.value
|
||||
|
||||
@property
|
||||
def team_count(self):
|
||||
"""
|
||||
:type: integer
|
||||
"""
|
||||
self._completeIfNotSet(self._team_count)
|
||||
return self._team_count.value
|
||||
|
||||
@property
|
||||
def total_private_repos(self):
|
||||
"""
|
||||
@@ -610,6 +641,8 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
|
||||
self._hireable = github.GithubObject.NotSet
|
||||
self._html_url = github.GithubObject.NotSet
|
||||
self._id = github.GithubObject.NotSet
|
||||
self._invitation_teams_url = github.GithubObject.NotSet
|
||||
self._inviter = github.GithubObject.NotSet
|
||||
self._location = github.GithubObject.NotSet
|
||||
self._login = github.GithubObject.NotSet
|
||||
self._name = github.GithubObject.NotSet
|
||||
@@ -623,10 +656,12 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
|
||||
self._public_repos = github.GithubObject.NotSet
|
||||
self._received_events_url = github.GithubObject.NotSet
|
||||
self._repos_url = github.GithubObject.NotSet
|
||||
self._role = github.GithubObject.NotSet
|
||||
self._site_admin = github.GithubObject.NotSet
|
||||
self._starred_url = github.GithubObject.NotSet
|
||||
self._subscriptions_url = github.GithubObject.NotSet
|
||||
self._suspended_at = github.GithubObject.NotSet
|
||||
self._team_count = github.GithubObject.NotSet
|
||||
self._total_private_repos = github.GithubObject.NotSet
|
||||
self._type = github.GithubObject.NotSet
|
||||
self._updated_at = github.GithubObject.NotSet
|
||||
@@ -671,6 +706,10 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
|
||||
self._html_url = self._makeStringAttribute(attributes["html_url"])
|
||||
if "id" in attributes: # pragma no branch
|
||||
self._id = self._makeIntAttribute(attributes["id"])
|
||||
if "invitation_teams_url" in attributes: # pragma no branch
|
||||
self._invitation_teams_url = self._makeStringAttribute(attributes["invitation_teams_url"])
|
||||
if "inviter" in attributes: # pragma no branch
|
||||
self._inviter = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["inviter"])
|
||||
if "location" in attributes: # pragma no branch
|
||||
self._location = self._makeStringAttribute(attributes["location"])
|
||||
if "login" in attributes: # pragma no branch
|
||||
@@ -697,6 +736,8 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
|
||||
self._received_events_url = self._makeStringAttribute(attributes["received_events_url"])
|
||||
if "repos_url" in attributes: # pragma no branch
|
||||
self._repos_url = self._makeStringAttribute(attributes["repos_url"])
|
||||
if "role" in attributes: # pragma no branch
|
||||
self._role = self._makeStringAttribute(attributes["role"])
|
||||
if "site_admin" in attributes: # pragma no branch
|
||||
self._site_admin = self._makeBoolAttribute(attributes["site_admin"])
|
||||
if "starred_url" in attributes: # pragma no branch
|
||||
@@ -705,6 +746,8 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
|
||||
self._subscriptions_url = self._makeStringAttribute(attributes["subscriptions_url"])
|
||||
if "suspended_at" in attributes: # pragma no branch
|
||||
self._suspended_at = self._makeDatetimeAttribute(attributes["suspended_at"])
|
||||
if "team_count" in attributes:
|
||||
self._team_count = self._makeIntAttribute(attributes["team_count"])
|
||||
if "total_private_repos" in attributes: # pragma no branch
|
||||
self._total_private_repos = self._makeIntAttribute(attributes["total_private_repos"])
|
||||
if "type" in attributes: # pragma no branch
|
||||
|
||||
@@ -824,6 +824,21 @@ class Organization(github.GithubObject.CompletableGithubObject):
|
||||
None
|
||||
)
|
||||
|
||||
def invitations(self):
|
||||
"""
|
||||
:calls: `GET /orgs/:org/invitations <https://developer.github.com/v3/orgs/members>`_
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
|
||||
"""
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.NamedUser.NamedUser,
|
||||
self._requester,
|
||||
self.url + "/invitations",
|
||||
None,
|
||||
headers={
|
||||
"Accept": Consts.mediaTypeOrganizationInvitationPreview
|
||||
}
|
||||
)
|
||||
|
||||
def invite_user(self, user=github.GithubObject.NotSet, email=github.GithubObject.NotSet, role=github.GithubObject.NotSet, teams=github.GithubObject.NotSet):
|
||||
"""
|
||||
:calls: `POST /orgs/:org/invitations <http://developer.github.com/v3/orgs/members>`_
|
||||
|
||||
@@ -48,6 +48,7 @@ import github.Repository
|
||||
import github.NamedUser
|
||||
import github.Organization
|
||||
|
||||
import Consts
|
||||
|
||||
class Team(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
@@ -291,6 +292,21 @@ class Team(github.GithubObject.CompletableGithubObject):
|
||||
None
|
||||
)
|
||||
|
||||
def invitations(self):
|
||||
"""
|
||||
:calls: `GET /teams/:id/invitations <https://developer.github.com/v3/teams/members>`_
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
|
||||
"""
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.NamedUser.NamedUser,
|
||||
self._requester,
|
||||
self.url + "/invitations",
|
||||
None,
|
||||
headers={
|
||||
"Accept": Consts.mediaTypeOrganizationInvitationPreview
|
||||
}
|
||||
)
|
||||
|
||||
def has_in_members(self, member):
|
||||
"""
|
||||
:calls: `GET /teams/:id/members/:user <http://developer.github.com/v3/orgs/teams>`_
|
||||
|
||||
Reference in New Issue
Block a user