@@ -1090,21 +1090,21 @@ class ProjectTagManager(BaseManager):
10901090
10911091class ProjectMergeRequestDiff (GitlabObject ):
10921092 _url = ('/projects/%(project_id)s/merge_requests/'
1093- '%(merge_request_id )s/versions' )
1093+ '%(merge_request_iid )s/versions' )
10941094 canCreate = False
10951095 canUpdate = False
10961096 canDelete = False
1097- requiredUrlAttrs = ['project_id' , 'merge_request_id ' ]
1097+ requiredUrlAttrs = ['project_id' , 'merge_request_iid ' ]
10981098
10991099
11001100class ProjectMergeRequestDiffManager (BaseManager ):
11011101 obj_cls = ProjectMergeRequestDiff
11021102
11031103
11041104class ProjectMergeRequestNote (GitlabObject ):
1105- _url = '/projects/%(project_id)s/merge_requests/%(merge_request_id )s/notes'
1105+ _url = '/projects/%(project_id)s/merge_requests/%(merge_request_iid )s/notes'
11061106 _constructorTypes = {'author' : 'User' }
1107- requiredUrlAttrs = ['project_id' , 'merge_request_id ' ]
1107+ requiredUrlAttrs = ['project_id' , 'merge_request_iid ' ]
11081108 requiredCreateAttrs = ['body' ]
11091109
11101110
@@ -1123,12 +1123,13 @@ class ProjectMergeRequest(GitlabObject):
11231123 'description' , 'state_event' , 'labels' ,
11241124 'milestone_id' ]
11251125 optionalListAttrs = ['iids' , 'state' , 'order_by' , 'sort' ]
1126+ idAttr = 'iid'
11261127
11271128 managers = (
11281129 ('notes' , 'ProjectMergeRequestNoteManager' ,
1129- [('project_id' , 'project_id' ), ('merge_request_id ' , 'id ' )]),
1130+ [('project_id' , 'project_id' ), ('merge_request_iid ' , 'iid ' )]),
11301131 ('diffs' , 'ProjectMergeRequestDiffManager' ,
1131- [('project_id' , 'project_id' ), ('merge_request_id ' , 'id ' )]),
1132+ [('project_id' , 'project_id' ), ('merge_request_iid ' , 'iid ' )]),
11321133 )
11331134
11341135 def _data_for_gitlab (self , extra_parameters = {}, update = False ,
@@ -1149,9 +1150,9 @@ def subscribe(self, **kwargs):
11491150 GitlabConnectionError: If the server cannot be reached.
11501151 GitlabSubscribeError: If the subscription cannot be done
11511152 """
1152- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1153+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
11531154 'subscribe' %
1154- {'project_id' : self .project_id , 'mr_id ' : self .id })
1155+ {'project_id' : self .project_id , 'mr_iid ' : self .iid })
11551156
11561157 r = self .gitlab ._raw_post (url , ** kwargs )
11571158 raise_error_from_response (r , GitlabSubscribeError , [201 , 304 ])
@@ -1165,9 +1166,9 @@ def unsubscribe(self, **kwargs):
11651166 GitlabConnectionError: If the server cannot be reached.
11661167 GitlabUnsubscribeError: If the unsubscription cannot be done
11671168 """
1168- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1169+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
11691170 'unsubscribe' %
1170- {'project_id' : self .project_id , 'mr_id ' : self .id })
1171+ {'project_id' : self .project_id , 'mr_iid ' : self .iid })
11711172
11721173 r = self .gitlab ._raw_post (url , ** kwargs )
11731174 raise_error_from_response (r , GitlabUnsubscribeError , [201 , 304 ])
@@ -1179,7 +1180,7 @@ def cancel_merge_when_pipeline_succeeds(self, **kwargs):
11791180
11801181 u = ('/projects/%s/merge_requests/%s/'
11811182 'cancel_merge_when_pipeline_succeeds'
1182- % (self .project_id , self .id ))
1183+ % (self .project_id , self .iid ))
11831184 r = self .gitlab ._raw_put (u , ** kwargs )
11841185 errors = {401 : GitlabMRForbiddenError ,
11851186 405 : GitlabMRClosedError ,
@@ -1198,7 +1199,7 @@ def closes_issues(self, **kwargs):
11981199 GitlabGetError: If the server fails to perform the request.
11991200 """
12001201 url = ('/projects/%s/merge_requests/%s/closes_issues' %
1201- (self .project_id , self .id ))
1202+ (self .project_id , self .iid ))
12021203 return self .gitlab ._raw_list (url , ProjectIssue ,
12031204 {'project_id' : self .project_id },
12041205 ** kwargs )
@@ -1214,7 +1215,7 @@ def commits(self, **kwargs):
12141215 GitlabListError: If the server fails to perform the request.
12151216 """
12161217 url = ('/projects/%s/merge_requests/%s/commits' %
1217- (self .project_id , self .id ))
1218+ (self .project_id , self .iid ))
12181219 return self .gitlab ._raw_list (url , ProjectCommit ,
12191220 {'project_id' : self .project_id },
12201221 ** kwargs )
@@ -1230,7 +1231,7 @@ def changes(self, **kwargs):
12301231 GitlabListError: If the server fails to perform the request.
12311232 """
12321233 url = ('/projects/%s/merge_requests/%s/changes' %
1233- (self .project_id , self .id ))
1234+ (self .project_id , self .iid ))
12341235 r = self .gitlab ._raw_get (url , ** kwargs )
12351236 raise_error_from_response (r , GitlabListError )
12361237 return r .json ()
@@ -1257,7 +1258,7 @@ def merge(self, merge_commit_message=None,
12571258 GitlabMRClosedError: If the MR is already closed
12581259 """
12591260 url = '/projects/%s/merge_requests/%s/merge' % (self .project_id ,
1260- self .id )
1261+ self .iid )
12611262 data = {}
12621263 if merge_commit_message :
12631264 data ['merge_commit_message' ] = merge_commit_message
@@ -1278,8 +1279,8 @@ def todo(self, **kwargs):
12781279 Raises:
12791280 GitlabConnectionError: If the server cannot be reached.
12801281 """
1281- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/todo' %
1282- {'project_id' : self .project_id , 'mr_id ' : self .id })
1282+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/todo' %
1283+ {'project_id' : self .project_id , 'mr_iid ' : self .iid })
12831284 r = self .gitlab ._raw_post (url , ** kwargs )
12841285 raise_error_from_response (r , GitlabTodoError , [201 , 304 ])
12851286
@@ -1289,23 +1290,28 @@ def time_stats(self, **kwargs):
12891290 Raises:
12901291 GitlabConnectionError: If the server cannot be reached.
12911292 """
1292- url = ('/projects/%(project_id)s/merge_requests/%(mr_id)s/time_stats' %
1293- {'project_id' : self .project_id , 'mr_id' : self .id })
1293+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid)s/'
1294+ 'time_stats' %
1295+ {'project_id' : self .project_id , 'mr_iid' : self .iid })
12941296 r = self .gitlab ._raw_get (url , ** kwargs )
12951297 raise_error_from_response (r , GitlabGetError )
12961298 return r .json ()
12971299
1298- def time_estimate (self , ** kwargs ):
1300+ def time_estimate (self , duration , ** kwargs ):
12991301 """Set an estimated time of work for the merge request.
13001302
1303+ Args:
1304+ duration (str): duration in human format (e.g. 3h30)
1305+
13011306 Raises:
13021307 GitlabConnectionError: If the server cannot be reached.
13031308 """
1304- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1309+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
13051310 'time_estimate' %
1306- {'project_id' : self .project_id , 'mr_id' : self .id })
1307- r = self .gitlab ._raw_post (url , ** kwargs )
1308- raise_error_from_response (r , GitlabTimeTrackingError , 201 )
1311+ {'project_id' : self .project_id , 'mr_iid' : self .iid })
1312+ data = {'duration' : duration }
1313+ r = self .gitlab ._raw_post (url , data , ** kwargs )
1314+ raise_error_from_response (r , GitlabTimeTrackingError , 200 )
13091315 return r .json ()
13101316
13111317 def reset_time_estimate (self , ** kwargs ):
@@ -1314,24 +1320,28 @@ def reset_time_estimate(self, **kwargs):
13141320 Raises:
13151321 GitlabConnectionError: If the server cannot be reached.
13161322 """
1317- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1323+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
13181324 'reset_time_estimate' %
1319- {'project_id' : self .project_id , 'mr_id ' : self .id })
1325+ {'project_id' : self .project_id , 'mr_iid ' : self .iid })
13201326 r = self .gitlab ._raw_post (url , ** kwargs )
13211327 raise_error_from_response (r , GitlabTimeTrackingError , 200 )
13221328 return r .json ()
13231329
1324- def add_spent_time (self , ** kwargs ):
1330+ def add_spent_time (self , duration , ** kwargs ):
13251331 """Set an estimated time of work for the merge request.
13261332
1333+ Args:
1334+ duration (str): duration in human format (e.g. 3h30)
1335+
13271336 Raises:
13281337 GitlabConnectionError: If the server cannot be reached.
13291338 """
1330- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1339+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
13311340 'add_spent_time' %
1332- {'project_id' : self .project_id , 'mr_id' : self .id })
1333- r = self .gitlab ._raw_post (url , ** kwargs )
1334- raise_error_from_response (r , GitlabTimeTrackingError , 200 )
1341+ {'project_id' : self .project_id , 'mr_iid' : self .iid })
1342+ data = {'duration' : duration }
1343+ r = self .gitlab ._raw_post (url , data , ** kwargs )
1344+ raise_error_from_response (r , GitlabTimeTrackingError , 201 )
13351345 return r .json ()
13361346
13371347 def reset_spent_time (self , ** kwargs ):
@@ -1340,9 +1350,9 @@ def reset_spent_time(self, **kwargs):
13401350 Raises:
13411351 GitlabConnectionError: If the server cannot be reached.
13421352 """
1343- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1353+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
13441354 'reset_spent_time' %
1345- {'project_id' : self .project_id , 'mr_id ' : self .id })
1355+ {'project_id' : self .project_id , 'mr_iid ' : self .iid })
13461356 r = self .gitlab ._raw_post (url , ** kwargs )
13471357 raise_error_from_response (r , GitlabTimeTrackingError , 200 )
13481358 return r .json ()
0 commit comments