
    	                     \    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	mZ
 d Zd Zy	)
zEUtility functions for Functions specific to deploying Gen2 functions.    )absolute_import)division)print_function)unicode_literals)utilc                      dj                  t        j                  t        j                                     } t        j
                  | ddgd       y)zEnsures the project's Pub/Sub service account has permission to create tokens.

  If the permission is missing, prompts the user to grant it. If the console
  cannot prompt, prints a warning instead.
  z0service-{}@gcp-sa-pubsub.iam.gserviceaccount.comz$roles/iam.serviceAccountTokenCreatorzroles/pubsub.serviceAgentzPub/Sub needs this role to create identity tokens. For more details, please see https://cloud.google.com/pubsub/docs/push#authentication)	alt_rolesreasonN)formatprojects_utilGetProjectNumberapi_util
GetProjectPromptToBindRoleIfMissing)	pubsub_sas    :lib/googlecloudsdk/command_lib/functions/v2/deploy_util.py'ensure_pubsub_sa_has_token_creator_roler      sN     AGG$$X%8%8%:;) $$,,-E	    c                     | D cg c]  }|j                   dk(  s| }}|r#t        j                  |d   j                         yyc c}w )a  Ensures appropriate Data Access Audit Logs are enabled for the given event filters.

  If they're not, the user will be prompted to enable them or warned if the
  console cannot prompt.

  Args:
    trigger_event_filters: the CAL trigger's event filters.
  serviceNamer   N)	attributer   !PromptToEnableDataAccessAuditLogsvalue)trigger_event_filtersfservice_filters      r   #ensure_data_access_logs_are_enabledr   1   sT     '&A!++*Fa&   ..~a/@/F/FG s
   AAN)__doc__
__future__r   r   r   r   #googlecloudsdk.api_lib.functions.v2r   r   #googlecloudsdk.command_lib.projectsr   r   r    r   r   <module>r#      s*    L '  % ' @ E,Hr   