
                         2   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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 ej*                   ej,                  ej.                  j0                         G d dej2                                      Zy)zBQ copy command.    )absolute_import)division)unicode_literals)util)waiter)base)command_utils)hooks)	arg_utils)log)
properties)	resourcesc                   2    e Zd ZdZddddZed        Zd Zy)	CopyzBq Copy Command.z#Copy one BigQuery table to another.zJ            *{command}* Copies one BigQuery table to another.
            a            The following copies table `my-table`  to table `my-other-table`, in dataset `my-dataset`
          overwriting destination if it exists:

            $ {command} --source my-table --destination my-other-table --source-dataset my-dataset --overwrite
            )briefDESCRIPTIONEXAMPLESc                 4   t         j                  j                  |        t        j                  ddddd      j                  |        t        j                  dddd	      j                  |        t	        j
                         d
   }|j                  |        y )Nz--overwrite
store_trueFz)Overwrite if the resource already exists.)actiondefaultrequiredhelpz--job-id z[A unique job ID to use for the request. If not specified a unique job id will be generated.)r   r   r   r   )r   
ASYNC_FLAGAddToParserArgumentr	   GetTableCopyResourceArgs)parserconcept_parsers     lib/surface/bq/tables/copy.pyArgsz	Copy.Args1   s    OO'MM8:
 ;F+f:MMM	 *k&1";;=a@Nv&    c           	         t        j                  |j                        }t        j                  d      } |       }|j
                  xs4 t        j                  j                  j
                  j                  d      }||_
        t        j                  d ||      }t        j                  d ||      }t        j                  |d|       t        j                  |d|       t        j                          }|j"                  }|j"                  j%                  |      }|j&                  j(                  j+                         }	|j&                  j,                  j+                         }
dj/                  |	j1                         j3                         |	j3                         |
j1                         j3                         |
j3                               }|j4                  s$t7        j8                  |j:                  d|       |S |j<                  }t        j>                  ||      }t@        jB                  j+                  |jD                  jF                  d	|id
      }tI        jJ                  |||      }t6        jL                  jO                  dj/                  |	j1                         j3                         |	j3                         |
j1                         j3                         |
j3                                      |S )NBigqueryJobsInsertRequestT)r   zjob.jobReference.jobIdzjob.jobReference.projectIdzCopying {0}:{1} to {2}:{3}.Job)kinddetails	projectIdzbigquery.jobs)params
collection)polleroperation_refmessagezCopied {0}:{1} to {2}:{3}.)(r
   JobIdProcessorjob_idapi_utilGetApiMessageprojectr   VALUEScoreGetr)   r	   ProcessTableCopyConfigurationProcessTableCopyOverwriter   SetFieldInMessageGetApiClientjobsInsertCONCEPTSsourceParsedestinationformatParentNameasync_r   CreatedResourceidtablesBqJobPollerr   REGISTRYjobReferencejobIdr   WaitForstatusPrint)selfargsr0   requests_typerequestr3   clientjob_servicejob
source_refdestination_refcopy_messageresult_servicer,   job_refresults                   r!   RunzCopy.RunD   sP   !!$++.F**+FGMoGllOj//44<<@@$@OGG99$gNG55dD'JG)A6J)EwO""$F++K
++

W
%C%%++-Jmm//557O077  "JOO$5 %%')=)=)?AL ;;	#&&ulCj]]N&&{NCF  &&s'7'7'='=/:G.D2A ' CG ^^6$02F JJ188  "JOO$5 %%')=)=)?A B Mr#   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr"   r\    r#   r!   r   r       s4     4- ' '$$r#   r   N)r`   
__future__r   r   r   googlecloudsdk.api_lib.bqr   r1   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.command_lib.bqr	   r
   $googlecloudsdk.command_lib.util.apisr   googlecloudsdk.corer   r   r   UniverseCompatibleReleaseTracksReleaseTrackALPHACommandr   rc   r#   r!   <module>rp      sw     &  ' 6 . ( 7 / : # * ) D%%++,F4<< F - Fr#   