
                         b   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ZdZej                  j                  eiZd	Zej                  j$                  fd
efdZefd
ej                  fdZej                  j$                  fdZej                  j$                  fdZdedefdZd Zy)z3Utility functions for the Hypercompute Cluster API.    )
exceptions)apis)waiter)base)	resourceshypercomputeclusterv1alphaz1hypercomputecluster.projects.locations.operationsreturnc                 T    | t         vrt        j                  d|        t         |    S )4Returns the API version for the given release track.zUnsupported release track: )TRACK_TO_API_VERSIONcalliope_exceptionsToolException)release_tracks    7lib/googlecloudsdk/api_lib/hypercomputecluster/utils.pyGetApiVersionr   "   s5    ..

+
+
%m_5  
m	,,    c                     | t         j                         vrt        j                  d|        t         j	                         D cg c]  \  }}|| k(  s| c}}d   S c c}}w )r   zUnsupported API version: r   )r   valuesr   r   items)api_versionkeyvalues      r   GetReleaseTrackr   +   sq    ,3355

+
+
#K=1  1668
8jc5E[<Pc8

  
s   AAc                 L    t        |       }t        j                  t        |      S )z8Returns the client instance for the given release track.)r   r   GetClientInstanceAPI_NAMEr   r   s     r   r   r   6       m,+			+	66r   c                 L    t        |       }t        j                  t        |      S )z8Returns the messages module for the given release track.)r   r   GetMessagesModuler   r   s     r   r!   r!   <   r   r   messagemax_wait_secc                     t         j                  j                  |j                  t              }t        j                  t        j                  | j                  | j                        |||dz        S )z*Waits for the given operation to complete.)
collectioni  )polleroperation_refr"   max_wait_ms)	r   REGISTRYParseRelativeNamenameOPERATIONS_COLLECTIONr   WaitForCloudOperationPollerprojects_locations_operations)client	operationr"   r#   r'   s        r   WaitForOperationr2   B   sj    $$66nn& 7 -
 
((

.
.

.
. "%
 r   c                    |j                   j                  j                         }	 | j                  j	                  |j                  |j                                     S # t        j                  $ r}t        j                  |      d}~ww xY w)zGReturns the cluster message for the cluster name derived from the args.)r+   N)CONCEPTSclusterParseprojects_locations_clustersGet6HypercomputeclusterProjectsLocationsClustersGetRequestRelativeNameapitools_exceptions	HttpErrorr   HttpException)r0   argsmessagescluster_referrors        r   
GetClusterrB   T   s    %%++-+3--11GG))+ 	H 	
 
 
	&	& 3

+
+E
223s   8A B2BBN)__doc__apitools.base.pyr   r;   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper   r   googlecloudsdk.corer   r   ALPHA_API_VERSIONReleaseTrackALPHAr   r,   GAstrr   r   r   r!   intr2   rB    r   r   <module>rO      s     : > , . ( E ) ! ))//1BC K  !% 1 1 4 4 - - !2 d6G6G  %)$5$5$8$8 7 %)$5$5$8$8 7 C $
3r   