
                             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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+Base command class for Hub gcloud commands.    )absolute_import)division)unicode_literals)encoding)client)util)waiter)log)
propertiesc                       \ rS rSrSr\S 5       r\S 5       r\S 5       r\S 5       r	\
SS j5       r\
SS j5       r\
   SS
 j5       r\
SS j5       r\
   SS j5       r\
SS j5       r\
SS j5       rSS jrSrg	)
HubCommand   z:HubCommand is a mixin adding common utils to Hub commands.c                     [        U S5      (       d)  [        R                  " U R                  5       5      U l        U R                  $ ),The HubClient for the current release track._client)hasattrr   	HubClientReleaseTrackr   selfs    6lib/googlecloudsdk/command_lib/container/fleet/base.py	hubclientHubCommand.hubclient!   s6     4##%%d&7&7&9:dl<<    c                     [        U S5      (       d)  [        R                  " U R                  5       5      U l        U R                  $ )r   
_client_v2)r   r   HubV2Clientr   r   r   s    r   hubclient_v2HubCommand.hubclient_v2)   s6     4&&**4+<+<+>?do??r   c                 .    U R                   R                  $ )z,Convenience property for hubclient.messages.)r   messagesr   s    r   r!   HubCommand.messages1   s     >>"""r   c                 .    U R                   R                  $ )z/Convenience property for hubclient_v2.messages.)r   r!   r   s    r   messages_v2HubCommand.messages_v26   s     %%%r   c                     [         R                  R                  R                  R	                  5       nU (       a  [
        R                  " U5      $ U$ )zSimple helper for getting the current project.

Args:
  number: Boolean, whether to return the project number instead of the ID.

Returns:
  The project ID or project number, as a string.
)r   VALUEScoreproject	GetOrFailproject_utilGetProjectNumber)numberr)   s     r   ProjectHubCommand.Project;   s=     $$,,668G**733Nr   c                 R    [         R                  " [        R                  U5      U S9$ )Nlocation)r   LocationResourceNamer   r.   )r2   
use_numbers     r   r3   HubCommand.LocationResourceNameJ   s%    $$:&; ;r   Nc                 h    U=(       d    [         R                  U5      n[        R                  " XUS9$ )z[Builds the full resource name, using the core project property if no project is specified..r1   )r   r.   r   FeatureResourceName)namer)   r2   r4   s       r   r7   HubCommand.FeatureResourceNameO   s,     7++J7G##GHEEr   c                 R    [         R                  " [        R                  U5      XS9$ )z?Builds a full Membership name, using the core project property.r1   )r   MembershipResourceNamer   r.   r8   r2   r4   s      r   r;   !HubCommand.MembershipResourceNameX   s)     &&:&A Ar   c                 l    U=(       d    [         R                  U5      n[        R                  " UU UUS9$ )zdBuilds the full MembershipFeature name, using the core project property if no project is specified..r1   )r   r.   r   MembershipFeatureResourceName)membership_namefeature_namer)   r2   r4   s        r   r?   (HubCommand.MembershipFeatureResourceName^   s8     7++J7G--	 r   c                 R    [         R                  " [        R                  U5      XS9$ )z>Builds a full Workspace name, using the core project property.r1   )r   WorkspaceResourceNamer   r.   r<   s      r   rD    HubCommand.WorkspaceResourceNameo   s)     %%:&A Ar   c                 R    [         R                  " [        R                  U5      XS9$ )z:Builds a full Scope name, using the core project property.r1   )r   ScopeResourceNamer   r.   r<   s      r   rG   HubCommand.ScopeResourceNameu   s)     !!:&A Ar   c                    U R                   R                  U5      n[        R                  " X4SU0UD6nU(       aP  UR	                  U5      n[
        R                  " UR                  5      n	SU	;   a  [        R                  " U	S   5        U$ )zBHelper wrapping waiter.WaitFor() with additional warning handling.messagestatusDetail)
r   OperationRefr	   WaitForPollr   MessageToPyValuemetadatar
   warning)
r   polleroprJ   warningskwargsop_refresultfinal_opmetadata_dicts
             r   WaitForHubOpHubCommand.WaitForHubOp{   ss    ^^((,F^^FFGFvFFV$h//0A0ABm	=	(M.12Mr   )r   r   )F)globalF)Nr\   F)NT)__name__
__module____qualname____firstlineno____doc__propertyr   r   r!   r$   staticmethodr.   r3   r7   r;   r?   rD   rG   rZ   __static_attributes__ r   r   r   r      s    B    # # & &   ; ; "&#+%*F F A A
     A A
 A A
	r   r   N)ra   
__future__r   r   r   apitools.base.pyr   &googlecloudsdk.api_lib.container.fleetr   r   googlecloudsdk.api_lib.utilr	   #googlecloudsdk.command_lib.projectsr+   googlecloudsdk.corer
   r   objectr   re   r   r   <module>rm      s6    2 &  ' % 9 7 . D # *f fr   