
                            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 ej                   ej                   ej"                  j$                         G d
 dej&                                      Zy)z2'logging views remove_iam_policy_binding' command.    )absolute_import)division)unicode_literals)util)
exceptions)arg_parsers)base)iam_utilc                   X    e Zd ZdZddiZed        Z ej                  d      d        Z	y)RemoveIamPolicyBindingz(Remove IAM policy binding to a log view.EXAMPLESax            To remove an IAM policy binding for the role 'roles/my-role' for the user 'my-user@gmail.com' on my-view, run:

            $ {command} my-view --member='user:my-user@gmail.com' --role='roles/my-role' --bucket=my-bucket --location=global


          To remove a binding with a condition, run:

            $ {command} my-view --member='user:my-user@gmail.com' --role='roles/my-role' --bucket=my-bucket --location=global --condition=expression=[expression],title=[title],description=[description]

          See https://cloud.google.com/iam/docs/managing-policies for details about IAM policies and member types.
          c                    | j                  dd       t        j                  | d       t        j                  | dd       | j                  ddt	        j
                  dd	      d
       t        j                  | d       y)z Register flags for this command.VIEW_IDz,ID of the view that contains the IAM policy.)helpz!view that contains the IAM policyTz.Location of the bucket that contains the view.z--bucketz.+zmust be non-emptyz(ID of the bucket that contains the view.)requiredtyper   )add_conditionN)add_argumentr   AddParentArgsAddBucketLocationArgr   RegexpValidatorr
    AddArgsForRemoveIamPolicyBinding)parsers    6lib/surface/logging/views/remove_iam_policy_binding.pyArgszRemoveIamPolicyBinding.Args1   s     F   	vBCF ((0CD7	   --fDI    z-Status code: {status_code}. {status_message}.c                    t        j                  t        j                  t        j                  |      d|j                        d|j                        }t        j
                  |      }t        j                  |      }t        j                  ||j                  |j                  |       t        j                  ||      }t        j                  |d       |S )zThis 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 updated policy.
    bucketsviews)policymemberrole	conditionzlogging view)r   CreateResourceNameGetBucketLocationFromArgsbucketr   GetIamPolicyr
   ValidateAndExtractCondition'RemoveBindingFromIamPolicyWithConditionr!   r"   SetIamPolicyLogSetIamPolicy)selfargsviewr    r#   resultss         r   RunzRemoveIamPolicyBinding.RunC   s     ""**40)T[[	
 	D t$F44T:I44{{YY	 f-GT>2Nr   N)
__name__
__module____qualname____doc__detailed_helpstaticmethodr   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionr0    r   r   r   r      sS     1  - J J" 5445r   r   N)r4   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.api_lib.utilr   r7   googlecloudsdk.callioper   r	   googlecloudsdk.command_lib.iamr
   UniverseCompatibleReleaseTracksReleaseTrackGACommandr   r9   r   r   <module>rD      sm    9 '  ' / F / ( 3 D%%(()BT\\ B * Br   