
                            d Z ddlmZ ddlmZ ddlmZ ddl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
Z ej"                  ej$                  j&                  ej$                  j(                  ej$                  j*                        ej,                   G d dej.                                      Z G d dej2                        Zy)z<The command to update the RbacRoleBinding Actuation Feature.    )absolute_import)division)unicode_literalsN)
exceptions)arg_parsers)base)	arg_utilsrbacrolebindingactuationc                   <     e Zd ZdZdZed        Zd Z fdZ xZ	S )Updatea  Update RbacRoleBinding Actuation Feature.

  This command updates RbacRoleBinding Actuation Feature in a fleet.

  ## EXAMPLES

  To update the RbacRoleBinding Actuation Feature, run:

    $ gcloud container fleet rbacrolebinding-actuation update \
        --allowed-custom-roles=role1,role2

    $ gcloud container fleet rbacrolebinding-actuation update \
        --add-allowed-custom-role=role1

    $ gcloud container fleet rbacrolebinding-actuation update \
        --remove-allowed-custom-role=role2
  r
   c                     |j                  d      }|j                  dt        j                         dt	        j
                  d             |j                  dt        d	       |j                  d
t        d	       y )NT)requiredz--allowed-custom-rolesROLESzk          The list of allowed custom roles that can be used in scope
          RBACRoleBindings.
          )typemetavarhelpz--add-allowed-custom-rolez:Add a single custom role to the allowed custom roles list.)r   r   z--remove-allowed-custom-rolez?Remove a single custom role from the allowed custom roles list.)add_mutually_exclusive_groupadd_argumentr   ArgListtextwrapdedentstr)clsparsergroups      >lib/surface/container/fleet/rbacrolebindingactuation/update.pyArgszUpdate.Args9   s    ///>E	   "__  	   
#I  
 
&N      c                     t        j                  |dd      }t        |      }|j                  |      }| j	                  ||       y )Nz	--projectT)use_defaults)r	   GetFromNamespace_EnableCommandGetWithForceEnabler   )selfargsproject
enable_cmdfeatures        r   Runz
Update.RunP   s>    (({NG%J++G4GKKr   c                 .   | j                         }|j                  j                  j                  }|j                  |j                  }n`|j
                  |j                  |j
                         |}n6|j                  |D cg c]  }||j                  k7  r| }}nt        d      | j                  j                  | j                  j                  | j                  j                  |                  }d}t        t        | ;  |g|      S c c}w )zBUpdates RbacRoleBinding Actuation Feature information for a fleet.zlOne of --allowed-custom-roles, --add-allowed-custom-role, or --remove-allowed-custom-role must be specified.)allowedCustomRoles)r
   )specz2spec.rbacrolebindingactuation.allowed_custom_roles)
GetFeaturer,   r
   r+   allowed_custom_rolesadd_allowed_custom_roleappendremove_allowed_custom_role
ValueErrormessagesFeatureCommonFeatureSpec#RBACRoleBindingActuationFeatureSpecsuperr   )
r$   r(   r%   rrb_featurecurrent_custom_rolesupdated_custom_rolesrolepatchpath	__class__s
            r   r   zUpdate.UpdateV   s)   //#K11DD    ,!66		%	%	1!!$">">?1		(	(	4 +*dT444 *   = 
 MM!!]],,%)]]%V%V#7 &W & - 
 " E @D%tfe44's   D)
__name__
__module____qualname____doc__feature_nameclassmethodr   r)   r   __classcell__)r>   s   @r   r   r       s0    
$ ,, ,5 5r   r   c                   "    e Zd ZdZd Zd Zd Zy)r"   z>Base class for enabling the RBACRoleBinding Actuation Feature.c                 (    t         | _        || _        y )N)!RBACROLEBINDING_ACTUATION_FEATURErC   r%   )r$   r%   s     r   __init__z_EnableCommand.__init__{   s    9DDIr   c                 J    | j                   j                  j                         S )z:Required to initialize HubClient. See calliope base class.)r%   calliope_commandReleaseTrack)r$   s    r   rL   z_EnableCommand.ReleaseTrack   s    99%%2244r   c                     	 | j                   j                  | j                  |            S # t        j                  $ r< | j                  | j                  j                                | j                         cY S w xY w)zBGets the project's Cluster Upgrade Feature, enabling if necessary.)r&   )	hubclientr-   FeatureResourceNameapitools_exceptionsHttpNotFoundErrorEnabler3   r4   )r$   r&   s     r   r#   z!_EnableCommand.GetWithForceEnable   sn    
^^&&

"
"7
"
3  00  kk$--'')*__s   *- AA<;A<N)r?   r@   rA   rB   rI   rL   r#    r   r   r"   r"   x   s    F5r   r"   )rB   
__future__r   r   r   r   apitools.base.pyr   rP   googlecloudsdk.callioper   r   3googlecloudsdk.command_lib.container.fleet.featuresfeature_base$googlecloudsdk.command_lib.util.apisr	   rH   ReleaseTracksrL   ALPHABETAGADefaultUniverseOnlyUpdateCommandr   EnableCommandMixinr"   rS   r   r   <module>ra      s    C &  '  > / ( T :$> ! T..33T5F5F5I5I Q5\'' Q5 Q5h\44 r   