Skip to content

Commit

Permalink
improve user org list check list comprehension
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Gumprich <[email protected]>
  • Loading branch information
Nemental and rndmh3ro authored Jan 3, 2024
1 parent cadfd0a commit 0531acd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/modules/grafana_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,9 @@ def switch_organization(self, org_id):
def organization_by_name(self, org_name):
url = "/api/user/orgs"
organizations = self._send_request(url, headers=self.headers, method='GET')
for org in organizations:
if org['name'] == org_name:
return org['orgId']
orga = next((org for org in organizations if org['name'] == org_name))
if orga:
return orga['orgId']

return self._module.fail_json(failed=True, msg="Current user isn't member of organization: %s" % org_name)

Expand Down

0 comments on commit 0531acd

Please sign in to comment.