
                            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dlmZ ddlmZ dd	lmZ dd
lmZ dddZ e	j&                  e	j(                  j*                         G d dej,                               Z e	j&                  e	j(                  j0                         G d de             Z e	j&                  e	j(                  j4                         G d de             Zy)zDAdd an invoker binding to the IAM policy of a Google Cloud Function.    )absolute_import)division)unicode_literals)util)base)parser_extensions)flags)command)iam_utila        Adds an invoker role IAM policy binding that allows the specified member
      to invoke the specified function.

      For Cloud Functions (1st gen), this adds the Cloud Functions Invoker
      binding to the IAM policy of the specified function.

      For Cloud Functions (2nd gen), this adds the Cloud Run Invoker binding to
      the IAM policy of the specified function's underlying Cloud Run service.
      z          To add the invoker role policy binding for `FUNCTION-1` for member
          `MEMBER-1` run:

            $ {command} FUNCTION-1 --member=MEMBER-1
          )DESCRIPTIONEXAMPLESc                   J    e Zd ZdZeZed        Zdej                  fdZ
d Zy)AddInvokerPolicyBindingAdds an invoker binding to the IAM policy of a Google Cloud Function.

  This command applies to Cloud Functions 2nd gen only.
  c                     t        j                  | d       t        j                  | dd       t        j                  | dd       y)z!Registers flags for this command.zto add the invoker binding toT)hiddenzto add to the IAM policyFN)r	   AddFunctionResourceArgAddGen2Flagr   AddMemberFlag)parsers    3lib/surface/functions/add_invoker_policy_binding.pyArgszAddInvokerPolicyBinding.Args;   s;     
  )HI	f=dK6#=uE    argsc                     t        j                  |j                  j                  j	                         j                         |j                  d      S )Nzroles/cloudfunctions.invoker)memberrole)api_util_v1AddFunctionIamPolicyBindingCONCEPTSnameParseRelativeNamer   selfr   s     r   _RunV1zAddInvokerPolicyBinding._RunV1B   s>    22  "//1{{+ r   c                 J    t        j                  || j                               S )N)
command_v2RunReleaseTrackr$   s     r   _RunV2zAddInvokerPolicyBinding._RunV2I   s    >>$ 1 1 344r   N)__name__
__module____qualname____doc___DETAILED_HELPdetailed_helpstaticmethodr   r   	Namespacer&   r+    r   r   r   r   2   s:    
 !-F F*44 5r   r   c                       e Zd ZdZy)AddInvokerPolicyBindingBetar   Nr,   r-   r.   r/   r4   r   r   r6   r6   M       r   r6   c                       e Zd ZdZy)AddInvokerPolicyBindingAlphazAdd an invoker binding to the IAM policy of a Google Cloud Function.

  This command applies to Cloud Functions 2nd Gen only.
  Nr7   r4   r   r   r:   r:   U   r8   r   r:   N)r/   
__future__r   r   r   #googlecloudsdk.api_lib.functions.v1r   r   googlecloudsdk.callioper   r   $googlecloudsdk.command_lib.functionsr	   Bgooglecloudsdk.command_lib.functions.v2.add_invoker_policy_bindingr
   r(   googlecloudsdk.command_lib.iamr   r0   ReleaseTracksr*   GAFunctionResourceCommandr   BETAr6   ALPHAr:   r4   r   r   <module>rF      s    K &  ' C ( 5 6 5 d 3	
( D%%(()5d:: 5 *54 D%%**+"9  , D%%++,#>  -r   