
                             S r SSKJr  SSKJr  SSKJ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.    )absolute_import)division)unicode_literalsN)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-   1   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   AwaitClusterr2   7       &	22M	KKr   c                 B    [        5       n[        UR                  X5      $ )z6Waits for instance long running operation to complete.)r   r-   projects_instancesr1   s      r   AwaitInstancer6   =   s    &	))=	BBr   c                 B    [        5       n[        UR                  X5      $ )z9Waits for app profile long running operation to complete.)r   r-   projects_instances_appProfilesr1   s      r   AwaitAppProfiler9   C   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_tablesr1   s      r   
AwaitTabler<   I   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_backupsr1   s      r   AwaitBackupr?   O   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_logicalViewsr1   s      r   AwaitLogicalViewrB   W   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_materializedViewsr1   s      r   AwaitMaterializedViewrE   ]   s"    &	11=
 r   c                 B    [        5       n[        UR                  X5      $ )z:Waits for memory layer long running operation to complete.r/   r1   s      r   AwaitMemoryLayerrG   e   r3   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   GetAppProfileRefrU   k   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.rI   z)bigtableadmin.projects.instances.clustersrL   rO   )rS   clusters     r   GetClusterRefrX   w   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.rI   z-bigtableadmin.projects.instances.logicalViewsrL   rO   )rS   logical_views     r   GetLogicalViewRefr[      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
   rP   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.rJ   z bigtableadmin.projects.instancesrL   rO   )rS   s    r   GetInstanceRefrb      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.rI   z'bigtableadmin.projects.instances.tablesrL   rO   )rS   tables     r   GetTableRefre      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detailrj   	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__
__future__r   r   r   ro   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper   googlecloudsdk.corer	   r
   r   r   r   r#   r-   r2   r6   r9   r<   r?   rB   rE   rG   rU   rX   r[   r`   rb   re   rt   r   r   r   r   <module>r      s     6 &  '  , . . * )7
7
F98LCOJPL				 ; 'r   