in analytics-hub/snippets/create_listing_python/main.py [0:0]
def listing_add_iam_policy_member(client: bigquery_analyticshub_v1.AnalyticsHubServiceClient, listing_id: str, role: str, member: str):
newPolicy = False
exitLoop = False
while not exitLoop:
exitLoop = True
try:
# Make the request
request = create_set_iam_policy_request(client, listing_id, role, member)
if request:
# Make the request
response = client.set_iam_policy(request=request)
# Handle the response
newPolicy = response
except Exception as ex:
# CONFLICT == concurrent modification / Etag mismatch
if ex.code == HTTPStatus.CONFLICT:
print("listing_add_iam_policy_member: concurrent modification (Etag mismatch), retrying")
time.sleep(60)
exitLoop = False
# TODO: handle UserNotFound error (e.g. the user to be added does not exist)
else:
print(ex)
return newPolicy