Skip to content

Commit

Permalink
fix error when there are no permissions to validate
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon So committed Apr 1, 2019
1 parent 11c6a6e commit 0265376
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,23 @@ def __init__(self, org_id, shared_vpc=False, parent=False):
self.permissions += self.PARENT_PERMISSIONS

def validate(self, credentials):
body = {"permissions": self.permissions}
resource = "organizations/" + self.org_id

# no permissions to validate
if len(self.permissions) == 0:
return {
"type": "Service account permissions on organization",
"name": "organizations/" + self.org_id,
"satisfied": [],
"unsatisfied": []
}

service = discovery.build(
'cloudresourcemanager', 'v1',
credentials=credentials
)

body = {"permissions": self.permissions}
resource = "organizations/" + self.org_id

request = service.organizations().testIamPermissions(
resource=resource,
body=body)
Expand Down

0 comments on commit 0265376

Please sign in to comment.