
    
                     Z    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\	5      r
g	)
z%API helpers for interacting with IAM.    )absolute_import)division)unicode_literals)apis)iam_utilc                   :    \ rS rSrSrS
S jrS rS rS rS r	S	r
g)Client   z"A client for interacting with IAM.Nc                 p    [         R                  " U5      U l        [         R                  " U5      U l        g N)r   GetClientInstanceclientGetMessagesModulemessages)selfapi_versions     4lib/googlecloudsdk/api_lib/container/binauthz/iam.py__init__Client.__init__   s&    ((5DK**;7DM    c                     U R                   R                  R                  U R                  R	                  UR                  5       [        R                  S95      $ )z.Gets the IamPolicy associated with a resource.)resourceoptions_requestedPolicyVersion)r   projects_policyGetIamPolicyr   4BinaryauthorizationProjectsPolicyGetIamPolicyRequestRelativeNamer   !MAX_LIBRARY_IAM_SUPPORTED_VERSION)r   any_refs     r   Get
Client.Get    sL    ;;&&33JJ))++3.. 	K 	01 1r   c           	          [         R                  Ul        U R                  R                  R                  U R                  R                  UR                  5       U R                  R                  US9S95      $ )a  Sets a resource's IamPolicy to the one provided.

If 'policy' has no etag specified, this will BLINDLY OVERWRITE the IAM
policy!

Args:
    any_ref: A resources.Resource naming the resource.
    policy: A protorpc.Message instance of an IamPolicy object.

Returns:
    The IAM Policy.
)policy)r   setIamPolicyRequest)
r   r   versionr   r   SetIamPolicyr   4BinaryauthorizationProjectsPolicySetIamPolicyRequestr   SetIamPolicyRequest)r   r   r#   s      r   Set
Client.Set(   sm     ??FN;;&&33JJ))+ $ A A !B !  	K 	
 r   c                     U R                  U5      n[        R                  " U R                  R                  XBU5        U R                  X5      $ )z@Does an atomic Read-Modify-Write, adding the member to the role.)r    r   AddBindingToIamPolicyr   Bindingr)   r   r   memberroler#   s        r   
AddBindingClient.AddBinding=   s;    XXgF""4==#8#8&$O88G$$r   c                 t    U R                  U5      n[        R                  " XBU5        U R                  X5      $ )zDDoes an atomic Read-Modify-Write, removing the member from the role.)r    r   RemoveBindingFromIamPolicyr)   r.   s        r   RemoveBindingClient.RemoveBindingC   s/    XXgF''=88G$$r   )r   r   r   )__name__
__module____qualname____firstlineno____doc__r   r    r)   r1   r5   __static_attributes__ r   r   r	   r	      s    *81*%%r   r	   N)r;   
__future__r   r   r   )googlecloudsdk.api_lib.container.binauthzr   googlecloudsdk.command_lib.iamr   objectr	   r=   r   r   <module>rB      s%    , &  ' : 3.%V .%r   