mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-16 18:25:12 -06:00
Fix BigAnimal API v2 compatibility issue for checking the cluster creation permission.
This commit is contained in:
parent
046b56bab1
commit
5d9bcde50d
@ -250,15 +250,23 @@ class BigAnimalProvider():
|
|||||||
"""
|
"""
|
||||||
_url = "{0}/{1}".format(
|
_url = "{0}/{1}".format(
|
||||||
self.BASE_URL,
|
self.BASE_URL,
|
||||||
'permissions')
|
'user-info')
|
||||||
resp = requests.get(_url, headers=self._get_headers())
|
resp = requests.get(_url, headers=self._get_headers())
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
return False
|
return False
|
||||||
if resp.status_code == 200 and resp.content:
|
if resp.status_code == 200 and resp.content:
|
||||||
content = json.loads(resp.content)
|
content = json.loads(resp.content)
|
||||||
if 'data' in content and 'create:clusters' in content[
|
if 'data' in content:
|
||||||
'data']:
|
# BigAnimal introduced Project feature in v3,
|
||||||
return True
|
# 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
|
return False
|
||||||
|
|
||||||
def get_regions(self):
|
def get_regions(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user