
    *                     \   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  SSKJr  SSKJr  SSKJr  \R,                  \R.                  " \R0                  R2                  \R0                  R4                  5       " S S\R6                  5      5       5       rg)z:`gcloud dataplex datascans create data-discovery` command.    )absolute_import)division)unicode_literals)datascan)util)
exceptions)arg_parsers)base)resource_args)labels_util)log)
propertiesc                       \ rS rSrSrSS\R                  R                  R                  R                  5        S30r
\S 5       r\R                  " S5      S 5       rS	rg
)DataDiscovery    zCreate a Dataplex data discovery scan job.

Allows users to auto discover BigQuery External and BigLake tables from
underlying Cloud Storage buckets.
EXAMPLESa/  
          To create a data discovery scan `data-discovery-datascan`
          in project `test-project` located in `us-central1` on Cloud Storage bucket `test-bucket`, run:

            $ {command} data-discovery-datascan --project=test-project --location=us-central1 --data-source-resource="//storage.z7/projects/test-project/buckets/test-bucket"

          c                 v   [         R                  " U S5        U R                  SSSS9  U R                  SSSS9  U R                  SS	S
S9  U R                  SS9nUR                  SS9nUR                  SSSS.SS9  UR                  SSS9  UR                  SSS9  UR                  SSS9  UR                  SS9nUR                  S[        R
                  " 5       SSS9  UR                  S[        R
                  " 5       SS S9  UR                  S!S9nUR                  S"S#S9  UR                  S$S%S9  UR                  S&S'S9  UR                  S([        S)S*9  UR                  S+S,S9  UR                  S-S9nUR                  S.S/S9  UR                  S0[        S1S*9  U R                  S2S9nUR                  S	S3S49nUR                  S5[        S6S*9  UR                  S7S8S9  U R                  S	SS9S:9nUR                  S;S<SS=S>9  [        R                  R                  U5        [        R                  " U 5        g )?Nz$to create a data discovery scan for.z--descriptionFz'Description of the data discovery scan.)requiredhelpz--display-namez(Display name of the data discovery scan.z--data-source-resourceTzFully-qualified service resource name of the cloud resource bucket that contains the data for the data discovery scan, of the form: `//storage.googleapis.com/projects/{project_id_or_number}/buckets/{bucket_id}`.z&Data spec for the data discovery scan.)r   zABigQuery publishing config arguments for the data discovery scan.z --bigquery-publishing-table-typezNDefault value. Cloud Storage bucket is discovered to BigQuery External tables.z>Cloud Storage bucket is discovered to BigQuery BigLake tables.)EXTERNALBIGLAKEzBigQuery table type to discover the cloud resource bucket. Can be either `EXTERNAL` or `BIGLAKE`. If not specified, the table type will be set to `EXTERNAL`.)choicesr   z --bigquery-publishing-connectionzBigQuery connection to use for auto discovering cloud resource bucket to BigLake tables in format `projects/{project_id}/locations/{location_id}/connections/{connection_id}`. Connection is required for `BIGLAKE` BigQuery publishing table type.z%--bigquery-publishing-dataset-projectzThe project of the BigQuery dataset to publish BigLake external or non-BigLake external tables to. If not specified, the cloud resource bucket project will be used to create the dataset. The format is "projects/{project_id_or_number}.z&--bigquery-publishing-dataset-locationa)  The location of the BigQuery dataset to publish BigLake external or non-BigLake external tables to. If not specified, the dataset location will be set to the location of the data source resource. Refer to https://cloud.google.com/bigquery/docs/locations#supportedLocations for supported locations.z5Storage config arguments for the data discovery scan.z--storage-include-patternsPATTERNzList of patterns that identify the data to include during discovery when only a subset of the data should be considered. These patterns are interpreted as glob patterns used to match object names in the Cloud Storage bucket.)typemetavarr   z--storage-exclude-patternszList of patterns that identify the data to exclude during discovery. These patterns are interpreted as glob patterns used to match object names in the Cloud Storage bucket. Exclude patterns will be applied before include patterns.z2CSV options arguments for the data discovery scan.z--csv-header-row-countzuThe number of rows to interpret as header rows that should be skipped when reading data rows. The default value is 1.z--csv-delimiterznDelimiter used to separate values in the CSV file. If not specified, the delimiter will be set to comma (",").z--csv-encodingzXCharacter encoding of the CSV file. If not specified, the encoding will be set to UTF-8.z--csv-disable-type-inferencezlWhether to disable the inference of data types for CSV data. If true, all columns are registered as strings.)r   r   z--csv-quote-characterzThe character used to quote column values. Accepts " (double quotation mark) or ' (single quotation mark). If unspecified, defaults to " (double quotation mark).z3JSON options arguments for the data discovery scan.z--json-encodingzYCharacter encoding of the JSON file. If not specified, the encoding will be set to UTF-8.z--json-disable-type-inferencezmWhether to disable the inference of data types for JSON data. If true, all columns are registered as strings.z'Data discovery scan execution settings.z4Data discovery scan scheduling and trigger settings.)mutexr   z--on-demandzJIf set, the scan runs one-time shortly after data discovery scan creation.z
--schedulea  Cron schedule (https://en.wikipedia.org/wiki/Cron) for running scans periodically. To explicitly set a timezone to the cron tab, apply a prefix in the cron tab: "CRON_TZ=${IANA_TIME_ZONE}" or "TZ=${IANA_TIME_ZONE}". The ${IANA_TIME_ZONE} may only be a valid string from IANA time zone database. For example, `CRON_TZ=America/New_York 1 * * * *` or `TZ=America/New_York 1 * * * *`. This field is required for RECURRING scans.z:At most one of --async | --validate-only can be specified.)r   r   r   z--validate-only
store_truez:Validate the create action, but don't actually perform it.)actiondefaultr   )r   AddDatascanResourceArgadd_argument	add_groupr	   ArgListboolr
   
ASYNC_FLAGAddToParserr   AddCreateLabelsFlags)	parser	data_specbigquery_publishing_config_argstorage_config_argcsv_options_argjson_options_argexecution_spectriggerasync_groups	            7lib/surface/dataplex/datascans/create/data_discovery.pyArgsDataDiscovery.Args4   s   ((6 6  
 7  
  _	     5 ! I &/%8%8O &9 &"
 #//* e U
* 0   #//* 0 	 #///? 0  #//0( 0 
 #,,D -  ##$  "9 $ 
 ##$  "A $ 
 )22A 3 O    G !    D !    % !    &?	 !    C !  *33B 4  !!. "  !!'?	 "  %%6 & N &&O ' G 	   C   ""I # K
 I	   	OO,$$V,    z-Status code: {status_code}. {status_message}.c           	      :   UR                   R                  R                  5       n[        USS5        [        R
                  " 5       nUR                  R                  [        R                  " 5       R                  UR                  5       UR                  5       R                  5       [        R                  " U5      S95      n[        USS5      (       a   [        R                   R#                  S5        g [        USS5      nU(       d[  [        R$                  " U5      n[        R&                  " UR(                  SR+                  UR,                  UR.                  5      S	9  U$ [        R                   R#                  S
R+                  X$R(                  5      5        U$ )N	scan_type	DISCOVERY)
dataScanIdparentgoogleCloudDataplexV1DataScanvalidate_onlyFz1Validation completed. Skipping resource creation.async_z@Data discovery scan created in project [{0}] with location [{1}])detailszACreating data discovery scan with path [{0}] and operation [{1}].)CONCEPTSr   Parsesetattrdataplex_utilGetClientInstanceprojects_locations_dataScansCreateGetMessageModule/DataplexProjectsLocationsDataScansCreateRequestNameParentRelativeName GenerateDatascanForCreateRequestgetattrr   statusPrintWaitForOperationCreatedResourcenameformat
projectsIdlocationsId)selfargsdatascan_refdataplex_clientcreate_req_opr<   responses          r1   RunDataDiscovery.Run   sG    ==))//1LD+{+#557O#@@GG&&(XX#((*&&(557*2*S*S+ 	Y 	
M t_e,,	jjJKT8U+F**=9h	
--Pvl--|/G/GH	 oJJK	00	1 r4    N)__name__
__module____qualname____firstlineno____doc__r   VALUEScoreuniverse_domainGetdetailed_helpstaticmethodr2   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrZ   __static_attributes__r\   r4   r1   r   r       s      C
 DN  DU  DU  DZ  DZ  Dj  Dj  Dn  Dn  Dp  Cq q	- F- F-P 445""r4   r   N)ra   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   rA   googlecloudsdk.api_lib.utilr   rh   googlecloudsdk.callioper	   r
   #googlecloudsdk.command_lib.dataplexr   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHAGACommandr   r\   r4   r1   <module>rx      s    A &  ' 4 A F / ( = < # * D%%++T->->-A-AB@DLL @ C @r4   