
                            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iZ ej$                  ej&                  j(                        e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 deploy-index command.    )absolute_import)division)unicode_literals)client)base)	constants)endpoint_util)flags)index_endpoints_util)
validation)logEXAMPLESa          To deploy index ``345'' to an index endpoint ``456'' with 2 min replica count and 10 max replica count under project ``example'' in region ``us-central1'', within reserved ip ranges
        ``vertex-ai-ip-range-1'' and ``vertex-ai-ip-range-2'' run:

          $ {command} 456 --project=example --region=us-central1 --index=345 --deployed-index-id=deployed-index-345 --display-name=deployed-index-345 --min-replica-count=2 --max-replica-count=10 --reserved-ip-ranges=vertex-ai-ip-range-1,vertex-ai-ip-range-2
        c                   0    e Zd ZdZeZed        Zd Zd Z	y)DeployIndexV1.Deploy an index to a Vertex AI index endpoint.c                 "   t        j                  | d       t        j                         j                  |        t        j                         j                  |        t        j
                  d      j                  |        t        j                  | d       t        j                  | d       t        j                  |        t        j                  | d       t        j                         j                  |        t        j                  |        y )Nzto deploy an indexzdeployed index)r
   AddIndexEndpointResourceArgGetDeployedIndexIdAddToParserGetIndexIdArgGetDisplayNameArgAddDeploymentResourcesArgsAddReservedIpRangesArgsAddDeploymentGroupArgAddAuthConfigArgsGetEnableAccessLoggingArgAddPscAutomationConfigsArgs)parsers    .lib/surface/ai/index_endpoints/deploy_index.pyArgszDeployIndexV1.Args0   s    	%%f.BC	**62	%%f-	,-99&A	$$V-=>	!!&*:;	'	F$45	##%11&9	%%f-    c                    t        j                  |j                         |j                  j                  j                         }|j                         d   }|j                         d   }t        j                  ||      5  t        j                  |      }|t        j                  k(  r|j                  ||      }n|j                  ||      }t        j                   |j"                        }|j                         d   }	t$        j&                  j)                  t        j*                  j-                  |j"                  d|j/                         dj-                  |	||                   |cd d d        S # 1 sw Y   y xY w)	N
projectsIdlocationsId)region)versionindexEndpointsIdzdeploy indexz.--index-endpoint={} --region={} [--project={}])nameverbidsub_commands)r   ValidateDisplayNamedisplay_nameCONCEPTSindex_endpointParseAsDictr	   AiplatformEndpointOverridesr   IndexEndpointsClientr   
GA_VERSIONDeployIndexDeployIndexBetar   ParseIndexEndpointOperationr(   r   statusPrint"OPERATION_CREATION_DISPLAY_MESSAGEformatName)
selfargsr&   index_endpoint_ref
project_idr%   index_endpoint_client	operationop_refindex_endpoint_ids
             r   _RunzDeployIndexV1._Run=   s6   ""4#4#4555;;=#**,\:J&&(7F		2	276	J$99'J	I((	()556H$O	)99&	 $??	Of --/*<=	jj

6
6
=
=>>!Kv'< > >? % 
K	J	Js   C+E66E?c                 B    | j                  |t        j                        S N)rE   r   r4   r=   r>   s     r   RunzDeployIndexV1.RunV   s    99T9//00r!   N)
__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpstaticmethodr    rE   rI    r!   r   r   r   )   s(     7-
. 
.21r!   r   c                       e Zd ZdZeZd Zy)DeployIndexV1Beta1r   c                 B    | j                  |t        j                        S rG   )rE   r   BETA_VERSIONrH   s     r   rI   zDeployIndexV1Beta1.Run`   s    99T91122r!   N)rJ   rK   rL   rM   rN   rO   rI   rQ   r!   r   rS   rS   Z   s    6-3r!   rS   N)rM   
__future__r   r   r   )googlecloudsdk.api_lib.ai.index_endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r	   r
   r   r   googlecloudsdk.corer   rN   ReleaseTracksReleaseTrackGADefaultUniverseOnlyCommandr   ALPHABETArS   rQ   r!   r   <module>rb      s    6 &  ' < ( 3 7 / > 4 # 	 D%%((),1DLL ,1  *,1^ D%%++T->->-C-CD3 3 E3r!   