This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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