
                         ^   d Z ddl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
dZ ej                  ej                  j                   ej                  j"                  ej                  j$                        ej&                   G d dej(                                      Zee_        y).Update the configuration of an insight config.    N)insights_config)
exceptions)base)flags)resource_args)logzE
          Update the configuration of an insights config.
          a  
          To update the state of an insights config, run:

            $ {command} insights-config-name --run-discovery

          To update the Artifact Analysis project for an artifact in an insights config, run:

            $ {command} insights-config-name --artifact-uri=us-{location}-docker.pkg.dev/my-project/my-artifact-repo/my-image --build-project={build_project}
          )DESCRIPTIONEXAMPLESc                   &    e Zd ZdZed        Zd Zy)Updater   c                 p   	 t        j                  | d       | j                  dd      }|j                         }t        j                  |       t        j                  |       t        j                  |       y# t        j                  $ r&}t        j
                  j                  d       |d}~ww xY w)z Adds arguments for this command.update)verbz/Failed to add insight config resource argument.NTzUpdate the insight config.)requiredhelp)r   AddInsightConfigResourceArgr   HttpExceptionr	   statusPrint	add_groupr   AddDiscoveryArgumentAddArtifactArgumentAddBuildProjectArgument)parsereupdate_groupartifact_groups       8lib/surface/developer_connect/insights_configs/update.pyArgszUpdate.Args1   s    //XF ##8 $ L "++-N	|,	n-	!!.1 ## 	jjHIgs   A< <B5!B00B5c                    t        j                  d      }t        j                  t        j
                  j                        }|j                  j                  j                         }	 |j                  ||j                  |j                  |j                        }t        j                   j#                  dj%                  |j'                                      |j)                  |j+                  |      dj%                  |j+                  |      j'                               d|      S # t        j                  $ rC}t        j                   j#                  dj%                  |j'                                      |d }~ww xY w)	N   )seconds)insight_config_ref	discoverybuild_projectartifact_uriz'Failed to update the insight config {}.zUpdating the insight config {}.z-Waiting for operation [{}] to be completed...T)operation_refmessage
has_resultmax_wait)datetime	timedeltar   InsightsConfigClientr   ReleaseTrackALPHACONCEPTSParser   run_discoveryr&   r'   r   r   r	   r   r   formatRelativeNameWaitForOperationGetOperationRef)selfargsr+   clientinsights_config_ref	operationr   s          r   Runz
Update.RunC   sH   !!"-H11$2C2C2I2IJF--77==?--0&&**((	   i JJ6==((*  "",,Y7?	""9-::<
> #   ## 	jj@GG

*
*
, 	 g	s   )3D( (E>;>E99E>N)__name__
__module____qualname____doc__staticmethodr    r=        r   r   r   *   s    
 72 2"rD   r   )rA   r,   9googlecloudsdk.api_lib.developer_connect.insights_configsr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   ,googlecloudsdk.command_lib.developer_connectr   r   googlecloudsdk.corer	   DETAILED_HELPReleaseTracksr/   r0   BETAGADefaultUniverseOnlyUpdateCommandr   detailed_helprC   rD   r   <module>rQ      s    5  U 2 ( > F #	  T..33T5F5F5I5I 1T 1 1d % rD   