
                         D   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  ej(                  ej*                  j,                  ej*                  j.                        ej0                   G d dej2                                      Zy)z8`gcloud dataplex datascans create data-quality` command.    )absolute_import)division)unicode_literals)datascan)util)
exceptions)base)resource_args)labels_util)logc                   X    e Zd ZdZddiZed        Z ej                  d      d        Z	y)DataQualityzCreate 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                    t        j                  | d       | j                  ddd       | j                  ddd       | j                  ddd	
      }|j                  dd       |j                  dd       | j                  ddd       | j                  d      }|j                  dd       |j                  dd      }|j                  dt        d       |j                  dd       | j                  ddd
      }|j                  dddd        t
        j                  j                  |       t        j                  |        y )!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Argsz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           	      *   |j                   j                  j                         }t        j                         }t        |dd       |j                  j                  t        j                         j                  |j                         |j                         j                         t        j                  |                  }t        |dd      r t        j                   j#                  d       y t        |dd      }|s\t        j$                  |      }t        j&                  |j(                  dj+                  |j,                  |j.                        	       |S t        j                   j#                  d
j+                  ||j(                               |S )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_opr.   responses          r$   RunzDataQuality.Run   sF    ==))//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	m00	1 r&   N)
__name__
__module____qualname____doc__detailed_helpstaticmethodr%   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrL    r&   r$   r   r      sT      - ]- ]-~ 5445""r&   r   N)rP   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   r2   googlecloudsdk.api_lib.utilr   rS   googlecloudsdk.callioper	   #googlecloudsdk.command_lib.dataplexr
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHAGAUniverseCompatibleCommandr   rU   r&   r$   <module>rc      s    ? &  ' 4 A F ( = < # D%%++T->->-A-ABW$,, W  CWr&   