
    [                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSK
Jr  SS	KJr  S
rSrSS jrS rS rSS jrS rg)z"Cloud Run utility library for GCF.    )absolute_import)division)unicode_literals)util)global_methods)connection_context)serverless_operations)	resourceszrun.namespaces.serviceszrun.projects.locations.servicesc                    [        X5      n[        UR                  5      n[        R                  " U5       nUR                  [        UR                  5       5      UU[        R                  S9sSSS5        $ ! , (       d  f       g= f)a  Add the IAM binding for the invoker role on the function's Cloud Run service.

Args:
  function: cloudfunctions_v2_messages.Function, a GCF v2 function.
  member: str, The user to bind the Invoker role to.
  add_binding: bool, Whether to add to or remove from the IAM policy.
  is_gen2: bool, Whether the function is a 2nd gen function. If false, the
    function is a 1st gen function undergoing upgrade.

Returns:
  A google.iam.v1.Policy
)add_bindingmemberroleN)	_GetOnePlatformServiceRef _GetRunRegionalConnectionContextlocationsIdr	   ConnectAddOrRemoveIamPolicyBinding_GetK8sServiceRefName ALLOW_UNAUTH_POLICY_BINDING_ROLE)functionr   r   is_gen2service_ref_one_platformrun_connection_context
operationss          4lib/googlecloudsdk/command_lib/functions/run_util.pyAddOrRemoveInvokerBindingr       sv     7xI;** $$%;<
112779:"CC	 2  =<<s   7A88
Bc                     [        U 5      n[        UR                  5      n[        R                  " U5       nUR                  [        UR                  5       5      5      sSSS5        $ ! , (       d  f       g= f)z1Get the Cloud Run service for the given function.N)r   r   r   r	   r   
GetServicer   r   )r   r   r   r   s       r   r   r   <   s`    6x@;** $$%;<
  2779: =<<s   (A))
A7c                 j    [         R                  " U [        R                  [        R                  5      $ N)r   RegionalConnectionContextr   SERVERLESS_API_NAMESERVERLESS_API_VERSION)locations    r   r   r   J   s*    		5	5((++
     c                     U(       a  U R                   R                  OU R                  R                   R                  n[        R                  R                  U[        5      $ r!   )serviceConfigserviceupgradeInfor
   REGISTRYParseRelativeName*_CLOUD_RUN_SERVICE_COLLECTION_ONE_PLATFORM)r   r   service_names      r   r   r   R   sS     
 $$--55 
 
			-	->
 r&   c                     [         R                  R                  SR                  [        R
                  " 5       U 5      [        5      $ )Nznamespaces/{}/services/{})r
   r+   r,   formatapi_util
GetProject!_CLOUD_RUN_SERVICE_COLLECTION_K8S)r.   s    r   r   r   ]   s7    				-	-!(()<)<)>M'
 r&   N)TT)T)__doc__
__future__r   r   r   #googlecloudsdk.api_lib.functions.v2r   r1   googlecloudsdk.api_lib.runr   googlecloudsdk.command_lib.runr   r	   googlecloudsdk.corer
   r3   r-   r   r   r   r   r    r&   r   <module>r;      sI    ) &  ' @ 5 = @ ) %> !-N *8r&   