From 55e5b86ec46b9ce6ecabf67851e2780d16b03888 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Fri, 9 Oct 2020 07:33:03 -0700 Subject: [PATCH] Make labels display useful (#1260) With the existing code you get these columns: labels.cloudidentity.googleapis.com/groups.discussion_forum,labels.cloudidentity.googleapis.com/groups.security but there is no data in the columns so you can't tell whcih groups have which values; by translating '' to True you can. --- src/gam/gapi/cloudidentity/groups.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gam/gapi/cloudidentity/groups.py b/src/gam/gapi/cloudidentity/groups.py index 4cebed80..cdce61b4 100644 --- a/src/gam/gapi/cloudidentity/groups.py +++ b/src/gam/gapi/cloudidentity/groups.py @@ -237,6 +237,11 @@ def print_(): for groupEntity in entityList: i += 1 groupEmail = groupEntity['groupKey']['id'] + for k, v in iter(groupEntity.pop('labels', {}).items()): + if v == '': + groupEntity[f'labels.{k}'] = True + else: + groupEntity[f'labels.{k}'] = v group = utils.flatten_json(groupEntity) for a_key in group: if a_key not in titles: @@ -304,7 +309,7 @@ def print_(): csvRows.append(group) if sortHeaders: display.sort_csv_titles([ - 'Email', + 'name', 'groupKey.id' ], titles) display.write_csv_file(csvRows, titles, 'Groups', todrive)