def get_policy()

in terraform-modules/cloud-functions/src/provide-project-permissions/main.py [0:0]


def get_policy(org_id):
  """Function to fetch the policy of the project.
  Args:
      org_id (string); organization id.

  Returns:
      policy (dict);  returns IAM policy.
  """
  from google.oauth2 import service_account
  import googleapiclient.discovery
  service = googleapiclient.discovery.build(
      "cloudresourcemanager", "v1"
  )
  policy = (
      service.organizations()
      .getIamPolicy(
          resource='organizations/' + org_id,
          body={"options": {"requestedPolicyVersion": 1}},
      )
      .execute()
  )
  return(policy)