
                            S r SSKJr  SSKJr  SSKJr  SSK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SKJr  SrSr\	R2                  " \	R4                  R6                  5       " S S\	R8                  5      5       r\	R2                  " \	R4                  R<                  \	R4                  R>                  5       " S S\5      5       r g)z5Command to create a Persistent Resource in Vertex AI.    )absolute_import)division)unicode_literalsN)client)base)	constants)endpoint_util)
validation)flags)persistent_resource_util)labels_util)log)
propertieszFprojects/{project_number}/locations/{region}/operations/{operation_id}zOperation to create PersistentResource [{display_name}] is submitted successfully.

You may view the status of your PersistentResource create operation with the command

  $ {command_prefix} ai operations describe {operation_resource_name}
c                   R    \ rS rSrSr\R                  r\S 5       r	S r
S rS rSrg)	CreateGA/     Create a new persistent resource.

This command will create a persistent resource on the users project to use
with Vertex AI custom training jobs. Persistent resources remain active until
they are deleted by the user.

## EXAMPLES

To create a PersistentResource under project ``example'' in region
``us-central1'', run:

  $ {command} --region=us-central1 --project=example
  --resource-pool-spec=replica-count=1,machine-type='n1-standard-4'
  --display-name=example-resource
c                 0    [         R                  " U 5        g )N)r    AddCreatePersistentResourceFlags)parsers    -lib/surface/ai/persistent_resources/create.pyArgsCreateGA.ArgsC   s    	**62    c                    SnU R                  5       R                  (       a   USU R                  5       R                  -   -  n[        R                  " SUR                  5      R                  S5      S   n[        R                  UUUS9n[        R                  R                  [        R                  UR                  UUS95        g )Ngcloud zoperations\/(\d+)r   )project_numberregionoperation_id)display_namecommand_prefixoperation_resource_name)ReleaseTrackprefixresearchnamegroups!_OPERATION_RESOURCE_NAME_TEMPLATEformatr   statusPrint6_PERSISTENT_RESOURCE_CREATION_DISPLAY_MESSAGE_TEMPLATE)selfresponser   r   
cmd_prefixr    r#   s          r   _DisplayResultCreateGA._DisplayResultG   s    J!!C$++-4444j9918==AHHKANL?FF%! G  JJ>EE!%$; 	F 	
r   c                 *   UR                   (       a  UR                  UR                   S5      OUR                  5       n[        R                  " XU R
                  5        [        UR                  =(       d    / 5      n[        R                  " UUUS9nU$ )NPersistentResource)persistent_resource_configresource_pool_specs)
configImportResourceMessagePersistentResourceMessager
   ValidateCreateArgs_versionlistresource_pool_specr   ConstructResourcePools)r/   args
api_clientr6   r7   persistent_resource_specs         r   _PrepareResourcePoolsCreateGA._PrepareResourcePools[   s     ;; 	((6JK113  !!$-- t66<"=7NN#=/ 
 $#r   c                    [         R                  R                  R                  R	                  5       nUR
                  R                  R                  5       nUR                  5       S   n[        R                  " U5        [        R                  " U R                  US9   [        R                  " U R                  S9nU R!                  X5      n["        R$                  " XR'                  5       R(                  5      nUR+                  UR-                  5       UR.                  UUR0                  [2        R4                  " U5      UUR6                  UR8                  S9nU R;                  XU5        UsS S S 5        $ ! , (       d  f       g = f)NlocationsId)versionr   )rG   )parentr!   resource_poolspersistent_resource_idkms_key_namelabelsnetworkenable_custom_service_account)r   VALUEScoreproject	GetOrFailCONCEPTSr   ParseAsDictr
   ValidateRegionr	   AiplatformEndpointOverridesr<   r   PersistentResourcesClientrC   r   ParseCreateArgsr:   LabelsValueCreateRelativeNamer!   rJ   common_validationGetAndValidateKmsKeyrM   rN   r2   )	r/   r@   rQ   
region_refr   rA   rI   rL   r0   s	            r   RunCreateGA.Runm   s=   $$,,668G%%++-J /Ff%		2	2f
 33DMMJj11
n **
446BBf ""((*(('!%!<!<(==dC,,(,(J(J # h (V41
 
 
s   CE::
F N)__name__
__module____qualname____firstlineno____doc__r   
GA_VERSIONr<   staticmethodr   r2   rC   r`   __static_attributes__rb   r   r   r   r   /   s5      !!(3 3($$r   r   c                   0    \ rS rSrSr\R                  rSrg)CreatePreGA   r   rb   N)	rc   rd   re   rf   rg   r   BETA_VERSIONr<   rj   rb   r   r   rl   rl      s      ##(r   rl   )!rg   
__future__r   r   r   r&   .googlecloudsdk.api_lib.ai.persistent_resourcesr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r	   r
   r]   2googlecloudsdk.command_lib.ai.persistent_resourcesr   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r*   r.   ReleaseTracksr$   GACreateCommandr   ALPHABETArl   rb   r   r   <module>r{      s    < &  ' 	 A ( 3 7 I D W I < # * M ": 6 D%%(()[t!! [ *[| D%%++T->->-C-CD$( $ E$r   