Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/github/Team.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author | bcclaywell |
---|---|
date | Mon, 12 Oct 2015 17:43:33 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d67268158946 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 # ########################## Copyrights and license ############################ | |
4 # # | |
5 # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> # | |
6 # Copyright 2012 Zearin <zearin@gonk.net> # | |
7 # Copyright 2013 AKFish <akfish@gmail.com> # | |
8 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # | |
9 # Copyright 2013 martinqt <m.ki2@laposte.net> # | |
10 # # | |
11 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # | |
12 # # | |
13 # PyGithub is free software: you can redistribute it and/or modify it under # | |
14 # the terms of the GNU Lesser General Public License as published by the Free # | |
15 # Software Foundation, either version 3 of the License, or (at your option) # | |
16 # any later version. # | |
17 # # | |
18 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # | |
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # | |
20 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # | |
21 # details. # | |
22 # # | |
23 # You should have received a copy of the GNU Lesser General Public License # | |
24 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # | |
25 # # | |
26 # ############################################################################## | |
27 | |
28 import github.GithubObject | |
29 import github.PaginatedList | |
30 | |
31 import github.Repository | |
32 import github.NamedUser | |
33 | |
34 | |
35 class Team(github.GithubObject.CompletableGithubObject): | |
36 """ | |
37 This class represents Teams. The reference can be found here http://developer.github.com/v3/orgs/teams/ | |
38 """ | |
39 | |
40 @property | |
41 def id(self): | |
42 """ | |
43 :type: integer | |
44 """ | |
45 self._completeIfNotSet(self._id) | |
46 return self._id.value | |
47 | |
48 @property | |
49 def members_count(self): | |
50 """ | |
51 :type: integer | |
52 """ | |
53 self._completeIfNotSet(self._members_count) | |
54 return self._members_count.value | |
55 | |
56 @property | |
57 def members_url(self): | |
58 """ | |
59 :type: string | |
60 """ | |
61 self._completeIfNotSet(self._members_url) | |
62 return self._members_url.value | |
63 | |
64 @property | |
65 def name(self): | |
66 """ | |
67 :type: string | |
68 """ | |
69 self._completeIfNotSet(self._name) | |
70 return self._name.value | |
71 | |
72 @property | |
73 def permission(self): | |
74 """ | |
75 :type: string | |
76 """ | |
77 self._completeIfNotSet(self._permission) | |
78 return self._permission.value | |
79 | |
80 @property | |
81 def repos_count(self): | |
82 """ | |
83 :type: integer | |
84 """ | |
85 self._completeIfNotSet(self._repos_count) | |
86 return self._repos_count.value | |
87 | |
88 @property | |
89 def repositories_url(self): | |
90 """ | |
91 :type: string | |
92 """ | |
93 self._completeIfNotSet(self._repositories_url) | |
94 return self._repositories_url.value | |
95 | |
96 @property | |
97 def slug(self): | |
98 """ | |
99 :type: string | |
100 """ | |
101 self._completeIfNotSet(self._slug) | |
102 return self._slug.value | |
103 | |
104 @property | |
105 def url(self): | |
106 """ | |
107 :type: string | |
108 """ | |
109 self._completeIfNotSet(self._url) | |
110 return self._url.value | |
111 | |
112 def add_to_members(self, member): | |
113 """ | |
114 :calls: `PUT /teams/:id/members/:user <http://developer.github.com/v3/orgs/teams>`_ | |
115 :param member: :class:`github.NamedUser.NamedUser` | |
116 :rtype: None | |
117 """ | |
118 assert isinstance(member, github.NamedUser.NamedUser), member | |
119 headers, data = self._requester.requestJsonAndCheck( | |
120 "PUT", | |
121 self.url + "/members/" + member._identity | |
122 ) | |
123 | |
124 def add_to_repos(self, repo): | |
125 """ | |
126 :calls: `PUT /teams/:id/repos/:org/:repo <http://developer.github.com/v3/orgs/teams>`_ | |
127 :param repo: :class:`github.Repository.Repository` | |
128 :rtype: None | |
129 """ | |
130 assert isinstance(repo, github.Repository.Repository), repo | |
131 headers, data = self._requester.requestJsonAndCheck( | |
132 "PUT", | |
133 self.url + "/repos/" + repo._identity | |
134 ) | |
135 | |
136 def delete(self): | |
137 """ | |
138 :calls: `DELETE /teams/:id <http://developer.github.com/v3/orgs/teams>`_ | |
139 :rtype: None | |
140 """ | |
141 headers, data = self._requester.requestJsonAndCheck( | |
142 "DELETE", | |
143 self.url | |
144 ) | |
145 | |
146 def edit(self, name, permission=github.GithubObject.NotSet): | |
147 """ | |
148 :calls: `PATCH /teams/:id <http://developer.github.com/v3/orgs/teams>`_ | |
149 :param name: string | |
150 :param permission: string | |
151 :rtype: None | |
152 """ | |
153 assert isinstance(name, (str, unicode)), name | |
154 assert permission is github.GithubObject.NotSet or isinstance(permission, (str, unicode)), permission | |
155 post_parameters = { | |
156 "name": name, | |
157 } | |
158 if permission is not github.GithubObject.NotSet: | |
159 post_parameters["permission"] = permission | |
160 headers, data = self._requester.requestJsonAndCheck( | |
161 "PATCH", | |
162 self.url, | |
163 input=post_parameters | |
164 ) | |
165 self._useAttributes(data) | |
166 | |
167 def get_members(self): | |
168 """ | |
169 :calls: `GET /teams/:id/members <http://developer.github.com/v3/orgs/teams>`_ | |
170 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` | |
171 """ | |
172 return github.PaginatedList.PaginatedList( | |
173 github.NamedUser.NamedUser, | |
174 self._requester, | |
175 self.url + "/members", | |
176 None | |
177 ) | |
178 | |
179 def get_repos(self): | |
180 """ | |
181 :calls: `GET /teams/:id/repos <http://developer.github.com/v3/orgs/teams>`_ | |
182 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` | |
183 """ | |
184 return github.PaginatedList.PaginatedList( | |
185 github.Repository.Repository, | |
186 self._requester, | |
187 self.url + "/repos", | |
188 None | |
189 ) | |
190 | |
191 def has_in_members(self, member): | |
192 """ | |
193 :calls: `GET /teams/:id/members/:user <http://developer.github.com/v3/orgs/teams>`_ | |
194 :param member: :class:`github.NamedUser.NamedUser` | |
195 :rtype: bool | |
196 """ | |
197 assert isinstance(member, github.NamedUser.NamedUser), member | |
198 status, headers, data = self._requester.requestJson( | |
199 "GET", | |
200 self.url + "/members/" + member._identity | |
201 ) | |
202 return status == 204 | |
203 | |
204 def has_in_repos(self, repo): | |
205 """ | |
206 :calls: `GET /teams/:id/repos/:owner/:repo <http://developer.github.com/v3/orgs/teams>`_ | |
207 :param repo: :class:`github.Repository.Repository` | |
208 :rtype: bool | |
209 """ | |
210 assert isinstance(repo, github.Repository.Repository), repo | |
211 status, headers, data = self._requester.requestJson( | |
212 "GET", | |
213 self.url + "/repos/" + repo._identity | |
214 ) | |
215 return status == 204 | |
216 | |
217 def remove_from_members(self, member): | |
218 """ | |
219 :calls: `DELETE /teams/:id/members/:user <http://developer.github.com/v3/orgs/teams>`_ | |
220 :param member: :class:`github.NamedUser.NamedUser` | |
221 :rtype: None | |
222 """ | |
223 assert isinstance(member, github.NamedUser.NamedUser), member | |
224 headers, data = self._requester.requestJsonAndCheck( | |
225 "DELETE", | |
226 self.url + "/members/" + member._identity | |
227 ) | |
228 | |
229 def remove_from_repos(self, repo): | |
230 """ | |
231 :calls: `DELETE /teams/:id/repos/:owner/:repo <http://developer.github.com/v3/orgs/teams>`_ | |
232 :param repo: :class:`github.Repository.Repository` | |
233 :rtype: None | |
234 """ | |
235 assert isinstance(repo, github.Repository.Repository), repo | |
236 headers, data = self._requester.requestJsonAndCheck( | |
237 "DELETE", | |
238 self.url + "/repos/" + repo._identity | |
239 ) | |
240 | |
241 @property | |
242 def _identity(self): | |
243 return self.id | |
244 | |
245 def _initAttributes(self): | |
246 self._id = github.GithubObject.NotSet | |
247 self._members_count = github.GithubObject.NotSet | |
248 self._members_url = github.GithubObject.NotSet | |
249 self._name = github.GithubObject.NotSet | |
250 self._permission = github.GithubObject.NotSet | |
251 self._repos_count = github.GithubObject.NotSet | |
252 self._repositories_url = github.GithubObject.NotSet | |
253 self._slug = github.GithubObject.NotSet | |
254 self._url = github.GithubObject.NotSet | |
255 | |
256 def _useAttributes(self, attributes): | |
257 if "id" in attributes: # pragma no branch | |
258 self._id = self._makeIntAttribute(attributes["id"]) | |
259 if "members_count" in attributes: # pragma no branch | |
260 self._members_count = self._makeIntAttribute(attributes["members_count"]) | |
261 if "members_url" in attributes: # pragma no branch | |
262 self._members_url = self._makeStringAttribute(attributes["members_url"]) | |
263 if "name" in attributes: # pragma no branch | |
264 self._name = self._makeStringAttribute(attributes["name"]) | |
265 if "permission" in attributes: # pragma no branch | |
266 self._permission = self._makeStringAttribute(attributes["permission"]) | |
267 if "repos_count" in attributes: # pragma no branch | |
268 self._repos_count = self._makeIntAttribute(attributes["repos_count"]) | |
269 if "repositories_url" in attributes: # pragma no branch | |
270 self._repositories_url = self._makeStringAttribute(attributes["repositories_url"]) | |
271 if "slug" in attributes: # pragma no branch | |
272 self._slug = self._makeStringAttribute(attributes["slug"]) | |
273 if "url" in attributes: # pragma no branch | |
274 self._url = self._makeStringAttribute(attributes["url"]) |