
    >                     r    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	\5      rg
)z+Base command class for Hub gcloud commands.    )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.messages.   s     >>"""r   c                 .    U R                   R                  $ )z/Convenience property for hubclient_v2.messages.)r   r   r   s    r   messages_v2HubCommand.messages_v23   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.Project8   s=     $$,,668G**733Nr   c                 R    [         R                  " [        R                  U5      U S9$ )Nlocation)r   LocationResourceNamer
   r+   )r/   
use_numbers     r   r0   HubCommand.LocationResourceNameG   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..r.   )r
   r+   r   FeatureResourceName)namer&   r/   r1   s       r   r4   HubCommand.FeatureResourceNameL   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.r.   )r   MembershipResourceNamer
   r+   r5   r/   r1   s      r   r8   !HubCommand.MembershipResourceNameU   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..r.   )r
   r+   r   MembershipFeatureResourceName)membership_namefeature_namer&   r/   r1   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.r.   )r   WorkspaceResourceNamer
   r+   r9   s      r   rA    HubCommand.WorkspaceResourceNamel   s)     %%:&A Ar   c                 R    [         R                  " [        R                  U5      XS9$ )z:Builds a full Scope name, using the core project property.r.   )r   ScopeResourceNamer
   r+   r9   s      r   rD   HubCommand.ScopeResourceNamer   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oprG   warningskwargsop_refresultfinal_opmetadata_dicts
             r   WaitForHubOpHubCommand.WaitForHubOpx   ss    ^^((,F^^FFGFvFFV$h//0A0ABm	=	(M.12Mr   )r   r   )F)globalF)NrY   F)NT)__name__
__module____qualname____firstlineno____doc__propertyr   r   r   r!   staticmethodr+   r0   r4   r8   r<   rA   rD   rW   __static_attributes__ r   r   r
   r
      s    B    # # & &   ; ; "&#+%*F F A A
     A A
 A A
	r   r
   N)r^   apitools.base.pyr   &googlecloudsdk.api_lib.container.fleetr   r   googlecloudsdk.api_lib.utilr   #googlecloudsdk.command_lib.projectsr(   googlecloudsdk.corer   r   objectr
   rb   r   r   <module>ri      s/    2 & 9 7 . D # *f fr   