@@ -217,32 +217,38 @@ def __str__(self):
217
217
class User (GitlabObject ):
218
218
url = '/users'
219
219
220
- class Group (GitlabObject ):
221
- url = '/groups'
222
- constructorTypes = {'projects' : 'Project' }
223
-
224
- class Project (GitlabObject ):
225
- url = '/projects'
226
- constructorTypes = {'owner' : 'User' , 'namespace' : 'Group' }
220
+ class CurrentUser (GitlabObject ):
221
+ url = '/user'
222
+ canGetList = False
223
+ canCreate = False
227
224
canUpdate = False
228
225
canDelete = False
229
226
230
- class ProjectMember (GitlabObject ):
231
- url = '/projects/%(project_id)d/members '
232
- returnClass = User
227
+ class CurrentUserKey (GitlabObject ):
228
+ url = '/user/keys '
229
+ canUpdate = False
233
230
234
- class ProjectHook (GitlabObject ):
235
- url = '/projects/%(project_id)d/hooks'
231
+ url = '/users'
236
232
237
- class ProjectBranch (GitlabObject ):
238
- url = '/projects/%(project_id)d/repository/branches'
233
+ class Group (GitlabObject ):
234
+ url = '/groups'
235
+ constructorTypes = {'projects' : 'Project' }
236
+
237
+ class Issue (GitlabObject ):
238
+ url = '/issues'
239
+ constructorTypes = {'author' : 'User' , 'assignee' : 'User' ,
240
+ 'milestone' : 'ProjectMilestone' }
241
+ canGet = False
239
242
canDelete = False
240
243
canUpdate = False
241
244
canCreate = False
242
245
243
- class ProjectTag (GitlabObject ):
244
- url = '/projects/%(project_id)d/repository/tags'
245
- canGet = False
246
+ class Session (object ):
247
+ def __init__ (self ):
248
+ raise NotImplementedError
249
+
250
+ class ProjectBranch (GitlabObject ):
251
+ url = '/projects/%(project_id)d/repository/branches'
246
252
canDelete = False
247
253
canUpdate = False
248
254
canCreate = False
@@ -254,50 +260,76 @@ class ProjectCommit(GitlabObject):
254
260
canUpdate = False
255
261
canCreate = False
256
262
257
- class ProjectMilestone (GitlabObject ):
258
- url = '/projects/%(project_id)s/milestones'
259
- canDelete = False
263
+ class ProjectHook (GitlabObject ):
264
+ url = '/projects/%(project_id)d/hooks'
260
265
261
- class ProjectMergeRequest (GitlabObject ):
262
- url = '/projects/%(project_id)d/merge_request '
263
- constructorTypes = { 'author' : 'User' , 'assignee' : 'User' }
266
+ class ProjectIssue (GitlabObject ):
267
+ url = '/projects/%(project_id)s/issues/ '
268
+ returnClass = Issue
264
269
canDelete = False
265
270
266
- class Issue (GitlabObject ):
267
- url = '/issues'
268
- constructorTypes = {'author' : 'User' , 'assignee' : 'User' ,
269
- 'milestone' : 'ProjectMilestone' }
271
+ class ProjectMember (GitlabObject ):
272
+ url = '/projects/%(project_id)d/members'
273
+ returnClass = User
274
+
275
+ class ProjectTag (GitlabObject ):
276
+ url = '/projects/%(project_id)d/repository/tags'
270
277
canGet = False
271
278
canDelete = False
272
279
canUpdate = False
273
280
canCreate = False
274
281
275
- class ProjectIssue (GitlabObject ):
276
- url = '/projects/%(project_id)s/issues/ '
277
- returnClass = Issue
282
+ class ProjectMergeRequest (GitlabObject ):
283
+ url = '/projects/%(project_id)d/merge_request '
284
+ constructorTypes = { 'author' : 'User' , 'assignee' : 'User' }
278
285
canDelete = False
279
286
280
- class Session ( object ):
281
- def __init__ ( self ):
282
- raise NotImplementedError
287
+ class ProjectMilestone ( GitlabObject ):
288
+ url = '/projects/%(project_id)s/milestones'
289
+ canDelete = False
283
290
284
291
class ProjectSnippet (GitlabObject ):
285
292
url = '/projects/%(project_id)d/snippets'
286
293
constructorTypes = {'author' : 'User' }
287
294
288
- class User (GitlabObject ):
289
- url = '/users'
290
-
291
- class CurrentUser (GitlabObject ):
292
- url = '/user'
293
- canGetList = False
294
- canCreate = False
295
+ class Project (GitlabObject ):
296
+ url = '/projects'
297
+ constructorTypes = {'owner' : 'User' , 'namespace' : 'Group' }
295
298
canUpdate = False
296
299
canDelete = False
297
300
298
- class CurrentUserKey (GitlabObject ):
299
- url = '/user/keys'
300
- canUpdate = False
301
+ def objGetter (self , cls , id ):
302
+ if id == None :
303
+ return cls .list (self .gitlab , project_id = self .id )
304
+ else :
305
+ return cls .get (self .gitlab , id , project_id = self .id )
306
+
307
+ def Branch (self , id = None ):
308
+ return self .objGetter (ProjectBranch , id )
309
+
310
+ def Commit (self , id = None ):
311
+ return self .objGetter (ProjectCommit , id )
312
+
313
+ def Hook (self , id = None ):
314
+ return self .objGetter (ProjectHook , id )
315
+
316
+ def Issue (self , id = None ):
317
+ return self .objGetter (ProjectIssue , id )
318
+
319
+ def Member (self , id = None ):
320
+ return self .objGetter (ProjectMember , id )
321
+
322
+ def MergeRequest (self , id = None ):
323
+ return self .objGetter (ProjectMergeRequest , id )
324
+
325
+ def Milestone (self , id = None ):
326
+ return self .objGetter (ProjectMilestone , id )
327
+
328
+ def Snippet (self , id = None ):
329
+ return self .objGetter (ProjectSnippet , id )
330
+
331
+ def Tag (self , id = None ):
332
+ return self .objGetter (ProjectTag , id )
301
333
302
334
if __name__ == '__main__' :
303
335
# quick "doc"
0 commit comments