
    D                     P   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.                        ej0                   G d dej2                                      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)DataQualityzUpdate 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 update description of a data quality scan `data-quality-datascan`
          in project `test-project` located in `us-central1`, run:

            $ {command} data-quality-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
      }|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 quality scan for.z--descriptionFz$Description of the data quality scan)requiredhelpz--display-namez%Display name of the data quality scanz--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-gcloud)r   z%Data quality scan execution settings.Tz1Data quality scan scheduling and trigger settings)mutexr   z--on-demandzHIf set, the scan runs one-time shortly after data quality 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execution_spectriggerasync_groups       5lib/surface/dataplex/datascans/update/data_quality.pyArgszDataQuality.Args4   sH   ((4 3  
 4  
 "e  	 %%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QUALITY,)namevalidateOnly
updateMaskgoogleCloudDataplexV1DataScanvalidate_onlyFz/Validation completed. Skipping resource update.async_z>Data quality scan updated in project [{0}] with location [{1}])detailsz?Updating data quality scan with path [{0}] and operation [{1}].)r   GenerateUpdateMasklenr   HttpExceptionCONCEPTSParsedataplex_utilGetClientInstanceGetMessageModulesetattrprojects_locations_dataScansPatch.DataplexProjectsLocationsDataScansPatchRequestRelativeNamer/   join GenerateDatascanForUpdateRequestgetattrr   statusPrintWaitForOperationUpdatedResourcer+   format
projectsIdlocationsId)	selfargsupdate_maskdatascan_refdataplex_clientmessageupdate_req_opr0   responses	            r#   RunzDataQuality.Runu   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 CatchHTTPErrorRaiseHTTPExceptionrQ    r%   r#   r   r      sR      	- >- >-@ 5445**r%   r   N)rU   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   r7   googlecloudsdk.api_lib.utilr   rX   googlecloudsdk.callioper	   #googlecloudsdk.command_lib.dataplexr
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHAGAUniverseCompatibleCommandr   rZ   r%   r#   <module>rh      s    2 &  ' 4 A F ( . = < # D%%++T->->-A-ABA$,, A  CAr%   