
    s9                        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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  \R2                  r\R2                  R4                  r\R2                  R6                  r\R2                  R8                  r\R2                  R:                  r " S S\R<                  5      rg)z The show command for the BQ CLI.    )Optional)app)flagsN)client_connection)client_data_transfer)client_dataset)client_deprecated)client_reservation)client_row_access_policy)utils)bigquery_command)bq_cached_client)utils_flags)utils_id)bq_error)bq_id_utilsc                   p   ^  \ rS rSrSrSrS\S\R                  SS4U 4S jjr	SS	\S\
\   4S
 jjrSrU =r$ )Show!   z5The BQ CLI command to display a resource to the user.zshow [<identifier>]namefvreturnNc                 ,  > [         [        U ]  X5        [        R                  " SSSSUS9  [        R                  " SSSSUS9  [        R                  " S	SS
US9  [        R                  " SSSUS9  [        R                  " SSSUS9  [        R                  " SSSUS9  [        R                  " SSSUS9  [        R                  " SSSUS9  [        R                  " SSSUS9  [        R                  " SSSSUS9  [        R                  " SSSUS9  [        R                  " SS SUS9  [        R                  " SS S US9  [        R                  " S!S S"US9  [        R                  " S#S S$US9  [        R
                  " S%S / S&QS'US9  [        R
                  " S(S / S)QS*US9  [        R                  " S+S S,US9  [        R                  " S-S S.US9  [        R
                  " S/S / S0QS1US9  [        R                  " S2S S3US9  U R                  U5        g )4NjobFz/If true, interpret this identifier as a job id.j)
short_nameflag_valuesdatasetzShow dataset with this name.dviewz<Show view specific details instead of general table details.)r   materialized_viewzIShow materialized view specific details instead of general table details.table_replicazEShow table replica specific details instead of general table details.schemaz6Show only the schema instead of general table details.encryption_service_accountzUShow the service account for a user if it exists, or create one if it does not exist.transfer_configz<Show transfer configuration for configuration resource name.transfer_runz3Show information about the particular transfer run.modelz)Show details of model with this model ID.mroutinez)Show the details of a particular routine.reservationz?Shows details for the reservation described by this identifier.capacity_commitmentzGShows details for the capacity commitment described by this identifier.reservation_assignmenta  Looks up reservation assignments for a specified project/folder/organization. Explicit reservation assignments will be returned if exist. Otherwise implicit reservation assignments from parents will be returned. Used in conjunction with --job_type, --assignee_type and --assignee_id.reservation_groupzEShows details for the reservation group described by this identifier.job_type)	QUERYPIPELINEML_EXTERNAL
BACKGROUNDSPARK
CONTINUOUSBACKGROUND_CHANGE_DATA_CAPTURE BACKGROUND_COLUMN_METADATA_INDEXBACKGROUND_SEARCH_INDEX_REFRESHa  Type of jobs to search reservation assignment for. Options include:
 QUERY
 PIPELINE
 ML_EXTERNAL
 BACKGROUND
 SPARK
 CONTINUOUS
 BACKGROUND_CHANGE_DATA_CAPTURE
 BACKGROUND_COLUMN_METADATA_INDEX
 BACKGROUND_SEARCH_INDEX_REFRESH
 Used in conjunction with --reservation_assignment.assignee_type)PROJECTFOLDERORGANIZATIONzType of assignees for the reservation assignment. Options include:
 PROJECT
 FOLDER
 ORGANIZATION
 Used in conjunction with --reservation_assignment.assignee_idzxProject/folder/organization ID, to which the reservation is assigned. Used in conjunction with --reservation_assignment.
connectionz>Shows details for the connection described by this identifier.dataset_view)METADATAACLFULLzSpecifies the view that determines which dataset information is returned. By default, metadata and ACL information are returned. Options include:
 METADATA
 ACL
 FULL
 If not set, defaults as FULLmigration_workflowz@Show details of migration workflow described by this identifier.)superr   __init__r   DEFINE_booleanDEFINE_enumDEFINE_string_ProcessCommandRc)selfr   r   	__class__s      $platform/bq/frontend/command_show.pyrD   Show.__init__&   s   	$t(	9 
& 
F	 
	 
O	 
@	 
$	  
F	 
=	 
3 
3	 
I	 
	 
 	 
 
O	 

	
D 9< 
-	@
 
 
	= 
H	 
#	*  
J	 	2    
identifierc                 2   [         R                  R                  5       nSnSnSnU R                  (       a0  [        R
                  " UU[        R                  R                  S9nGO@U R                  (       aS  U R                  SSU5        [        R                  " X!S9n[        R                  " UR                  UU R                  S9nGOU R                   (       a  [        R"                  " X!S9nSnGOU R$                  (       a  [        R"                  " X!S9nS	nGOU R&                  (       a  [        R"                  " X!S9nS
nGOaU R(                  (       aL  [        R*                  R                  S;  a  [,        R.                  " S5      e[        R"                  " X!S9nSnGOU R0                  (       aF  [2        R4                  " X!5      n[7        US9n[8        R:                  " UR=                  5       U5      nGOU R>                  (       aF  [2        R4                  " X!5      n[A        US9n[8        RB                  " UR=                  5       U5      nGOVU RD                  (       a  [        RF                  " X!S9nGO/U RH                  (       a  [        RJ                  " X!S9nGOU RL                  (       aS  [        RN                  " UU[        R                  R                  S9n[P        RR                  " URU                  5       US9nGOU RV                  (       a  SnU(       a\  [P        RX                  " URU                  5       [        R                  R                  U RZ                  U R\                  U R^                  S9n[`        Rb                  Re                  SSSSS9nSnGO
U Rf                  (       aS  [        Rh                  " UU[        R                  R                  S9n[P        Rj                  " URU                  5       US9nGOU Rl                  (       a   [n        Rp                  " [        Rr                  Rt                  5        [        Rv                  " UU[        R                  R                  S9n[P        Rx                  " URU                  5       US9nGOU R                  (       ad  UR                  R                  5       R                  [        R                  " US9R                  S9R                  5       nUS   n
SU
0n[        SS9nOU R                  (       aR  [        R                  " UU[        R                  R                  S9n[        R                  " UR                  5       US9nO;U R                  (       a  SnU R                  SSU5        O[        R                  " X!S9nUc  [,        R.                  " S5      e[        U[        5      (       aE  U(       d>  U R                  SSU5        [        R                  " UR                  UU R                  S9n Uc5  [        R                  " UR                  UR                  UR                  US 9n[        R                  " UUUUS!9  g! [z         a#  n	[|        R~                  " SU< SU	< 35      eSn	A	ff = f)"a  Show all information about an object.

Examples:
  bq show -j <job_id>
  bq show dataset
  bq show [--schema] dataset.table
  bq show [--view] dataset.view
  bq show [--materialized_view] dataset.materialized_view
  bq show -m ds.model
  bq show --routine ds.routine
  bq show --transfer_config projects/p/locations/l/transferConfigs/c
  bq show --transfer_run projects/p/locations/l/transferConfigs/c/runs/r
  bq show --encryption_service_account
  bq show --connection --project_id=project --location=us connection
  bq show --capacity_commitment project:US.capacity_commitment_id
  bq show --reservation --location=US --project_id=project reservation_name
  bq show --reservation_assignment --project_id=project --location=US
      --assignee_type=PROJECT --assignee_id=myproject --job_type=QUERY
  bq show --reservation_assignment --project_id=project --location=US
      --assignee_type=FOLDER --assignee_id=123 --job_type=QUERY
  bq show --reservation_assignment --project_id=project --location=US
      --assignee_type=ORGANIZATION --assignee_id=456 --job_type=QUERY
  bq show --reservation_group --location=US --project_id=project
      reservation_group_name
  bq show --migration_workflow projects/p/locations/l/workflows/workflow_id

Arguments:
  identifier: the identifier of the resource to show.
showNT)id_fallbacksrN   default_locationdatasets)rQ   rN   )	apiclient	referencer>   r    r!   r"   )N
prettyjsonjsonz6Table schema output format must be json or prettyjson.r#   )transferConfigName)transferRunName)clientrU   )rZ   locationr.   r8   r<    )	projectIdr[   reservationIdreservationAssignmentIdF)reservation_group_clientrU   z!Failed to get reservation group 'z': )rQ   )r]   emailServiceAccountIDserviceAccount)rc   migration_workflowsz$Must provide an identifier for show.)rT   get_routines_api_clientget_models_api_clientrU   )custom_formatprint_reference)Wr   ClientGetr   bq_client_utilsGetJobReferencebq_flagsLOCATIONvaluer   PossiblyDelegateToGcloudAndExitGetDatasetReferencer   
GetDatasetrT   r>   r    GetTableReferencer!   r"   r#   FORMATr   
UsageErrorr%   frontend_id_utilsFormatDataTransferIdentifiersTransferConfigReferencer   get_transfer_configGetTransferV1ApiClientr&   TransferRunReferenceget_transfer_runr(   GetModelReferencer)   GetRoutineReferencer*   GetReservationReferencer
   GetReservationGetReservationApiClientr,   SearchAllReservationAssignmentsr.   r8   r<   ApiClientHelperReservationAssignmentReferenceCreater+   GetCapacityCommitmentReferenceGetCapacityCommitmentr-   r   fail_if_not_using_alpha_featureAlphaFeaturesRESERVATION_GROUPSGetReservationGroupReferenceGetReservationGroupBaseExceptionr   BigqueryErrorr$   projectsgetServiceAccountGetProjectReferencer]   executeEncryptionServiceAccountr=   GetConnectionReferencer   GetConnectionGetConnectionV1ApiClientrB   DelegateToGcloudAndExitGetReference
isinstanceDatasetReferencer	   get_object_infoGetRoutinesApiClientGetModelsApiClientbq_frontend_utilsPrintObjectInfo)rI   rN   rZ   rg   object_inforh   rU   formatted_identifiersearch_all_projectsera   s              rK   RunWithArgsShow.RunWithArgs   s   > $$((*FMKOvv!11#,,22i
 

**:vzJ!55i #--$$((k
 
!33i m			!33i *m			!33i &m				&B	BnnD
 	
 "33i m			.LL
 *1i )<<

'
'
)+?k 
		.LL
 '7KLi(99

'
'
)+?k 
!33i 
!55i 
		!99#,,22i
 '55//1Yk 
	$	$ 	(HH113&&,,]],,((
 "@@GG"%	 H i o		!	!!@@#,,22i
 '<<//1k 
		
33""55	
 $@@!%..44
	
 )<<%+%C%C%E
 
	(	(



#
#
%';;%	  
 79  '"e'/k*:JKi	!88#,,22i
 &33002ik 
	 	 i
""


 "..i NNABB)-..{
**:vzJ"--$$((k
 %55$$"("="= & 9 9	k %%#'	s  
$$:DaH
 	

s   A?Y) )
Z3ZZ ) )__name__
__module____qualname____firstlineno____doc__usagestrr   
FlagValuesrD   r   intr   __static_attributes____classcell__)rJ   s   @rK   r   r   !   sP    =
#%p3 pE$4$4 p pdYC Y# Y YrM   r   ) r   typingr   abslr   r   rm   clientsr   r   r   r	   r
   r   r   rk   frontendr   r   r   r   r   rv   r   r   r   r   rx   r{   r   BigqueryCmdr   r   rM   rK   <module>r      s    &     % ( " % & , , % % /   2   --..?? %55MM "22GG &66OO P'' PrM   