
                         |   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  ej                  ej                  j                        ej                   G d d	ej                                       Z ej                  ej                  j$                  ej                  j&                         G d
 de             Zy)zRemove IAM Policy Binding.    )absolute_import)division)unicode_literals)base)iam_util)utilc                   2    e Zd ZdZddiZdZed        Zd Zy)RemoveIamPolicyBinding"  Remove IAM policy binding from an IAP IAM resource.

  Removes a policy binding from the IAM policy of an IAP IAM resource. One
  binding consists of a member, a role and an optional condition.
  See $ {parent_command} get-iam-policy for examples of how to
  specify an IAP IAM resource.
  EXAMPLESav            See $ {parent_command} get-iam-policy for examples of how to specify
          an IAP IAM resource.

          To remove an IAM policy binding for the role of 'roles/editor' for the
          user 'test-user@gmail.com' on IAP IAM resource IAP_IAM_RESOURCE, run:

            $ {command} --resource-type=IAP_IAM_RESOURCE --member='user:test-user@gmail.com'
                --role='roles/editor'

          To remove an IAM policy binding for the role of 'roles/editor' for the
          user 'test-user@gmail.com' on regional IAP IAM resource
          IAP_IAM_RESOURCE, run:

            $ {command} --resource-type=IAP_IAM_RESOURCE --member='user:test-user@gmail.com'
                --role='roles/editor' --region=REGION

          To remove an IAM policy binding for the role of 'roles/editor' from
          all authenticated users on IAP IAM resource IAP_IAM_RESOURCE,run:

            $ {command} --resource-type=IAP_IAM_RESOURCE --member='allAuthenticatedUsers'
                --role='roles/editor'

          To remove an IAM policy binding with a condition of
          expression='request.time < timestamp("2019-01-01T00:00:00Z")',
          title='expires_end_of_2018', and description='Expires at midnight on
          2018-12-31' for the role of 'roles/browser' for the user
          'test-user@gmail.com' on IAP IAM resource IAP_IAM_RESOURCE,
          run:

            $ {command} --resource-type=IAP_IAM_RESOURCE --member='user:test-user@gmail.com'
                --role='roles/browser' --condition='expression=request.time <
                timestamp("2019-01-01T00:00:00Z"),title=expires_end_of_2018,
                description=Expires at midnight on 2018-12-31'

          To remove all IAM policy bindings regardless of the condition for the
          role of 'roles/browser' and for the user 'test-user@gmail.com' on IAP
          IAM resource IAP_IAM_RESOURCE, run:

            $ {command} --resource-type=IAP_IAM_RESOURCE --member='user:test-user@gmail.com'
                --role='roles/browser' --all

          See https://cloud.google.com/iam/docs/managing-policies for details of
          policy role and member types.
  Fc                     t        j                  || j                         t        j                  |       t        j
                  j                  |       y)zRegister flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
          to capture some information, but behaves like an ArgumentParser.
    )support_cloud_runN)iap_utilAddIapIamResourceArgs_support_cloud_runAddRemoveIamPolicyBindingArgsr   URI_FLAGRemoveFromParser)clsparsers     0lib/surface/iap/web/remove_iam_policy_binding.pyArgszRemoveIamPolicyBinding.ArgsX   s@     ""00
 **62MM""6*    c                     t        j                  |      }t        j                  | j	                         || j
                        }|j                  |j                  |j                  ||j                        S )a  This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      The specified function with its description and configured filter.
    )
r   ValidateAndExtractConditionr   ParseIapIamResourceReleaseTrackr   r
   memberroleall)selfargs	conditioniap_iam_refs       r   RunzRemoveIamPolicyBinding.Rung   sf     44T:I..K
 --dkk499i.2hh8 8r   N)	__name__
__module____qualname____doc__detailed_helpr   classmethodr   r%    r   r   r
   r
      s8     ,/-b + +8r   r
   c                       e Zd ZdZdZy)RemoveIamPolicyBindingAlphar   TN)r&   r'   r(   r)   r   r,   r   r   r.   r.   {   s     r   r.   N)r)   
__future__r   r   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   googlecloudsdk.command_lib.iapr   r   ReleaseTracksr   GADefaultUniverseOnlyCommandr
   ALPHABETAr.   r,   r   r   <module>r9      s     ! &  ' ( 3 ; D%%(()[8T\\ [8  *[8| D%%++T->->-C-CD	"8 	 E	r   