comparison venv/lib/python2.7/site-packages/github/Authorization.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.AuthorizationApplication
30
31
32 class Authorization(github.GithubObject.CompletableGithubObject):
33 """
34 This class represents Authorizations as returned for example by http://developer.github.com/v3/todo
35 """
36
37 @property
38 def app(self):
39 """
40 :type: :class:`github.AuthorizationApplication.AuthorizationApplication`
41 """
42 self._completeIfNotSet(self._app)
43 return self._app.value
44
45 @property
46 def created_at(self):
47 """
48 :type: datetime.datetime
49 """
50 self._completeIfNotSet(self._created_at)
51 return self._created_at.value
52
53 @property
54 def id(self):
55 """
56 :type: integer
57 """
58 self._completeIfNotSet(self._id)
59 return self._id.value
60
61 @property
62 def note(self):
63 """
64 :type: string
65 """
66 self._completeIfNotSet(self._note)
67 return self._note.value
68
69 @property
70 def note_url(self):
71 """
72 :type: string
73 """
74 self._completeIfNotSet(self._note_url)
75 return self._note_url.value
76
77 @property
78 def scopes(self):
79 """
80 :type: list of string
81 """
82 self._completeIfNotSet(self._scopes)
83 return self._scopes.value
84
85 @property
86 def token(self):
87 """
88 :type: string
89 """
90 self._completeIfNotSet(self._token)
91 return self._token.value
92
93 @property
94 def updated_at(self):
95 """
96 :type: datetime.datetime
97 """
98 self._completeIfNotSet(self._updated_at)
99 return self._updated_at.value
100
101 @property
102 def url(self):
103 """
104 :type: string
105 """
106 self._completeIfNotSet(self._url)
107 return self._url.value
108
109 def delete(self):
110 """
111 :calls: `DELETE /authorizations/:id <http://developer.github.com/v3/oauth>`_
112 :rtype: None
113 """
114 headers, data = self._requester.requestJsonAndCheck(
115 "DELETE",
116 self.url
117 )
118
119 def edit(self, scopes=github.GithubObject.NotSet, add_scopes=github.GithubObject.NotSet, remove_scopes=github.GithubObject.NotSet, note=github.GithubObject.NotSet, note_url=github.GithubObject.NotSet):
120 """
121 :calls: `PATCH /authorizations/:id <http://developer.github.com/v3/oauth>`_
122 :param scopes: list of string
123 :param add_scopes: list of string
124 :param remove_scopes: list of string
125 :param note: string
126 :param note_url: string
127 :rtype: None
128 """
129 assert scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in scopes), scopes
130 assert add_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in add_scopes), add_scopes
131 assert remove_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in remove_scopes), remove_scopes
132 assert note is github.GithubObject.NotSet or isinstance(note, (str, unicode)), note
133 assert note_url is github.GithubObject.NotSet or isinstance(note_url, (str, unicode)), note_url
134 post_parameters = dict()
135 if scopes is not github.GithubObject.NotSet:
136 post_parameters["scopes"] = scopes
137 if add_scopes is not github.GithubObject.NotSet:
138 post_parameters["add_scopes"] = add_scopes
139 if remove_scopes is not github.GithubObject.NotSet:
140 post_parameters["remove_scopes"] = remove_scopes
141 if note is not github.GithubObject.NotSet:
142 post_parameters["note"] = note
143 if note_url is not github.GithubObject.NotSet:
144 post_parameters["note_url"] = note_url
145 headers, data = self._requester.requestJsonAndCheck(
146 "PATCH",
147 self.url,
148 input=post_parameters
149 )
150 self._useAttributes(data)
151
152 def _initAttributes(self):
153 self._app = github.GithubObject.NotSet
154 self._created_at = github.GithubObject.NotSet
155 self._id = github.GithubObject.NotSet
156 self._note = github.GithubObject.NotSet
157 self._note_url = github.GithubObject.NotSet
158 self._scopes = github.GithubObject.NotSet
159 self._token = github.GithubObject.NotSet
160 self._updated_at = github.GithubObject.NotSet
161 self._url = github.GithubObject.NotSet
162
163 def _useAttributes(self, attributes):
164 if "app" in attributes: # pragma no branch
165 self._app = self._makeClassAttribute(github.AuthorizationApplication.AuthorizationApplication, attributes["app"])
166 if "created_at" in attributes: # pragma no branch
167 self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
168 if "id" in attributes: # pragma no branch
169 self._id = self._makeIntAttribute(attributes["id"])
170 if "note" in attributes: # pragma no branch
171 self._note = self._makeStringAttribute(attributes["note"])
172 if "note_url" in attributes: # pragma no branch
173 self._note_url = self._makeStringAttribute(attributes["note_url"])
174 if "scopes" in attributes: # pragma no branch
175 self._scopes = self._makeListOfStringsAttribute(attributes["scopes"])
176 if "token" in attributes: # pragma no branch
177 self._token = self._makeStringAttribute(attributes["token"])
178 if "updated_at" in attributes: # pragma no branch
179 self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
180 if "url" in attributes: # pragma no branch
181 self._url = self._makeStringAttribute(attributes["url"])