Skip to content

Commit 71b2bce

Browse files
Bitbucket: Check project existence (#708)
Co-authored-by: Yevgen Lasman <[email protected]>
1 parent 5b27a0f commit 71b2bce

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

atlassian/bitbucket/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,21 @@ def project(self, key):
297297
url = self._url_project(key)
298298
return self.get(url) or {}
299299

300+
def project_exists(self, project_key):
301+
"""
302+
Check if project with the provided project key exists and available.
303+
:param project_key: Key of the project where to check for repository.
304+
:return: False is requested repository doesn't exist in the project or not accessible to the requestor
305+
"""
306+
exists = False
307+
try:
308+
self.project(project_key)
309+
exists = True
310+
except HTTPError as e:
311+
if e.response.status_code in (401, 404):
312+
pass
313+
return exists
314+
300315
def update_project(self, key, **params):
301316
"""
302317
Update project

0 commit comments

Comments
 (0)