@@ -1090,21 +1090,21 @@ class ProjectTagManager(BaseManager):
1090
1090
1091
1091
class ProjectMergeRequestDiff (GitlabObject ):
1092
1092
_url = ('/projects/%(project_id)s/merge_requests/'
1093
- '%(merge_request_id )s/versions' )
1093
+ '%(merge_request_iid )s/versions' )
1094
1094
canCreate = False
1095
1095
canUpdate = False
1096
1096
canDelete = False
1097
- requiredUrlAttrs = ['project_id' , 'merge_request_id ' ]
1097
+ requiredUrlAttrs = ['project_id' , 'merge_request_iid ' ]
1098
1098
1099
1099
1100
1100
class ProjectMergeRequestDiffManager (BaseManager ):
1101
1101
obj_cls = ProjectMergeRequestDiff
1102
1102
1103
1103
1104
1104
class 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'
1106
1106
_constructorTypes = {'author' : 'User' }
1107
- requiredUrlAttrs = ['project_id' , 'merge_request_id ' ]
1107
+ requiredUrlAttrs = ['project_id' , 'merge_request_iid ' ]
1108
1108
requiredCreateAttrs = ['body' ]
1109
1109
1110
1110
@@ -1123,12 +1123,13 @@ class ProjectMergeRequest(GitlabObject):
1123
1123
'description' , 'state_event' , 'labels' ,
1124
1124
'milestone_id' ]
1125
1125
optionalListAttrs = ['iids' , 'state' , 'order_by' , 'sort' ]
1126
+ idAttr = 'iid'
1126
1127
1127
1128
managers = (
1128
1129
('notes' , 'ProjectMergeRequestNoteManager' ,
1129
- [('project_id' , 'project_id' ), ('merge_request_id ' , 'id ' )]),
1130
+ [('project_id' , 'project_id' ), ('merge_request_iid ' , 'iid ' )]),
1130
1131
('diffs' , 'ProjectMergeRequestDiffManager' ,
1131
- [('project_id' , 'project_id' ), ('merge_request_id ' , 'id ' )]),
1132
+ [('project_id' , 'project_id' ), ('merge_request_iid ' , 'iid ' )]),
1132
1133
)
1133
1134
1134
1135
def _data_for_gitlab (self , extra_parameters = {}, update = False ,
@@ -1149,9 +1150,9 @@ def subscribe(self, **kwargs):
1149
1150
GitlabConnectionError: If the server cannot be reached.
1150
1151
GitlabSubscribeError: If the subscription cannot be done
1151
1152
"""
1152
- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1153
+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
1153
1154
'subscribe' %
1154
- {'project_id' : self .project_id , 'mr_id ' : self .id })
1155
+ {'project_id' : self .project_id , 'mr_iid ' : self .iid })
1155
1156
1156
1157
r = self .gitlab ._raw_post (url , ** kwargs )
1157
1158
raise_error_from_response (r , GitlabSubscribeError , [201 , 304 ])
@@ -1165,9 +1166,9 @@ def unsubscribe(self, **kwargs):
1165
1166
GitlabConnectionError: If the server cannot be reached.
1166
1167
GitlabUnsubscribeError: If the unsubscription cannot be done
1167
1168
"""
1168
- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1169
+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
1169
1170
'unsubscribe' %
1170
- {'project_id' : self .project_id , 'mr_id ' : self .id })
1171
+ {'project_id' : self .project_id , 'mr_iid ' : self .iid })
1171
1172
1172
1173
r = self .gitlab ._raw_post (url , ** kwargs )
1173
1174
raise_error_from_response (r , GitlabUnsubscribeError , [201 , 304 ])
@@ -1179,7 +1180,7 @@ def cancel_merge_when_pipeline_succeeds(self, **kwargs):
1179
1180
1180
1181
u = ('/projects/%s/merge_requests/%s/'
1181
1182
'cancel_merge_when_pipeline_succeeds'
1182
- % (self .project_id , self .id ))
1183
+ % (self .project_id , self .iid ))
1183
1184
r = self .gitlab ._raw_put (u , ** kwargs )
1184
1185
errors = {401 : GitlabMRForbiddenError ,
1185
1186
405 : GitlabMRClosedError ,
@@ -1198,7 +1199,7 @@ def closes_issues(self, **kwargs):
1198
1199
GitlabGetError: If the server fails to perform the request.
1199
1200
"""
1200
1201
url = ('/projects/%s/merge_requests/%s/closes_issues' %
1201
- (self .project_id , self .id ))
1202
+ (self .project_id , self .iid ))
1202
1203
return self .gitlab ._raw_list (url , ProjectIssue ,
1203
1204
{'project_id' : self .project_id },
1204
1205
** kwargs )
@@ -1214,7 +1215,7 @@ def commits(self, **kwargs):
1214
1215
GitlabListError: If the server fails to perform the request.
1215
1216
"""
1216
1217
url = ('/projects/%s/merge_requests/%s/commits' %
1217
- (self .project_id , self .id ))
1218
+ (self .project_id , self .iid ))
1218
1219
return self .gitlab ._raw_list (url , ProjectCommit ,
1219
1220
{'project_id' : self .project_id },
1220
1221
** kwargs )
@@ -1230,7 +1231,7 @@ def changes(self, **kwargs):
1230
1231
GitlabListError: If the server fails to perform the request.
1231
1232
"""
1232
1233
url = ('/projects/%s/merge_requests/%s/changes' %
1233
- (self .project_id , self .id ))
1234
+ (self .project_id , self .iid ))
1234
1235
r = self .gitlab ._raw_get (url , ** kwargs )
1235
1236
raise_error_from_response (r , GitlabListError )
1236
1237
return r .json ()
@@ -1257,7 +1258,7 @@ def merge(self, merge_commit_message=None,
1257
1258
GitlabMRClosedError: If the MR is already closed
1258
1259
"""
1259
1260
url = '/projects/%s/merge_requests/%s/merge' % (self .project_id ,
1260
- self .id )
1261
+ self .iid )
1261
1262
data = {}
1262
1263
if merge_commit_message :
1263
1264
data ['merge_commit_message' ] = merge_commit_message
@@ -1278,8 +1279,8 @@ def todo(self, **kwargs):
1278
1279
Raises:
1279
1280
GitlabConnectionError: If the server cannot be reached.
1280
1281
"""
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 })
1283
1284
r = self .gitlab ._raw_post (url , ** kwargs )
1284
1285
raise_error_from_response (r , GitlabTodoError , [201 , 304 ])
1285
1286
@@ -1289,23 +1290,28 @@ def time_stats(self, **kwargs):
1289
1290
Raises:
1290
1291
GitlabConnectionError: If the server cannot be reached.
1291
1292
"""
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 })
1294
1296
r = self .gitlab ._raw_get (url , ** kwargs )
1295
1297
raise_error_from_response (r , GitlabGetError )
1296
1298
return r .json ()
1297
1299
1298
- def time_estimate (self , ** kwargs ):
1300
+ def time_estimate (self , duration , ** kwargs ):
1299
1301
"""Set an estimated time of work for the merge request.
1300
1302
1303
+ Args:
1304
+ duration (str): duration in human format (e.g. 3h30)
1305
+
1301
1306
Raises:
1302
1307
GitlabConnectionError: If the server cannot be reached.
1303
1308
"""
1304
- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1309
+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
1305
1310
'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 )
1309
1315
return r .json ()
1310
1316
1311
1317
def reset_time_estimate (self , ** kwargs ):
@@ -1314,24 +1320,28 @@ def reset_time_estimate(self, **kwargs):
1314
1320
Raises:
1315
1321
GitlabConnectionError: If the server cannot be reached.
1316
1322
"""
1317
- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1323
+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
1318
1324
'reset_time_estimate' %
1319
- {'project_id' : self .project_id , 'mr_id ' : self .id })
1325
+ {'project_id' : self .project_id , 'mr_iid ' : self .iid })
1320
1326
r = self .gitlab ._raw_post (url , ** kwargs )
1321
1327
raise_error_from_response (r , GitlabTimeTrackingError , 200 )
1322
1328
return r .json ()
1323
1329
1324
- def add_spent_time (self , ** kwargs ):
1330
+ def add_spent_time (self , duration , ** kwargs ):
1325
1331
"""Set an estimated time of work for the merge request.
1326
1332
1333
+ Args:
1334
+ duration (str): duration in human format (e.g. 3h30)
1335
+
1327
1336
Raises:
1328
1337
GitlabConnectionError: If the server cannot be reached.
1329
1338
"""
1330
- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1339
+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
1331
1340
'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 )
1335
1345
return r .json ()
1336
1346
1337
1347
def reset_spent_time (self , ** kwargs ):
@@ -1340,9 +1350,9 @@ def reset_spent_time(self, **kwargs):
1340
1350
Raises:
1341
1351
GitlabConnectionError: If the server cannot be reached.
1342
1352
"""
1343
- url = ('/projects/%(project_id)s/merge_requests/%(mr_id )s/'
1353
+ url = ('/projects/%(project_id)s/merge_requests/%(mr_iid )s/'
1344
1354
'reset_spent_time' %
1345
- {'project_id' : self .project_id , 'mr_id ' : self .id })
1355
+ {'project_id' : self .project_id , 'mr_iid ' : self .iid })
1346
1356
r = self .gitlab ._raw_post (url , ** kwargs )
1347
1357
raise_error_from_response (r , GitlabTimeTrackingError , 200 )
1348
1358
return r .json ()
0 commit comments