
    I                        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 ddlmZ  ej&                  ej(                  j*                         G d dej,                               Z ej&                  ej(                  j0                  ej(                  j2                         G d de             Zy)z)Vertex AI index endpoints update command.    )absolute_import)division)unicode_literals)client)base)	constants)endpoint_util)errors)flags)
validation)labels_util)logc                   ,    e Zd ZdZed        Zd Zd Zy)UpdateV1Update an Vertex AI index endpoint.

  ## EXAMPLES

  To update display name of index endpoint `123` under project `example` in
  region `us-central1`, run:

    $ {command} --display-name=new-name --project=example --region=us-central1
  c                     t        j                  | d       t        j                  dd      j                  |        t        j                  d      j                  |        t        j                  |        y )Nz	to updatezindex endpointF)required)r   AddIndexEndpointResourceArgGetDisplayNameArgAddToParserGetDescriptionArgr   AddUpdateLabelsFlags)parsers    (lib/surface/ai/index_endpoints/update.pyArgszUpdateV1.Args,   sW    	%%fk:	5**5+f*=	,-99&A$$V,    c                    t        j                  j                         j                  j                  j                         }|j                         d   }t        j                  ||      5  t        j                  |      }	 |t        j                  k(  r|j                  |      }n|j                  |      }t        j                   |j"                  d       |cd d d        S # t$        j&                  $ rC g d}t)        fd|D              s t        j*                  j-                  d       Y d d d        y w xY w# 1 sw Y   y xY w)	NlocationsId)region)versionzVertex AI index endpoint)kind)display_namedescriptionupdate_labelsclear_labelsremove_labelsc              3   @   K   | ]  }j                  |        y wN)IsSpecified).0argargss     r   	<genexpr>z UpdateV1._Run.<locals>.<genexpr>D   s     J4IS4##C(4Is   zNo update to perform.)r   ValidateDisplayNamer"   CONCEPTSindex_endpointParseAsDictr	   AiplatformEndpointOverridesr   IndexEndpointsClientr   
GA_VERSIONPatch	PatchBetar   UpdatedResourcenamer
   NoFieldsSpecifiedErroranystatusPrint)selfr,   r    index_endpoint_refr   index_endpoint_clientresultavailable_update_argss    `      r   _RunzUpdateV1._Run4   s   ""4#4#4555;;=&&(7F		2	276	J$99'Ji***(../A4H&(223EtL& 	FKK.HI% 
K	J ** !
 J4IJJ


01 
K	J 
K	Js1   /E8C+?"E+AE6E EEEc                 B    | j                  |t        j                        S r(   )rC   r   r5   r>   r,   s     r   RunzUpdateV1.RunL   s    99T9//00r   N)__name__
__module____qualname____doc__staticmethodr   rC   rF    r   r   r   r       s%     - -01r   r   c                       e Zd ZdZd Zy)UpdateV1Beta1r   c                 B    | j                  |t        j                        S r(   )rC   r   BETA_VERSIONrE   s     r   rF   zUpdateV1Beta1.Run\   s    99T91122r   N)rG   rH   rI   rJ   rF   rL   r   r   rN   rN   P   s    3r   rN   N)rJ   
__future__r   r   r   )googlecloudsdk.api_lib.ai.index_endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r	   r
   r   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackGAUpdateCommandr   BETAALPHArN   rL   r   r   <module>r]      s    0 &  ' < ( 3 7 0 / 4 < # D%%((),1t!! ,1 *,1^ D%%**D,=,=,C,CD3H 3 E3r   