in terraform-modules/cloud-functions/src/provide-billing-permissions/main.py [0:0]
def get_policy(billing_ac):
"""Function to fetch the policy of the billing account.
Args:
billing_ac (string); billing account.
Returns:
policy (dict); returns IAM policy.
"""
from google.cloud import billing_v1
from google.iam.v1 import iam_policy_pb2
from google.protobuf.json_format import MessageToDict
client = billing_v1.CloudBillingClient()
request = iam_policy_pb2.GetIamPolicyRequest(
resource="billingAccounts/" + billing_ac,
)
response = client.get_iam_policy(request=request)
return(MessageToDict(response))