
                         D   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  \R(                  " \R*                  R,                  \R*                  R.                  5      \R0                   " S S\R2                  5      5       5       rg)z8`gcloud dataplex datascans create data-quality` command.    )absolute_import)division)unicode_literals)datascan)util)
exceptions)base)resource_args)labels_util)logc                   `    \ rS rSrSrSS0r\S 5       r\R                  " S5      S 5       r
Srg	)
DataQuality   zCreate a Dataplex data quality scan job.

Represents a user-visible job which provides the insights for the
related data source and generates queries based on the rules and runs
against the data to get data quality check results.
EXAMPLESa  
          To create a data quality scan `data-quality-datascan`
          in project `test-project` located in `us-central1` on bigquery resource table `test-table` in dataset `test-dataset` with data spec file `data-quality-spec.json`, run:

            $ {command} data-quality-datascan --project=test-project --location=us-central1 --data-source-resource="//bigquery.googleapis.com/projects/test-project/datasets/test-dataset/tables/test-table" --data-quality-spec-file="data-quality-spec.json"
          c                 R   [         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nUR                  SSS9  UR                  SSS9  U R                  SSSS9  U R                  SS9nUR                  SSS9  UR                  SSS9nUR                  S[        SS9  UR                  SSS9  U R                  SSSS
9nUR                  SSSSS 9  [
        R                  R                  U5        [        R                  " U 5        g )!Nz"to create a data quality scan for.z--descriptionFz%Description of the data quality scan.)requiredhelpz--display-namez&Display name of the data quality scan.Tz&Data source for the data quality scan.)mutexr   r   z--data-source-entityzDataplex entity that contains the data for the data quality scan, of the form: `projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}`.)r   z--data-source-resourcezFully-qualified service resource name of the cloud resource that contains the data for the data quality scan, of the form: `//bigquery.googleapis.com/projects/{project_number}/datasets/{dataset_id}/tables/{table_id}`.z--data-quality-spec-filea.  Path to the JSON/YAML file containing the spec for the data quality scan. The JSON representation reference: https://cloud.google.com/dataplex/docs/reference/rest/v1/DataQualitySpec The YAML representation reference: https://cloud.google.com/dataplex/docs/use-auto-data-quality#create-scan-using-gcloudz%Data quality scan execution settings.z--incremental-fieldzRField that contains values that monotonically increase over time (e.g. timestamp).z1Data quality scan scheduling and trigger settings)r   r   z--on-demandzHIf set, the scan runs one-time shortly after data quality scan creation.)typer   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.z--validate-only
store_truez:Validate the create action, but don't actually perform it.)actiondefaultr   )
r
   AddDatascanResourceArgadd_argument	add_groupboolr	   
ASYNC_FLAGAddToParserr   AddCreateLabelsFlags)parserdata_sourceexecution_spectriggerasync_groups        5lib/surface/dataplex/datascans/create/data_quality.pyArgsDataQuality.Args2   s   ((4 4  
 5  
 ""T(P # K y    n   "e	  
 %%3 & N
 !    &&L ' G 	   C   ""I # K
 I	   	OO,$$V,    z-Status code: {status_code}. {status_message}.c           	      :   UR                   R                  R                  5       n[        R                  " 5       n[        USS5        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QUALITY)
dataScanIdparentgoogleCloudDataplexV1DataScanvalidate_onlyFz1Validation completed. Skipping resource creation.async_z>Data quality scan created in project [{0}] with location [{1}])detailsz?Creating Data quality scan with path [{0}] and operation [{1}].)CONCEPTSr   Parsedataplex_utilGetClientInstancesetattr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_opr0   responses          r%   RunDataQuality.Run   sG    ==))//1L#557OD+y)#@@GG&&(XX#((*&&(557*2*S*S+ 	Y 	
M t_e,,	jjJKT8U+F**=9h	
--Nvl--|/G/GH	 oJJI	00	1 r(    N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr&   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrN   __static_attributes__rP   r(   r%   r   r      sQ      - ]- ]-~ 445""r(   r   N)rU   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   r4   googlecloudsdk.api_lib.utilr   rX   googlecloudsdk.callioper	   #googlecloudsdk.command_lib.dataplexr
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHAGAUniverseCompatibleCommandr   rP   r(   r%   <module>rh      s~    ? &  ' 4 A F ( = < # D%%++T->->-A-ABW$,, W  CWr(   