Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/github/Hook.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 # # | |
10 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # | |
11 # # | |
12 # PyGithub is free software: you can redistribute it and/or modify it under # | |
13 # the terms of the GNU Lesser General Public License as published by the Free # | |
14 # Software Foundation, either version 3 of the License, or (at your option) # | |
15 # any later version. # | |
16 # # | |
17 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # | |
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # | |
19 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # | |
20 # details. # | |
21 # # | |
22 # You should have received a copy of the GNU Lesser General Public License # | |
23 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # | |
24 # # | |
25 # ############################################################################## | |
26 | |
27 import github.GithubObject | |
28 | |
29 import github.HookResponse | |
30 | |
31 | |
32 class Hook(github.GithubObject.CompletableGithubObject): | |
33 """ | |
34 This class represents Hooks as returned for example by http://developer.github.com/v3/repos/hooks | |
35 """ | |
36 | |
37 @property | |
38 def active(self): | |
39 """ | |
40 :type: bool | |
41 """ | |
42 self._completeIfNotSet(self._active) | |
43 return self._active.value | |
44 | |
45 @property | |
46 def config(self): | |
47 """ | |
48 :type: dict | |
49 """ | |
50 self._completeIfNotSet(self._config) | |
51 return self._config.value | |
52 | |
53 @property | |
54 def created_at(self): | |
55 """ | |
56 :type: datetime.datetime | |
57 """ | |
58 self._completeIfNotSet(self._created_at) | |
59 return self._created_at.value | |
60 | |
61 @property | |
62 def events(self): | |
63 """ | |
64 :type: list of string | |
65 """ | |
66 self._completeIfNotSet(self._events) | |
67 return self._events.value | |
68 | |
69 @property | |
70 def id(self): | |
71 """ | |
72 :type: integer | |
73 """ | |
74 self._completeIfNotSet(self._id) | |
75 return self._id.value | |
76 | |
77 @property | |
78 def last_response(self): | |
79 """ | |
80 :type: :class:`github.HookResponse.HookResponse` | |
81 """ | |
82 self._completeIfNotSet(self._last_response) | |
83 return self._last_response.value | |
84 | |
85 @property | |
86 def name(self): | |
87 """ | |
88 :type: string | |
89 """ | |
90 self._completeIfNotSet(self._name) | |
91 return self._name.value | |
92 | |
93 @property | |
94 def test_url(self): | |
95 """ | |
96 :type: string | |
97 """ | |
98 self._completeIfNotSet(self._test_url) | |
99 return self._test_url.value | |
100 | |
101 @property | |
102 def updated_at(self): | |
103 """ | |
104 :type: datetime.datetime | |
105 """ | |
106 self._completeIfNotSet(self._updated_at) | |
107 return self._updated_at.value | |
108 | |
109 @property | |
110 def url(self): | |
111 """ | |
112 :type: string | |
113 """ | |
114 self._completeIfNotSet(self._url) | |
115 return self._url.value | |
116 | |
117 def delete(self): | |
118 """ | |
119 :calls: `DELETE /repos/:owner/:repo/hooks/:id <http://developer.github.com/v3/repos/hooks>`_ | |
120 :rtype: None | |
121 """ | |
122 headers, data = self._requester.requestJsonAndCheck( | |
123 "DELETE", | |
124 self.url | |
125 ) | |
126 | |
127 def edit(self, name, config, events=github.GithubObject.NotSet, add_events=github.GithubObject.NotSet, remove_events=github.GithubObject.NotSet, active=github.GithubObject.NotSet): | |
128 """ | |
129 :calls: `PATCH /repos/:owner/:repo/hooks/:id <http://developer.github.com/v3/repos/hooks>`_ | |
130 :param name: string | |
131 :param config: dict | |
132 :param events: list of string | |
133 :param add_events: list of string | |
134 :param remove_events: list of string | |
135 :param active: bool | |
136 :rtype: None | |
137 """ | |
138 assert isinstance(name, (str, unicode)), name | |
139 assert isinstance(config, dict), config | |
140 assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events | |
141 assert add_events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in add_events), add_events | |
142 assert remove_events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in remove_events), remove_events | |
143 assert active is github.GithubObject.NotSet or isinstance(active, bool), active | |
144 post_parameters = { | |
145 "name": name, | |
146 "config": config, | |
147 } | |
148 if events is not github.GithubObject.NotSet: | |
149 post_parameters["events"] = events | |
150 if add_events is not github.GithubObject.NotSet: | |
151 post_parameters["add_events"] = add_events | |
152 if remove_events is not github.GithubObject.NotSet: | |
153 post_parameters["remove_events"] = remove_events | |
154 if active is not github.GithubObject.NotSet: | |
155 post_parameters["active"] = active | |
156 headers, data = self._requester.requestJsonAndCheck( | |
157 "PATCH", | |
158 self.url, | |
159 input=post_parameters | |
160 ) | |
161 self._useAttributes(data) | |
162 | |
163 def test(self): | |
164 """ | |
165 :calls: `POST /repos/:owner/:repo/hooks/:id/tests <http://developer.github.com/v3/repos/hooks>`_ | |
166 :rtype: None | |
167 """ | |
168 headers, data = self._requester.requestJsonAndCheck( | |
169 "POST", | |
170 self.url + "/tests" | |
171 ) | |
172 | |
173 def _initAttributes(self): | |
174 self._active = github.GithubObject.NotSet | |
175 self._config = github.GithubObject.NotSet | |
176 self._created_at = github.GithubObject.NotSet | |
177 self._events = github.GithubObject.NotSet | |
178 self._id = github.GithubObject.NotSet | |
179 self._last_response = github.GithubObject.NotSet | |
180 self._name = github.GithubObject.NotSet | |
181 self._test_url = github.GithubObject.NotSet | |
182 self._updated_at = github.GithubObject.NotSet | |
183 self._url = github.GithubObject.NotSet | |
184 | |
185 def _useAttributes(self, attributes): | |
186 if "active" in attributes: # pragma no branch | |
187 self._active = self._makeBoolAttribute(attributes["active"]) | |
188 if "config" in attributes: # pragma no branch | |
189 self._config = self._makeDictAttribute(attributes["config"]) | |
190 if "created_at" in attributes: # pragma no branch | |
191 self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) | |
192 if "events" in attributes: # pragma no branch | |
193 self._events = self._makeListOfStringsAttribute(attributes["events"]) | |
194 if "id" in attributes: # pragma no branch | |
195 self._id = self._makeIntAttribute(attributes["id"]) | |
196 if "last_response" in attributes: # pragma no branch | |
197 self._last_response = self._makeClassAttribute(github.HookResponse.HookResponse, attributes["last_response"]) | |
198 if "name" in attributes: # pragma no branch | |
199 self._name = self._makeStringAttribute(attributes["name"]) | |
200 if "test_url" in attributes: # pragma no branch | |
201 self._test_url = self._makeStringAttribute(attributes["test_url"]) | |
202 if "updated_at" in attributes: # pragma no branch | |
203 self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) | |
204 if "url" in attributes: # pragma no branch | |
205 self._url = self._makeStringAttribute(attributes["url"]) |