// Call the Cloud IAM Roles API
// If using pylint, disable weak-typing warnings
// pylint: disable=no-member
response = service.roles().list().execute()
roles = response["roles"]
// Process the response
for role in roles:
print("Title: " + role["title"])
print("Name: " + role["name"])
if "description" in role:
print("Description: " + role["description"])
After Change
// Gets the project"s policy and prints all members with the "Log Writer" role.
policy = get_policy(crm_service, project_id)
binding = next(b for b in policy["bindings"] if b["role"] == role)
print(f"Role: {(binding["role"])}")
print("Members: ")
for m in binding["members"]:
print(f"[{m}]")