Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/github/UserKey.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 | |
30 | |
31 class UserKey(github.GithubObject.CompletableGithubObject): | |
32 """ | |
33 This class represents UserKeys. The reference can be found here http://developer.github.com/v3/users/keys/ | |
34 """ | |
35 | |
36 @property | |
37 def id(self): | |
38 """ | |
39 :type: integer | |
40 """ | |
41 self._completeIfNotSet(self._id) | |
42 return self._id.value | |
43 | |
44 @property | |
45 def key(self): | |
46 """ | |
47 :type: string | |
48 """ | |
49 self._completeIfNotSet(self._key) | |
50 return self._key.value | |
51 | |
52 @property | |
53 def title(self): | |
54 """ | |
55 :type: string | |
56 """ | |
57 self._completeIfNotSet(self._title) | |
58 return self._title.value | |
59 | |
60 @property | |
61 def url(self): | |
62 """ | |
63 :type: string | |
64 """ | |
65 self._completeIfNotSet(self._url) | |
66 return self._url.value | |
67 | |
68 @property | |
69 def verified(self): | |
70 """ | |
71 :type: bool | |
72 """ | |
73 self._completeIfNotSet(self._verified) | |
74 return self._verified.value | |
75 | |
76 def delete(self): | |
77 """ | |
78 :calls: `DELETE /user/keys/:id <http://developer.github.com/v3/users/keys>`_ | |
79 :rtype: None | |
80 """ | |
81 headers, data = self._requester.requestJsonAndCheck( | |
82 "DELETE", | |
83 self.url | |
84 ) | |
85 | |
86 def edit(self, title=github.GithubObject.NotSet, key=github.GithubObject.NotSet): | |
87 """ | |
88 :calls: `PATCH /user/keys/:id <http://developer.github.com/v3/users/keys>`_ | |
89 :param title: string | |
90 :param key: string | |
91 :rtype: None | |
92 """ | |
93 assert title is github.GithubObject.NotSet or isinstance(title, (str, unicode)), title | |
94 assert key is github.GithubObject.NotSet or isinstance(key, (str, unicode)), key | |
95 post_parameters = dict() | |
96 if title is not github.GithubObject.NotSet: | |
97 post_parameters["title"] = title | |
98 if key is not github.GithubObject.NotSet: | |
99 post_parameters["key"] = key | |
100 headers, data = self._requester.requestJsonAndCheck( | |
101 "PATCH", | |
102 self.url, | |
103 input=post_parameters | |
104 ) | |
105 self._useAttributes(data) | |
106 | |
107 def _initAttributes(self): | |
108 self._id = github.GithubObject.NotSet | |
109 self._key = github.GithubObject.NotSet | |
110 self._title = github.GithubObject.NotSet | |
111 self._url = github.GithubObject.NotSet | |
112 self._verified = github.GithubObject.NotSet | |
113 | |
114 def _useAttributes(self, attributes): | |
115 if "id" in attributes: # pragma no branch | |
116 self._id = self._makeIntAttribute(attributes["id"]) | |
117 if "key" in attributes: # pragma no branch | |
118 self._key = self._makeStringAttribute(attributes["key"]) | |
119 if "title" in attributes: # pragma no branch | |
120 self._title = self._makeStringAttribute(attributes["title"]) | |
121 if "url" in attributes: # pragma no branch | |
122 self._url = self._makeStringAttribute(attributes["url"]) | |
123 if "verified" in attributes: # pragma no branch | |
124 self._verified = self._makeBoolAttribute(attributes["verified"]) |