Skip to content

Commit

Permalink
Do not throw errors when trying to list members from a non-existent G…
Browse files Browse the repository at this point in the history
…oogle Group (#5522)

* Do not throw errors when trying to list members from a non-existent Google Group

* Update src/dispatch/plugins/dispatch_google/groups/plugin.py

Co-authored-by: Marc Vilanova <[email protected]>
Signed-off-by: Avery <[email protected]>

---------

Signed-off-by: Avery <[email protected]>
Co-authored-by: Marc Vilanova <[email protected]>
  • Loading branch information
metroid-samus and mvilanova authored Nov 22, 2024
1 parent 916efbd commit f0ef158
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/dispatch/plugins/dispatch_google/groups/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,16 @@ def remove(self, email: str, participants: List[str]):
for p in participants:
remove_member(client, email, p)

def list(self, email: str):
def list(self, email: str) -> list[str]:
"""Lists members from an existing Google Group."""
client = get_service(self.configuration, "admin", "directory_v1", self.scopes)
members = list_members(client, email)
return [m["email"] for m in members.get("members", [])]
try:
members = list_members(client, email)
return [m["email"] for m in members.get("members", [])]
except HttpError as e:
if e.resp.status == 404:
log.warning(f"Group does not exist. GroupKey={email} Trying to list members.")
return []

def delete(self, email: str):
"""Deletes an existing Google group."""
Expand Down

0 comments on commit f0ef158

Please sign in to comment.