@@ -906,44 +906,35 @@ def cancel_merge_when_pipeline_succeeds(self, **kwargs):
906
906
self ._update_attrs (server_data )
907
907
908
908
def closes_issues (self , ** kwargs ):
909
- """List issues closed by the MR.
909
+ """List issues that will close on merge."
910
910
911
911
Returns:
912
- list (ProjectIssue): List of closed issues
913
-
914
- Raises:
915
- GitlabConnectionError: If the server cannot be reached.
916
- GitlabGetError: If the server fails to perform the request.
912
+ list (ProjectIssue): List of issues
917
913
"""
918
- # FIXME(gpocentek)
919
- url = ('/projects/%s/merge_requests/%s/closes_issues' %
920
- (self .project_id , self .iid ))
921
- return self .gitlab ._raw_list (url , ProjectIssue , ** kwargs )
914
+ path = '%s/%s/closes_issues' % (self .manager .path , self .get_id ())
915
+ data_list = self .manager .gitlab .http_list (path , ** kwargs )
916
+ manager = ProjectIssueManager (self .manager .gitlab ,
917
+ parent = self .manager ._parent )
918
+ return RESTObjectList (manager , ProjectIssue , data_list )
922
919
923
920
def commits (self , ** kwargs ):
924
921
"""List the merge request commits.
925
922
926
923
Returns:
927
924
list (ProjectCommit): List of commits
928
-
929
- Raises:
930
- GitlabConnectionError: If the server cannot be reached.
931
- GitlabListError: If the server fails to perform the request.
932
925
"""
933
- # FIXME(gpocentek)
934
- url = ('/projects/%s/merge_requests/%s/commits' %
935
- (self .project_id , self .iid ))
936
- return self .gitlab ._raw_list (url , ProjectCommit , ** kwargs )
926
+
927
+ path = '%s/%s/commits' % (self .manager .path , self .get_id ())
928
+ data_list = self .manager .gitlab .http_list (path , ** kwargs )
929
+ manager = ProjectCommitManager (self .manager .gitlab ,
930
+ parent = self .manager ._parent )
931
+ return RESTObjectList (manager , ProjectCommit , data_list )
937
932
938
933
def changes (self , ** kwargs ):
939
934
"""List the merge request changes.
940
935
941
936
Returns:
942
937
list (dict): List of changes
943
-
944
- Raises:
945
- GitlabConnectionError: If the server cannot be reached.
946
- GitlabListError: If the server fails to perform the request.
947
938
"""
948
939
path = '%s/%s/changes' % (self .manager .path , self .get_id ())
949
940
return self .manager .gitlab .http_get (path , ** kwargs )
@@ -960,14 +951,6 @@ def merge(self, merge_commit_message=None,
960
951
branch
961
952
merged_when_build_succeeds (bool): Wait for the build to succeed,
962
953
then merge
963
-
964
- Returns:
965
- ProjectMergeRequest: The updated MR
966
- Raises:
967
- GitlabConnectionError: If the server cannot be reached.
968
- GitlabMRForbiddenError: If the user doesn't have permission to
969
- close thr MR
970
- GitlabMRClosedError: If the MR is already closed
971
954
"""
972
955
path = '%s/%s/merge' % (self .manager .path , self .get_id ())
973
956
data = {}
@@ -1002,23 +985,31 @@ class ProjectMilestone(SaveMixin, RESTObject):
1002
985
_short_print_attr = 'title'
1003
986
1004
987
def issues (self , ** kwargs ):
1005
- url = '/projects/%s/milestones/%s/issues' % (self .project_id , self .id )
1006
- return self .gitlab ._raw_list (url , ProjectIssue , ** kwargs )
988
+ """List issues related to this milestone
989
+
990
+ Returns:
991
+ list (ProjectIssue): The list of issues
992
+ """
993
+
994
+ path = '%s/%s/issues' % (self .manager .path , self .get_id ())
995
+ data_list = self .manager .gitlab .http_list (path , ** kwargs )
996
+ manager = ProjectCommitManager (self .manager .gitlab ,
997
+ parent = self .manager ._parent )
998
+ # FIXME(gpocentek): the computed manager path is not correct
999
+ return RESTObjectList (manager , ProjectIssue , data_list )
1007
1000
1008
1001
def merge_requests (self , ** kwargs ):
1009
1002
"""List the merge requests related to this milestone
1010
1003
1011
1004
Returns:
1012
1005
list (ProjectMergeRequest): List of merge requests
1013
-
1014
- Raises:
1015
- GitlabConnectionError: If the server cannot be reached.
1016
- GitlabListError: If the server fails to perform the request.
1017
1006
"""
1018
- # FIXME(gpocentek)
1019
- url = ('/projects/%s/milestones/%s/merge_requests' %
1020
- (self .project_id , self .id ))
1021
- return self .gitlab ._raw_list (url , ProjectMergeRequest , ** kwargs )
1007
+ path = '%s/%s/merge_requests' % (self .manager .path , self .get_id ())
1008
+ data_list = self .manager .gitlab .http_list (path , ** kwargs )
1009
+ manager = ProjectCommitManager (self .manager .gitlab ,
1010
+ parent = self .manager ._parent )
1011
+ # FIXME(gpocentek): the computed manager path is not correct
1012
+ return RESTObjectList (manager , ProjectMergeRequest , data_list )
1022
1013
1023
1014
1024
1015
class ProjectMilestoneManager (RetrieveMixin , CreateMixin , DeleteMixin ,
@@ -1425,20 +1416,29 @@ def repository_tree(self, path='', ref='', **kwargs):
1425
1416
1426
1417
Returns:
1427
1418
str: The json representation of the tree.
1428
-
1429
- Raises:
1430
- GitlabConnectionError: If the server cannot be reached.
1431
- GitlabGetError: If the server fails to perform the request.
1432
1419
"""
1433
- path = '/projects/%s/repository/tree' % self .get_id ()
1420
+ gl_path = '/projects/%s/repository/tree' % self .get_id ()
1434
1421
query_data = {}
1435
1422
if path :
1436
1423
query_data ['path' ] = path
1437
1424
if ref :
1438
1425
query_data ['ref' ] = ref
1439
- return self .manager .gitlab .http_get (path , query_data = query_data ,
1426
+ return self .manager .gitlab .http_get (gl_path , query_data = query_data ,
1440
1427
** kwargs )
1441
1428
1429
+ def repository_blob (self , sha , ** kwargs ):
1430
+ """Returns a blob by blob SHA.
1431
+
1432
+ Args:
1433
+ sha(str): ID of the blob
1434
+
1435
+ Returns:
1436
+ str: The blob as json
1437
+ """
1438
+
1439
+ path = '/projects/%s/repository/blobs/%s' % (self .get_id (), sha )
1440
+ return self .manager .gitlab .http_get (path , ** kwargs )
1441
+
1442
1442
def repository_raw_blob (self , sha , streamed = False , action = None ,
1443
1443
chunk_size = 1024 , ** kwargs ):
1444
1444
"""Returns the raw file contents for a blob by blob SHA.
@@ -1454,13 +1454,9 @@ def repository_raw_blob(self, sha, streamed=False, action=None,
1454
1454
1455
1455
Returns:
1456
1456
str: The blob content
1457
-
1458
- Raises:
1459
- GitlabConnectionError: If the server cannot be reached.
1460
- GitlabGetError: If the server fails to perform the request.
1461
1457
"""
1462
- path = '/projects/%s/repository/raw_blobs /%s' % (self .get_id (), sha )
1463
- result = self .gitlab ._raw_get (path , streamed = streamed , ** kwargs )
1458
+ path = '/projects/%s/repository/blobs /%s/raw ' % (self .get_id (), sha )
1459
+ result = self .manager . gitlab .http_get (path , streamed = streamed , ** kwargs )
1464
1460
return utils .response_content (result , streamed , action , chunk_size )
1465
1461
1466
1462
def repository_compare (self , from_ , to , ** kwargs ):
@@ -1472,10 +1468,6 @@ def repository_compare(self, from_, to, **kwargs):
1472
1468
1473
1469
Returns:
1474
1470
str: The diff
1475
-
1476
- Raises:
1477
- GitlabConnectionError: If the server cannot be reached.
1478
- GitlabGetError: If the server fails to perform the request.
1479
1471
"""
1480
1472
path = '/projects/%s/repository/compare' % self .get_id ()
1481
1473
query_data = {'from' : from_ , 'to' : to }
@@ -1486,11 +1478,7 @@ def repository_contributors(self, **kwargs):
1486
1478
"""Returns a list of contributors for the project.
1487
1479
1488
1480
Returns:
1489
- list: The contibutors
1490
-
1491
- Raises:
1492
- GitlabConnectionError: If the server cannot be reached.
1493
- GitlabGetError: If the server fails to perform the request.
1481
+ list: The contributors
1494
1482
"""
1495
1483
path = '/projects/%s/repository/contributors' % self .get_id ()
1496
1484
return self .manager .gitlab .http_get (path , ** kwargs )
@@ -1510,38 +1498,26 @@ def repository_archive(self, sha=None, streamed=False, action=None,
1510
1498
1511
1499
Returns:
1512
1500
str: The binary data of the archive.
1513
-
1514
- Raises:
1515
- GitlabConnectionError: If the server cannot be reached.
1516
- GitlabGetError: If the server fails to perform the request.
1517
1501
"""
1518
1502
path = '/projects/%s/repository/archive' % self .get_id ()
1519
1503
query_data = {}
1520
1504
if sha :
1521
1505
query_data ['sha' ] = sha
1522
- result = self .gitlab ._raw_get (path , query_data = query_data ,
1523
- streamed = streamed , ** kwargs )
1506
+ result = self .manager . gitlab .http_get (path , query_data = query_data ,
1507
+ streamed = streamed , ** kwargs )
1524
1508
return utils .response_content (result , streamed , action , chunk_size )
1525
1509
1526
1510
def create_fork_relation (self , forked_from_id , ** kwargs ):
1527
1511
"""Create a forked from/to relation between existing projects.
1528
1512
1529
1513
Args:
1530
1514
forked_from_id (int): The ID of the project that was forked from
1531
-
1532
F438
code>
- Raises:
1533
- GitlabConnectionError: If the server cannot be reached.
1534
- GitlabCreateError: If the server fails to perform the request.
1535
1515
"""
1536
1516
path = '/projects/%s/fork/%s' % (self .get_id (), forked_from_id )
1537
1517
self .manager .gitlab .http_post (path , ** kwargs )
1538
1518
1539
1519
def delete_fork_relation (self , ** kwargs ):
1540
1520
"""Delete a forked relation between existing projects.
1541
-
1542
- Raises:
1543
- GitlabConnectionError: If the server cannot be reached.
1544
- GitlabDeleteError: If the server fails to perform the request.
1545
1521
"""
1546
1522
path = '/projects/%s/fork' % self .get_id ()
1547
1523
self .manager .gitlab .http_delete (path , ** kwargs )
@@ -1551,10 +1527,6 @@ def star(self, **kwargs):
1551
1527
1552
1528
Returns:
1553
1529
Project: the updated Project
1554
-
1555
- Raises:
1556
- GitlabCreateError: If the action cannot be done
1557
- GitlabConnectionError: If the server cannot be reached.
1558
1530
"""
1559
1531
path = '/projects/%s/star' % self .get_id ()
1560
1532
server_data = self .manager .gitlab .http_post (path , ** kwargs )
@@ -1565,10 +1537,6 @@ def unstar(self, **kwargs):
1565
1537
1566
1538
Returns:
1567
1539
Project: the updated Project
1568
-
1569
- Raises:
1570
- GitlabDeleteError: If the action cannot be done
1571
- GitlabConnectionError: If the server cannot be reached.
1572
1540
"""
1573
1541
path = '/projects/%s/unstar' % self .get_id ()
1574
1542
server_data = self .manager .gitlab .http_post (path , ** kwargs )
@@ -1579,10 +1547,6 @@ def archive(self, **kwargs):
1579
1547
1580
1548
Returns:
1581
1549
Project: the updated Project
1582
-
1583
- Raises:
1584
- GitlabCreateError: If the action cannot be done
1585
- GitlabConnectionError: If the server cannot be reached.
1586
1550
"""
1587
1551
path = '/projects/%s/archive' % self .get_id ()
1588
1552
server_data = self .manager .gitlab .http_post (path , ** kwargs )
@@ -1593,10 +1557,6 @@ def unarchive(self, **kwargs):
1593
1557
1594
1558
Returns:
1595
1559
Project: the updated Project
1596
-
1597
- Raises:
1598
- GitlabDeleteError: If the action cannot be done
1599
- GitlabConnectionError: If the server cannot be reached.
1600
1560
"""
1601
1561
path = '/projects/%s/unarchive' % self .get_id ()
1602
1562
server_data = self .manager .gitlab .http_post (path , ** kwargs )
@@ -1608,10 +1568,6 @@ def share(self, group_id, group_access, expires_at=None, **kwargs):
1608
1568
Args:
1609
1569
group_id (int): ID of the group.
1610
1570
group_access (int): Access level for the group.
1611
-
1612
- Raises:
1613
- GitlabConnectionError: If the server cannot be reached.
1614
- GitlabCreateError: If the server fails to perform the request.
1615
1571
"""
1616
1572
path = '/projects/%s/share' % self .get_id ()
1617
1573
data = {'group_id' : group_id ,
@@ -1628,10 +1584,6 @@ def trigger_pipeline(self, ref, token, variables={}, **kwargs):
1628
1584
ref (str): Commit to build; can be a commit SHA, a branch name, ...
1629
1585
token (str): The trigger token
1630
1586
variables (dict): Variables passed to the build script
1631
-
1632
- Raises:
1633
- GitlabConnectionError: If the server cannot be reached.
1634
- GitlabCreateError: If the server fails to perform the request.
1635
1587
"""
1636
1588
path = '/projects/%s/trigger/pipeline' % self .get_id ()
1637
1589
form = {r'variables[%s]' % k : v for k , v in six .iteritems (variables )}
0 commit comments