
                            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 ddlmZ ddlmZ  ej.                  ej0                  j2                         G d dej4                               Z ej.                  ej0                  j8                  ej0                  j:                         G d de             Zy)z!Vertex AI indexes update command.    )absolute_import)division)unicode_literals)encoding)
operations)client)base)	constants)endpoint_util)flags)indexes_util)operations_util)labels_util)logc                   ,    e Zd ZdZed        Zd Zd Zy)UpdateV1Update an Vertex AI index.

  ## EXAMPLES

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

    $ {command} --display-name=new-name
    --metadata-file=path/to/your/metadata.json --project=example
    --region=us-central1
  c                 6   t        j                  | d       t        j                  dd      j                  |        t        j                  d      j                  |        t        j
                  d      j                  |        t        j                  |        y )Nz	to updateindexF)required)r   AddIndexResourceArgGetDisplayNameArgAddToParserGetDescriptionArgGetMetadataFilePathArgr   AddUpdateLabelsFlags)parsers     lib/surface/ai/indexes/update.pyArgszUpdateV1.Args/   sm    	fk2	Ge4@@H	G$008	  )55f=$$V,    c                    |j                   j                  j                         }|j                         d   }|j                         d   }t	        j
                  ||      5  t        j                  |      }|t        j                  k(  r|j                  ||      }n|j                  ||      }|j                  t        j                  |j                        }t         j"                  j%                  t        j&                  j)                  |j                  d|j+                         dj)                  |j+                         ||                   |cd d d        S t-        j.                  t1        j2                  |      |t        j                  |j                        d	      }	|	3t5        j6                  |	      }
d
|
v rt!        j8                  |
d
   d       |	cd d d        S # 1 sw Y   y xY w)NlocationsId
projectsId)region)versionzupdate indexz%--index={} --region={} [--project={}])nameverbidsub_commandsupdate)operations_clientopop_ref
log_methodr&   zVertex AI index)kind)CONCEPTSr   ParseAsDictr   AiplatformEndpointOverridesr   IndexesClientr
   
GA_VERSIONPatch	PatchBetametadata_filer   ParseIndexOperationr&   r   statusPrint"OPERATION_CREATION_DISPLAY_MESSAGEformatNamer   WaitForOpMayber   OperationsClientr   MessageToPyValueUpdatedResource)selfargsr%   	index_refr$   
project_idindex_client	operationr-   response_msgresponses              r   _RunzUpdateV1._Run7   s   ##))+I.F!!#L1J		2	276	J))':l	I((	( &&y$7	 **9d;					'11)..A

88??^^#;;=DKKNN$fj:	 @ ;	< # 
K	J( %33&77H11)..A	l
 
	!,,\:X


hv.5F
G; 
K	J	Js   "C2G(B G((G1c                 B    | j                  |t        j                        S N)rK   r
   r5   rC   rD   s     r   RunzUpdateV1.RunZ   s    99T9//00r    N)__name__
__module____qualname____doc__staticmethodr   rK   rO    r    r   r   r   "   s&    	 - -!F1r    r   c                       e Zd ZdZd Zy)UpdateV1Beta1r   c                 B    | j                  |t        j                        S rM   )rK   r
   BETA_VERSIONrN   s     r   rO   zUpdateV1Beta1.Runk   s    99T91122r    N)rP   rQ   rR   rS   rO   rU   r    r   rW   rW   ^   s    	3r    rW   N)rS   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.air   !googlecloudsdk.api_lib.ai.indexesr   googlecloudsdk.callioper	   googlecloudsdk.command_lib.air
   r   r   r   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackGAUpdateCommandr   BETAALPHArW   rU   r    r   <module>rh      s    ( &  ' % 0 4 ( 3 7 / 6 9 < # D%%(()81t!! 81 *81v D%%**D,=,=,C,CD3H 3 E3r    