forked from ask/python-github2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteams.py
More file actions
63 lines (48 loc) · 2.1 KB
/
teams.py
File metadata and controls
63 lines (48 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from github2.core import BaseData, GithubCommand, Attribute
from github2.repositories import Repository
from github2.users import User
class Team(BaseData):
id = Attribute("The team id")
name = Attribute("Name of the team")
permission = Attribute("Permissions of the team")
def __repr__(self):
return "<Team: %s>" % self.name
class Teams(GithubCommand):
domain = "teams"
def show(self, team_id):
"""Get information on team_id
:param int team_id: team to get information for
"""
return self.get_value(str(team_id), filter="team", datatype=Team)
def members(self, team_id):
"""Get list of all team members
:param int team_id: team to get information for
"""
return self.get_values(str(team_id), "members", filter="users",
datatype=User)
def repositories(self, team_id):
"""Get list of all team members
:param int team_id: team to get information for
"""
return self.get_values(str(team_id), "repositories",
filter="repositories", datatype=Repository)
def add_project(self, team_id, project):
"""Add a project to a team
:param int team_id: team to add repository to
:param str project: GitHub project
"""
if isinstance(project, Repository):
project = project.project
return self.make_request(str(team_id), "repositories", method="POST",
post_data={'name': project},
filter="repositories", datatype=Repository)
def remove_project(self, team_id, project):
"""Remove a project to a team
:param int team_id: team to remove project from
:param str project: GitHub project
"""
if isinstance(project, Repository):
project = project.project
return self.make_request(str(team_id), "repositories", method="DELETE",
post_data={'name': project},
filter="repositories", datatype=Repository)