
    1U                     x    S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSK
Jr  S	 r " S
 S\5      rg)z;Utilities for dealing with AI Platform index endpoints API.    )
list_pager)apis)	constants)errors)labels_util)
properties)	resourcesc                     [         R                  R                  U U[        R                  R
                  R                  R                  S.SS9$ )z/Parses a index ID into a index resource object.)locationsId
projectsIdz%aiplatform.projects.locations.indexes)params
collection)r	   REGISTRYParser   VALUEScoreproject	GetOrFail)index_idlocation_ids     7lib/googlecloudsdk/api_lib/ai/index_endpoints/client.py_ParseIndexr      sK    				!	!$"))..66@@ 9 
" 
: :    c                       \ rS rSrSrSS\R                  4S jrS rS r	S r
S rS	 rS
 rS rS rS rS rS rSS jrS rS rS rS rS rSrg)IndexEndpointsClient&   z>High-level client for the AI Platform index endpoints surface.Nc                 
   U=(       d6    [         R                  " [        R                  [        R                  U   5      U l        U=(       d    U R
                  R                  U l        U R
                  R                  U l	        g N)
r   GetClientInstancer   AI_PLATFORM_API_NAMEAI_PLATFORM_API_VERSIONclientMESSAGES_MODULEmessages!projects_locations_indexEndpoints_service)selfr"   r$   versions       r   __init__IndexEndpointsClient.__init__)   s[     4D22&&))'24DK ; ; ;DMKKAADMr   c                    [         R                  " UU R                  R                  R                  5      nSnUR
                  b#  U R                  R                  UR
                  S9nSnUR                  (       a  U R                  R                  UR                  UR                  (       a  UR                  O/ S9nU R                  R                  UR                  5       U R                  R                  UR                  UR                  UR                  UUUS9S9nOUR                  bb  U R                  R                  UR                  5       U R                  R                  UR                  UR                  UR                  UUS9S9nOXU R                  R                  UR                  5       U R                  R                  UR                  UR                  SUUUS9S9nU R                   R#                  U5      $ )zCreate a new index endpoint.N
kmsKeyNameenablePrivateServiceConnectprojectAllowlistdisplayNamedescriptionpublicEndpointEnabledlabelsencryptionSpecprivateServiceConnectConfig)parent)googleCloudAiplatformV1beta1IndexEndpointr2   r3   networkr5   r6   T)r   ParseCreateArgsr$   )GoogleCloudAiplatformV1beta1IndexEndpointLabelsValueencryption_kms_key_name*GoogleCloudAiplatformV1beta1EncryptionSpecenable_private_service_connect7GoogleCloudAiplatformV1beta1PrivateServiceConnectConfigproject_allowlist6AiplatformProjectsLocationsIndexEndpointsCreateRequestRelativeNamedisplay_namer3   public_endpoint_enabledr;   r&   Creater'   location_refargsr5   encryption_specprivate_service_connect_configreqs          r   
CreateBetaIndexEndpointsClient.CreateBeta0   s   ((??KKMF O##/
--
B
B55 C 7  &*"**
--
O
O*.*M*M#'#9#9 !% 6 6?A P  % MMPP**,48MM4k4k++**$($@$@,*H 5l 5 Q 
c 
	!MMPP**,48MM4k4k++**ll, 5l 5 Q 	c MMPP**,48MM4k4k++**$(,*H 5l 5 Q 
c ==$$r   c                     [         R                  " X R                  R                  R                  5      nSnUR
                  b#  U R                  R                  UR
                  S9nSnUR                  (       a  U R                  R                  UR                  UR                  (       a  UR                  O/ S9nU R                  R                  UR                  5       U R                  R                  UR                  UR                  UR                  UUUS9S9nOUR                  bb  U R                  R                  UR                  5       U R                  R                  UR                  UR                  UR                  UUS9S9nOXU R                  R                  UR                  5       U R                  R                  UR                  UR                  SUUUS9S9nU R                   R#                  U5      $ )zCreate a new v1 index endpoint.Nr,   r.   r1   )r8   $googleCloudAiplatformV1IndexEndpointr:   T)r   r<   r$   $GoogleCloudAiplatformV1IndexEndpointr>   r?   %GoogleCloudAiplatformV1EncryptionSpecrA   2GoogleCloudAiplatformV1PrivateServiceConnectConfigrC   rD   rE   rF   r3   rG   r;   r&   rH   rI   s          r   rH   IndexEndpointsClient.Createk   s   ((mm@@LLNF O##/
--
=
=55 > 7  &*"**
--
J
J*.*M*M#'#9#9 !% 6 6?A K  % MMPP**,/3}}/a/a++**$($@$@,*H 0b 0 Q 
c 
	!MMPP**,/3}}/a/a++**ll, 0b 0 Q 	c MMPP**,/3}}/a/a++**$(,*H 0b 0 Q 
c ==$$r   c                   ^ ^ T R                   R                  5       n/ nUR                  b"  UR                  Ul        UR	                  S5        UR
                  b"  UR
                  Ul        UR	                  S5        UU 4S jn[        R                  " UT R                   R                  R                  U5      nUR                  (       a"  UR                  Ul
        UR	                  S5        U(       d  [        R                  " S5      eT R                   R                  TR                  5       USR                  U5      S9nT R                   R#                  U5      $ )zUpdate an index endpoint.rF   r3   c                  :   > TR                  T 5      R                  $ r   Getr5   index_endpoint_refr'   s   r   	GetLabels1IndexEndpointsClient.PatchBeta.<locals>.GetLabels       XX()000r   r5   No updates requested.,)namer9   
updateMask)r$   r=   rF   r2   appendr3   r   ProcessUpdateArgsLazyr>   needs_updater5   r   NoFieldsSpecifiedError5AiplatformProjectsLocationsIndexEndpointsPatchRequestrE   joinr&   Patchr'   r\   rK   index_endpointupdate_maskr]   labels_updaterequests   ``      r   	PatchBetaIndexEndpointsClient.PatchBeta   s"   ]]LLNNK$#'#4#4n (##'#3#3n '1  55??KKM !!+22n"))*ABBmmQQ,,.2@88K( R *G ==w''r   c                   ^ ^ T R                   R                  5       n/ nUR                  b"  UR                  Ul        UR	                  S5        UR
                  b"  UR
                  Ul        UR	                  S5        UU 4S jn[        R                  " UT R                   R                  R                  U5      nUR                  (       a"  UR                  Ul
        UR	                  S5        U(       d  [        R                  " S5      eT R                   R                  TR                  5       USR                  U5      S9nT R                   R#                  U5      $ )zUpdate an v1 index endpoint.rF   r3   c                  :   > TR                  T 5      R                  $ r   rY   r[   s   r   r]   -IndexEndpointsClient.Patch.<locals>.GetLabels   r_   r   r5   r`   ra   )rb   rR   rc   )r$   rS   rF   r2   rd   r3   r   re   r>   rf   r5   r   rg   rh   rE   ri   r&   rj   rk   s   ``      r   rj   IndexEndpointsClient.Patch   s!   ]]GGINK$#'#4#4n (##'#3#3n '1  55dmm@@LLM !!+22n"))*ABBmmQQ,,.-;88K( R *G ==w''r   c                 
   [        UR                  UR                  5      nU R                  R	                  UR
                  UR                  UR                  5       S9nUR                  b%  UR                  R                  UR                  5        UR                  b  UR                  Ul        UR                  (       aB  U R                  R                  R                  UR                  R                  5       5      Ul        UR"                  b  UR"                  Ul        UR&                  b  UR(                  b  U R                  R+                  5       nUR&                  R                  UR&                  5        UR,                  R                  UR(                  5        U R                  R/                  US9Ul        UR2                  b  U R                  R5                  5       nU R                  R7                  UR2                  S9Ul        UR:                  b  UR:                  Ul        UR>                  b  UR>                  Ul         Xdl!        O\U R                  RE                  5       nUR:                  b  UR:                  Ul        UR>                  b  UR>                  Ul         Xtl#        U R                  RI                  US9nU R                  RK                  UR                  5       US9n	U RL                  RO                  U	5      $ )z%Deploy an index to an index endpoint.)r2   idindexauthProvidermachineTypedeployedIndex)indexEndpoint.googleCloudAiplatformV1beta1DeployIndexRequest)(r   rx   regionr$   )GoogleCloudAiplatformV1beta1DeployedIndexrF   deployed_index_idrE   reserved_ip_rangesreservedIpRangesextenddeployment_groupdeploymentGroupdeployment_tierDeploymentTierValueValuesEnumupperdeploymentTierenable_access_loggingenableAccessLogging	audiencesallowed_issuers?GoogleCloudAiplatformV1beta1DeployedIndexAuthConfigAuthProviderallowedIssuers3GoogleCloudAiplatformV1beta1DeployedIndexAuthConfigdeployedIndexAuthConfigmachine_type.GoogleCloudAiplatformV1beta1DedicatedResources'GoogleCloudAiplatformV1beta1MachineSpecmachineSpecmin_replica_countminReplicaCountmax_replica_countmaxReplicaCountdedicatedResources.GoogleCloudAiplatformV1beta1AutomaticResourcesautomaticResources.GoogleCloudAiplatformV1beta1DeployIndexRequest;AiplatformProjectsLocationsIndexEndpointsDeployIndexRequestr&   DeployIndex)
r'   r\   rK   	index_refdeployed_indexauth_providerdedicated_resourcesautomatic_resourcesdeploy_index_reqro   s
             r   DeployIndexBeta$IndexEndpointsClient.DeployIndexBeta   s   DJJ4I]]LL%%!!$$& M N *%%,,T-D-DE('+'<'<n$&*mm&]&]&{&{



$
$
&'(n# !!-+/+E+En(~~!d&:&:&Fmmccem$$T^^4""))$*>*>?
--
K
K( L * , $
--
F
F
H  --
?
?++ @  %
 
			+.2.D.D+				+.2.D.D+*=' --
F
F
H  
			+.2.D.D+				+.2.D.D+*='}}SS$ T &mmWW(5577G X IG ==$$W--r   c                    [        UR                  UR                  5      nU R                  R	                  UR
                  UR                  UR                  5       UR                  S9nUR                  b%  UR                  R                  UR                  5        UR                  b  UR                  Ul        UR                  (       aB  U R                  R                  R                  UR                  R!                  5       5      Ul        UR$                  b  UR&                  b  U R                  R)                  5       nUR$                  R                  UR$                  5        UR*                  R                  UR&                  5        U R                  R-                  US9Ul        UR0                  bS  / Ul        UR0                   H<  nUR2                  R5                  U R                  R7                  US   US   S95        M>     UR8                  b  U R                  R;                  5       nU R                  R=                  UR8                  S9Ul        UR@                  b  UR@                  Ul!        URD                  b  URD                  Ul#        Xtl$        O\U R                  RK                  5       nUR@                  b  UR@                  Ul!        URD                  b  URD                  Ul#        Xl&        U R                  RO                  US9n	U R                  RQ                  UR                  5       U	S9n
U RR                  RU                  U
5      $ )	z(Deploy an v1 index to an index endpoint.)r2   rw   rx   r   ry   z
project-idr;   )	projectIdr;   r{   r}   )r   )googleCloudAiplatformV1DeployIndexRequest)+r   rx   r   r$   $GoogleCloudAiplatformV1DeployedIndexrF   r   rE   r   r   r   r   r   r   r   r   r   r   r   r   :GoogleCloudAiplatformV1DeployedIndexAuthConfigAuthProviderr   .GoogleCloudAiplatformV1DeployedIndexAuthConfigr   psc_automation_configspscAutomationConfigsrd   *GoogleCloudAiplatformV1PSCAutomationConfigr   )GoogleCloudAiplatformV1DedicatedResources"GoogleCloudAiplatformV1MachineSpecr   r   r   r   r   r   )GoogleCloudAiplatformV1AutomaticResourcesr   )GoogleCloudAiplatformV1DeployIndexRequestr   r&   r   )r'   r\   rK   r   r   r   psc_automation_configr   r   r   ro   s              r   r    IndexEndpointsClient.DeployIndex#  s   DJJ4I]]GG%%!!$$& 66	 H N *%%,,T-D-DE('+'<'<n$&*mm&X&X&v&v



$
$
&'(n# ~~!d&:&:&Fmm^^`m$$T^^4""))$*>*>?
--
F
F( G * ,
 "".,.n)#'#>#>
++22MMDD/=-i8 E 	
 $? $
--
A
A
C  --
:
:++ ;  %
 
			+.2.D.D+				+.2.D.D+*=' --
A
A
C  
			+.2.D.D+				+.2.D.D+*='}}NN$ O &mmWW(5572B X DG ==$$W--r   c                     U R                   R                  UR                  S9nU R                   R                  UR	                  5       US9nU R
                  R                  U5      $ )z'Undeploy an index to an index endpoint.deployedIndexId)r   0googleCloudAiplatformV1beta1UndeployIndexRequest)r$   0GoogleCloudAiplatformV1beta1UndeployIndexRequestr   =AiplatformProjectsLocationsIndexEndpointsUndeployIndexRequestrE   r&   UndeployIndexr'   r\   rK   undeploy_index_reqro   s        r   UndeployIndexBeta&IndexEndpointsClient.UndeployIndexBetaj  sg    WW.. X 0mmYY(5579K Z MG ==&&w//r   c                     U R                   R                  UR                  S9nU R                   R                  UR	                  5       US9nU R
                  R                  U5      $ )z*Undeploy an v1 index to an index endpoint.r   )r   +googleCloudAiplatformV1UndeployIndexRequest)r$   +GoogleCloudAiplatformV1UndeployIndexRequestr   r   rE   r&   r   r   s        r   r   "IndexEndpointsClient.UndeployIndexs  sg    RR.. S 0mmYY(5574F Z HG ==&&w//r   c                 0   U R                   R                  UR                  UR                  S9nUR                  b  U R                  U5      Ul        OU R                  U5      Ul        UR                  b%  UR                  R                  UR                  5        UR                  b  UR                  Ul        UR                  b  UR                  b  U R                   R!                  5       nUR                  R                  UR                  5        UR"                  R                  UR                  5        U R                   R%                  US9Ul        U R                   R)                  UR+                  5       US9nU R,                  R/                  U5      $ )/Mutate a deployed index from an index endpoint.rw   r   ry   )r   )googleCloudAiplatformV1beta1DeployedIndex)r$   r   r   r   r   _GetDedicatedResourcesBetar   _GetAutomaticResourcesBetar   r   r   r   r   r   r   r   r   r   r   r   CAiplatformProjectsLocationsIndexEndpointsMutateDeployedIndexRequestrE   r&   MutateDeployedIndexr'   r\   rK   r   r   ro   s         r   MutateDeployedIndexBeta,IndexEndpointsClient.MutateDeployedIndexBeta|  sc    ]]LL!! 66 M N
 $*.*I*I$*On'*.*I*I$*On'*%%,,T-D-DE('+'<'<n$~~!d&:&:&Fmmccem$$T^^4""))$*>*>?
--
K
K( L * , mm__(5572@ ` BG ==,,W55r   c                 0   U R                   R                  UR                  UR                  S9nUR                  b  U R                  U5      Ul        OU R                  U5      Ul        UR                  b%  UR                  R                  UR                  5        UR                  b  UR                  Ul        UR                  b  UR                  b  U R                   R!                  5       nUR                  R                  UR                  5        UR"                  R                  UR                  5        U R                   R%                  US9Ul        U R                   R)                  UR+                  5       US9nU R,                  R/                  U5      $ )r   r   ry   )r   $googleCloudAiplatformV1DeployedIndex)r$   r   r   r   r   _GetDedicatedResourcesr   _GetAutomaticResourcesr   r   r   r   r   r   r   r   r   r   r   r   r   rE   r&   r   r   s         r   r   (IndexEndpointsClient.MutateDeployedIndex  sb    ]]GG!! 66 H N
 $*.*E*Ed*Kn'*.*E*Ed*Kn'*%%,,T-D-DE('+'<'<n$~~!d&:&:&Fmm^^`m$$T^^4""))$*>*>?
--
F
F( G * , mm__(557-; ` =G ==,,W55r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ N)rb   )r$   3AiplatformProjectsLocationsIndexEndpointsGetRequestrE   r&   rZ   r'   r\   ro   s      r   rZ   IndexEndpointsClient.Get  s=    mmOO,,. P 0G==W%%r   c                     [         R                  " U R                  U R                  R	                  UR                  5       S9SSUS9$ )N)r8   indexEndpointspageSize)fieldbatch_size_attributelimit)r   YieldFromListr&   r$   4AiplatformProjectsLocationsIndexEndpointsListRequestrE   )r'   r   
region_refs      r   ListIndexEndpointsClient.List  sI    ##JJ**, 	K 	.' r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ r   )r$   6AiplatformProjectsLocationsIndexEndpointsDeleteRequestrE   r&   Deleter   s      r   r   IndexEndpointsClient.Delete  s=    mmRR,,. S 0G==((r   c                    U R                   R                  5       nU R                   R                  UR                  S9Ul        UR
                  b  UR
                  Ul        UR                  b  UR                  Ul        U$ )z+Construct dedicated resources for beta API.r{   )	r$   r   r   r   r   r   r   r   r   r'   rK   r   s      r   r   /IndexEndpointsClient._GetDedicatedResourcesBeta  s     	DDF  	==)) 	> 	
 #
 ),0,B,B)),0,B,B)r   c                     U R                   R                  5       nUR                  b  UR                  Ul        UR                  b  UR                  Ul        U$ )z+Construct automatic resources for beta API.)r$   r   r   r   r   r   r'   rK   r   s      r   r   /IndexEndpointsClient._GetAutomaticResourcesBeta  sW     	DDF  ),0,B,B)),0,B,B)r   c                    U R                   R                  5       nU R                   R                  UR                  S9Ul        UR
                  b  UR
                  Ul        UR                  b  UR                  Ul        U$ )z)Construct dedicated resources for GA API.r{   )	r$   r   r   r   r   r   r   r   r   r   s      r   r   +IndexEndpointsClient._GetDedicatedResources  s     	??A  	88)) 	9 	
 #
 ),0,B,B)),0,B,B)r   c                     U R                   R                  5       nUR                  b  UR                  Ul        UR                  b  UR                  Ul        U$ )z)Construct automatic resources for GA API.)r$   r   r   r   r   r   r   s      r   r   +IndexEndpointsClient._GetAutomaticResources  sW     	??A  ),0,B,B)),0,B,B)r   )r&   r"   r$   )NN)__name__
__module____qualname____firstlineno____doc__r   
GA_VERSIONr)   rO   rH   rp   rj   r   r   r   r   r   r   rZ   r   r   r   r   r   r   __static_attributes__ r   r   r   r   &   sv    F 49M9M B9%v8%t(B(@;.zE.N006@6@&
)
 	 	r   r   N)r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.command_lib.air   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r	   r   objectr   r   r   r   <module>r     s5    B ( , 3 0 < * ):]6 ]r   