From 8be4445f0d9fe56cafbd54e540cdc82cadc1d24b Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 15 Sep 2022 14:45:02 +0000 Subject: [PATCH] Fix crm org retrieval --- src/gam/gapi/cloudresourcemanager.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gam/gapi/cloudresourcemanager.py b/src/gam/gapi/cloudresourcemanager.py index 1f05b6f6..5a8f06c0 100644 --- a/src/gam/gapi/cloudresourcemanager.py +++ b/src/gam/gapi/cloudresourcemanager.py @@ -13,12 +13,14 @@ def get_org_id(): gapi_directory_customer.setTrueCustomerId() crm = build() query = f'directorycustomerid:{GC_Values[GC_CUSTOMER_ID]}' - orgs = gapi.get_all_pages(crm.organizations(), + results = gapi.call(crm.organizations(), 'search', - 'organizations', + pageSize=1, + fields='organizations/name', query=query) - if len(orgs) < 1: + orgs = results.get('organizations') + if not orgs: # return nothing and let calling API deal with it # since caller knows what GCP role would serve best return - return orgs[0]['name'] + return orgs[0].get('name')