
                         2   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 ddlmZ  ej(                  ej*                  j,                  ej*                  j.                         G d dej0                               Zy)z+`gcloud dataplex datascans update` 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)DataProfilezUpdate 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 update description of a data profile scan `data-profile-datascan`
          in project `test-project` located in `us-central1`, run:

            $ {command} data-profile-datascan --project=test-project --location=us-central1 --description="Description is updated."

          c                    t        j                  | d       | j                  ddd       | j                  ddd       | j                  dd	
      }|j                  dd       |j                  d      }|j                  dd       |j                  dd       |j                  dd       |j                  dd       | j                  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 update a data profile scan for.z--descriptionFz$Description of the data profile scan)requiredhelpz--display-namez%Display name of the data profile scanTz$Data spec for the data profile scan.)mutexr   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/DataProfileSpec)r   z6Command 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%Data profile scan execution settings.z1Data profile scan scheduling and trigger settingsz--on-demandzHIf set, the scan runs one-time shortly after data profile scan updation.)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.)r   r   r   z--validate-only
store_truez:Validate the update action, but don't actually perform it.)actiondefaultr   )
r
   AddDatascanResourceArgadd_argument	add_groupboolr	   
ASYNC_FLAGAddToParserr   AddCreateLabelsFlags)parser	data_specdata_spec_argexecution_spectriggerasync_groups         5lib/surface/dataplex/datascans/update/data_profile.pyArgszDataProfile.Args3   s   ((4 3  
 4  
   3 ! I "X   ''E ( M N   "   "   -   %%4 & N &&L ' G 	   C   ""I # K
 I	   	OO,$$V,    z-Status code: {status_code}. {status_message}.c           
         t        j                  |      }t        |      dk  rt        j                  d      |j
                  j                   j                         }t        j                         }t        j                         }t        |dd       |j                  j                  |j                  |j                         |j                  dj!                  |      t        j"                  |                  }t%        |dd      r t&        j(                  j+                  d	       y t%        |d
d      }|s\t        j,                  |      }t'        j.                  |j0                  dj3                  |j4                  |j6                               |S t&        j(                  j+                  dj3                  ||j0                               |S )N   zIUpdate commands must specify at least one additional parameter to change.	scan_typePROFILE,)namevalidateOnly
updateMaskgoogleCloudDataplexV1DataScanvalidate_onlyFz/Validation completed. Skipping resource update.async_z>Data profile scan updated in project [{0}] with location [{1}])detailsz?Updating data profile scan with path [{0}] and operation [{1}].)r   GenerateUpdateMasklenr   HttpExceptionCONCEPTSParsedataplex_utilGetClientInstanceGetMessageModulesetattrprojects_locations_dataScansPatch.DataplexProjectsLocationsDataScansPatchRequestRelativeNamer1   join GenerateDatascanForUpdateRequestgetattrr   statusPrintWaitForOperationUpdatedResourcer-   format
projectsIdlocationsId)	selfargsupdate_maskdatascan_refdataplex_clientmessageupdate_req_opr2   responses	            r%   RunzDataProfile.Run   s    --d3K
;!$$  ==))//1L#557O,,.GD+y)#@@FF>>**,++xx,*2*S*S+	 	? 	
	M t_e,	jjHI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 CatchHTTPErrorRaiseHTTPExceptionrS    r'   r%   r   r      sT      	- `- `-D 5445**r'   r   N)rW   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   r9   googlecloudsdk.api_lib.utilr   rZ   googlecloudsdk.callioper	   #googlecloudsdk.command_lib.dataplexr
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHAGACommandr   r\   r'   r%   <module>ri      su    2 &  ' 4 A F ( . = < # D%%++T->->-A-ABc$,, c Ccr'   