
                             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                   G d
 de	j                               Zy)z$Command to update fleet information.    )absolute_import)division)unicode_literals)client)util)base)	resources)labels_utilc                   &    e Zd ZdZed        Zd Zy)Updatea  Update a fleet scope RBAC RoleBinding.

  This command can fail for the following reasons:
  * The RoleBinding does not exist in the project.
  * The caller does not have permission to access the RoleBinding.

  ## EXAMPLES

  To update the RBAC RoleBinding `RBRB` in scope `SCOPE` in the active
  project to the `viewer` role:

    $ {command} RBRB --scope=SCOPE --role=viewer

  To update the RBAC RoleBinding `RBRB` in scope `SCOPE` in the active
  project to the custom role `custom-role`:

    $ {command} RBRB --scope=SCOPE --custom-role=custom-role

  To update the RBAC RoleBinding `RBRB` in scope `SCOPE` in the active
  project to the user `someone@google.com`:

    $ {command} RBRB --scope=SCOPE --user=someone@google.com
  c                    t        j                  |t        j                  | j	                            d       |j                         }|j                  dt        d       |j                  dt        d       |j                         }|j                  dg d	d
       |j                  dt        d       t        j                  |       y )NzqName of the RBAC RoleBinding to be updated. Must comply with RFC 1123 (up to 63 characters, alphanumeric and '-'))api_versionrbacrb_helpz--userz*User for the RBACRoleBinding to update to.)typehelpz--groupz+Group for the RBACRoleBinding to update to.z--role)admineditviewz;Predefined role to assign to principal (admin, edit, view).)choicesr   z--custom-rolez#Custom role to assign to principal.)
r	   AddScopeRBACResourceArgr   VERSION_MAPReleaseTrackadd_mutually_exclusive_groupadd_argumentstrr
   AddUpdateLabelsFlags)clsparsergrouproledefs       =lib/surface/container/fleet/scopes/rbacrolebindings/update.pyArgszUpdate.Args6   s    %%$$S%5%5%78$	 //1E	9  
 
:  
 113G)J  
 2  
 $$V,    c                    t        j                  | j                               }g }|j                  t	        j
                  |            }dD ]A  }|j                  |      s|dk(  s|dk(  r|j                  d       1|j                  |       C t        j                  j                  |      }|j                  |j                  j                  j                  |j                        j!                         }|r|j                  d       |sy |j"                  }|j%                  t	        j
                  |      |j&                  |j(                  |j*                  ||dj-                  |            S )N)release_track)rolecustom_roleuserr   r&   r'   labels,)r(   r   r&   r'   r)   mask)r   FleetClientr   GetScopeRBACRoleBindingr	   RBACResourceNameIsKnownAndSpecifiedappendr
   DiffFromUpdateArgsApplymessagesRBACRoleBindingLabelsValuer)   	GetOrNoner'   UpdateScopeRBACRoleBindingr(   r   r&   join)	selfargsfleetclientr+   current_rbac_rolebindingflaglabels_diff
new_labelsr'   s	            r!   Runz
Update.RunY   sA   $$43D3D3FGKD*BB""4(  9		!	!$	'6>T]2
++f

++d
 9 ""11$7K"",,88 '' ik  
kk( ""K11""4(YYjjYYXXd^ 2  r#   N)__name__
__module____qualname____doc__classmethodr"   rA    r#   r!   r   r      s!    0  -  -D%r#   r   N)rE   
__future__r   r   r   &googlecloudsdk.api_lib.container.fleetr   r   googlecloudsdk.callioper   *googlecloudsdk.command_lib.container.fleetr	   $googlecloudsdk.command_lib.util.argsr
   DefaultUniverseOnlyUpdateCommandr   rG   r#   r!   <module>rO      sL    + &  ' 9 7 ( @ < aT a ar#   