
    l                         S r SSK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 r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSrS rg)z/A library that is used to support our commands.    N)apis)waiter)
exceptions)
properties)	resourcesc                  0    [         R                  " SS5      $ )z1Shortcut to get the latest Bigtable Admin client.bigtableadminv2)r   GetClientInstance     +lib/googlecloudsdk/api_lib/bigtable/util.pyGetAdminClientr          				66r   c                  0    [         R                  " SS5      $ )z3Shortcut to get the latest Bigtable Admin messages.r	   r
   )r   GetMessagesModuler   r   r   GetAdminMessagesr   !   r   r   c                      SR                  S[        R                  R                  R                  R                  5       /5      $ )N/projects)joinr   VALUEScoreprojectGetr   r   r   
ProjectUrlr   &   s1    	:z0055==AACD	EEr   c                 :    SR                  [        5       SU /5      $ )Nr   	locations)r   r   )locations    r   LocationUrlr    *   s    	:<h7	88r   c                     [        5       n[        R                  " XR                  5      n[        R                  " XAU5      $ )N)r   r   CloudOperationPoller
operationsWaitFor)result_serviceoperation_refmessageclientpollers        r   _Awaitr*   .   s1    &&&~7H7HI&	w	77r   c                 B    [        5       n[        UR                  X5      $ )z5Waits for cluster long running operation to complete.r   r*   projects_instances_clustersr&   r'   r(   s      r   AwaitClusterr/   4       &	22M	KKr   c                 B    [        5       n[        UR                  X5      $ )z6Waits for instance long running operation to complete.)r   r*   projects_instancesr.   s      r   AwaitInstancer3   :   s    &	))=	BBr   c                 B    [        5       n[        UR                  X5      $ )z9Waits for app profile long running operation to complete.)r   r*   projects_instances_appProfilesr.   s      r   AwaitAppProfiler6   @   s    &	55}	NNr   c                 B    [        5       n[        UR                  X5      $ )z3Waits for table long running operation to complete.)r   r*   projects_instances_tablesr.   s      r   
AwaitTabler9   F   s    &	00-	IIr   c                 B    [        5       n[        UR                  X5      $ )z4Waits for backup long running operation to complete.)r   r*   #projects_instances_clusters_backupsr.   s      r   AwaitBackupr<   L   s"    &	00-
 r   c                 B    [        5       n[        UR                  X5      $ )z:Waits for logical view long running operation to complete.)r   r*   projects_instances_logicalViewsr.   s      r   AwaitLogicalViewr?   T   s    &	66	OOr   c                 B    [        5       n[        UR                  X5      $ )z?Waits for materialized view long running operation to complete.)r   r*   $projects_instances_materializedViewsr.   s      r   AwaitMaterializedViewrB   Z   s"    &	11=
 r   c                 B    [        5       n[        UR                  X5      $ )z:Waits for memory layer long running operation to complete.r,   r.   s      r   AwaitMemoryLayerrD   b   r0   r   c                     [         R                  R                  U[        R                  R
                  R                  R                  U S.SS9$ )z+Get a resource reference to an app profile.
projectsIdinstancesIdz,bigtableadmin.projects.instances.appProfilesparams
collectionr   REGISTRYParser   r   r   r   	GetOrFail)instanceapp_profiles     r   GetAppProfileRefrR   h   sL    				!	!"))..66@@! @ 
" 
 r   c                     [         R                  R                  U[        R                  R
                  R                  R                  U S.SS9$ )z&Get a resource reference to a cluster.rF   z)bigtableadmin.projects.instances.clustersrI   rL   )rP   clusters     r   GetClusterRefrU   t   sK    				!	!"))..66@@! = 
" 
 r   c                     [         R                  R                  U[        R                  R
                  R                  R                  U S.SS9$ )z+Get a resource reference to a logical view.rF   z-bigtableadmin.projects.instances.logicalViewsrI   rL   )rP   logical_views     r   GetLogicalViewRefrX      sL    				!	!"))..66@@! A 
" 
 r   c                 V    [         R                  R                  U R                  S5      $ )z5Get a resource reference to a long running operation.zbigtableadmin.operations)r   rM   ParseRelativeNamename)	operations    r   GetOperationRefr]      s%    				-	-nn0
 r   c                     [         R                  R                  U S[        R                  R
                  R                  R                  0SS9$ )z(Get a resource reference to an instance.rG   z bigtableadmin.projects.instancesrI   rL   )rP   s    r   GetInstanceRefr_      sJ    				!	!

))..66@@ 4 
" 
 r   c                     [         R                  R                  U[        R                  R
                  R                  R                  U S.SS9$ )z$Get a resource reference to a table.rF   z'bigtableadmin.projects.instances.tablesrI   rL   )rP   tables     r   GetTableRefrb      sK    				!	!"))..66@@! ; 
" 
 r   "CLOUD_BIGTABLE_APP_PROFILE_WARNINGc                    [         R                  " U R                  5      nUR                  S5      b!  UR                  S5      R                  S5      c  U eS/nS/nUS   S    H  nUR                  S/ 5      nU Hn  nUR                  S5      R	                  [
        5      (       a"  UR                  UR                  S5      5        MN  UR                  UR                  S5      5        Mp     M     Sn[        U5      S	:  a  US
R                  U5      -  n[        U5      S	:  a  US
R                  U5      -  nU(       d  U e[        R                  " U SR                  US   S   U5      5      e)a  Format app profile error message from API and raise new exception.

The error messages returned from the backend API are not formatted well when
using the default format. This raises a new generic exception with a well
formatted error message built from the original response.

Args:
  exception: HttpError raised by API.

Raises:
  exceptions.HttpException: Reformatted error raised by API.
errordetailszErrors:z!Warnings (use --force to ignore):
violationstypedescription    z
	z{}
{}r'   )jsonloadscontentget
startswithWARNING_TYPE_PREFIXappendlenr   r   HttpExceptionformat)	exceptionresponseerrorswarningsdetailrg   	violation	error_msgs           r   FormatErrorMessagesr}      sA    ZZ	))*(ll7#	g		"	"9	-	5
O;&12(!),fL"-J		v		)	)*=	>	>	m45immM23	   - )]QX&&I[1_V$$I	
O  '!29!=yI	 r   )__doc__rl   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper   googlecloudsdk.corer   r   r   r   r   r    r*   r/   r3   r6   r9   r<   r?   rB   rD   rR   rU   rX   r]   r_   rb   rq   r}   r   r   r   <module>r      s     6  , . . * )7
7
F98LCOJPL				 ; 'r   