
                         8   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 ddlmZ ddlmZ d Zd Zd Z ej8                  ej:                  j<                        ej>                   G d dej@                                      Z! ej8                  ej:                  jD                  ej:                  jF                        ej>                   G d dej@                                      Z$y)z#Vertex AI endpoints create command.    )absolute_import)division)unicode_literals)encoding)
operations)client)base)	constants)endpoint_util)endpoints_util)flags)operations_util)region_util)
validation)labels_util)logc                 N   t        j                  d      j                  |        t        j                  | dt        j
                         t        j                  d      j                  |        t        j                  d      j                  |        t        j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                  |        y Nendpointzto create endpoint)prompt_func)r   GetDisplayNameArgAddToParserAddRegionResourceArgr   PromptForOpRegionGetDescriptionArgGetUserSpecifiedIdArgr   AddCreateLabelsFlagsGetEndpointNetworkArgGetEncryptionKmsKeyNameArgGetHiddenGdceZoneArg(AddRequestResponseLoggingConfigGroupArgsparsers    "lib/surface/ai/endpoints/create.py
_AddArgsGar%   $   s    *%11&9"0M0MO*%11&9j)55f=""6*++F3""$008**62008    c                    t        j                  d      j                  |        t        j                  | dt        j
                         t        j                  d      j                  |        t        j                  d      j                  |        t        j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                  |        y r   )r   r   r   r   r   r   r   r   r   r   r   r   r    GetGdcZoneArgr!   r"   s    r$   _AddArgsr)   1   s    *%11&9"0M0MO*%11&9j)55f=""6*++F3""$008**62##F+008r&   c                    t        j                  | j                         | j                  j                  j                         }|j                         d   | _        t        j                  || j                        5  t        j                  |      }t        j                         }|t        j                  k(  r|j                  || j                  t!        j"                  | |j$                  j&                  j(                        | j*                  | j,                  | j.                  | j0                  | j2                  | j4                  	      }n|j7                  || j                  t!        j"                  | |j$                  j8                  j(                        | j*                  | j,                  | j.                  | j0                  | j:                  | j<                  | j2                  | j4                        }t?        j@                  ||tC        jD                  |jF                              }|JtI        jJ                  |      }d|v r1tL        jN                  jQ                  djS                  |d                |cddd       S # 1 sw Y   yxY w)	z Create a new Vertex AI endpoint.locationsId)region)version)descriptionnetworkendpoint_idencryption_kms_key_namerequest_response_logging_tablerequest_response_logging_rate)r.   r/   r0   r1   	gdce_zonegdc_zoner2   r3   NnamezCreated Vertex AI endpoint: {}.)*r   ValidateDisplayNamedisplay_nameCONCEPTSr,   ParseAsDictr   AiplatformEndpointOverridesr   EndpointsClientr   OperationsClientr
   
GA_VERSIONCreater   ParseCreateArgsmessagesGoogleCloudAiplatformV1EndpointLabelsValuer.   r/   r0   r1   r2   r3   
CreateBeta$GoogleCloudAiplatformV1beta1Endpointr4   r5   r   WaitForOpMayber   ParseOperationr6   r   MessageToPyValuer   statusPrintformat)argsr-   
region_refendpoints_clientoperation_clientopresponse_msgresponses           r$   _RunrT   ?   s     !2!23}}##))+*!!#M2$+00M--g>!224)&&&""
d''

%
%$--MM{ &&,,&&"&">">)-)L)L(,(J(J # 
Lb &&





%
%''LLXX &&,,&&"&">">NN==)-)L)L(,(J(J ' b  #11"n;;BGGDFL**<8h	8	

.66x7GH	JO NMMs   =G:JJ
c                   &    e Zd ZdZed        Zd Zy)CreateGaCreate a new Vertex AI endpoint.

  ## EXAMPLES

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

    $ {command} --project=example --region=us-central1
    --display-name=my_endpoint
  c                     t        |        y N)r%   r"   s    r$   ArgszCreateGa.Args}   s
    vr&   c                 6    t        |t        j                        S rY   )rT   r
   r?   selfrM   s     r$   RunzCreateGa.Run   s    i**++r&   N__name__
__module____qualname____doc__staticmethodrZ   r^    r&   r$   rV   rV   o   s     	  ,r&   rV   c                   &    e Zd ZdZed        Zd Zy)rE   rW   c                     t        |        y rY   )r)   r"   s    r$   rZ   zCreateBeta.Args   s
    Vr&   c                 6    t        |t        j                        S rY   )rT   r
   BETA_VERSIONr\   s     r$   r^   zCreateBeta.Run   s    i,,--r&   Nr_   re   r&   r$   rE   rE      s     	  .r&   rE   N)%rc   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.air   #googlecloudsdk.api_lib.ai.endpointsr   googlecloudsdk.callioper	   googlecloudsdk.command_lib.air
   r   r   r   r   r   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r%   r)   rT   ReleaseTracksReleaseTrackGAUniverseCompatibleCreateCommandrV   BETAALPHArE   re   r&   r$   <module>ry      s    * &  ' % 0 6 ( 3 7 8 / 9 5 4 < #
99-` D%%((),t!! ,  *,( D%%**D,=,=,C,CD.## .  E.r&   