
                         |   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Add 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)AddIamPolicyBinding  Add IAM policy binding to an IAP IAM resource.

  Adds a policy binding to 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.
  EXAMPLESa            See $ {parent_command} get-iam-policy for examples of how to specify
          an IAP IAM resource.

          To add 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 add 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 add an IAM policy binding for the role of 'roles/editor' for all
          authenticated users on IAP IAM resource IAP_IAM_RESOURCE,
          run:

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

          To add an IAM policy binding which expires at the end of the year 2018
          for the role of 'roles/browser' and 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'

          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AddAddIamPolicyBindingArgsr   URI_FLAGRemoveFromParser)clsparsers     -lib/surface/iap/web/add_iam_policy_binding.pyArgszAddIamPolicyBinding.ArgsP   s@     ""00 ''/MM""6*    c                     t        j                  |      }t        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   $ValidateAndExtractConditionMutexRoler   ParseIapIamResourceReleaseTrackr   r
   memberrole)selfargs	conditioniap_iam_refs       r   RunzAddIamPolicyBinding.Run_   s[     ==dCI..K
 **4;;		9MMr   N)	__name__
__module____qualname____doc__detailed_helpr   classmethodr   r$    r   r   r
   r
      s9     $'-R + +Nr   r
   c                       e Zd ZdZdZy)AddIamPolicyBindingAlphar   TN)r%   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>r8      s      &  ' ( 3 ; D%%(()RN$,, RN  *RNj D%%++T->->-C-CD	2 	 E	r   