Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelneale/a9a49d052a8e473c94b4d6cfbc26ca09 to your computer and use it in GitHub Desktop.
Save michaelneale/a9a49d052a8e473c94b4d6cfbc26ca09 to your computer and use it in GitHub Desktop.
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