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
Embed
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.
Args:
event (dict): Event payload.
context (google.cloud.functions.Context): Metadata for the event.
"""
env = os.environ
print(env)
# Create the Cloud IAM service object
service = googleapiclient.discovery.build('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'])
print('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment