@@ -19,16 +19,6 @@ def project_list(self, limit=None):
19
19
params ['limit' ] = limit
20
20
return (self .get ('rest/api/1.0/projects' , params = params ) or {}).get ('values' )
21
21
22
- def repo_list (self , project_key ):
23
- """
24
- Provide the repository list in a specific BB project
25
- :param project_key: The Project Key ID you need to list
26
- return:
27
- """
28
- url = 'rest/api/1.0/projects/{projectKey}/repos?limit=1000' .format (
29
- projectKey = project_key )
30
- return self .get (url )
31
-
32
22
def project (self , key ):
33
23
"""
34
24
Provide project info
@@ -57,11 +47,10 @@ def update_project(self, key, **params):
57
47
"""
58
48
Update project
59
49
:param key:
60
- :param **params:
61
50
:return:
62
51
"""
63
52
data = self .project (key )
64
- if not 'errors' in data :
53
+ if 'errors' not in data :
65
54
data .update (params )
66
55
url = 'rest/api/1.0/projects/{0}' .format (key )
67
56
return self .put (url , data = data )
@@ -72,7 +61,7 @@ def update_project(self, key, **params):
72
61
def project_avatar (self , key , content_type = 'image/png' ):
73
62
"""
74
63
Get project avatar
75
-
64
+ :param content_type:
76
65
:param key:
77
66
:return:
78
67
"""
@@ -86,8 +75,9 @@ def project_avatar(self, key, content_type='image/png'):
86
75
def set_project_avatar (self , key , icon , content_type = 'image/png' ):
87
76
"""
88
77
Set project avatar
89
-
90
- :param key:
78
+ :param key: A Project key
79
+ :param icon:
80
+ :param content_type:
91
81
:return:
92
82
"""
93
83
headers = {'X-Atlassian-Token' : 'no-check' }
@@ -174,18 +164,18 @@ def project_remove_user_permissions(self, project_key, username):
174
164
username = username )
175
165
return self .delete (url )
176
166
177
- def project_grant_group_permissions (self , project_key , groupname , permission ):
167
+ def project_grant_group_permissions (self , project_key , group_name , permission ):
178
168
"""
179
169
Grant the specified project permission to an specific group
180
170
:param project_key: project key involved
181
- :param groupname : group to be granted
171
+ :param group_name : group to be granted
182
172
:param permission: the project permissions available are 'PROJECT_ADMIN', 'PROJECT_WRITE' and 'PROJECT_READ'
183
173
:return:
184
174
"""
185
- url = 'rest/api/1.0/projects/{project_key}/permissions/groups?permission={permission}&name={groupname }' .format (
175
+ url = 'rest/api/1.0/projects/{project_key}/permissions/groups?permission={permission}&name={group_name }' .format (
186
176
project_key = project_key ,
187
177
permission = permission ,
188
- groupname = groupname )
178
+ group_name = group_name )
189
179
return self .put (url )
190
180
191
181
def project_remove_group_permissions (self , project_key , groupname ):
@@ -199,9 +189,9 @@ def project_remove_group_permissions(self, project_key, groupname):
199
189
:param groupname: group to be granted
200
190
:return:
201
191
"""
202
- url = 'rest/api/1.0/projects/{project_key}/permissions/groups?name={groupname }' .format (
192
+ url = 'rest/api/1.0/projects/{project_key}/permissions/groups?name={group_name }' .format (
203
193
project_key = project_key ,
204
- groupname = groupname )
194
+ group_name = groupname )
205
195
return self .delete (url )
206
196
207
197
def repo_grant_user_permissions (self , project_key , repo_key , username , permission ):
@@ -273,6 +263,8 @@ def repo_remove_group_permissions(self, project_key, repo_key, groupname, permis
273
263
:return:
274
264
"""
275
265
params = {'name' : groupname }
266
+ if permission :
267
+ params ['permission' ] = permission
276
268
url = 'rest/api/1.0/projects/{project_key}/repos/{repo_key}/permissions/groups' .format (project_key = project_key ,
277
269
repo_key = repo_key )
278
270
return self .delete (url , params = params )
@@ -506,6 +498,20 @@ def get_default_branch(self, project, repository):
506
498
repository = repository )
507
499
return self .get (url )
508
500
501
+ def set_default_branch (self , project , repository , ref_branch_name ):
502
+ """
503
+ Update the default branch of a repository.
504
+ The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.
505
+ :param project: project key
506
+ :param repository: repo slug
507
+ :param ref_branch_name: ref name like refs/heads/master
508
+ :return:
509
+ """
510
+ data = {'id' : ref_branch_name }
511
+ url = 'rest/api/1.0/projects/{project}/repos/{repository}/branches/default' .format (project = project ,
512
+ repository = repository )
513
+ return self .put (url , data = data )
514
+
509
515
def create_branch (self , project_key , repository , name , start_point , message = "" ):
510
516
"""Creates a branch using the information provided in the request.
511
517
@@ -587,6 +593,7 @@ def get_pull_requests(self, project, repository, state='OPEN', order='newest', l
587
593
(as in: "oldest first") or NEWEST.
588
594
:param limit:
589
595
:param start:
596
+ :param at:
590
597
:return:
591
598
"""
592
599
url = 'rest/api/1.0/projects/{project}/repos/{repository}/pull-requests' .format (project = project ,
@@ -613,7 +620,7 @@ def get_pull_requests(self, project, repository, state='OPEN', order='newest', l
613
620
pr_list += (response or {}).get ('values' )
614
621
return pr_list
615
622
616
- def get_pull_requests_activities (self , project , repository , pull_request_id ):
623
+ def get_pull_requests_activities (self , project , repository , pull_request_id , start = 0 ):
617
624
"""
618
625
Get pull requests activities
619
626
:param project:
@@ -625,7 +632,7 @@ def get_pull_requests_activities(self, project, repository, pull_request_id):
625
632
project = project ,
626
633
repository = repository ,
627
634
pullRequestId = pull_request_id )
628
- params = {'start' : 0 }
635
+ params = {'start' : start }
629
636
response = self .get (url , params = params )
630
637
if 'values' not in response :
631
638
return []
@@ -807,7 +814,7 @@ def update_pull_request_comment(self, project, repository, pull_request_id, comm
807
814
that must match the server's version of the comment
808
815
or the update will fail.
809
816
"""
810
- url = "/ rest/api/1.0/projects/{project}/repos/{repository}/pull-requests/{pull_request_id}/comments/{comment_id}" .format (
817
+ url = "rest/api/1.0/projects/{project}/repos/{repository}/pull-requests/{pull_request_id}/comments/{comment_id}" .format (
811
818
project = project , repository = repository , pull_request_id = pull_request_id , comment_id = comment_id
812
819
)
813
820
payload = {
@@ -1321,6 +1328,8 @@ def upload_plugin(self, plugin_path):
1321
1328
def upload_file (self , project , repository , content , message , branch , filename ):
1322
1329
"""
1323
1330
Upload new file for given branch.
1331
+ :param project:
1332
+ :param repository:
1324
1333
:param content:
1325
1334
:param message:
1326
1335
:param branch:
@@ -1392,8 +1401,10 @@ def delete_code_insights_report(self, project_key, repository_slug, commit_id, r
1392
1401
def create_code_insights_report (self , project_key , repository_slug , commit_id , report_key , report_title ,
1393
1402
** report_params ):
1394
1403
"""
1395
- Create a new insight report, or replace the existing one if a report already exists for the given repository, commit, and report key.
1396
- A request to replace an existing report will be rejected if the authenticated user was not the creator of the specified report.
1404
+ Create a new insight report, or replace the existing one
1405
+ if a report already exists for the given repository, commit, and report key.
1406
+ A request to replace an existing report will be rejected
1407
+ if the authenticated user was not the creator of the specified report.
1397
1408
For further information visit: https://docs.atlassian.com/bitbucket-server/rest/6.6.1/bitbucket-code-insights-rest.html
1398
1409
:projectKey: str
1399
1410
:repositorySlug: str
0 commit comments