@@ -51,13 +51,26 @@ class GitlabAuthenticationError(Exception):
51
51
52
52
53
53
class Gitlab (object ):
54
+ """Represents a GitLab server connection"""
54
55
def __init__ (self , url , private_token = None , email = None , password = None ):
56
+ """Stores informations about the server
57
+
58
+ url: the URL of the Gitlab server
59
+ private_token: the user private token
60
+ email: the user email/login
61
+ password: the user password (associated with email)
62
+ """
55
63
self .url = '%s/api/v3' % url
56
64
self .private_token = private_token
57
65
self .email = email
58
66
self .password = password
59
67
60
68
def auth (self ):
69
+ """Perform an authentication using either the private token, or the
70
+ email/password pair.
71
+
72
+ The user attribute will hold a CurrentUser object on success.
73
+ """
61
74
r = False
62
75
if self .private_token :
63
76
r = self .token_auth ()
@@ -86,12 +99,15 @@ def token_auth(self):
86
99
return False
87
100
88
101
def setUrl (self , url ):
102
+ """Updates the gitlab URL"""
89
103
self .url = '%s/api/v3' % url
90
104
91
105
def setToken (self , token ):
106
+ """Set the private token for authentication"""
92
107
self .private_token = token
93
108
94
109
def setCredentials (self , email , password ):
110
+ """Set the email/login and password for authentication"""
95
111
self .email = email
96
112
self .password = password
97
113
@@ -226,15 +242,49 @@ def getListOrObject(self, cls, id, **kwargs):
226
242
return cls (self , id , ** kwargs )
227
243
228
244
def Project (self , id = None ):
245
+ """Creates/gets/lists project(s) known by the GitLab server.
246
+
247
+ If id is None, returns a list of projects.
248
+
249
+ If id is an integer, returns the matching project (or raise a
250
+ GitlabGetError if not found)
251
+
252
+ If id is a dict, create a new object using attributes provided. The
253
+ object is NOT saved on the server. Use the save() method on the object
254
+ to write it on the server.
255
+ """
229
256
return self .getListOrObject (Project , id )
230
257
231
258
def Group (self , id = None ):
259
+ """Creates/gets/lists groups(s) known by the GitLab server.
260
+
261
+ If id is None, returns a list of projects.
262
+
263
+ If id is an integer, returns the matching project (or raise a
264
+ GitlabGetError if not found)
265
+
266
+ If id is a dict, create a new object using attributes provided. The
267
+ object is NOT saved on the server. Use the save() method on the object
268
+ to write it on the server.
269
+ """
232
270
return self .getListOrObject (Group , id )
233
271
234
- def Issue (self , id = None ):
235
- return self .getListOrObject (Issue , id )
272
+ def Issue (self ):
273
+ """Lists issues(s) known by the GitLab server."""
274
+ return self .getListOrObject (Issue , None )
236
275
237
276
def User (self , id = None ):
277
+ """Creates/gets/lists users(s) known by the GitLab server.
278
+
279
+ If id is None, returns a list of projects.
280
+
281
+ If id is an integer, returns the matching project (or raise a
282
+ GitlabGetError if not found)
283
+
284
+ If id is a dict, create a new object using attributes provided. The
285
+ object is NOT saved on the server. Use the save() method on the object
286
+ to write it on the server.
287
+ """
238
288
return self .getListOrObject (User , id )
239
289
240
290
0 commit comments