
                          &   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.                         G d dej0                               Zy)z8`gcloud dataplex datascans create data-profile` 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)DataProfilezCreate a Dataplex data profile scan job.

  Represents a user-visible job which provides the insights for the
  related data source about the structure, content and relationships
  (such as null percent, cardinality, min/max/mean, etc).
  EXAMPLESa  
          To create a data profile scan `data-profile-datascan`
          in project `test-project` located in `us-central1` on bigquery resource table `test-table` in dataset `test-dataset`, run:

            $ {command} data-profile-datascan --project=test-project --location=us-central1 --data-source-resource="//bigquery.googleapis.com/projects/test-project/datasets/test-dataset/tables/test-table"

          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      }|j                  dd       |j                  d      }|j                  dd       |j                  dd       |j                  dd       |j                  dd       |j                  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 profile scan for.z--descriptionFz%Description of the data profile scan.)requiredhelpz--display-namez&Display name of the data profile scan.Tz&Data source for the data profile scan.)mutexr   r   z--data-source-entityzDataplex entity that contains the data for the data profile 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 profile scan, of the form: `//bigquery.googleapis.com/projects/{project_number}/datasets/{dataset_id}/tables/{table_id}`.z$Data spec for the data profile scan.)r   r   z--data-profile-spec-filezpath to the JSON/YAML file containing the spec for the data profile scan. The JSON representation reference: https://cloud.google.com/dataplex/docs/reference/rest/v1/DataProfileSpecz6Command line spec arguments for the data profile scan.z--row-filterz?A filter applied to all rows in a single data profile scan job.z--sampling-percentzTThe percentage of the records to be selected from the dataset for data profile scan.z--include-field-nameszNames of the fields to include in data profile. If not specified, all fields at the time of profile scan job execution are included. The fields listed in the `--exclude-field-names` flag are excluded.z--exclude-field-nameszNames of the fields to exclude from data profile. If specified, the respective fields will be excluded from data profile, regardless of the fields specified in the `--include-field-names` flag.z--export-results-tablezpath to the resource table to export data profile scan results, of the form: `//bigquery.googleapis.com/projects/{project_number}/datasets/{dataset_id}/tables/{table_id}`. The table will be created if not present.z%Data profile scan execution settings.z--incremental-fieldzRField that contains values that monotonically increase over time (e.g. timestamp).z2Data profile scan scheduling and trigger settings.z--on-demandzHIf set, the scan runs one-time shortly after data profile 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	data_specdata_spec_argexecution_spectriggerasync_groups          5lib/surface/dataplex/datascans/create/data_profile.pyArgszDataProfile.Args2   s   ((4 4  
 5  
 ""5 # K
 y    n     3 ! I "X   ''E ( M N   "   "   -    9   %%3 & N
 !    &&M ' G 	   C   ""I # K
 I	   	OO,$$V,    z-Status code: {status_code}. {status_message}.c           	      *   |j                   j                  j                         }t        |dd       t	        j
                         }|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PROFILE)
dataScanIdparentgoogleCloudDataplexV1DataScanvalidate_onlyFz1Validation completed. Skipping resource creation.async_z>Data profile scan created in project [{0}] with location [{1}])detailsz?Creating data profile 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_opr0   responses          r&   RunzDataProfile.Run   sF    ==))//1LD+y)#557O#@@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 CatchHTTPErrorRaiseHTTPExceptionrN    r(   r&   r   r      sT      	- H- H-T 5445""r(   r   N)rR   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   r5   googlecloudsdk.api_lib.utilr   rU   googlecloudsdk.callioper	   #googlecloudsdk.command_lib.dataplexr
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHAGACommandr   rW   r(   r&   <module>rd      sr    ? &  ' 4 A F ( = < # D%%++T->->-A-ABC$,, C CCr(   