
                            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 Zd Z ej,                  ej.                  j0                        ej2                   G d dej4                                      Z ej,                  ej.                  j8                  ej.                  j:                        ej2                   G d de                    Zy)z#Vertex AI endpoints update command.    )absolute_import)division)unicode_literals)client)base)	constants)endpoint_util)errors)flags)region_util)
validation)labels_util)logc                 b   t        j                  | dt        j                         t        j                  dd      j                  |        t        j                  d      j                  |        t        j                  |        t        j                  |        t        j                  |        y )Nz	to update)prompt_funcendpointF)required)r   AddEndpointResourceArgr   PromptForOpRegionGetDisplayNameArgAddToParserGetDescriptionArgAddTrafficSplitGroupArgs.AddRequestResponseLoggingConfigUpdateGroupArgsr   AddUpdateLabelsFlagsparsers    "lib/surface/ai/endpoints/update.py_AddArgsr   !   s|    k{'D'DF*u5AA&I*%11&9  (66v>""6*    c                     t        j                   j                          j                  j                  j                         j                         d    _        t        j                  | j                        5  t        j                  |      fd}	 |t        j                  k(  rj                  t        j                    j"                  j$                  j&                  |       j                   j(                   j*                   j,                   j.                   j0                   j2                  	      }nj5                  t        j                    j"                  j6                  j&                  |       j                   j(                   j*                   j,                   j.                   j0                   j2                  	      }t9        j:                  |j<                  d       |cddd       S # t>        j@                  $ rC g d	}tC         fd
|D              s t8        jD                  jG                  d       Y ddd       yw xY w# 1 sw Y   yxY w)z&Update an existing Vertex AI endpoint.locationsId)region)versionc                  :    j                         j                  S N)Getlabels)endpoint_refendpoints_clients   r   	GetLabelsz_Run.<locals>.GetLabels4   s    !!,/666r    )display_namedescriptiontraffic_splitclear_traffic_splitrequest_response_logging_tablerequest_response_logging_rate disable_request_response_loggingzVertex AI endpoint)kindN)
r,   r.   r/   update_labelsclear_labelsremove_labelsr-   r0   r1   r2   c              3   @   K   | ]  }j                  |        y wr&   )IsSpecified).0argargss     r   	<genexpr>z_Run.<locals>.<genexpr>[   s     H2G3!!#&2Gs   zNo update to perform.)$r   ValidateDisplayNamer,   CONCEPTSr   ParseAsDictr#   r	   AiplatformEndpointOverridesr   EndpointsClientr   
GA_VERSIONPatchr   ProcessUpdateArgsLazymessagesGoogleCloudAiplatformV1EndpointLabelsValuer-   r.   r/   r0   r1   r2   	PatchBeta$GoogleCloudAiplatformV1beta1Endpointr   UpdatedResourcenamer
   NoFieldsSpecifiedErroranystatusPrint)r;   r$   r+   opavailable_update_argsr)   r*   s   `    @@r   _RunrS   +   s     !2!23''--/,##%m4$+00M--g>7*	I((	(##--&//OOi) **((,, $ 8 8+/+N+N*.*L*L-1-- $ / ''--&//55kk9N **((,, $ 8 8+/+N+N*.*L*L-1-- ( /2 
"''(<=a NMF (( 
 H2GHH	jj./[ NMF
G NMs2    ID:H"IAIIIII&c                   &    e Zd ZdZed        Zd Zy)UpdateGaUpdate an existing Vertex AI endpoint.

  ## EXAMPLES

  To update an endpoint ``123'' under project ``example'' in region
  ``us-central1'', run:

    $ {command} 123 --project=example --region=us-central1
    --display-name=new_name
  c                     t        |        y r&   )r   r   s    r   ArgszUpdateGa.Argsr   s
    Vr    c                 6    t        |t        j                        S r&   )rS   r   rC   selfr;   s     r   RunzUpdateGa.Runv   s    i**++r    N)__name__
__module____qualname____doc__staticmethodrX   r\    r    r   rU   rU   d   s     	  ,r    rU   c                       e Zd ZdZd Zy)
UpdateBetarV   c                 6    t        |t        j                        S r&   )rS   r   BETA_VERSIONrZ   s     r   r\   zUpdateBeta.Run   s    i,,--r    N)r]   r^   r_   r`   r\   rb   r    r   rd   rd   z   s    	.r    rd   N)r`   
__future__r   r   r   #googlecloudsdk.api_lib.ai.endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r	   r
   r   r   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   rS   ReleaseTracksReleaseTrackGAUniverseCompatibleUpdateCommandrU   BETAALPHArd   rb   r    r   <module>rt      s    * &  ' 6 ( 3 7 0 / 5 4 < #+6r D%%((),t!! ,  *,( D%%**D,=,=,C,CD. .  E.r    