Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import base64
import os
from google.oauth2 import service_account
import googleapiclient.discovery
def hello_pubsub(event, context):
"""Triggered from a message on a Cloud Pub/Sub topic.
event (dict): Event payload.
context ( Metadata for the event.
env = os.environ
# Create the Cloud IAM service object
service ='iam', 'v1')
# 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'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment