
                         B   S 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  \	R                  \	R                   " \	R"                  R$                  \	R"                  R&                  5       " S
 S\	R(                  5      5       5       rSS jrg)z?Command to export Security Command Center findings to bigquery.    )absolute_import)division)print_function)unicode_literals)securitycenter_client)base)flags)utilc                   :    \ rS rSrSrSSSS.r\S 5       rS rSr	g	)
Export   z4Export Security Command Center findings to bigquery.a  
      To export findings for a given parent ``organizations/123/sources/456/locations/global`` and dataset ``projects/project_id/datasets/dataset_id`` run:

        $ {command} organizations/123 --dataset=projects/project_id/datasets/dataset_id --source=456 --location=global

      z
      This command uses the Security Command Center API. For more information,
      see [Security Command Center API.](https://cloud.google.com/security-command-center/docs/reference/rest))DESCRIPTIONEXAMPLESzAPI REFERENCEc                     [         R                  " 5       S   R                  U 5        [        R                  R                  U 5        [         R
                  R                  U 5        U R                  SSSS9  g )Nr   z	--datasetz'BigQuery dataset to export findings to.T)helprequired)	scc_flagsAppendParentArgAddToParserr	   SOURCE_FLAGLOCATION_FLAGadd_argument)parsers    .lib/surface/scc/findings/export_to_bigquery.pyArgsExport.Args1   sd     "..v6	!!&)''/
6      c                    Sn[         R                  " U5      n[         R                  " U5      nUR                  c  [	        S5      eUR                  5       n[        R                  " UR                  5      nUR                  UR                  US9S9Ul        [        X5      Ul        UR                  R                  U5      $ )Nv2zParent must be specified.)dataset)bigQueryDestination)r   GetMessages	GetClientparent
ValueError@SecuritycenterOrganizationsSourcesLocationsFindingsExportRequestr
   ValidateDatasetr    ExportFindingsRequestBigQueryDestinationexportFindingsRequest_GenerateParentResource(organizations_sources_locations_findingsr   )selfargsversionmessagesclientrequestvalidated_datasets          r   Run
Export.Run>   s    G$009H",,W5F{{233 	QQS  ,,T\\:$,$B$B$88% 9 
 %C %G!
 -T;GN::AA'JJr    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   r4   __static_attributes__r6   r   r   r   r      s9     = L
r- 
 
Kr   r   c                     [         R                  " U 5        U R                  (       a!  SU R                  ;   a  U R                  U l        [         R                  " X5      nU$ )zEGenerate a parent's name and parent using org, source and finding id.z	/sources/)r
   ValidateMutexOnSourceAndParentr$   sourceGetFullSourceName)r.   r/   r$   s      r   r+   r+   T   sB    %%d+	[[[DKK/++DK!!$0&	-r   N)r   )r;   
__future__r   r   r   r   googlecloudsdk.api_lib.sccr   googlecloudsdk.callioper   googlecloudsdk.command_lib.sccr	   r   'googlecloudsdk.command_lib.scc.findingsr
   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHAGACommandr   r+   r6   r   r   <module>rN      s    F &  % ' < ( = 9 8 D%%++T->->-A-AB2KT\\ 2K C 2Kjr   