mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-26 02:30:21 -06:00
Fix BigAnimal API v2 compatibility issue for checking the cluster creation permission.
This commit is contained in:
parent
046b56bab1
commit
5d9bcde50d
@ -250,14 +250,22 @@ class BigAnimalProvider():
|
||||
"""
|
||||
_url = "{0}/{1}".format(
|
||||
self.BASE_URL,
|
||||
'permissions')
|
||||
'user-info')
|
||||
resp = requests.get(_url, headers=self._get_headers())
|
||||
if resp.status_code != 200:
|
||||
return False
|
||||
if resp.status_code == 200 and resp.content:
|
||||
content = json.loads(resp.content)
|
||||
if 'data' in content and 'create:clusters' in content[
|
||||
'data']:
|
||||
if 'data' in content:
|
||||
# BigAnimal introduced Project feature in v3,
|
||||
# so all the existing clusters moved to the default Project.
|
||||
# For now, we can get the Proj Id by replacing 'org' to 'prj'
|
||||
# in organization ID: org_1234 -> prj_1234
|
||||
proj_Id = content['data']['organizationId'].replace('org',
|
||||
'prj')
|
||||
for permission in content['data']['scopedPermissions']:
|
||||
if proj_Id == permission['scope'] and\
|
||||
'create:clusters' in permission['permissions']:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user