
    T                         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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.    )absolute_import)division)unicode_literals)
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r5   r6   networkr8   r9   T)r
   ParseCreateArgsr'   )GoogleCloudAiplatformV1beta1IndexEndpointLabelsValueencryption_kms_key_name*GoogleCloudAiplatformV1beta1EncryptionSpecenable_private_service_connect7GoogleCloudAiplatformV1beta1PrivateServiceConnectConfigproject_allowlist6AiplatformProjectsLocationsIndexEndpointsCreateRequestRelativeNamedisplay_namer6   public_endpoint_enabledr>   r)   Creater*   location_refargsr8   encryption_specprivate_service_connect_configreqs          r   
CreateBetaIndexEndpointsClient.CreateBeta3   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/   r1   r4   )r;   $googleCloudAiplatformV1IndexEndpointr=   T)r
   r?   r'   $GoogleCloudAiplatformV1IndexEndpointrA   rB   %GoogleCloudAiplatformV1EncryptionSpecrD   2GoogleCloudAiplatformV1PrivateServiceConnectConfigrF   rG   rH   rI   r6   rJ   r>   r)   rK   rL   s          r   rK   IndexEndpointsClient.Createn   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.rI   r6   c                  :   > TR                  T 5      R                  $ r!   Getr8   index_endpoint_refr*   s   r   	GetLabels1IndexEndpointsClient.PatchBeta.<locals>.GetLabels       XX()000r   r8   No updates requested.,)namer<   
updateMask)r'   r@   rI   r5   appendr6   r
   ProcessUpdateArgsLazyrA   needs_updater8   r	   NoFieldsSpecifiedError5AiplatformProjectsLocationsIndexEndpointsPatchRequestrH   joinr)   Patchr*   r_   rN   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.rI   r6   c                  :   > TR                  T 5      R                  $ r!   r\   r^   s   r   r`   -IndexEndpointsClient.Patch.<locals>.GetLabels   rb   r   r8   rc   rd   )re   rU   rf   )r'   rV   rI   r5   rg   r6   r
   rh   rA   ri   r8   r	   rj   rk   rH   rl   r)   rm   rn   s   ``      r   rm   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                 d   [        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                  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*                  b  U R                  R-                  5       nU R                  R/                  UR*                  S9Ul        UR2                  b  UR2                  Ul        UR6                  b  UR6                  Ul        Xdl        O\U R                  R=                  5       nUR2                  b  UR2                  Ul        UR6                  b  UR6                  Ul        Xtl        U R                  RA                  US9nU R                  RC                  UR                  5       US9n	U RD                  RG                  U	5      $ )z%Deploy an index to an index endpoint.)r5   idindexauthProvidermachineTypedeployedIndex)indexEndpoint.googleCloudAiplatformV1beta1DeployIndexRequest)$r   r{   regionr'   )GoogleCloudAiplatformV1beta1DeployedIndexrI   deployed_index_idrH   reserved_ip_rangesreservedIpRangesextenddeployment_groupdeploymentGroup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_   rN   	index_refdeployed_indexauth_providerdedicated_resourcesautomatic_resourcesdeploy_index_reqrr   s
             r   DeployIndexBeta$IndexEndpointsClient.DeployIndexBeta   sf   DJJ4I]]LL%%!!$$& M N *%%,,T-D-DE('+'<'<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                  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(                  bS  / Ul        UR(                   H<  nUR*                  R-                  U R                  R/                  US   US   S95        M>     UR0                  b  U R                  R3                  5       nU R                  R5                  UR0                  S9Ul        UR8                  b  UR8                  Ul        UR<                  b  UR<                  Ul        Xtl         O\U R                  RC                  5       nUR8                  b  UR8                  Ul        UR<                  b  UR<                  Ul        Xl"        U R                  RG                  US9n	U R                  RI                  UR                  5       U	S9n
U RJ                  RM                  U
5      $ )	z(Deploy an v1 index to an index endpoint.)r5   rz   r{   r   r|   z
project-idr>   )	projectIdr>   r~   r   )r   )googleCloudAiplatformV1DeployIndexRequest)'r   r{   r   r'   $GoogleCloudAiplatformV1DeployedIndexrI   r   rH   r   r   r   r   r   r   r   r   :GoogleCloudAiplatformV1DeployedIndexAuthConfigAuthProviderr   .GoogleCloudAiplatformV1DeployedIndexAuthConfigr   psc_automation_configspscAutomationConfigsrg   *GoogleCloudAiplatformV1PSCAutomationConfigr   )GoogleCloudAiplatformV1DedicatedResources"GoogleCloudAiplatformV1MachineSpecr   r   r   r   r   r   )GoogleCloudAiplatformV1AutomaticResourcesr   )GoogleCloudAiplatformV1DeployIndexRequestr   r)   r   )r*   r_   rN   r   r   r   psc_automation_configr   r   r   rr   s              r   r    IndexEndpointsClient.DeployIndex"  s   DJJ4I]]GG%%!!$$& 66	 H N *%%,,T-D-DE('+'<'<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   =AiplatformProjectsLocationsIndexEndpointsUndeployIndexRequestrH   r)   UndeployIndexr*   r_   rN   undeploy_index_reqrr   s        r   UndeployIndexBeta&IndexEndpointsClient.UndeployIndexBetae  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   rH   r)   r   r   s        r   r   "IndexEndpointsClient.UndeployIndexn  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.rz   r   r|   )r   )googleCloudAiplatformV1beta1DeployedIndex)r'   r   r   r   r   _GetDedicatedResourcesBetar   _GetAutomaticResourcesBetar   r   r   r   r   r   r   r   r   r   r   r   CAiplatformProjectsLocationsIndexEndpointsMutateDeployedIndexRequestrH   r)   MutateDeployedIndexr*   r_   rN   r   r   rr   s         r   MutateDeployedIndexBeta,IndexEndpointsClient.MutateDeployedIndexBetaw  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   r|   )r   $googleCloudAiplatformV1DeployedIndex)r'   r   r   r   r   _GetDedicatedResourcesr   _GetAutomaticResourcesr   r   r   r   r   r   r   r   r   r   r   r   r   rH   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)re   )r'   3AiplatformProjectsLocationsIndexEndpointsGetRequestrH   r)   r]   r*   r_   rr   s      r   r]   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)r;   indexEndpointspageSize)fieldbatch_size_attributelimit)r   YieldFromListr)   r'   4AiplatformProjectsLocationsIndexEndpointsListRequestrH   )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'   6AiplatformProjectsLocationsIndexEndpointsDeleteRequestrH   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*   rN   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*   rN   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,   rR   rK   rs   rm   r   r   r   r   r   r   r]   r   r   r   r   r   r   __static_attributes__ r   r   r   r   )   sv    F 49M9M B9%v8%t(B(@7.rA.F006@6@&
)
 	 	r   r   N)r   
__future__r   r   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     s<    B &  ' ' , 3 0 < * ):U6 Ur   